diff options
author | Mike Reed <reed@google.com> | 2017-06-08 12:45:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-08 18:23:19 +0000 |
commit | 70bc94f273224ed0755ae11dc479c57ff37e0436 (patch) | |
tree | f25bc45fd7e882d3baee4b3640b82b881d45ae23 /src/shaders | |
parent | bc2cdd154bf5a031ca9d3a530123d9f7a4c0925d (diff) |
Bump min picture to 7+ months ago
Delete lots of support code, including need for SkXfermode objects
which are no longer used anywhere else.
Bug: skia:
Change-Id: Id6b7ef0f529691041ff2b206c35e336e8a4c974d
Reviewed-on: https://skia-review.googlesource.com/19059
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/shaders')
-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 |
3 files changed, 38 insertions, 91 deletions
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(); } |