diff options
-rw-r--r-- | include/core/SkPicture.h | 17 | ||||
-rw-r--r-- | src/core/SkColorTable.cpp | 4 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 25 | ||||
-rw-r--r-- | src/core/SkReadBuffer.h | 2 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkDropShadowImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkPictureImageFilter.cpp | 14 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 18 | ||||
-rw-r--r-- | src/shaders/SkComposeShader.cpp | 9 | ||||
-rw-r--r-- | src/shaders/SkPictureShader.cpp | 10 | ||||
-rw-r--r-- | src/shaders/gradients/SkGradientShader.cpp | 110 | ||||
-rw-r--r-- | src/utils/SkBitmapSourceDeserializer.cpp | 7 |
13 files changed, 51 insertions, 179 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index 70f2acb6ab..9f14f80a17 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -203,24 +203,9 @@ private: // V53: SaveLayerRec clip mask // Only SKPs within the min/current picture version range (inclusive) can be read. - static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39. + static const uint32_t MIN_PICTURE_VERSION = 51; // Produced by Chrome ~M56. static const uint32_t CURRENT_PICTURE_VERSION = 53; - static_assert(MIN_PICTURE_VERSION <= 41, - "Remove kFontFileName and related code from SkFontDescriptor.cpp."); - - static_assert(MIN_PICTURE_VERSION <= 42, - "Remove COMMENT API handlers from SkPicturePlayback.cpp"); - - static_assert(MIN_PICTURE_VERSION <= 43, - "Remove SkBitmapSourceDeserializer."); - - static_assert(MIN_PICTURE_VERSION <= 45, - "Remove decoding of old SkTypeface::Style from SkFontDescriptor.cpp."); - - static_assert(MIN_PICTURE_VERSION <= 48, - "Remove legacy gradient deserialization code from SkGradientShader.cpp."); - static bool IsValidPictInfo(const SkPictInfo& info); static sk_sp<SkPicture> Forwardport(const SkPictInfo&, const SkPictureData*, diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp index 928f5158d4..2816de926a 100644 --- a/src/core/SkColorTable.cpp +++ b/src/core/SkColorTable.cpp @@ -92,10 +92,6 @@ void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { } sk_sp<SkColorTable> SkColorTable::Create(SkReadBuffer& buffer) { - if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) { - /*fAlphaType = */buffer.readUInt(); - } - const int count = buffer.getArrayCount(); if (0 == count) { return sk_sp<SkColorTable>(new SkColorTable(nullptr, 0)); diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index a0d3df7500..453bcfda98 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -140,10 +140,6 @@ bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) { uint32_t flags = buffer.readUInt(); fCropRect = CropRect(rect, flags); - if (buffer.isVersionLT(SkReadBuffer::kImageFilterNoUniqueID_Version)) { - - (void) buffer.readUInt(); - } return buffer.isValid(); } diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 78754957cf..dcd29d6100 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1917,14 +1917,9 @@ void SkPaint::unflatten(SkReadBuffer& buffer) { uint32_t tmp = buffer.readUInt(); this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); - if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) { - this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); - this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); - } else { - this->setStyle(static_cast<Style>((tmp >> 12) & 0xF)); - this->setTextEncoding(static_cast<TextEncoding>((tmp >> 8) & 0xF)); - this->setBlendMode((SkBlendMode)(tmp & 0xFF)); - } + this->setStyle(static_cast<Style>((tmp >> 12) & 0xF)); + this->setTextEncoding(static_cast<TextEncoding>((tmp >> 8) & 0xF)); + this->setBlendMode((SkBlendMode)(tmp & 0xFF)); if (flatFlags & kHasTypeface_FlatFlag) { this->setTypeface(buffer.readTypeface()); @@ -1935,25 +1930,11 @@ void SkPaint::unflatten(SkReadBuffer& buffer) { if (flatFlags & kHasEffects_FlatFlag) { this->setPathEffect(buffer.readPathEffect()); this->setShader(buffer.readShader()); - if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) { - sk_sp<SkXfermode> xfer = buffer.readXfermode(); - this->setBlendMode(xfer ? xfer->blend() : SkBlendMode::kSrcOver); - } this->setMaskFilter(buffer.readMaskFilter()); this->setColorFilter(buffer.readColorFilter()); this->setRasterizer(buffer.readRasterizer()); this->setLooper(buffer.readDrawLooper()); this->setImageFilter(buffer.readImageFilter()); - - if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) { - // We used to store annotations here (string+skdata) if this bool was true - if (buffer.readBool()) { - // Annotations have moved to drawAnnotation, so we just drop this one on the floor. - SkString key; - buffer.readString(&key); - (void)buffer.readByteArrayAsData(); - } - } } else { this->setPathEffect(nullptr); this->setShader(nullptr); diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h index 453d22fe91..4e6105013a 100644 --- a/src/core/SkReadBuffer.h +++ b/src/core/SkReadBuffer.h @@ -56,7 +56,6 @@ public: kImageFilterUniqueID_Version = 31, kRemoveAndroidPaintOpts_Version = 32, kFlattenCreateProc_Version = 33, - */ kRemoveColorTableAlpha_Version = 36, kDropShadowMode_Version = 37, kPictureImageFilterResolution_Version = 38, @@ -71,6 +70,7 @@ public: kGradientShaderFloatColor_Version = 49, kXfermodeToBlendMode_Version = 50, kXfermodeToBlendMode2_Version = 51, + */ kTextBlobImplicitRunCount_Version = 52, }; diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index a44105d616..50a97ff196 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -743,11 +743,7 @@ sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { flags &= SkBlurMaskFilter::kAll_BlurFlag; SkRect occluder; - if (buffer.isVersionLT(SkReadBuffer::kBlurMaskFilterWritesOccluder)) { - occluder.setEmpty(); - } else { - buffer.readRect(&occluder); - } + buffer.readRect(&occluder); if (style <= kLastEnum_SkBlurStyle) { return SkBlurMaskFilter::Make((SkBlurStyle)style, sigma, occluder, flags); diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp index 87e465f2f4..9d778e054d 100644 --- a/src/effects/SkDropShadowImageFilter.cpp +++ b/src/effects/SkDropShadowImageFilter.cpp @@ -46,9 +46,7 @@ sk_sp<SkFlattenable> SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) { SkScalar sigmaX = buffer.readScalar(); SkScalar sigmaY = buffer.readScalar(); SkColor color = buffer.readColor(); - ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ? - kDrawShadowAndForeground_ShadowMode : - static_cast<ShadowMode>(buffer.readInt()); + ShadowMode shadowMode = static_cast<ShadowMode>(buffer.readInt()); return Make(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0), &common.cropRect()); } diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index 2a863542fe..d6d433deb9 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -71,21 +71,11 @@ sk_sp<SkFlattenable> SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { } } buffer.readRect(&cropRect); - PictureResolution pictureResolution; - if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) { - pictureResolution = kDeviceSpace_PictureResolution; - } else { - pictureResolution = (PictureResolution)buffer.readInt(); - } + PictureResolution pictureResolution = (PictureResolution)buffer.readInt(); if (kLocalSpace_PictureResolution == pictureResolution) { //filterLevel is only serialized if pictureResolution is LocalSpace - SkFilterQuality filterQuality; - if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) { - filterQuality = kLow_SkFilterQuality; - } else { - filterQuality = (SkFilterQuality)buffer.readInt(); - } + SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt(); return MakeForLocalSpace(picture, cropRect, filterQuality); } return Make(picture, cropRect); diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 2af6d22a34..3228d15932 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -85,21 +85,9 @@ SkXfermodeImageFilter_Base::SkXfermodeImageFilter_Base(SkBlendMode mode, {} static int unflatten_blendmode(SkReadBuffer& buffer, SkArithmeticParams* arith) { - if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) { - sk_sp<SkXfermode> xfer = buffer.readXfermode(); - if (xfer) { - if (xfer->isArithmetic(arith)) { - return -1; - } - return (int)xfer->blend(); - } else { - return (int)SkBlendMode::kSrcOver; - } - } else { - uint32_t mode = buffer.read32(); - (void)buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode); - return mode; - } + uint32_t mode = buffer.read32(); + (void)buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode); + return mode; } sk_sp<SkFlattenable> SkXfermodeImageFilter_Base::CreateProc(SkReadBuffer& buffer) { diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp index 135f91d362..75f9cd2654 100644 --- a/src/shaders/SkComposeShader.cpp +++ b/src/shaders/SkComposeShader.cpp @@ -36,13 +36,8 @@ sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> sk_sp<SkFlattenable> SkComposeShader::CreateProc(SkReadBuffer& buffer) { sk_sp<SkShader> shaderA(buffer.readShader()); sk_sp<SkShader> shaderB(buffer.readShader()); - SkBlendMode mode; - if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode2_Version)) { - sk_sp<SkXfermode> xfer = buffer.readXfermode(); - mode = xfer ? xfer->blend() : SkBlendMode::kSrcOver; - } else { - mode = (SkBlendMode)buffer.read32(); - } + SkBlendMode mode = (SkBlendMode)buffer.read32(); + if (!shaderA || !shaderB) { return nullptr; } diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp index d6ee941251..4bef53da75 100644 --- a/src/shaders/SkPictureShader.cpp +++ b/src/shaders/SkPictureShader.cpp @@ -137,18 +137,12 @@ sk_sp<SkFlattenable> SkPictureShader::CreateProc(SkReadBuffer& buffer) { sk_sp<SkPicture> picture; if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnabled()) { - if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version)) { - // Older code blindly serialized pictures. We don't trust them. - buffer.validate(false); - return nullptr; - } // Newer code won't serialize pictures in disallow-cross-process-picture mode. // Assert that they didn't serialize anything except a false here. buffer.validate(!buffer.readBool()); } else { - // Old code always serialized the picture. New code writes a 'true' first if it did. - if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version) || - buffer.readBool()) { + bool didSerialize = buffer.readBool(); + if (didSerialize) { picture = SkPicture::MakeFromBuffer(buffer); } } diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index ab774f6b04..2d217855d3 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -67,85 +67,43 @@ void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const { } bool SkGradientShaderBase::DescriptorScope::unflatten(SkReadBuffer& buffer) { - if (buffer.isVersionLT(SkReadBuffer::kGradientShaderFloatColor_Version)) { - fCount = buffer.getArrayCount(); - if (fCount > kStorageCount) { - size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount; - fDynamicStorage.reset(allocSize); - fColors = (SkColor4f*)fDynamicStorage.get(); - fPos = (SkScalar*)(fColors + fCount); - } else { - fColors = fColorStorage; - fPos = fPosStorage; - } - - // Old gradients serialized SkColor. Read that to a temporary location, then convert. - SkSTArray<2, SkColor, true> colors; - colors.resize_back(fCount); - if (!buffer.readColorArray(colors.begin(), fCount)) { - return false; - } - for (int i = 0; i < fCount; ++i) { - mutableColors()[i] = SkColor4f::FromColor(colors[i]); - } - - if (buffer.readBool()) { - if (!buffer.readScalarArray(const_cast<SkScalar*>(fPos), fCount)) { - return false; - } - } else { - fPos = nullptr; - } - - fColorSpace = nullptr; - fTileMode = (SkShader::TileMode)buffer.read32(); - fGradFlags = buffer.read32(); - - if (buffer.readBool()) { - fLocalMatrix = &fLocalMatrixStorage; - buffer.readMatrix(&fLocalMatrixStorage); - } else { - fLocalMatrix = nullptr; - } + // New gradient format. Includes floating point color, color space, densely packed flags + uint32_t flags = buffer.readUInt(); + + fTileMode = (SkShader::TileMode)((flags >> kTileModeShift_GSF) & kTileModeMask_GSF); + fGradFlags = (flags >> kGradFlagsShift_GSF) & kGradFlagsMask_GSF; + + fCount = buffer.getArrayCount(); + if (fCount > kStorageCount) { + size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount; + fDynamicStorage.reset(allocSize); + fColors = (SkColor4f*)fDynamicStorage.get(); + fPos = (SkScalar*)(fColors + fCount); } else { - // New gradient format. Includes floating point color, color space, densely packed flags - uint32_t flags = buffer.readUInt(); - - fTileMode = (SkShader::TileMode)((flags >> kTileModeShift_GSF) & kTileModeMask_GSF); - fGradFlags = (flags >> kGradFlagsShift_GSF) & kGradFlagsMask_GSF; - - fCount = buffer.getArrayCount(); - if (fCount > kStorageCount) { - size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount; - fDynamicStorage.reset(allocSize); - fColors = (SkColor4f*)fDynamicStorage.get(); - fPos = (SkScalar*)(fColors + fCount); - } else { - fColors = fColorStorage; - fPos = fPosStorage; - } - if (!buffer.readColor4fArray(mutableColors(), fCount)) { + fColors = fColorStorage; + fPos = fPosStorage; + } + if (!buffer.readColor4fArray(mutableColors(), fCount)) { + return false; + } + if (SkToBool(flags & kHasColorSpace_GSF)) { + sk_sp<SkData> data = buffer.readByteArrayAsData(); + fColorSpace = SkColorSpace::Deserialize(data->data(), data->size()); + } else { + fColorSpace = nullptr; + } + if (SkToBool(flags & kHasPosition_GSF)) { + if (!buffer.readScalarArray(mutablePos(), fCount)) { return false; } - if (SkToBool(flags & kHasColorSpace_GSF)) { - sk_sp<SkData> data = buffer.readByteArrayAsData(); - fColorSpace = SkColorSpace::Deserialize(data->data(), data->size()); - } else { - fColorSpace = nullptr; - } - if (SkToBool(flags & kHasPosition_GSF)) { - if (!buffer.readScalarArray(mutablePos(), fCount)) { - return false; - } - } else { - fPos = nullptr; - } - if (SkToBool(flags & kHasLocalMatrix_GSF)) { - fLocalMatrix = &fLocalMatrixStorage; - buffer.readMatrix(&fLocalMatrixStorage); - } else { - fLocalMatrix = nullptr; - } + } else { + fPos = nullptr; + } + if (SkToBool(flags & kHasLocalMatrix_GSF)) { + fLocalMatrix = &fLocalMatrixStorage; + buffer.readMatrix(&fLocalMatrixStorage); + } else { + fLocalMatrix = nullptr; } return buffer.isValid(); } diff --git a/src/utils/SkBitmapSourceDeserializer.cpp b/src/utils/SkBitmapSourceDeserializer.cpp index 1f8cc1c7bd..ccc95eefcf 100644 --- a/src/utils/SkBitmapSourceDeserializer.cpp +++ b/src/utils/SkBitmapSourceDeserializer.cpp @@ -14,12 +14,7 @@ #include "SkReadBuffer.h" sk_sp<SkFlattenable> SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) { - SkFilterQuality filterQuality; - if (buffer.isVersionLT(SkReadBuffer::kBitmapSourceFilterQuality_Version)) { - filterQuality = kHigh_SkFilterQuality; - } else { - filterQuality = (SkFilterQuality)buffer.readInt(); - } + SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt(); SkRect src, dst; buffer.readRect(&src); buffer.readRect(&dst); |