diff options
32 files changed, 49 insertions, 49 deletions
diff --git a/bench/SkLinearBitmapPipelineBench.cpp b/bench/SkLinearBitmapPipelineBench.cpp index 0fc2ac6a26..8a4ba2cef9 100644 --- a/bench/SkLinearBitmapPipelineBench.cpp +++ b/bench/SkLinearBitmapPipelineBench.cpp @@ -196,10 +196,9 @@ struct SkBitmapFPOrigShader : public CommonBitmapFPBenchmark { SkAutoTMalloc<SkPMColor> buffer4b(width*height); uint32_t storage[200]; - SkASSERT(fPaint.getShader()->contextSize() <= sizeof(storage)); - SkShader::Context* ctx = fPaint.getShader()->createContext( - {fPaint, fM, nullptr}, - storage); + const SkShader::ContextRec rec(fPaint, fM, nullptr); + SkASSERT(fPaint.getShader()->contextSize(rec) <= sizeof(storage)); + SkShader::Context* ctx = fPaint.getShader()->createContext(rec, storage); int count = 100; diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp index 73ce1a3b3b..a5a2a21523 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp @@ -571,7 +571,7 @@ SkShader::Context* SkPerlinNoiseShader2::onCreateContext(const ContextRec& rec, return new (storage) PerlinNoiseShaderContext(*this, rec); } -size_t SkPerlinNoiseShader2::contextSize() const { +size_t SkPerlinNoiseShader2::contextSize(const ContextRec&) const { return sizeof(PerlinNoiseShaderContext); } diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h index fd93a8d9db..a129ef8bcd 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h @@ -84,7 +84,7 @@ public: } - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class PerlinNoiseShaderContext : public SkShader::Context { public: diff --git a/gm/SkLinearBitmapPipelineGM.cpp b/gm/SkLinearBitmapPipelineGM.cpp index a446b7442f..fea095239a 100644 --- a/gm/SkLinearBitmapPipelineGM.cpp +++ b/gm/SkLinearBitmapPipelineGM.cpp @@ -67,11 +67,10 @@ static void draw_rect_orig(SkCanvas* canvas, const SkRect& r, SkColor c, const S paint.setFilterQuality(SkFilterQuality::kNone_SkFilterQuality); } paint.setShader(shader)->unref(); - SkASSERT(paint.getShader()->contextSize() <= sizeof(storage)); + const SkShader::ContextRec rec(paint, *mat, nullptr); + SkASSERT(paint.getShader()->contextSize(rec) <= sizeof(storage)); - SkShader::Context* ctx = paint.getShader()->createContext( - {paint, *mat, nullptr}, - storage); + SkShader::Context* ctx = paint.getShader()->createContext(rec, storage); for (int y = 0; y < ir.height(); y++) { ctx->shadeSpan(0, y, pmdst.writable_addr32(0, y), ir.width()); diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 36256f6f09..8e69fafa78 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -188,7 +188,7 @@ public: * Override this if your subclass overrides createContext, to return the correct size of * your subclass' context. */ - virtual size_t contextSize() const; + virtual size_t contextSize(const ContextRec&) const; /** * Returns true if this shader is just a bitmap, and if not null, returns the bitmap, diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h index ec7c08c8ea..e9c22d44fc 100644 --- a/include/effects/SkPerlinNoiseShader.h +++ b/include/effects/SkPerlinNoiseShader.h @@ -72,7 +72,7 @@ public: } - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class PerlinNoiseShaderContext : public SkShader::Context { public: diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 2134927c4c..05c5955f35 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -23,7 +23,7 @@ public: bool isOpaque() const override; - size_t contextSize() const override { return ContextSize(); } + size_t contextSize(const ContextRec&) const override { return ContextSize(); } SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index 41d6071d6e..804bc813d6 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -592,10 +592,10 @@ public: SkSafeUnref(fProxy); } - size_t contextSize() const override { + size_t contextSize(const ContextRec& rec) const override { size_t size = sizeof(Sk3DShaderContext); if (fProxy) { - size += fProxy->contextSize(); + size += fProxy->contextSize(rec); } return size; } @@ -876,7 +876,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device, SkShader::Context* shaderContext = nullptr; if (shader) { SkShader::ContextRec rec(*paint, matrix, nullptr); - size_t contextSize = shader->contextSize(); + size_t contextSize = shader->contextSize(rec); if (contextSize) { // Try to create the ShaderContext void* storage = allocator->reserveT<SkShader::Context>(contextSize); diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp index 618bf7191e..7b421e9b6d 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 { - return sizeof(FilterShaderContext) + fShader->contextSize(); +size_t SkColorFilterShader::contextSize(const ContextRec& rec) const { + return sizeof(FilterShaderContext) + fShader->contextSize(rec); } SkColorFilterShader::FilterShaderContext::FilterShaderContext( diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h index 55625b6991..60c45954dc 100644 --- a/src/core/SkColorFilterShader.h +++ b/src/core/SkColorFilterShader.h @@ -15,7 +15,7 @@ class SkColorFilterShader : public SkShader { public: SkColorFilterShader(SkShader* shader, SkColorFilter* filter); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; #if SK_SUPPORT_GPU const GrFragmentProcessor* asFragmentProcessor(GrContext*, diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h index eb55a07f13..6e4e42ad95 100644 --- a/src/core/SkColorShader.h +++ b/src/core/SkColorShader.h @@ -26,7 +26,7 @@ public: bool isOpaque() const override; - size_t contextSize() const override { + size_t contextSize(const ContextRec&) const override { return sizeof(ColorShaderContext); } diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp index 9e5e2c6a49..46ff4019fc 100644 --- a/src/core/SkComposeShader.cpp +++ b/src/core/SkComposeShader.cpp @@ -30,8 +30,10 @@ SkComposeShader::~SkComposeShader() { fShaderA->unref(); } -size_t SkComposeShader::contextSize() const { - return sizeof(ComposeShaderContext) + fShaderA->contextSize() + fShaderB->contextSize(); +size_t SkComposeShader::contextSize(const ContextRec& rec) const { + return sizeof(ComposeShaderContext) + + fShaderA->contextSize(rec) + + fShaderB->contextSize(rec); } class SkAutoAlphaRestore { @@ -75,7 +77,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* bStorage = aStorage + fShaderA->contextSize(); + char* bStorage = aStorage + fShaderA->contextSize(rec); // we preconcat our localMatrix (if any) with the device matrix // before calling our sub-shaders diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h index bc9d932ee5..6f6aa59525 100644 --- a/src/core/SkComposeShader.h +++ b/src/core/SkComposeShader.h @@ -34,7 +34,7 @@ public: SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); virtual ~SkComposeShader(); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; #if SK_SUPPORT_GPU const GrFragmentProcessor* asFragmentProcessor(GrContext*, diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index d07bcb8fcf..d42a179a94 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1697,7 +1697,7 @@ class SkTriColorShader : public SkShader { public: SkTriColorShader() {} - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class TriColorShaderContext : public SkShader::Context { public: @@ -1771,7 +1771,7 @@ SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} -size_t SkTriColorShader::contextSize() const { +size_t SkTriColorShader::contextSize(const ContextRec&) const { return sizeof(TriColorShaderContext); } void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) { diff --git a/src/core/SkEmptyShader.h b/src/core/SkEmptyShader.h index 6453e0e440..c1713d1a2e 100644 --- a/src/core/SkEmptyShader.h +++ b/src/core/SkEmptyShader.h @@ -20,7 +20,7 @@ class SK_API SkEmptyShader : public SkShader { public: SkEmptyShader() {} - size_t contextSize() const override { + 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); diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp index a68553e661..9d6c5864e2 100644 --- a/src/core/SkLightingShader.cpp +++ b/src/core/SkLightingShader.cpp @@ -79,7 +79,7 @@ public: SkFilterQuality) const override; #endif - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class LightingShaderContext : public SkShader::Context { public: @@ -416,7 +416,7 @@ bool SkLightingShaderImpl::isOpaque() const { return fDiffuseMap.isOpaque(); } -size_t SkLightingShaderImpl::contextSize() const { +size_t SkLightingShaderImpl::contextSize(const ContextRec&) const { return 2 * sizeof(SkBitmapProcState) + sizeof(LightingShaderContext); } diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index 62654275f4..d897d49ded 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -19,8 +19,8 @@ public: , fProxyShader(SkRef(proxy)) {} - size_t contextSize() const override { - return fProxyShader->contextSize(); + size_t contextSize(const ContextRec& rec) const override { + return fProxyShader->contextSize(rec); } GradientType asAGradient(GradientInfo* info) const override { diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 44f6ef10b5..8f6d43f862 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -237,7 +237,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM return tileShader.detach(); } -size_t SkPictureShader::contextSize() const { +size_t SkPictureShader::contextSize(const ContextRec&) const { return sizeof(PictureShaderContext); } @@ -266,7 +266,7 @@ SkPictureShader::PictureShaderContext::PictureShaderContext( : INHERITED(shader, rec) , fBitmapShader(SkRef(bitmapShader)) { - fBitmapShaderContextStorage = sk_malloc_throw(bitmapShader->contextSize()); + fBitmapShaderContextStorage = sk_malloc_throw(bitmapShader->contextSize(rec)); fBitmapShaderContext = bitmapShader->createContext(rec, fBitmapShaderContextStorage); //if fBitmapShaderContext is null, we are invalid } diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h index 02fc87f024..c7a6a44fe0 100644 --- a/src/core/SkPictureShader.h +++ b/src/core/SkPictureShader.h @@ -25,7 +25,7 @@ public: static SkShader* Create(const SkPicture*, TileMode, TileMode, const SkMatrix*, const SkRect*); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 20402a973d..9d0af03078 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -96,7 +96,7 @@ SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const return nullptr; } -size_t SkShader::contextSize() const { +size_t SkShader::contextSize(const ContextRec&) const { return 0; } diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 07917c3cd5..ed7340ca3a 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -434,7 +434,7 @@ SkShader::Context* SkPerlinNoiseShader::onCreateContext(const ContextRec& rec, return new (storage) PerlinNoiseShaderContext(*this, rec); } -size_t SkPerlinNoiseShader::contextSize() const { +size_t SkPerlinNoiseShader::contextSize(const ContextRec&) const { return sizeof(PerlinNoiseShaderContext); } diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 9a350b8ff2..1fbd96e40e 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -81,7 +81,7 @@ void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fEnd); } -size_t SkLinearGradient::contextSize() const { +size_t SkLinearGradient::contextSize(const ContextRec&) const { return use_4f_context(fGradFlags) ? sizeof(LinearGradient4fContext) : sizeof(LinearGradientContext); diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h index c81eea6d4a..33ddfc2f9e 100644 --- a/src/effects/gradients/SkLinearGradient.h +++ b/src/effects/gradients/SkLinearGradient.h @@ -33,7 +33,7 @@ public: SkLinearGradient(const SkPoint pts[2], const Descriptor&); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class LinearGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 020c25ec46..466ae045a5 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -40,7 +40,7 @@ SkRadialGradient::SkRadialGradient(const SkPoint& center, SkScalar radius, const , fRadius(radius) { } -size_t SkRadialGradient::contextSize() const { +size_t SkRadialGradient::contextSize(const ContextRec&) const { return sizeof(RadialGradientContext); } diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h index bd6fb3542f..9d98f18304 100644 --- a/src/effects/gradients/SkRadialGradient.h +++ b/src/effects/gradients/SkRadialGradient.h @@ -15,7 +15,7 @@ class SkRadialGradient : public SkGradientShaderBase { public: SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class RadialGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 94686524ed..de80c79ae0 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -45,7 +45,7 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fCenter); } -size_t SkSweepGradient::contextSize() const { +size_t SkSweepGradient::contextSize(const ContextRec&) const { return sizeof(SweepGradientContext); } diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index a6a0971323..ec6df45c64 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -15,7 +15,7 @@ class SkSweepGradient : public SkGradientShaderBase { public: SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor&); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class SweepGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index b7c95bc809..b938ebdec7 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -211,7 +211,7 @@ bool SkTwoPointConicalGradient::isOpaque() const { return false; } -size_t SkTwoPointConicalGradient::contextSize() const { +size_t SkTwoPointConicalGradient::contextSize(const ContextRec&) const { return sizeof(TwoPointConicalGradientContext); } diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h index 117e6e967d..f468de8007 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.h +++ b/src/effects/gradients/SkTwoPointConicalGradient.h @@ -45,7 +45,7 @@ public: bool flippedGrad, const Descriptor&); - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; class TwoPointConicalGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { public: diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp index 22189fa61a..1c4d422b1e 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 { +size_t SkImageShader::contextSize(const ContextRec&) const { return SkBitmapProcShader::ContextSize(); } diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h index e209b35938..d51dc5d4e4 100644 --- a/src/image/SkImageShader.h +++ b/src/image/SkImageShader.h @@ -16,7 +16,7 @@ public: static SkShader* Create(const SkImage*, TileMode tx, TileMode ty, const SkMatrix* localMatrix); bool isOpaque() const override; - size_t contextSize() const override; + size_t contextSize(const ContextRec&) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader) diff --git a/tests/SkColor4fTest.cpp b/tests/SkColor4fTest.cpp index 5700e4b79c..97ae5e3d5b 100644 --- a/tests/SkColor4fTest.cpp +++ b/tests/SkColor4fTest.cpp @@ -148,9 +148,9 @@ DEF_TEST(Color4f_shader, reporter) { for (const auto& rec : recs) { uint32_t storage[200]; paint.setShader(rec.fFact())->unref(); - SkASSERT(paint.getShader()->contextSize() <= sizeof(storage)); - SkShader::Context* ctx = paint.getShader()->createContext({paint, SkMatrix::I(), nullptr}, - storage); + const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr); + SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage)); + SkShader::Context* ctx = paint.getShader()->createContext(contextRec, storage); REPORTER_ASSERT(reporter, ctx->supports4f() == rec.fSupports4f); if (ctx->supports4f()) { const int N = 100; |