Only trigger serializing blender if it isn't a mode
Change-Id: I9f9cf7f92232c365538f3dd29df226933827771c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423582 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
043f010bd1
commit
569f29da86
@ -248,6 +248,8 @@ template <typename T> uint32_t shift_bits(T value, unsigned shift, unsigned bits
|
||||
return v << shift;
|
||||
}
|
||||
|
||||
constexpr uint8_t CUSTOM_BLEND_MODE_SENTINEL = 0xFF;
|
||||
|
||||
/* Packing the paint
|
||||
flags : 8 // 2...
|
||||
blend : 8 // 30+
|
||||
@ -260,9 +262,13 @@ template <typename T> uint32_t shift_bits(T value, unsigned shift, unsigned bits
|
||||
*/
|
||||
static uint32_t pack_v68(const SkPaint& paint, unsigned flatFlags) {
|
||||
uint32_t packed = 0;
|
||||
const auto bm = paint.asBlendMode();
|
||||
const unsigned mode = bm ? static_cast<unsigned>(bm.value())
|
||||
: CUSTOM_BLEND_MODE_SENTINEL;
|
||||
|
||||
packed |= shift_bits(((unsigned)paint.isDither() << 1) |
|
||||
(unsigned)paint.isAntiAlias(), 0, 8);
|
||||
packed |= shift_bits(paint.getBlendMode(), 8, 8);
|
||||
packed |= shift_bits(mode, 8, 8);
|
||||
packed |= shift_bits(paint.getStrokeCap(), 16, 2);
|
||||
packed |= shift_bits(paint.getStrokeJoin(), 18, 2);
|
||||
packed |= shift_bits(paint.getStyle(), 20, 2);
|
||||
@ -277,7 +283,13 @@ static uint32_t unpack_v68(SkPaint* paint, uint32_t packed, SkSafeRange& safe) {
|
||||
paint->setAntiAlias((packed & 1) != 0);
|
||||
paint->setDither((packed & 2) != 0);
|
||||
packed >>= 8;
|
||||
paint->setBlendMode(safe.checkLE(packed & 0xFF, SkBlendMode::kLastMode));
|
||||
{
|
||||
unsigned mode = packed & 0xFF;
|
||||
if (mode != CUSTOM_BLEND_MODE_SENTINEL) { // sentinel for custom blender
|
||||
paint->setBlendMode(safe.checkLE(mode, SkBlendMode::kLastMode));
|
||||
}
|
||||
// else we will unflatten the custom blender
|
||||
}
|
||||
packed >>= 8;
|
||||
paint->setStrokeCap(safe.checkLE(packed & 0x3, SkPaint::kLast_Cap));
|
||||
packed >>= 2;
|
||||
@ -303,7 +315,7 @@ void SkPaintPriv::Flatten(const SkPaint& paint, SkWriteBuffer& buffer) {
|
||||
paint.getMaskFilter() ||
|
||||
paint.getColorFilter() ||
|
||||
paint.getImageFilter() ||
|
||||
paint.getBlender()) {
|
||||
!paint.asBlendMode()) {
|
||||
flatFlags |= kHasEffects_FlatFlag;
|
||||
}
|
||||
|
||||
@ -343,7 +355,6 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
|
||||
paint->setMaskFilter(nullptr);
|
||||
paint->setColorFilter(nullptr);
|
||||
paint->setImageFilter(nullptr);
|
||||
paint->experimental_setBlender(nullptr);
|
||||
} else if (buffer.isVersionLT(SkPicturePriv::kSkBlenderInSkPaint)) {
|
||||
// This paint predates the introduction of user blend functions (via SkBlender).
|
||||
paint->setPathEffect(buffer.readPathEffect());
|
||||
@ -352,7 +363,6 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
|
||||
paint->setColorFilter(buffer.readColorFilter());
|
||||
(void)buffer.read32(); // was drawLooper (now deprecated)
|
||||
paint->setImageFilter(buffer.readImageFilter());
|
||||
paint->experimental_setBlender(nullptr);
|
||||
} else {
|
||||
paint->setPathEffect(buffer.readPathEffect());
|
||||
paint->setShader(buffer.readShader());
|
||||
|
@ -158,8 +158,8 @@ DEF_TEST(Paint_MoreFlattening, r) {
|
||||
ASSERT(reader.offset() == writer.bytesWritten());
|
||||
|
||||
// No matter the encoding, these must always hold.
|
||||
ASSERT(other.getColor() == paint.getColor());
|
||||
ASSERT(other.getBlendMode() == paint.getBlendMode());
|
||||
ASSERT(other.getColor() == paint.getColor());
|
||||
ASSERT(other.asBlendMode() == paint.asBlendMode());
|
||||
}
|
||||
|
||||
#include "include/effects/SkColorMatrixFilter.h"
|
||||
|
Loading…
Reference in New Issue
Block a user