diff options
author | Mike Reed <reed@google.com> | 2017-12-29 04:35:23 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-29 04:35:31 +0000 |
commit | 6f1151140f331c78d99ede3cac10462dc8b32cde (patch) | |
tree | decc8655a4ff7d570da3427fd1971daab2994c1d /src | |
parent | f3504d430cec35330017aa2af3a51083801c7dd9 (diff) |
Revert "remove legacy support for old old picture versions"
This reverts commit f3504d430cec35330017aa2af3a51083801c7dd9.
Reason for revert: breaks unittest in Printing unittest in chrome
Original change's description:
> remove legacy support for old old picture versions
>
> Bug: skia:
> Change-Id: Ieb97eabdb18e8c7bfa86e6a1fc6e0389cd096daa
> Reviewed-on: https://skia-review.googlesource.com/89860
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=mtklein@google.com,fmalita@chromium.org,reed@google.com
Change-Id: I9f90da5dcfb9543f2f575fa7dc3b9c82996b041d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/90020
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkReadBuffer.h | 2 | ||||
-rw-r--r-- | src/core/SkTextBlob.cpp | 11 | ||||
-rw-r--r-- | src/effects/SkMergeImageFilter.cpp | 20 | ||||
-rw-r--r-- | src/shaders/SkComposeShader.cpp | 9 |
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); } |