aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkReadBuffer.h2
-rw-r--r--src/core/SkTextBlob.cpp11
-rw-r--r--src/effects/SkMergeImageFilter.cpp20
-rw-r--r--src/shaders/SkComposeShader.cpp9
4 files changed, 35 insertions, 7 deletions
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 69aaf02ab8..665f4080e3 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -68,10 +68,10 @@ public:
kGradientShaderFloatColor_Version = 49,
kXfermodeToBlendMode_Version = 50,
kXfermodeToBlendMode2_Version = 51,
+ */
kTextBlobImplicitRunCount_Version = 52,
kComposeShaderCanLerp_Version = 54,
kNoModesInMergeImageFilter_Verison = 55,
- */
kTileModeInBlurImageFilter_Version = 56,
kTileInfoInSweepGradient_Version = 57,
k2PtConicalNoFlip_Version = 58,
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index 6d89e6f135..91ec79bcbf 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -790,13 +790,20 @@ void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
}
sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
+ const int runCount = reader.isVersionLT(SkReadBuffer::kTextBlobImplicitRunCount_Version)
+ ? reader.read32() : std::numeric_limits<int>::max();
+ if (runCount < 0) {
+ return nullptr;
+ }
+
SkRect bounds;
reader.readRect(&bounds);
SkTextBlobBuilder blobBuilder;
- for (;;) {
+ for (int i = 0; i < runCount; ++i) {
int glyphCount = reader.read32();
- if (glyphCount == 0) {
+ if (glyphCount == 0 &&
+ !reader.isVersionLT(SkReadBuffer::kTextBlobImplicitRunCount_Version)) {
// End-of-runs marker.
break;
}
diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp
index 1da4d41a0a..1d425ed04e 100644
--- a/src/effects/SkMergeImageFilter.cpp
+++ b/src/effects/SkMergeImageFilter.cpp
@@ -111,10 +111,26 @@ sk_sp<SkImageFilter> SkMergeImageFilter::onMakeColorSpace(SkColorSpaceXformer* x
sk_sp<SkFlattenable> SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
Common common;
- if (!common.unflatten(buffer, -1) || !buffer.isValid()) {
+ if (!common.unflatten(buffer, -1)) {
return nullptr;
}
- return Make(common.inputs(), common.inputCount(), &common.cropRect());
+
+ const int count = common.inputCount();
+ if (buffer.isVersionLT(SkReadBuffer::kNoModesInMergeImageFilter_Verison)) {
+ bool hasModes = buffer.readBool();
+ if (hasModes) {
+ // Older pictures may have stored blendmodes, but by inspection we think these were
+ // all src-over, so we have removed support for storing these.
+ SkAutoSTArray<4, uint8_t> modes8(count);
+ if (!buffer.readByteArray(modes8.get(), count)) {
+ return nullptr;
+ }
+ if (!buffer.isValid()) {
+ return nullptr;
+ }
+ }
+ }
+ return Make(common.inputs(), count, &common.cropRect());
}
void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp
index 2feae7788e..34e54863b7 100644
--- a/src/shaders/SkComposeShader.cpp
+++ b/src/shaders/SkComposeShader.cpp
@@ -43,12 +43,17 @@ sk_sp<SkFlattenable> SkComposeShader::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkShader> dst(buffer.readShader());
sk_sp<SkShader> src(buffer.readShader());
unsigned mode = buffer.read32();
- float lerp = buffer.readScalar();
+
+ float lerp = 1;
+ if (!buffer.isVersionLT(SkReadBuffer::kComposeShaderCanLerp_Version)) {
+ lerp = buffer.readScalar();
+ }
// check for valid mode before we cast to the enum type
- if (!buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode)) {
+ if (mode > (unsigned)SkBlendMode::kLastMode) {
return nullptr;
}
+
return MakeCompose(std::move(dst), std::move(src), static_cast<SkBlendMode>(mode), lerp);
}