Revert "Revert "remove legacy support for old old picture versions""

This reverts commit 6f1151140f.

Chrome has been updated, so this should be able to land.

Bug: skia:
Change-Id: I5a66782a39fecfac00edeb66fbd03dae4df1712c
Reviewed-on: https://skia-review.googlesource.com/90205
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-01-03 13:17:18 -05:00 committed by Skia Commit-Bot
parent 3c36ef6be9
commit c5166a9dcb
5 changed files with 8 additions and 36 deletions

View File

@ -163,7 +163,7 @@ private:
// V60: Remove flags in picture header
// Only SKPs within the min/current picture version range (inclusive) can be read.
static const uint32_t MIN_PICTURE_VERSION = 51; // Produced by Chrome ~M56.
static const uint32_t MIN_PICTURE_VERSION = 56; // august 2017
static const uint32_t CURRENT_PICTURE_VERSION = 60;
static bool IsValidPictInfo(const SkPictInfo& info);

View File

@ -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,

View File

@ -790,20 +790,13 @@ 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 (int i = 0; i < runCount; ++i) {
for (;;) {
int glyphCount = reader.read32();
if (glyphCount == 0 &&
!reader.isVersionLT(SkReadBuffer::kTextBlobImplicitRunCount_Version)) {
if (glyphCount == 0) {
// End-of-runs marker.
break;
}

View File

@ -111,26 +111,10 @@ sk_sp<SkImageFilter> SkMergeImageFilter::onMakeColorSpace(SkColorSpaceXformer* x
sk_sp<SkFlattenable> SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
Common common;
if (!common.unflatten(buffer, -1)) {
if (!common.unflatten(buffer, -1) || !buffer.isValid()) {
return nullptr;
}
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());
return Make(common.inputs(), common.inputCount(), &common.cropRect());
}
void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {

View File

@ -43,17 +43,12 @@ 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 = 1;
if (!buffer.isVersionLT(SkReadBuffer::kComposeShaderCanLerp_Version)) {
lerp = buffer.readScalar();
}
float lerp = buffer.readScalar();
// check for valid mode before we cast to the enum type
if (mode > (unsigned)SkBlendMode::kLastMode) {
if (!buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode)) {
return nullptr;
}
return MakeCompose(std::move(dst), std::move(src), static_cast<SkBlendMode>(mode), lerp);
}