diff options
author | reed <reed@google.com> | 2016-03-03 13:25:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-03 13:25:25 -0800 |
commit | d812fb458807245daa812adb7af0733cf5b54d96 (patch) | |
tree | 8a25dc8ae4bc984c78bb0a730b17130f5396d9cc | |
parent | e79586bf82997477b8bc95469147cd25a8e22ff0 (diff) |
enforce 16byte alignment in shader contexts
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1759653004
Review URL: https://codereview.chromium.org/1759653004
30 files changed, 81 insertions, 79 deletions
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp index a5a2a21523..a1784a4204 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp @@ -571,8 +571,8 @@ SkShader::Context* SkPerlinNoiseShader2::onCreateContext(const ContextRec& rec, return new (storage) PerlinNoiseShaderContext(*this, rec); } -size_t SkPerlinNoiseShader2::contextSize(const ContextRec&) const { - return sizeof(PerlinNoiseShaderContext); +size_t SkPerlinNoiseShader2::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(PerlinNoiseShaderContext)); } SkPerlinNoiseShader2::PerlinNoiseShaderContext::PerlinNoiseShaderContext( diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h index a129ef8bcd..fac098ab52 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h @@ -80,12 +80,9 @@ public: static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize* tileSize = NULL) { - return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize); + return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize); } - - size_t contextSize(const ContextRec&) const override; - class PerlinNoiseShaderContext : public SkShader::Context { public: PerlinNoiseShaderContext(const SkPerlinNoiseShader2& shader, const ContextRec&); @@ -118,6 +115,7 @@ public: protected: void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 0645809fe6..828467fec2 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -192,11 +192,8 @@ public: /** * Return the size of a Context returned by createContext. - * - * Override this if your subclass overrides createContext, to return the correct size of - * your subclass' context. */ - virtual size_t contextSize(const ContextRec&) const; + size_t contextSize(const ContextRec&) const; /** * Returns true if this shader is just a bitmap, and if not null, returns the bitmap, @@ -420,6 +417,12 @@ protected: */ virtual Context* onCreateContext(const ContextRec&, void* storage) const; + /** + * Override this if your subclass overrides createContext, to return the correct size of + * your subclass' context. + */ + virtual size_t onContextSize(const ContextRec&) const; + virtual bool onAsLuminanceColor(SkColor*) const { return false; } diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h index e9c22d44fc..d9b0277f92 100644 --- a/include/effects/SkPerlinNoiseShader.h +++ b/include/effects/SkPerlinNoiseShader.h @@ -68,12 +68,9 @@ public: static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize* tileSize = NULL) { - return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize); + return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize); } - - size_t contextSize(const ContextRec&) const override; - class PerlinNoiseShaderContext : public SkShader::Context { public: PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const ContextRec&); @@ -106,6 +103,7 @@ public: protected: void flatten(SkWriteBuffer&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; + size_t onContextSize(const ContextRec&) const override; private: SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 895922c6b8..6c87ebeda4 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -120,7 +120,7 @@ private: size_t SkBitmapProcShader::ContextSize(const ContextRec& rec) { // The SkBitmapProcState is stored outside of the context object, with the context holding // a pointer to it. - return sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); + return SkAlign16(sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState)); } SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader, diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 9f4c16202c..ebd9f3f8fb 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -21,7 +21,7 @@ public: bool isOpaque() const override; - size_t contextSize(const ContextRec& rec) const override { return ContextSize(rec); } + size_t onContextSize(const ContextRec& rec) const override { return ContextSize(rec); } SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index c7c903dc6b..bb5cfb72e3 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -592,7 +592,7 @@ public: SkSafeUnref(fProxy); } - size_t contextSize(const ContextRec& rec) const override { + size_t onContextSize(const ContextRec& rec) const override { size_t size = sizeof(Sk3DShaderContext); if (fProxy) { size += fProxy->contextSize(rec); diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp index 7b421e9b6d..c856f19150 100644 --- a/src/core/SkColorFilterShader.cpp +++ b/src/core/SkColorFilterShader.cpp @@ -62,8 +62,8 @@ SkShader::Context* SkColorFilterShader::onCreateContext(const ContextRec& rec, return new (storage) FilterShaderContext(*this, shaderContext, rec); } -size_t SkColorFilterShader::contextSize(const ContextRec& rec) const { - return sizeof(FilterShaderContext) + fShader->contextSize(rec); +size_t SkColorFilterShader::onContextSize(const ContextRec& rec) const { + return SkAlign16(sizeof(FilterShaderContext)) + fShader->contextSize(rec); } SkColorFilterShader::FilterShaderContext::FilterShaderContext( diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h index 60c45954dc..0f41a43c49 100644 --- a/src/core/SkColorFilterShader.h +++ b/src/core/SkColorFilterShader.h @@ -14,9 +14,7 @@ class SkColorFilterShader : public SkShader { public: SkColorFilterShader(SkShader* shader, SkColorFilter* filter); - - size_t contextSize(const ContextRec&) const override; - + #if SK_SUPPORT_GPU const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, @@ -51,9 +49,9 @@ public: protected: void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; - private: SkAutoTUnref<SkShader> fShader; SkAutoTUnref<SkColorFilter> fFilter; diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h index 6e4e42ad95..00a2bb61f0 100644 --- a/src/core/SkColorShader.h +++ b/src/core/SkColorShader.h @@ -26,10 +26,6 @@ public: bool isOpaque() const override; - size_t contextSize(const ContextRec&) const override { - return sizeof(ColorShaderContext); - } - class ColorShaderContext : public SkShader::Context { public: ColorShaderContext(const SkColorShader& shader, const ContextRec&); @@ -61,6 +57,9 @@ protected: SkColorShader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; + size_t onContextSize(const ContextRec&) const override { + return sizeof(ColorShaderContext); + } bool onAsLuminanceColor(SkColor* lum) const override { *lum = fColor; return true; diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp index 46ff4019fc..e4ad6e9eda 100644 --- a/src/core/SkComposeShader.cpp +++ b/src/core/SkComposeShader.cpp @@ -30,8 +30,8 @@ SkComposeShader::~SkComposeShader() { fShaderA->unref(); } -size_t SkComposeShader::contextSize(const ContextRec& rec) const { - return sizeof(ComposeShaderContext) +size_t SkComposeShader::onContextSize(const ContextRec& rec) const { + return SkAlign16(sizeof(ComposeShaderContext)) + fShaderA->contextSize(rec) + fShaderB->contextSize(rec); } @@ -76,7 +76,7 @@ template <typename T> void safe_call_destructor(T* obj) { } SkShader::Context* SkComposeShader::onCreateContext(const ContextRec& rec, void* storage) const { - char* aStorage = (char*) storage + sizeof(ComposeShaderContext); + char* aStorage = (char*) storage + SkAlign16(sizeof(ComposeShaderContext)); char* bStorage = aStorage + fShaderA->contextSize(rec); // we preconcat our localMatrix (if any) with the device matrix diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h index 6f6aa59525..9220a0de97 100644 --- a/src/core/SkComposeShader.h +++ b/src/core/SkComposeShader.h @@ -34,8 +34,6 @@ public: SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); virtual ~SkComposeShader(); - size_t contextSize(const ContextRec&) const override; - #if SK_SUPPORT_GPU const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, @@ -77,6 +75,7 @@ public: protected: SkComposeShader(SkReadBuffer& ); void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void*) const override; private: diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index cff4252579..e9b0677c33 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1698,8 +1698,6 @@ class SkTriColorShader : public SkShader { public: SkTriColorShader() {} - size_t contextSize(const ContextRec&) const override; - class TriColorShaderContext : public SkShader::Context { public: TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&); @@ -1722,6 +1720,7 @@ public: Factory getFactory() const override { sk_throw(); return nullptr; } protected: + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec& rec, void* storage) const override { return new (storage) TriColorShaderContext(*this, rec); } @@ -1772,9 +1771,10 @@ SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} -size_t SkTriColorShader::contextSize(const ContextRec&) const { - return sizeof(TriColorShaderContext); +size_t SkTriColorShader::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(TriColorShaderContext)); } + void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) { const int alphaScale = Sk255To256(this->getPaintAlpha()); diff --git a/src/core/SkEmptyShader.h b/src/core/SkEmptyShader.h index c1713d1a2e..42b61c52fe 100644 --- a/src/core/SkEmptyShader.h +++ b/src/core/SkEmptyShader.h @@ -20,16 +20,16 @@ class SK_API SkEmptyShader : public SkShader { public: SkEmptyShader() {} - size_t contextSize(const ContextRec&) const override { - // Even though createContext returns nullptr we have to return a value of at least - // sizeof(SkShader::Context) to satisfy SkSmallAllocator. - return sizeof(SkShader::Context); - } - SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) protected: + size_t onContextSize(const ContextRec&) const override { + // Even though createContext returns nullptr we have to return a value of at least + // sizeof(SkShader::Context) to satisfy SkSmallAllocator. + return SkAlign16(sizeof(SkShader::Context)); + } + SkShader::Context* onCreateContext(const ContextRec&, void*) const override { return nullptr; } diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp index c8a5a2b737..02f75f3516 100644 --- a/src/core/SkLightingShader.cpp +++ b/src/core/SkLightingShader.cpp @@ -79,8 +79,6 @@ public: SkFilterQuality) const override; #endif - size_t contextSize(const ContextRec&) const override; - class LightingShaderContext : public SkShader::Context { public: // The context takes ownership of the states. It will call their destructors @@ -106,6 +104,7 @@ public: protected: void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void*) const override; bool computeNormTotalInverse(const ContextRec& rec, SkMatrix* normTotalInverse) const; @@ -416,10 +415,6 @@ bool SkLightingShaderImpl::isOpaque() const { return fDiffuseMap.isOpaque(); } -size_t SkLightingShaderImpl::contextSize(const ContextRec&) const { - return 2 * sizeof(SkBitmapProcState) + sizeof(LightingShaderContext); -} - SkLightingShaderImpl::LightingShaderContext::LightingShaderContext(const SkLightingShaderImpl& shader, const ContextRec& rec, SkBitmapProcState* diffuseState, @@ -655,6 +650,10 @@ bool SkLightingShaderImpl::computeNormTotalInverse(const ContextRec& rec, return m->invert(normTotalInverse); } +size_t SkLightingShaderImpl::onContextSize(const ContextRec&) const { + return 2 * sizeof(SkBitmapProcState) + sizeof(LightingShaderContext); +} + SkShader::Context* SkLightingShaderImpl::onCreateContext(const ContextRec& rec, void* storage) const { diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index d897d49ded..8edea40d05 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -19,10 +19,6 @@ public: , fProxyShader(SkRef(proxy)) {} - size_t contextSize(const ContextRec& rec) const override { - return fProxyShader->contextSize(rec); - } - GradientType asAGradient(GradientInfo* info) const override { return fProxyShader->asAGradient(info); } @@ -53,6 +49,10 @@ protected: void flatten(SkWriteBuffer&) const override; Context* onCreateContext(const ContextRec&, void*) const override; + size_t onContextSize(const ContextRec& rec) const override { + return fProxyShader->contextSize(rec); + } + bool onIsABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* mode) const override { return fProxyShader->isABitmap(bitmap, matrix, mode); } diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index f1addadd20..630b1bf8e1 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -241,8 +241,8 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM return tileShader.detach(); } -size_t SkPictureShader::contextSize(const ContextRec&) const { - return sizeof(PictureShaderContext); +size_t SkPictureShader::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(PictureShaderContext)); } SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const { diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h index c7a6a44fe0..8cccd251d5 100644 --- a/src/core/SkPictureShader.h +++ b/src/core/SkPictureShader.h @@ -25,8 +25,6 @@ public: static SkShader* Create(const SkPicture*, TileMode, TileMode, const SkMatrix*, const SkRect*); - size_t contextSize(const ContextRec&) const override; - SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) @@ -40,6 +38,7 @@ public: protected: SkPictureShader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index e36df5b5af..fd5fb00b88 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -86,6 +86,10 @@ bool SkShader::asLuminanceColor(SkColor* colorPtr) const { } SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const { + // Currently we require each context to be allocated on 16byte boundary as some of our + // subclasses need that. Hence we check the ptr here. + SkASSERT(SkIsAlign16((intptr_t)storage)); + if (!this->computeTotalInverse(rec, nullptr)) { return nullptr; } @@ -96,7 +100,17 @@ SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const return nullptr; } -size_t SkShader::contextSize(const ContextRec&) const { +size_t SkShader::contextSize(const ContextRec& rec) const { + size_t size = this->onContextSize(rec); + + // Currently we require each context to be allocated on 16byte boundary as some of our + // subclasses need that. Hence we check the size here. + SkASSERT(SkIsAlign16(size)); + + return size; +} + +size_t SkShader::onContextSize(const ContextRec&) const { return 0; } diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index ed7340ca3a..a32d8ac2bb 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -434,8 +434,8 @@ SkShader::Context* SkPerlinNoiseShader::onCreateContext(const ContextRec& rec, return new (storage) PerlinNoiseShaderContext(*this, rec); } -size_t SkPerlinNoiseShader::contextSize(const ContextRec&) const { - return sizeof(PerlinNoiseShaderContext); +size_t SkPerlinNoiseShader::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(PerlinNoiseShaderContext)); } SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext( diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index cc8875cf8e..40503c96f1 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -88,10 +88,10 @@ void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fEnd); } -size_t SkLinearGradient::contextSize(const ContextRec& rec) const { +size_t SkLinearGradient::onContextSize(const ContextRec& rec) const { return use_4f_context(rec, fGradFlags) - ? sizeof(LinearGradient4fContext) - : sizeof(LinearGradientContext); + ? SkAlign16(sizeof(LinearGradient4fContext)) + : SkAlign16(sizeof(LinearGradientContext)); } SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void* storage) const { diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h index 33ddfc2f9e..f0ce49b8b3 100644 --- a/src/effects/gradients/SkLinearGradient.h +++ b/src/effects/gradients/SkLinearGradient.h @@ -33,8 +33,6 @@ public: SkLinearGradient(const SkPoint pts[2], const Descriptor&); - size_t contextSize(const ContextRec&) const override; - class LinearGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: LinearGradientContext(const SkLinearGradient&, const ContextRec&); @@ -71,6 +69,7 @@ public: protected: SkLinearGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 466ae045a5..da4c6f2412 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -40,8 +40,8 @@ SkRadialGradient::SkRadialGradient(const SkPoint& center, SkScalar radius, const , fRadius(radius) { } -size_t SkRadialGradient::contextSize(const ContextRec&) const { - return sizeof(RadialGradientContext); +size_t SkRadialGradient::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(RadialGradientContext)); } SkShader::Context* SkRadialGradient::onCreateContext(const ContextRec& rec, void* storage) const { diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h index 9d98f18304..428d7fae79 100644 --- a/src/effects/gradients/SkRadialGradient.h +++ b/src/effects/gradients/SkRadialGradient.h @@ -15,8 +15,6 @@ class SkRadialGradient : public SkGradientShaderBase { public: SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&); - size_t contextSize(const ContextRec&) const override; - class RadialGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: RadialGradientContext(const SkRadialGradient&, const ContextRec&); @@ -41,6 +39,7 @@ public: protected: SkRadialGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index de80c79ae0..12d55e8b49 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -45,8 +45,8 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fCenter); } -size_t SkSweepGradient::contextSize(const ContextRec&) const { - return sizeof(SweepGradientContext); +size_t SkSweepGradient::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(SweepGradientContext)); } SkShader::Context* SkSweepGradient::onCreateContext(const ContextRec& rec, void* storage) const { diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index ec6df45c64..f458cea8ce 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -15,8 +15,6 @@ class SkSweepGradient : public SkGradientShaderBase { public: SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor&); - size_t contextSize(const ContextRec&) const override; - class SweepGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: SweepGradientContext(const SkSweepGradient& shader, const ContextRec&); @@ -41,6 +39,7 @@ public: protected: void flatten(SkWriteBuffer& buffer) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 2209306fe3..f4b6b0c8b0 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -211,8 +211,8 @@ bool SkTwoPointConicalGradient::isOpaque() const { return false; } -size_t SkTwoPointConicalGradient::contextSize(const ContextRec&) const { - return sizeof(TwoPointConicalGradientContext); +size_t SkTwoPointConicalGradient::onContextSize(const ContextRec&) const { + return SkAlign16(sizeof(TwoPointConicalGradientContext)); } SkShader::Context* SkTwoPointConicalGradient::onCreateContext(const ContextRec& rec, diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h index 954b09698e..5783c39bd4 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.h +++ b/src/effects/gradients/SkTwoPointConicalGradient.h @@ -45,9 +45,6 @@ public: const SkPoint& end, SkScalar endRadius, bool flippedGrad, const Descriptor&); - - size_t contextSize(const ContextRec&) const override; - class TwoPointConicalGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: TwoPointConicalGradientContext(const SkTwoPointConicalGradient&, const ContextRec&); @@ -82,6 +79,7 @@ public: protected: SkTwoPointConicalGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; private: diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp index a07603c671..4c7ded906c 100644 --- a/src/image/SkImageShader.cpp +++ b/src/image/SkImageShader.cpp @@ -42,7 +42,7 @@ bool SkImageShader::isOpaque() const { return fImage->isOpaque(); } -size_t SkImageShader::contextSize(const ContextRec& rec) const { +size_t SkImageShader::onContextSize(const ContextRec& rec) const { return SkBitmapProcShader::ContextSize(rec); } diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h index d51dc5d4e4..07b938d202 100644 --- a/src/image/SkImageShader.h +++ b/src/image/SkImageShader.h @@ -16,7 +16,6 @@ public: static SkShader* Create(const SkImage*, TileMode tx, TileMode ty, const SkMatrix* localMatrix); bool isOpaque() const override; - size_t contextSize(const ContextRec&) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader) @@ -28,6 +27,7 @@ public: protected: void flatten(SkWriteBuffer&) const override; + size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; SkAutoTUnref<const SkImage> fImage; |