diff options
author | mtklein <mtklein@google.com> | 2014-12-01 10:56:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-01 10:56:05 -0800 |
commit | 6e78293ee896020104ffc4c23b565073e9a49893 (patch) | |
tree | ddbfc5b976c891adf2e318008043a76e9c4a7f8d /src | |
parent | 52c293547b973f7fb5de3c83f5062b07d759ab88 (diff) |
Revert of Remove SK_SUPPORT_LEGACY_DEEPFLATTENING. (patchset #1 id:1 of https://codereview.chromium.org/769953002/)
Reason for revert:
Breaks canary builds. Will reland after the Chromium change lands.
Original issue's description:
> Remove SK_SUPPORT_LEGACY_DEEPFLATTENING.
>
> This was needed for pictures before v33, and we're now requiring v35+.
>
> Will follow up with the same for skia/ext/pixel_ref_utils_unittest.cc
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/52c293547b973f7fb5de3c83f5062b07d759ab88
TBR=reed@google.com,mtklein@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/768183002
Diffstat (limited to 'src')
65 files changed, 785 insertions, 23 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index f01d559058..1a451fd591 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -39,6 +39,15 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo fTileModeY = (uint8_t)tmy; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) : INHERITED(buffer) { + buffer.readBitmap(&fRawBitmap); + fRawBitmap.setImmutable(); + fTileModeX = buffer.readUInt(); + fTileModeY = buffer.readUInt(); +} +#endif + SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]) const { diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index e6ff1af1cf..17bb83bf56 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -56,6 +56,9 @@ public: }; protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkBitmapProcShader(SkReadBuffer& ); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index ba260ad716..f4669d5959 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -714,6 +714,15 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fProxy = buffer.readShader(); + // Leaving this here until we bump the picture version, though this + // shader should never be recorded. + buffer.readColor(); + } +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { buffer.writeFlattenable(fProxy); } diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp index 3c6623d291..3c5b55aae6 100644 --- a/src/core/SkComposeShader.cpp +++ b/src/core/SkComposeShader.cpp @@ -26,6 +26,20 @@ SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { SkSafeRef(mode); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkComposeShader::SkComposeShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fShaderA = buffer.readShader(); + if (NULL == fShaderA) { + fShaderA = SkNEW_ARGS(SkColorShader, ((SkColor)0)); + } + fShaderB = buffer.readShader(); + if (NULL == fShaderB) { + fShaderB = SkNEW_ARGS(SkColorShader, ((SkColor)0)); + } + fMode = buffer.readXfermode(); +} +#endif + SkComposeShader::~SkComposeShader() { SkSafeUnref(fMode); fShaderB->unref(); diff --git a/src/core/SkEmptyShader.h b/src/core/SkEmptyShader.h index b7fefbe109..250e37ab66 100644 --- a/src/core/SkEmptyShader.h +++ b/src/core/SkEmptyShader.h @@ -30,6 +30,10 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + virtual SkShader::Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE { return NULL; } diff --git a/src/core/SkFilterShader.cpp b/src/core/SkFilterShader.cpp index 48c4b8b477..cb042e604c 100644 --- a/src/core/SkFilterShader.cpp +++ b/src/core/SkFilterShader.cpp @@ -21,6 +21,13 @@ SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) { filter->ref(); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkFilterShader::SkFilterShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fShader = buffer.readShader(); + fFilter = buffer.readColorFilter(); +} +#endif + SkFilterShader::~SkFilterShader() { fFilter->unref(); fShader->unref(); diff --git a/src/core/SkFilterShader.h b/src/core/SkFilterShader.h index 44c2632711..b98fc839a6 100644 --- a/src/core/SkFilterShader.h +++ b/src/core/SkFilterShader.h @@ -45,6 +45,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkFilterShader(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp index 27efe7ece3..f8fdd4f00e 100644 --- a/src/core/SkFlattenable.cpp +++ b/src/core/SkFlattenable.cpp @@ -9,6 +9,16 @@ #include "SkPtrRecorder.h" #include "SkReadBuffer.h" +/////////////////////////////////////////////////////////////////////////////// + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +bool SkFlattenable::NeedsDeepUnflatten(const SkReadBuffer& buffer) { + return false; // TODO: looks like all this can go away too now? +} +#endif + +/////////////////////////////////////////////////////////////////////////////// + SkNamedFactorySet::SkNamedFactorySet() : fNextAddedFactory(0) {} uint32_t SkNamedFactorySet::find(SkFlattenable::Factory factory) { @@ -47,6 +57,8 @@ void SkRefCntSet::decPtr(void* ptr) { } /////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// #define MAX_ENTRY_COUNT 1024 diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp index 544ad2fe4c..62d5e36d89 100644 --- a/src/core/SkLocalMatrixShader.cpp +++ b/src/core/SkLocalMatrixShader.cpp @@ -7,6 +7,15 @@ #include "SkLocalMatrixShader.h" +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fProxyShader.reset(buffer.readShader()); + if (NULL == fProxyShader.get()) { + sk_throw(); + } +} +#endif + SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) { SkMatrix lm; buffer.readMatrix(&lm); diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index aad5668033..b8e4714615 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -33,7 +33,7 @@ public: } #if SK_SUPPORT_GPU - + virtual bool asFragmentProcessor(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix, GrColor* grColor, GrFragmentProcessor** fp) const SK_OVERRIDE { @@ -43,17 +43,17 @@ public: } return fProxyShader->asFragmentProcessor(context, paint, &tmp, grColor, fp); } - -#else - + +#else + virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrFragmentProcessor**) const SK_OVERRIDE { SkDEBUGFAIL("Should not call in GPU-less build"); return false; } - + #endif - + virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const SK_OVERRIDE { if (localMatrix) { *localMatrix = this->getLocalMatrix(); @@ -65,6 +65,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkLocalMatrixShader(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE; diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 7338789de2..d0748670e3 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -49,6 +49,14 @@ void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { buffer.writeFlattenable(fPE1); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { + fPE0 = buffer.readPathEffect(); + fPE1 = buffer.readPathEffect(); + // either of these may fail, so we have to check for nulls later on +} +#endif + /////////////////////////////////////////////////////////////////////////////// SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) { diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 5fded935cc..1f32a7ecdf 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -100,6 +100,15 @@ SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod , fTmy(tmy) { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPictureShader::SkPictureShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fTmx = static_cast<SkShader::TileMode>(buffer.read32()); + fTmy = static_cast<SkShader::TileMode>(buffer.read32()); + buffer.readRect(&fTile); + fPicture = SkPicture::CreateFromBuffer(buffer); +} +#endif + SkPictureShader::~SkPictureShader() { fPicture->unref(); } diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 816d6fd329..39e8ed35f5 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -46,6 +46,17 @@ SkShader::SkShader(const SkMatrix* localMatrix) { } } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { + inc_shader_counter(); + if (buffer.readBool()) { + buffer.readMatrix(&fLocalMatrix); + } else { + fLocalMatrix.reset(); + } +} +#endif + SkShader::~SkShader() { dec_shader_counter(); } @@ -260,6 +271,12 @@ bool SkColorShader::isOpaque() const { return SkColorGetA(fColor) == 255; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { + fColor = b.readColor(); +} +#endif + SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { return SkNEW_ARGS(SkColorShader, (buffer.readColor())); } diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index e0abb4ebdd..4a3ec39702 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -1237,6 +1237,23 @@ GrFragmentProcessor* XferEffect::TestCreate(SkRandom* rand, /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkProcCoeffXfermode::SkProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { + uint32_t mode32 = buffer.read32() % SK_ARRAY_COUNT(gProcCoeffs); + if (mode32 >= SK_ARRAY_COUNT(gProcCoeffs)) { + // out of range, just set to something harmless + mode32 = SkXfermode::kSrcOut_Mode; + } + fMode = (SkXfermode::Mode)mode32; + + const ProcCoeff& rec = gProcCoeffs[fMode]; + fProc = rec.fProc; + // these may be valid, or may be CANNOT_USE_COEFF + fSrcCoeff = rec.fSC; + fDstCoeff = rec.fDC; +} +#endif + SkFlattenable* SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) { uint32_t mode32 = buffer.read32(); if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { @@ -1426,6 +1443,9 @@ public: private: SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkClearXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {} +#endif typedef SkProcCoeffXfermode INHERITED; }; @@ -1488,6 +1508,9 @@ public: private: SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkSrcXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {} +#endif typedef SkProcCoeffXfermode INHERITED; }; @@ -1553,6 +1576,9 @@ public: private: SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif typedef SkProcCoeffXfermode INHERITED; }; @@ -1597,6 +1623,9 @@ public: private: SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkDstOutXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif typedef SkProcCoeffXfermode INHERITED; }; diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h index d7b47046d1..f3b9b2491a 100644 --- a/src/core/SkXfermode_proccoeff.h +++ b/src/core/SkXfermode_proccoeff.h @@ -22,7 +22,7 @@ public: fSrcCoeff = rec.fSC; fDstCoeff = rec.fDC; } - + virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const SK_OVERRIDE; virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, @@ -43,6 +43,10 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkProcCoeffXfermode(SkReadBuffer& buffer); +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; Mode getMode() const { return fMode; } diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp index 83f684e2ca..47824fd0f2 100644 --- a/src/effects/Sk1DPathEffect.cpp +++ b/src/effects/Sk1DPathEffect.cpp @@ -147,6 +147,22 @@ static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas, } } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPath1DPathEffect::SkPath1DPathEffect(SkReadBuffer& buffer) { + fAdvance = buffer.readScalar(); + if (fAdvance > 0) { + buffer.readPath(&fPath); + fInitialOffset = buffer.readScalar(); + fStyle = (Style) buffer.readUInt(); + } else { + SkDEBUGF(("SkPath1DPathEffect can't use advance <= 0\n")); + // Make Coverity happy. + fInitialOffset = 0; + fStyle = kStyleCount; + } +} +#endif + SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const { return fInitialOffset; } diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp index 2ad202ae85..cef2266d50 100644 --- a/src/effects/Sk2DPathEffect.cpp +++ b/src/effects/Sk2DPathEffect.cpp @@ -73,6 +73,13 @@ void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const { buffer.writeMatrix(fMatrix); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { + buffer.readMatrix(&fMatrix); + fMatrixIsInvertible = fMatrix.invert(&fInverse); +} +#endif + /////////////////////////////////////////////////////////////////////////////// bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, @@ -97,6 +104,12 @@ void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { } } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { + fWidth = buffer.readScalar(); +} +#endif + SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) { SkMatrix matrix; buffer.readMatrix(&matrix); @@ -115,6 +128,12 @@ SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) : INHERITED(m), fPath(p) { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { + buffer.readPath(&fPath); +} +#endif + SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) { SkMatrix matrix; buffer.readMatrix(&matrix); diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index ffdba32264..e181675409 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -19,6 +19,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, @@ -235,6 +238,15 @@ void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) co #endif +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fInnerThreshold = buffer.readScalar(); + fOuterThreshold = buffer.readScalar(); + buffer.readRegion(&fRegion); +} +#endif + SkFlattenable* SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkScalar inner = buffer.readScalar(); diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index d1e7472f06..6fb5241c82 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -49,6 +49,16 @@ private: fEnforcePMColor = enforcePMColor; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) { + fK[0] = buffer.readScalar(); + fK[1] = buffer.readScalar(); + fK[2] = buffer.readScalar(); + fK[3] = buffer.readScalar(); + fEnforcePMColor = buffer.readBool(); + } +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { buffer.writeScalar(fK[0]); buffer.writeScalar(fK[1]); diff --git a/src/effects/SkAvoidXfermode.cpp b/src/effects/SkAvoidXfermode.cpp index 41c4e9646d..b596bfdb73 100644 --- a/src/effects/SkAvoidXfermode.cpp +++ b/src/effects/SkAvoidXfermode.cpp @@ -21,6 +21,14 @@ SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) { fMode = mode; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkAvoidXfermode::SkAvoidXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { + fOpColor = buffer.readColor(); + fDistMul = buffer.readUInt(); + fMode = (Mode)buffer.readUInt(); +} +#endif + SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) { const SkColor color = buffer.readColor(); const unsigned tolerance = buffer.readUInt(); diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp index ff76ab4bba..4da77a9e02 100644 --- a/src/effects/SkBitmapSource.cpp +++ b/src/effects/SkBitmapSource.cpp @@ -26,6 +26,15 @@ SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co , fSrcRect(srcRect) , fDstRect(dstRect) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) { + buffer.readBitmap(&fBitmap); + buffer.readRect(&fSrcRect); + buffer.readRect(&fDstRect); + buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect)); +} +#endif + SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) { SkRect src, dst; buffer.readRect(&src); diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp index b3094d6c45..fc9e47b0b4 100644 --- a/src/effects/SkBlurDrawLooper.cpp +++ b/src/effects/SkBlurDrawLooper.cpp @@ -62,6 +62,19 @@ void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, this->initEffects(); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) { + + fSigma = buffer.readScalar(); + fDx = buffer.readScalar(); + fDy = buffer.readScalar(); + fBlurColor = buffer.readColor(); + fBlurFlags = buffer.readUInt() & kAll_BlurFlag; + + this->initEffects(); +} +#endif + SkFlattenable* SkBlurDrawLooper::CreateProc(SkReadBuffer& buffer) { const SkColor color = buffer.readColor(); const SkScalar sigma = buffer.readScalar(); diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index e5bb8c1e74..4166d20035 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -31,6 +31,18 @@ static SkVector mapSigma(const SkSize& localSigma, const SkMatrix& ctm) { return sigma; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fSigma.fWidth = buffer.readScalar(); + fSigma.fHeight = buffer.readScalar(); + buffer.validate(SkScalarIsFinite(fSigma.fWidth) && + SkScalarIsFinite(fSigma.fHeight) && + (fSigma.fWidth >= 0) && + (fSigma.fHeight >= 0)); +} +#endif + SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input, diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index b5bcc3c5de..5b0e60adde 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -585,6 +585,16 @@ void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src, src.fRight + pad, src.fBottom + pad); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) : SkMaskFilter(buffer) { + fSigma = buffer.readScalar(); + fBlurStyle = (SkBlurStyle)buffer.readInt(); + fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag; + SkASSERT(fSigma > 0); + SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle); +} +#endif + SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { const SkScalar sigma = buffer.readScalar(); const unsigned style = buffer.readUInt(); diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp index 30641c3c30..18c5b5603f 100644 --- a/src/effects/SkColorCubeFilter.cpp +++ b/src/effects/SkColorCubeFilter.cpp @@ -161,6 +161,15 @@ void SkColorCubeFilter::filterSpan(const SkPMColor src[], int count, SkPMColor d } } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkColorCubeFilter::SkColorCubeFilter(SkReadBuffer& buffer) + : fCache(buffer.readInt()) { + fCubeData.reset(buffer.readByteArrayAsData()); + buffer.validate(is_valid_3D_lut(fCubeData, fCache.cubeDimension())); + fUniqueID = SkNextColorCubeUniqueID(); +} +#endif + SkFlattenable* SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) { int cubeDimension = buffer.readInt(); SkAutoDataUnref cubeData(buffer.readByteArrayAsData()); diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp index 10976d77f0..012f1329a4 100755 --- a/src/effects/SkColorFilterImageFilter.cpp +++ b/src/effects/SkColorFilterImageFilter.cpp @@ -84,6 +84,21 @@ SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, : INHERITED(1, &input, cropRect, uniqueID), fColorFilter(SkRef(cf)) { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { + fColorFilter = buffer.readColorFilter(); + // we aren't prepared for this to be NULL, and it can't ever be when we're NOT supporting + // SK_SUPPORT_LEGACY_DEEPFLATTENING, as we always go through a factory which can detect + // NULL. However, since here we're in the legacy code, we assign a dummy filter so we + // don't crash with a null-ptr. + if (NULL == fColorFilter) { + // colormatrix identity is effectively a no-op + fColorFilter = SkColorMatrixFilter::Create(SkColorMatrix()); + SkASSERT(fColorFilter); + } +} +#endif + SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter()); diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index 92e6f432f1..e085281aa5 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -84,6 +84,17 @@ protected: buffer.writeUInt(fMode); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkModeColorFilter(SkReadBuffer& buffer) { + fColor = buffer.readColor(); + fMode = (SkXfermode::Mode)buffer.readUInt(); + if (buffer.isValid()) { + this->updateCache(); + buffer.validate(SkIsValidMode(fMode)); + } + } +#endif + private: SkColor fColor; SkXfermode::Mode fMode; diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 27231b1466..20702920de 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -307,6 +307,15 @@ void SkColorMatrixFilter::flatten(SkWriteBuffer& buffer) const { buffer.writeScalarArray(fMatrix.fMat, 20); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer) : INHERITED(buffer) { + SkASSERT(buffer.getArrayCount() == 20); + if (buffer.readScalarArray(fMatrix.fMat, 20)) { + this->initState(fMatrix.fMat); + } +} +#endif + SkFlattenable* SkColorMatrixFilter::CreateProc(SkReadBuffer& buffer) { SkColorMatrix matrix; if (buffer.readScalarArray(matrix.fMat, 20)) { diff --git a/src/effects/SkComposeImageFilter.cpp b/src/effects/SkComposeImageFilter.cpp index 9bec500976..c0556749ac 100644 --- a/src/effects/SkComposeImageFilter.cpp +++ b/src/effects/SkComposeImageFilter.cpp @@ -40,3 +40,9 @@ SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); return SkComposeImageFilter::Create(common.getInput(0), common.getInput(1)); } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkComposeImageFilter::SkComposeImageFilter(SkReadBuffer& buffer) + : INHERITED(2, buffer) { +} +#endif diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp index 8dc506ace4..06558826bf 100644 --- a/src/effects/SkCornerPathEffect.cpp +++ b/src/effects/SkCornerPathEffect.cpp @@ -135,3 +135,9 @@ SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) { void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const { buffer.writeScalar(fRadius); } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkCornerPathEffect::SkCornerPathEffect(SkReadBuffer& buffer) { + fRadius = buffer.readScalar(); +} +#endif diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp index f866ea074e..f31d883c8e 100644 --- a/src/effects/SkDashPathEffect.cpp +++ b/src/effects/SkDashPathEffect.cpp @@ -369,3 +369,28 @@ SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { } return NULL; } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) + : INHERITED(buffer) + , fPhase(0) + , fInitialDashLength(0) + , fInitialDashIndex(0) + , fIntervalLength(0) { + fPhase = buffer.readScalar(); + fCount = buffer.getArrayCount(); + size_t allocSize = sizeof(SkScalar) * fCount; + if (buffer.validateAvailable(allocSize)) { + fIntervals = (SkScalar*)sk_malloc_throw(allocSize); + buffer.readScalarArray(fIntervals, fCount); + } else { + fIntervals = NULL; + } + + // set the internal data members, fPhase should have been between 0 and intervalLength + // when written to buffer so no need to adjust it + SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount, + &fInitialDashLength, &fInitialDashIndex, &fIntervalLength); +} +#endif + diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp index 8aa0e22356..e8cc6a2f70 100644 --- a/src/effects/SkDiscretePathEffect.cpp +++ b/src/effects/SkDiscretePathEffect.cpp @@ -87,3 +87,12 @@ void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const { buffer.writeScalar(fPerterb); buffer.writeUInt(fSeedAssist); } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDiscretePathEffect::SkDiscretePathEffect(SkReadBuffer& buffer) { + fSegLength = buffer.readScalar(); + fPerterb = buffer.readScalar(); + fSeedAssist = buffer.readUInt(); +} +#endif + diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index d39240e012..edae0441f4 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -192,6 +192,19 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel SkDisplacementMapEffect::~SkDisplacementMapEffect() { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDisplacementMapEffect::SkDisplacementMapEffect(SkReadBuffer& buffer) + : INHERITED(2, buffer) +{ + fXChannelSelector = (SkDisplacementMapEffect::ChannelSelectorType) buffer.readInt(); + fYChannelSelector = (SkDisplacementMapEffect::ChannelSelectorType) buffer.readInt(); + fScale = buffer.readScalar(); + buffer.validate(channel_selector_type_is_valid(fXChannelSelector) && + channel_selector_type_is_valid(fYChannelSelector) && + SkScalarIsFinite(fScale)); +} +#endif + SkFlattenable* SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt(); diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp index 5bbb958e9c..0ba8b234b7 100644 --- a/src/effects/SkDropShadowImageFilter.cpp +++ b/src/effects/SkDropShadowImageFilter.cpp @@ -29,6 +29,24 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDropShadowImageFilter::SkDropShadowImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fDx = buffer.readScalar(); + fDy = buffer.readScalar(); + fSigmaX = buffer.readScalar(); + fSigmaY = buffer.readScalar(); + fColor = buffer.readColor(); + fShadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ? + kDrawShadowAndForeground_ShadowMode : + static_cast<ShadowMode>(buffer.readInt()); + buffer.validate(SkScalarIsFinite(fDx) && + SkScalarIsFinite(fDy) && + SkScalarIsFinite(fSigmaX) && + SkScalarIsFinite(fSigmaY)); +} +#endif + SkFlattenable* SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkScalar dx = buffer.readScalar(); diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp index 8fcd272646..4841b92816 100644 --- a/src/effects/SkEmbossMaskFilter.cpp +++ b/src/effects/SkEmbossMaskFilter.cpp @@ -124,6 +124,15 @@ bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src, return true; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer) : SkMaskFilter(buffer) { + SkASSERT(buffer.getArrayCount() == sizeof(Light)); + buffer.readByteArray(&fLight, sizeof(Light)); + SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean + fBlurSigma = buffer.readScalar(); +} +#endif + SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) { Light light; if (buffer.readByteArray(&light, sizeof(Light))) { diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp index d3e112c3a4..b331a0363d 100644 --- a/src/effects/SkLayerRasterizer.cpp +++ b/src/effects/SkLayerRasterizer.cpp @@ -148,13 +148,18 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix, return true; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLayerRasterizer::SkLayerRasterizer(SkReadBuffer& buffer) + : SkRasterizer(buffer), fLayers(ReadLayers(buffer)) {} +#endif + SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) { return SkNEW_ARGS(SkLayerRasterizer, (ReadLayers(buffer))); } SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) { int count = buffer.readInt(); - + SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec))); for (int i = 0; i < count; i++) { SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back(); diff --git a/src/effects/SkLerpXfermode.cpp b/src/effects/SkLerpXfermode.cpp index 76c97ef9ac..0376a57b64 100644 --- a/src/effects/SkLerpXfermode.cpp +++ b/src/effects/SkLerpXfermode.cpp @@ -23,6 +23,12 @@ SkXfermode* SkLerpXfermode::Create(SkScalar scale) { SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { + fScale256 = buffer.readUInt(); +} +#endif + void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const { buffer.writeUInt(fScale256); } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 740ad02969..bf9877e044 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -290,6 +290,9 @@ protected: SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; @@ -319,6 +322,9 @@ protected: SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect*, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; @@ -936,6 +942,15 @@ SkImageFilter* SkLightingImageFilter::CreateSpotLitSpecular(const SkPoint3& loca SkLightingImageFilter::~SkLightingImageFilter() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLightingImageFilter::SkLightingImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fLight.reset(SkLight::UnflattenLight(buffer)); + fSurfaceScale = buffer.readScalar(); + buffer.validate(SkScalarIsFinite(fSurfaceScale)); +} +#endif + void SkLightingImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); fLight->flattenLight(buffer); @@ -966,6 +981,15 @@ SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkSca { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkReadBuffer& buffer) + : INHERITED(buffer) +{ + fKD = buffer.readScalar(); + buffer.validate(SkScalarIsFinite(fKD) && (fKD >= 0)); +} +#endif + SkFlattenable* SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkAutoTUnref<SkLight> light(SkLight::UnflattenLight(buffer)); @@ -1072,6 +1096,17 @@ SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkS { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkReadBuffer& buffer) + : INHERITED(buffer) +{ + fKS = buffer.readScalar(); + fShininess = buffer.readScalar(); + buffer.validate(SkScalarIsFinite(fKS) && (fKS >= 0) && + SkScalarIsFinite(fShininess)); +} +#endif + SkFlattenable* SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkAutoTUnref<SkLight> light(SkLight::UnflattenLight(buffer)); diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp index 9ad5797f35..2b57cb1cef 100644 --- a/src/effects/SkLumaColorFilter.cpp +++ b/src/effects/SkLumaColorFilter.cpp @@ -44,6 +44,10 @@ SkColorFilter* SkLumaColorFilter::Create() { SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLumaColorFilter::SkLumaColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) { return SkNEW(SkLumaColorFilter); } diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 973ac66905..e0826efe0d 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -235,7 +235,7 @@ void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar inset, SkImageFilter* input) { - + if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) { return NULL; } @@ -247,6 +247,22 @@ SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + float x = buffer.readScalar(); + float y = buffer.readScalar(); + float width = buffer.readScalar(); + float height = buffer.readScalar(); + fSrcRect = SkRect::MakeXYWH(x, y, width, height); + fInset = buffer.readScalar(); + + buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && + // Negative numbers in src rect are not supported + (fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0)); +} +#endif + SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input) : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) { diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 045f6a96d5..cdcf66f692 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -76,6 +76,50 @@ SkMatrixConvolutionImageFilter* SkMatrixConvolutionImageFilter::Create( input, cropRect, uniqueID)); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +static bool tile_mode_is_valid(SkMatrixConvolutionImageFilter::TileMode tileMode) { + switch (tileMode) { + case SkMatrixConvolutionImageFilter::kClamp_TileMode: + case SkMatrixConvolutionImageFilter::kRepeat_TileMode: + case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: + return true; + default: + break; + } + return false; +} + +SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fKernelSize.fWidth = buffer.readInt(); + fKernelSize.fHeight = buffer.readInt(); + if ((fKernelSize.fWidth >= 1) && (fKernelSize.fHeight >= 1) && + // Make sure size won't be larger than a signed int, + // which would still be extremely large for a kernel, + // but we don't impose a hard limit for kernel size + (gMaxKernelSize / fKernelSize.fWidth >= fKernelSize.fHeight)) { + size_t size = fKernelSize.fWidth * fKernelSize.fHeight; + fKernel = SkNEW_ARRAY(SkScalar, size); + SkDEBUGCODE(bool success =) buffer.readScalarArray(fKernel, size); + SkASSERT(success); + } else { + fKernel = 0; + } + fGain = buffer.readScalar(); + fBias = buffer.readScalar(); + fKernelOffset.fX = buffer.readInt(); + fKernelOffset.fY = buffer.readInt(); + fTileMode = (TileMode) buffer.readInt(); + fConvolveAlpha = buffer.readBool(); + buffer.validate((fKernel != 0) && + SkScalarIsFinite(fGain) && + SkScalarIsFinite(fBias) && + tile_mode_is_valid(fTileMode) && + (fKernelOffset.fX >= 0) && (fKernelOffset.fX < fKernelSize.fWidth) && + (fKernelOffset.fY >= 0) && (fKernelOffset.fY < fKernelSize.fHeight)); +} +#endif + SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkISize kernelSize; diff --git a/src/effects/SkMatrixImageFilter.cpp b/src/effects/SkMatrixImageFilter.cpp index 919dff3994..8b07dd4a46 100644 --- a/src/effects/SkMatrixImageFilter.cpp +++ b/src/effects/SkMatrixImageFilter.cpp @@ -31,6 +31,14 @@ SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform, return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input, uniqueID)); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + buffer.readMatrix(&fTransform); + fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt()); +} +#endif + SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkMatrix matrix; diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp index d932d3ccce..9e7f4e543c 100755 --- a/src/effects/SkMergeImageFilter.cpp +++ b/src/effects/SkMergeImageFilter.cpp @@ -140,3 +140,24 @@ void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); } } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkMergeImageFilter::SkMergeImageFilter(SkReadBuffer& buffer) + : INHERITED(-1, buffer) { + bool hasModes = buffer.readBool(); + if (hasModes) { + this->initAllocModes(); + int nbInputs = countInputs(); + size_t size = nbInputs * sizeof(fModes[0]); + SkASSERT(buffer.getArrayCount() == size); + if (buffer.validate(buffer.getArrayCount() == size) && + buffer.readByteArray(fModes, size)) { + for (int i = 0; i < nbInputs; ++i) { + buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); + } + } + } else { + fModes = 0; + } +} +#endif diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 3d27d10ee1..9c97c35bc2 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -22,6 +22,16 @@ #include "effects/Gr1DKernelEffect.h" #endif +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fRadius.fWidth = buffer.readInt(); + fRadius.fHeight = buffer.readInt(); + buffer.validate((fRadius.fWidth >= 0) && + (fRadius.fHeight >= 0)); +} +#endif + SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp index b7ded082d9..90528c62d8 100644 --- a/src/effects/SkOffsetImageFilter.cpp +++ b/src/effects/SkOffsetImageFilter.cpp @@ -108,3 +108,12 @@ SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter : INHERITED(1, &input, cropRect, uniqueID) { fOffset.set(dx, dy); } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + buffer.readPoint(&fOffset); + buffer.validate(SkScalarIsFinite(fOffset.fX) && + SkScalarIsFinite(fOffset.fY)); +} +#endif diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 8c608fa036..019258972d 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -51,6 +51,11 @@ inline SkScalar smoothCurve(SkScalar t) { return SkScalarMul(SkScalarSquare(t), SK_Scalar3 - 2 * t); } +bool perlin_noise_type_is_valid(SkPerlinNoiseShader::Type type) { + return (SkPerlinNoiseShader::kFractalNoise_Type == type) || + (SkPerlinNoiseShader::kTurbulence_Type == type); +} + } // end namespace struct SkPerlinNoiseShader::StitchData { @@ -283,6 +288,22 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkASSERT(numOctaves >= 0 && numOctaves < 256); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer) : INHERITED(buffer) { + fType = (SkPerlinNoiseShader::Type) buffer.readInt(); + fBaseFrequencyX = buffer.readScalar(); + fBaseFrequencyY = buffer.readScalar(); + fNumOctaves = buffer.readInt(); + fSeed = buffer.readScalar(); + fStitchTiles = buffer.readBool(); + fTileSize.fWidth = buffer.readInt(); + fTileSize.fHeight = buffer.readInt(); + buffer.validate(perlin_noise_type_is_valid(fType) && + (fNumOctaves >= 0) && (fNumOctaves <= 255) && + (fStitchTiles != fTileSize.isEmpty())); +} +#endif + SkPerlinNoiseShader::~SkPerlinNoiseShader() { } @@ -943,7 +964,7 @@ bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& const SkMatrix* externalLocalMatrix, GrColor* paintColor, GrFragmentProcessor** fp) const { SkASSERT(context); - + *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); SkMatrix localMatrix = this->getLocalMatrix(); diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index 5399ea7476..da5597d699 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -30,6 +30,21 @@ SkPictureImageFilter::~SkPictureImageFilter() { SkSafeUnref(fPicture); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer) + : INHERITED(0, buffer), + fPicture(NULL) { + if (!buffer.isCrossProcess()) { + if (buffer.readBool()) { + fPicture = SkPicture::CreateFromBuffer(buffer); + } + } else { + buffer.validate(!buffer.readBool()); + } + buffer.readRect(&fCropRect); +} +#endif + SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { SkAutoTUnref<SkPicture> picture; SkRect cropRect; diff --git a/src/effects/SkPixelXorXfermode.cpp b/src/effects/SkPixelXorXfermode.cpp index 2a6ac47aac..68b5306a52 100644 --- a/src/effects/SkPixelXorXfermode.cpp +++ b/src/effects/SkPixelXorXfermode.cpp @@ -25,6 +25,12 @@ void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { wb.writeColor(fOpColor); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb) : INHERITED(rb) { + fOpColor = rb.readColor(); +} +#endif + SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) { return Create(buffer.readColor()); } diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp index 91a127e0e3..09417c8840 100644 --- a/src/effects/SkRectShaderImageFilter.cpp +++ b/src/effects/SkRectShaderImageFilter.cpp @@ -34,6 +34,13 @@ SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr , fShader(SkRef(s)) { } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) + : INHERITED(0, buffer) { + fShader = buffer.readShader(); +} +#endif + SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); SkAutoTUnref<SkShader> shader(buffer.readShader()); diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 7cd628fd2d..c3c2ba067b 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -61,6 +61,9 @@ public: }; protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkTable_ColorFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: @@ -224,6 +227,27 @@ SkFlattenable* SkTable_ColorFilter::CreateProc(SkReadBuffer& buffer) { return SkTableColorFilter::CreateARGB(a, r, g, b); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkTable_ColorFilter::SkTable_ColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) { + fBitmap = NULL; + + uint8_t storage[5*256]; + + fFlags = buffer.readInt(); + + size_t size = buffer.getArrayCount(); + SkASSERT(size <= sizeof(storage)); + buffer.validate(size <= sizeof(storage)); + buffer.readByteArray(storage, size); + + SkDEBUGCODE(size_t raw = ) SkPackBits::Unpack8(storage, size, fStorage); + + SkASSERT(raw <= sizeof(fStorage)); + SkDEBUGCODE(size_t count = gCountNibBits[fFlags & 0xF]); + SkASSERT(raw == count * 256); +} +#endif + bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const { if (table) { if (NULL == fBitmap) { @@ -288,7 +312,7 @@ private: GrTextureAccess fTextureAccess; // currently not used in shader code, just to assist onComputeInvariantOutput(). - unsigned fFlags; + unsigned fFlags; GrTextureStripAtlas* fAtlas; int fRow; @@ -334,7 +358,7 @@ void GLColorTableEffect::setData(const GrGLProgramDataManager& pdm, const GrProc rgbaYValues[3] = 0.125; rgbaYValues[0] = 0.375; rgbaYValues[1] = 0.625; - rgbaYValues[2] = 0.875; + rgbaYValues[2] = 0.875; } pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); } diff --git a/src/effects/SkTableMaskFilter.cpp b/src/effects/SkTableMaskFilter.cpp index dc9b335fd4..42b4ab6ff6 100644 --- a/src/effects/SkTableMaskFilter.cpp +++ b/src/effects/SkTableMaskFilter.cpp @@ -82,6 +82,13 @@ SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { return Create(table); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkTableMaskFilter::SkTableMaskFilter(SkReadBuffer& rb) : INHERITED(rb) { + SkASSERT(256 == rb.getArrayCount()); + rb.readByteArray(fTable, 256); +} +#endif + /////////////////////////////////////////////////////////////////////////////// void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp index be991f6f83..a414c924f3 100755 --- a/src/effects/SkTestImageFilters.cpp +++ b/src/effects/SkTestImageFilters.cpp @@ -80,3 +80,11 @@ void SkDownSampleImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fScale); } + +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkDownSampleImageFilter::SkDownSampleImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + fScale = buffer.readScalar(); + buffer.validate(SkScalarIsFinite(fScale)); +} +#endif diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index d640ac7adb..04c62d0574 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -93,6 +93,15 @@ bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, return true; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkTileImageFilter::SkTileImageFilter(SkReadBuffer& buffer) + : INHERITED(1, buffer) { + buffer.readRect(&fSrcRect); + buffer.readRect(&fDstRect); + buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect)); +} +#endif + SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkRect src, dst; diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 1618b64036..379d6d8f95 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -32,6 +32,13 @@ SkXfermodeImageFilter::~SkXfermodeImageFilter() { SkSafeUnref(fMode); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkXfermodeImageFilter::SkXfermodeImageFilter(SkReadBuffer& buffer) + : INHERITED(2, buffer) { + fMode = buffer.readXfermode(); +} +#endif + SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); SkAutoTUnref<SkXfermode> mode(buffer.readXfermode()); diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index e70be04697..d7b51440b3 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -199,6 +199,56 @@ SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc) this->initCommon(); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +static SkShader::TileMode unpack_mode(uint32_t packed) { + return (SkShader::TileMode)(packed & 0xF); +} + +static uint32_t unpack_flags(uint32_t packed) { + return packed >> 4; +} + +SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buffer) { + int colorCount = fColorCount = buffer.getArrayCount(); + if (colorCount > kColorStorageCount) { + size_t allocSize = (sizeof(SkColor) + sizeof(SkScalar) + sizeof(Rec)) * colorCount; + if (buffer.validateAvailable(allocSize)) { + fOrigColors = reinterpret_cast<SkColor*>(sk_malloc_throw(allocSize)); + } else { + fOrigColors = NULL; + colorCount = fColorCount = 0; + } + } else { + fOrigColors = fStorage; + } + buffer.readColorArray(fOrigColors, colorCount); + + fOrigPos = (SkScalar*)(fOrigColors + colorCount); + + { + uint32_t packed = buffer.readUInt(); + fGradFlags = SkToU8(unpack_flags(packed)); + fTileMode = unpack_mode(packed); + } + fTileProc = gTileProcs[fTileMode]; + fRecs = (Rec*)(fOrigPos + colorCount); + if (colorCount > 2) { + Rec* recs = fRecs; + recs[0].fPos = 0; + fOrigPos[0] = 0; + for (int i = 1; i < colorCount; i++) { + recs[i].fPos = buffer.readInt(); + recs[i].fScale = buffer.readUInt(); + fOrigPos[i] = SkFixedToScalar(recs[i].fPos); + } + } else { + fOrigPos = NULL; + } + buffer.readMatrix(&fPtsToUnit); + this->initCommon(); +} +#endif + SkGradientShaderBase::~SkGradientShaderBase() { if (fOrigColors != fStorage) { sk_free(fOrigColors); diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 1faca5e4a1..3ab721950a 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -60,6 +60,14 @@ SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) pts_to_unit_matrix(pts, &fPtsToUnit); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkLinearGradient::SkLinearGradient(SkReadBuffer& buffer) + : INHERITED(buffer) + , fStart(buffer.readPoint()) + , fEnd(buffer.readPoint()) { +} +#endif + SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) { DescriptorScope desc; if (!desc.unflatten(buffer)) { @@ -560,7 +568,7 @@ bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa const SkMatrix* localMatrix, GrColor* paintColor, GrFragmentProcessor** fp) const { SkASSERT(context); - + SkMatrix matrix; if (!this->getLocalMatrix().invert(&matrix)) { return false; @@ -573,10 +581,10 @@ bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa matrix.postConcat(inv); } matrix.postConcat(fPtsToUnit); - + *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); - + return true; } diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 7c0e8f6031..99531d93d4 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -252,6 +252,14 @@ SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const { return kRadial_GradientType; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkRadialGradient::SkRadialGradient(SkReadBuffer& buffer) + : INHERITED(buffer), + fCenter(buffer.readPoint()), + fRadius(buffer.readScalar()) { +} +#endif + SkFlattenable* SkRadialGradient::CreateProc(SkReadBuffer& buffer) { DescriptorScope desc; if (!desc.unflatten(buffer)) { @@ -570,7 +578,7 @@ bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa const SkMatrix* localMatrix, GrColor* paintColor, GrFragmentProcessor** fp) const { SkASSERT(context); - + SkMatrix matrix; if (!this->getLocalMatrix().invert(&matrix)) { return false; @@ -583,10 +591,10 @@ bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa matrix.postConcat(inv); } matrix.postConcat(fPtsToUnit); - + *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); - + return true; } diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 163700641c..d080ec5fde 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -41,6 +41,13 @@ SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const { return kSweep_GradientType; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkSweepGradient::SkSweepGradient(SkReadBuffer& buffer) + : INHERITED(buffer), + fCenter(buffer.readPoint()) { +} +#endif + SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) { DescriptorScope desc; if (!desc.unflatten(buffer)) { @@ -287,7 +294,7 @@ void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix, GrColor* paintColor, GrFragmentProcessor** effect) const { - + SkMatrix matrix; if (!this->getLocalMatrix().invert(&matrix)) { return false; @@ -300,10 +307,10 @@ bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai matrix.postConcat(inv); } matrix.postConcat(fPtsToUnit); - + *effect = GrSweepGradient::Create(context, *this, matrix); *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); - + return true; } diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index 2ca4a623fa..d816295077 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -41,6 +41,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkSweepGradient(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 2fc848e109..5410f6a9df 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -343,6 +343,19 @@ SkShader::GradientType SkTwoPointConicalGradient::asAGradient( return kConical_GradientType; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkTwoPointConicalGradient::SkTwoPointConicalGradient( + SkReadBuffer& buffer) + : INHERITED(buffer) + , fCenter1(buffer.readPoint()) + , fCenter2(buffer.readPoint()) + , fRadius1(buffer.readScalar()) + , fRadius2(buffer.readScalar()) + , fFlippedGrad(buffer.readBool()) { + this->init(); +} +#endif + SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) { DescriptorScope desc; if (!desc.unflatten(buffer)) { diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 8ce3f435b7..3e400445ae 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -343,6 +343,17 @@ void SkTwoPointRadialGradient::toString(SkString* str) const { } #endif +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkTwoPointRadialGradient::SkTwoPointRadialGradient(SkReadBuffer& buffer) + : INHERITED(buffer), + fCenter1(buffer.readPoint()), + fCenter2(buffer.readPoint()), + fRadius1(buffer.readScalar()), + fRadius2(buffer.readScalar()) { + init(); +}; +#endif + SkFlattenable* SkTwoPointRadialGradient::CreateProc(SkReadBuffer& buffer) { DescriptorScope desc; if (!desc.unflatten(buffer)) { @@ -675,7 +686,7 @@ bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP const SkMatrix* localMatrix, GrColor* paintColor, GrFragmentProcessor** fp) const { SkASSERT(context); - + // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis. SkMatrix matrix; if (!this->getLocalMatrix().invert(&matrix)) { @@ -701,7 +712,7 @@ bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); - + return true; } diff --git a/src/opts/SkXfermode_opts_SSE2.cpp b/src/opts/SkXfermode_opts_SSE2.cpp index fccf665147..02ca0382dd 100644 --- a/src/opts/SkXfermode_opts_SSE2.cpp +++ b/src/opts/SkXfermode_opts_SSE2.cpp @@ -641,6 +641,13 @@ typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst); extern SkXfermodeProcSIMD gSSE2XfermodeProcs[]; +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { + fProcSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[this->getMode()]); + buffer.validate(fProcSIMD != NULL); +} +#endif + void SkSSE2ProcCoeffXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const { SkASSERT(dst && src && count >= 0); diff --git a/src/opts/SkXfermode_opts_SSE2.h b/src/opts/SkXfermode_opts_SSE2.h index 7ccce488fd..8512aee094 100644 --- a/src/opts/SkXfermode_opts_SSE2.h +++ b/src/opts/SkXfermode_opts_SSE2.h @@ -25,6 +25,10 @@ public: SK_TO_STRING_OVERRIDE() private: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer); +#endif + void* fProcSIMD; typedef SkProcCoeffXfermode INHERITED; }; diff --git a/src/opts/SkXfermode_opts_arm_neon.cpp b/src/opts/SkXfermode_opts_arm_neon.cpp index 7534c986ca..dca58eb53e 100644 --- a/src/opts/SkXfermode_opts_arm_neon.cpp +++ b/src/opts/SkXfermode_opts_arm_neon.cpp @@ -743,6 +743,12 @@ typedef uint8x8x4_t (*SkXfermodeProcSIMD)(uint8x8x4_t src, uint8x8x4_t dst); extern SkXfermodeProcSIMD gNEONXfermodeProcs[]; +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +SkNEONProcCoeffXfermode::SkNEONProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { + fProcSIMD = reinterpret_cast<void*>(gNEONXfermodeProcs[this->getMode()]); +} +#endif + void SkNEONProcCoeffXfermode::xfer32(SkPMColor* SK_RESTRICT dst, const SkPMColor* SK_RESTRICT src, int count, const SkAlpha* SK_RESTRICT aa) const { diff --git a/src/opts/SkXfermode_opts_arm_neon.h b/src/opts/SkXfermode_opts_arm_neon.h index f091432d88..745bfe260c 100644 --- a/src/opts/SkXfermode_opts_arm_neon.h +++ b/src/opts/SkXfermode_opts_arm_neon.h @@ -17,6 +17,10 @@ public: SK_TO_STRING_OVERRIDE() private: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkNEONProcCoeffXfermode(SkReadBuffer& buffer); +#endif + // void* is used to avoid pulling arm_neon.h in the core and having to build // it with -mfpu=neon. void* fProcSIMD; |