92 const unsigned paintAlpha =
paint->getAlpha();
94 (!
paint->getShader() ||
paint->getShader()->isOpaque())) {
96 }
else if (0 == paintAlpha) {
105 const auto bm =
paint->asBlendMode();
128 return p.getImageFilter() || p.getMaskFilter() ||
137 const auto* shader =
as_SB(
paint.getShader());
138 if (shader && !shader->asLuminanceColor(&c)) {
141 if (
paint.getColorFilter()) {
144 c =
paint.getColorFilter()->filterColor4f(c, cs, cs);
155 c = { 0.5f, 0.5f, 0.5f, 1.0f};
157 return c.toSkColor();
162 if (
SkShader* shader = p->getShader()) {
165 p->setShader(sk_make_sp<SkColorFilterShader>(
sk_ref_sp(shader),
170 p->setColor(filter->filterColor4f(p->getColor4f(),
sk_srgb_singleton(), dstCS), dstCS);
172 p->setColorFilter(
nullptr);
178 SkASSERT(bitCount > 0 && bitCount <= 32);
180 mask >>= (32 - bitCount);
184 #define ASSERT_FITS_IN(value, bitcount)
197template <
typename T> uint32_t
shift_bits(
T value,
unsigned shift,
unsigned bits) {
199 uint32_t v =
static_cast<uint32_t
>(
value);
218 const auto bm =
paint.asBlendMode();
219 const unsigned mode = bm ?
static_cast<unsigned>(bm.value())
223 (
unsigned)
paint.isAntiAlias(), 0, 8);
234 paint->setAntiAlias((packed & 1) != 0);
235 paint->setDither((packed & 2) != 0);
238 unsigned mode = packed & 0xFF;
261 uint8_t flatFlags = 0;
263 if (
paint.getPathEffect() ||
265 paint.getMaskFilter() ||
266 paint.getColorFilter() ||
267 paint.getImageFilter() ||
268 !
paint.asBlendMode()) {
304 paint.setPathEffect(
nullptr);
305 paint.setShader(
nullptr);
306 paint.setMaskFilter(
nullptr);
307 paint.setColorFilter(
nullptr);
308 paint.setImageFilter(
nullptr);
SK_API bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff *src, SkBlendModeCoeff *dst)
@ kLastMode
last valid value
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
SkColorSpace * sk_srgb_singleton()
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kUnknown_SkColorType
uninitialized
constexpr uint8_t CUSTOM_BLEND_MODE_SENTINEL
static bool blend_mode_is_opaque(SkBlendMode mode, SrcColorOpacity opacityType)
static bool just_a_color(const SkPaint &paint, SkColor4f *color)
static uint32_t pack_v68(const SkPaint &paint, unsigned flatFlags)
uint32_t shift_bits(T value, unsigned shift, unsigned bits)
@ kTransparentBlack_SrcColorOpacity
@ kTransparentAlpha_SrcColorOpacity
@ kUnknown_SrcColorOpacity
@ kOpaque_SrcColorOpacity
static bool changes_alpha(const SkPaint &paint)
static uint32_t unpack_v68(SkPaint *paint, uint32_t packed, SkSafeRange &safe)
#define ASSERT_FITS_IN(value, bitcount)
sk_sp< T > sk_ref_sp(T *obj)
SkShaderBase * as_SB(SkShader *shader)
bool isAlphaUnchanged() const
static void RemoveColorFilter(SkPaint *, SkColorSpace *dstCS)
static SkPaint Unflatten(SkReadBuffer &buffer)
static bool Overwrites(const SkPaint *paint, ShaderOverrideOpacity)
static bool ShouldDither(const SkPaint &, SkColorType)
@ kNone_ShaderOverrideOpacity
there is no overriding shader (bitmap or image)
@ kNotOpaque_ShaderOverrideOpacity
the overriding shader may not be opaque
static SkColor ComputeLuminanceColor(const SkPaint &)
static void Flatten(const SkPaint &paint, SkWriteBuffer &buffer)
@ kLast_Cap
largest Cap value
@ kStrokeAndFill_Style
sets to stroke and fill geometry
@ kLast_Join
equivalent to the largest value for Join
T checkLE(uint64_t value, T max)
virtual bool isConstant() const
static const uint8_t buffer[]