diff options
115 files changed, 1050 insertions, 38 deletions
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp index 749334a61e..4546b8add2 100644 --- a/gm/imagefiltersbase.cpp +++ b/gm/imagefiltersbase.cpp @@ -22,7 +22,11 @@ public: public: Registrar() { SkFlattenable::Register("FailImageFilter", +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + FailImageFilter::DeepCreateProc, +#else FailImageFilter::CreateProc, +#endif FailImageFilter::GetFlattenableType()); } }; @@ -40,6 +44,10 @@ protected: return false; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + FailImageFilter(SkReadBuffer& buffer) : INHERITED(0, buffer) {} +#endif + private: typedef SkImageFilter INHERITED; }; @@ -57,7 +65,11 @@ public: public: Registrar() { SkFlattenable::Register("IdentityImageFilter", +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + IdentityImageFilter::DeepCreateProc, +#else IdentityImageFilter::CreateProc, +#endif IdentityImageFilter::GetFlattenableType()); } }; @@ -76,6 +88,10 @@ protected: return true; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + IdentityImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) {} +#endif + private: typedef SkImageFilter INHERITED; }; diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp index 8469a43b59..8af268e568 100644 --- a/gm/imagefiltersgraph.cpp +++ b/gm/imagefiltersgraph.cpp @@ -29,7 +29,11 @@ public: public: Registrar() { SkFlattenable::Register("SimpleOffsetFilter", +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SimpleOffsetFilter::DeepCreateProc, +#else SimpleOffsetFilter::CreateProc, +#endif SimpleOffsetFilter::GetFlattenableType()); } }; @@ -65,6 +69,14 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SimpleOffsetFilter(SkReadBuffer& buffer) + : SkImageFilter(1, buffer) { + fDX = buffer.readScalar(); + fDY = buffer.readScalar(); + } +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeScalar(fDX); diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index 929607a398..31d4a01ee7 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -135,6 +135,9 @@ public: protected: SkColorFilter() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkColorFilter(SkReadBuffer& rb) : INHERITED(rb) {} +#endif private: typedef SkFlattenable INHERITED; diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h index c866183cb3..f771d01c70 100644 --- a/include/core/SkDrawLooper.h +++ b/include/core/SkDrawLooper.h @@ -114,6 +114,9 @@ public: protected: SkDrawLooper() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif private: typedef SkFlattenable INHERITED; diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h index 3cfa85af48..679f640d3c 100644 --- a/include/core/SkFlattenable.h +++ b/include/core/SkFlattenable.h @@ -13,6 +13,8 @@ class SkReadBuffer; class SkWriteBuffer; +#define SK_SUPPORT_LEGACY_DEEPFLATTENING + /* * Flattening is straight-forward: * 1. call getFactory() so we have a function-ptr to recreate the subclass @@ -43,6 +45,24 @@ class SkWriteBuffer; #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ virtual Factory getFactory() const SK_OVERRIDE { return NULL; } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING +#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ + SkFlattenable::Registrar(#flattenable, flattenable::DeepCreateProc, \ + flattenable::GetFlattenableType()); + +#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ + private: \ + static SkFlattenable* CreateProc(SkReadBuffer&); \ + static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { \ + if (NeedsDeepUnflatten(buffer)) { \ + return SkNEW_ARGS(flattenable, (buffer)); \ + } \ + return CreateProc(buffer); \ + } \ + friend class SkPrivateEffectInitializer; \ + public: \ + virtual Factory getFactory() const SK_OVERRIDE {return DeepCreateProc;} +#else #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ flattenable::GetFlattenableType()); @@ -53,6 +73,7 @@ class SkWriteBuffer; friend class SkPrivateEffectInitializer; \ public: \ virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } +#endif // If your subclass will *never* need to be unflattened, declare this. #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \ @@ -123,6 +144,11 @@ public: virtual void flatten(SkWriteBuffer&) const {} protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + static bool NeedsDeepUnflatten(const SkReadBuffer&); + SkFlattenable(SkReadBuffer&) {} +#endif + static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) { return NULL; } diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h index a651b466fa..026ef40cb1 100644 --- a/include/core/SkMaskFilter.h +++ b/include/core/SkMaskFilter.h @@ -153,6 +153,10 @@ public: protected: SkMaskFilter() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + // empty for now, but lets get our subclass to remember to init us for the future + SkMaskFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif enum FilterReturn { kFalse_FilterReturn, diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index 2a6e3a9c22..454614a262 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -135,6 +135,9 @@ public: protected: SkPathEffect() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif private: // illegal @@ -156,6 +159,9 @@ public: protected: SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkPairPathEffect(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; @@ -191,6 +197,10 @@ protected: SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(outer, inner) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + private: // illegal SkComposePathEffect(const SkComposePathEffect&); @@ -224,6 +234,10 @@ protected: SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first, second) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + private: // illegal SkSumPathEffect(const SkSumPathEffect&); diff --git a/include/core/SkRasterizer.h b/include/core/SkRasterizer.h index 10caad76bf..3280f42611 100644 --- a/include/core/SkRasterizer.h +++ b/include/core/SkRasterizer.h @@ -32,6 +32,10 @@ public: protected: SkRasterizer() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkRasterizer(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, const SkIRect* clipBounds, SkMask* mask, SkMask::CreateMode mode) const; diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 0033485e29..e9911cef81 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -479,6 +479,9 @@ public: SK_DEFINE_FLATTENABLE_TYPE(SkShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkShader(SkReadBuffer& ); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 6d723e8fc2..bedcc24569 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -215,6 +215,10 @@ public: protected: SkXfermode() {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} +#endif + /** The default implementation of xfer32/xfer16/xferA8 in turn call this method, 1 color at a time (upscaled to a SkPMColor). The default implmentation of this method just returns dst. If performance is diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h index 9ba11b0812..87047e4ec2 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -64,6 +64,9 @@ public: protected: SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkPath1DPathEffect(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; // overrides from Sk1DPathEffect diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h index 97c86ec7f2..80a27a3793 100644 --- a/include/effects/Sk2DPathEffect.h +++ b/include/effects/Sk2DPathEffect.h @@ -39,6 +39,9 @@ protected: // protected so that subclasses can call this during unflattening explicit Sk2DPathEffect(const SkMatrix& mat); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit Sk2DPathEffect(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: @@ -67,6 +70,10 @@ public: protected: SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) : Sk2DPathEffect(matrix), fWidth(width) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkLine2DPathEffect(SkReadBuffer&); +#endif + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; @@ -91,6 +98,9 @@ public: protected: SkPath2DPathEffect(const SkMatrix&, const SkPath&); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkPath2DPathEffect(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h index c79227f762..53ce708e36 100644 --- a/include/effects/SkAvoidXfermode.h +++ b/include/effects/SkAvoidXfermode.h @@ -54,6 +54,9 @@ public: protected: SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkAvoidXfermode(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkBitmapSource.h b/include/effects/SkBitmapSource.h index 8b678b2eb8..27c7ae204f 100644 --- a/include/effects/SkBitmapSource.h +++ b/include/effects/SkBitmapSource.h @@ -27,6 +27,9 @@ public: protected: explicit SkBitmapSource(const SkBitmap& bitmap); SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkBitmapSource(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h index cb912c1a85..9db9f0d7d2 100644 --- a/include/effects/SkBlurDrawLooper.h +++ b/include/effects/SkBlurDrawLooper.h @@ -53,6 +53,9 @@ protected: SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, uint32_t flags); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkBlurDrawLooper(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool asABlurShadow(BlurShadowRec*) const SK_OVERRIDE; diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index 9064579bea..cfa895a6cf 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -30,6 +30,9 @@ protected: SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkBlurImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkColorCubeFilter.h b/include/effects/SkColorCubeFilter.h index ebd5e5fbb5..2cfee45e9c 100644 --- a/include/effects/SkColorCubeFilter.h +++ b/include/effects/SkColorCubeFilter.h @@ -32,6 +32,9 @@ public: protected: SkColorCubeFilter(SkData* cubeData, int cubeDimension); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkColorCubeFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkColorFilterImageFilter.h b/include/effects/SkColorFilterImageFilter.h index ff163c7cd4..46f2d2aede 100644 --- a/include/effects/SkColorFilterImageFilter.h +++ b/include/effects/SkColorFilterImageFilter.h @@ -23,6 +23,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkColorFilterImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h index 379ca5755a..dad40623f1 100644 --- a/include/effects/SkColorMatrixFilter.h +++ b/include/effects/SkColorMatrixFilter.h @@ -41,6 +41,9 @@ public: protected: explicit SkColorMatrixFilter(const SkColorMatrix&); explicit SkColorMatrixFilter(const SkScalar array[20]); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkColorMatrixFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h index 0478909cd1..26eed37872 100644 --- a/include/effects/SkComposeImageFilter.h +++ b/include/effects/SkComposeImageFilter.h @@ -32,6 +32,10 @@ protected: SkASSERT(inputs[0]); SkASSERT(inputs[1]); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkComposeImageFilter(SkReadBuffer& buffer); +#endif + virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE; virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const SK_OVERRIDE; diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h index 6b75da66e3..e61d49405d 100644 --- a/include/effects/SkCornerPathEffect.h +++ b/include/effects/SkCornerPathEffect.h @@ -32,6 +32,9 @@ public: protected: explicit SkCornerPathEffect(SkScalar radius); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkCornerPathEffect(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h index 210b378fb2..394622426d 100644 --- a/include/effects/SkDashPathEffect.h +++ b/include/effects/SkDashPathEffect.h @@ -55,6 +55,9 @@ public: protected: SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDashPathEffect(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h index 18c7b4bdf8..8f1082cb40 100644 --- a/include/effects/SkDiscretePathEffect.h +++ b/include/effects/SkDiscretePathEffect.h @@ -45,6 +45,9 @@ protected: SkDiscretePathEffect(SkScalar segLength, SkScalar deviation, uint32_t seedAssist); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDiscretePathEffect(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h index a5296fd6a7..0a658aceaf 100644 --- a/include/effects/SkDisplacementMapEffect.h +++ b/include/effects/SkDisplacementMapEffect.h @@ -54,6 +54,9 @@ protected: SkScalar scale, SkImageFilter* inputs[2], const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDisplacementMapEffect(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h index a931ad00ff..c6b936a23c 100644 --- a/include/effects/SkDropShadowImageFilter.h +++ b/include/effects/SkDropShadowImageFilter.h @@ -51,6 +51,9 @@ protected: SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDropShadowImageFilter(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE; virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, diff --git a/include/effects/SkEmbossMaskFilter.h b/include/effects/SkEmbossMaskFilter.h index 8b6a3c3ac2..74895fb0cf 100644 --- a/include/effects/SkEmbossMaskFilter.h +++ b/include/effects/SkEmbossMaskFilter.h @@ -37,6 +37,9 @@ public: protected: SkEmbossMaskFilter(SkScalar blurSigma, const Light& light); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkEmbossMaskFilter(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index d21e399762..5bb8b6646b 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -81,7 +81,14 @@ public: SK_TO_STRING_OVERRIDE() +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { + return CreateProc(buffer); + } + virtual Factory getFactory() const SK_OVERRIDE { return DeepCreateProc; } +#else virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } +#endif static SkFlattenable* CreateProc(SkReadBuffer& buffer); protected: diff --git a/include/effects/SkLayerRasterizer.h b/include/effects/SkLayerRasterizer.h index 1d66383ec9..60b3f205c3 100644 --- a/include/effects/SkLayerRasterizer.h +++ b/include/effects/SkLayerRasterizer.h @@ -69,6 +69,9 @@ public: protected: SkLayerRasterizer(); SkLayerRasterizer(SkDeque* layers); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkLayerRasterizer(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; // override from SkRasterizer diff --git a/include/effects/SkLerpXfermode.h b/include/effects/SkLerpXfermode.h index 923e840c5d..d779f16777 100644 --- a/include/effects/SkLerpXfermode.h +++ b/include/effects/SkLerpXfermode.h @@ -32,6 +32,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkLerpXfermode(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h index 323da88ec8..5fb0822666 100644 --- a/include/effects/SkLightingImageFilter.h +++ b/include/effects/SkLightingImageFilter.h @@ -75,6 +75,9 @@ protected: SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkLightingImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; const SkLight* light() const { return fLight.get(); } SkScalar surfaceScale() const { return fSurfaceScale; } diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h index ae666c0bca..420999f2e8 100644 --- a/include/effects/SkLumaColorFilter.h +++ b/include/effects/SkLumaColorFilter.h @@ -35,6 +35,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkLumaColorFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h index 68c3fdfee4..4dd47ef7bd 100644 --- a/include/effects/SkMagnifierImageFilter.h +++ b/include/effects/SkMagnifierImageFilter.h @@ -20,6 +20,9 @@ public: protected: SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkMagnifierImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h index b97dabe269..c04d7d1568 100644 --- a/include/effects/SkMatrixConvolutionImageFilter.h +++ b/include/effects/SkMatrixConvolutionImageFilter.h @@ -76,6 +76,9 @@ protected: SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkMatrixConvolutionImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkMatrixImageFilter.h b/include/effects/SkMatrixImageFilter.h index 0063e41630..ae6a0b7abb 100644 --- a/include/effects/SkMatrixImageFilter.h +++ b/include/effects/SkMatrixImageFilter.h @@ -43,6 +43,9 @@ protected: SkPaint::FilterLevel, SkImageFilter* input, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkMatrixImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h index 59183e3fc1..5e723aa290 100644 --- a/include/effects/SkMergeImageFilter.h +++ b/include/effects/SkMergeImageFilter.h @@ -38,6 +38,9 @@ protected: const SkXfermode::Mode modes[], const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkMergeImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index ff7ed89d43..3f2be45cc5 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -34,6 +34,9 @@ protected: bool filterImageGeneric(Proc procX, Proc procY, Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const; +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkMorphologyImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; #if SK_SUPPORT_GPU virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } @@ -73,6 +76,10 @@ public: protected: SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) : INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + private: typedef SkMorphologyImageFilter INHERITED; }; @@ -101,6 +108,9 @@ public: protected: SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) : INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif private: typedef SkMorphologyImageFilter INHERITED; diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h index 6a60e62bda..a870c0b8ee 100644 --- a/include/effects/SkOffsetImageFilter.h +++ b/include/effects/SkOffsetImageFilter.h @@ -28,6 +28,9 @@ public: protected: SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkOffsetImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h index fc6748462c..2937926cd7 100644 --- a/include/effects/SkPerlinNoiseShader.h +++ b/include/effects/SkPerlinNoiseShader.h @@ -103,6 +103,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkPerlinNoiseShader(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; @@ -112,13 +115,16 @@ private: const SkISize* tileSize); virtual ~SkPerlinNoiseShader(); - const SkPerlinNoiseShader::Type fType; - const SkScalar fBaseFrequencyX; - const SkScalar fBaseFrequencyY; - const int fNumOctaves; - const SkScalar fSeed; - const SkISize fTileSize; - const bool fStitchTiles; + // TODO (scroggo): Once all SkShaders are created from a factory, and we have removed the + // constructor that creates SkPerlinNoiseShader from an SkReadBuffer, several fields can + // be made constant. + /*const*/ SkPerlinNoiseShader::Type fType; + /*const*/ SkScalar fBaseFrequencyX; + /*const*/ SkScalar fBaseFrequencyY; + /*const*/ int fNumOctaves; + /*const*/ SkScalar fSeed; + /*const*/ SkISize fTileSize; + /*const*/ bool fStitchTiles; typedef SkShader INHERITED; }; diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h index f4f1fff4ef..ed5c63c18a 100644 --- a/include/effects/SkPictureImageFilter.h +++ b/include/effects/SkPictureImageFilter.h @@ -40,6 +40,9 @@ protected: * SkReadBuffer::setBitmapDecoder() before calling this constructor. * @param SkReadBuffer Serialized picture data. */ +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkPictureImageFilter(SkReadBuffer&); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h index 758a5e9815..eb485b4652 100644 --- a/include/effects/SkPixelXorXfermode.h +++ b/include/effects/SkPixelXorXfermode.h @@ -26,6 +26,9 @@ public: protected: explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkPixelXorXfermode(SkReadBuffer& rb); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; // override from SkXfermode diff --git a/include/effects/SkRectShaderImageFilter.h b/include/effects/SkRectShaderImageFilter.h index dc35c947ba..c4311db43e 100644 --- a/include/effects/SkRectShaderImageFilter.h +++ b/include/effects/SkRectShaderImageFilter.h @@ -34,6 +34,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkRectShaderImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkTableMaskFilter.h b/include/effects/SkTableMaskFilter.h index ec071d0e6a..8b9417900e 100644 --- a/include/effects/SkTableMaskFilter.h +++ b/include/effects/SkTableMaskFilter.h @@ -55,6 +55,9 @@ public: protected: SkTableMaskFilter(); explicit SkTableMaskFilter(const uint8_t table[256]); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkTableMaskFilter(SkReadBuffer& rb); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h index 6acd1d293c..a8186e08c2 100644 --- a/include/effects/SkTestImageFilters.h +++ b/include/effects/SkTestImageFilters.h @@ -23,6 +23,9 @@ public: protected: SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) : INHERITED(1, &input), fScale(scale) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkDownSampleImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h index 49d69a0ebf..440337a642 100644 --- a/include/effects/SkTileImageFilter.h +++ b/include/effects/SkTileImageFilter.h @@ -32,6 +32,9 @@ public: protected: SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input, uint32_t uniqueID) : INHERITED(1, &input, NULL, uniqueID), fSrcRect(srcRect), fDstRect(dstRect) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkTileImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; diff --git a/include/effects/SkTransparentShader.h b/include/effects/SkTransparentShader.h index 96de80abe5..e23687c021 100644 --- a/include/effects/SkTransparentShader.h +++ b/include/effects/SkTransparentShader.h @@ -41,6 +41,10 @@ protected: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE {} private: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + typedef SkShader INHERITED; }; diff --git a/include/effects/SkXfermodeImageFilter.h b/include/effects/SkXfermodeImageFilter.h index 96d258fd08..6736889ac8 100644 --- a/include/effects/SkXfermodeImageFilter.h +++ b/include/effects/SkXfermodeImageFilter.h @@ -47,6 +47,9 @@ public: protected: SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2], const CropRect* cropRect, uint32_t uniqueID); +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit SkXfermodeImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp index 4ba65bd894..46d4120c9b 100644 --- a/samplecode/ClockFaceView.cpp +++ b/samplecode/ClockFaceView.cpp @@ -90,6 +90,13 @@ protected: dst->addCircle(loc.fX, loc.fY, fRadius); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { + fRadius = buffer.readScalar(); + fPts = NULL; + } +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { buffer.writeMatrix(this->getMatrix()); buffer.writeScalar(fRadius); @@ -119,7 +126,13 @@ public: } SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) +protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif + private: + typedef SkPathEffect INHERITED; }; diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index f5a7c143f4..19e692f518 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -172,6 +172,11 @@ protected: dst->addCircle(loc.fX, loc.fY, fRadius); } +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { + fRadius = buffer.readScalar(); + } +#endif virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeScalar(fRadius); 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; diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 9fd4351b42..6fefe49dcb 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -58,6 +58,13 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) protected: +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL) { + fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr()); + buffer.readMatrix(&fExpectedMatrix); + } +#endif + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeFunctionPtr(fReporter); @@ -67,7 +74,7 @@ protected: private: skiatest::Reporter* fReporter; SkMatrix fExpectedMatrix; - + typedef SkImageFilter INHERITED; }; @@ -480,7 +487,7 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { } } -static void draw_saveLayer_picture(int width, int height, int tileSize, +static void draw_saveLayer_picture(int width, int height, int tileSize, SkBBHFactory* factory, SkBitmap* result) { SkMatrix matrix; @@ -494,8 +501,8 @@ static void draw_saveLayer_picture(int width, int height, int tileSize, paint.setImageFilter(imageFilter.get()); SkPictureRecorder recorder; SkRect bounds = SkRect::Make(SkIRect::MakeXYWH(0, 0, 50, 50)); - SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(width), - SkIntToScalar(height), + SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(width), + SkIntToScalar(height), factory, 0); recordingCanvas->translate(-55, 0); recordingCanvas->saveLayer(&bounds, &paint); @@ -618,11 +625,11 @@ DEF_TEST(ImageFilterDrawTiledBlurRTree, reporter) { SkPictureRecorder recorder1, recorder2; // The only difference between these two pictures is that one has RTree aceleration. - SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width), - SkIntToScalar(height), + SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width), + SkIntToScalar(height), NULL, 0); - SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width), - SkIntToScalar(height), + SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width), + SkIntToScalar(height), &factory, 0); draw_blurred_rect(recordingCanvas1); draw_blurred_rect(recordingCanvas2); diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index 60a1099136..05677cd1ab 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -444,6 +444,11 @@ public: return true; } SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING + explicit DummyImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL) { + fVisited = buffer.readBool(); + } +#endif bool visited() const { return fVisited; } private: |