From 87fcd950198a16211b3988610beebb5ca5bcf323 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 23 Apr 2014 19:10:51 +0000 Subject: Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/) Reason for revert: Chromium side change landed along side DEPS roll that includes r14323. Original issue's description: > Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/) > > Reason for revert: > This is blocking the DEPS roll into Chromium. Failures can be seen here: > > http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333 > > Original issue's description: > > Extract most of the mutable state of SkShader into a separate Context object. > > > > SkShader currently stores some state during draw calls via setContext(...). > > Move that mutable state into a separate SkShader::Context class that is > > constructed on demand for the duration of the draw. > > > > Calls to setContext() are replaced with createContext() which returns a context > > corresponding to the shader object or NULL if the parameters to createContext > > are invalid. > > > > TEST=out/Debug/dm > > BUG=skia:1976 > > > > Committed: http://code.google.com/p/skia/source/detail?r=14216 > > > > Committed: http://code.google.com/p/skia/source/detail?r=14323 > > TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org > NOTREECHECKS=true > NOTRY=true > BUG=skia:1976 > > Committed: http://code.google.com/p/skia/source/detail?r=14326 R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org NOTREECHECKS=true NOTRY=true BUG=skia:1976 Author: bsalomon@google.com Review URL: https://codereview.chromium.org/246403013 git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/effects/gradients/SkSweepGradient.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/effects/gradients/SkSweepGradient.cpp') diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 7024945bf0..6dff1e71cd 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -52,6 +52,24 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fCenter); } +size_t SkSweepGradient::contextSize() const { + return sizeof(SweepGradientContext); +} + +SkShader::Context* SkSweepGradient::createContext(const SkBitmap& device, const SkPaint& paint, + const SkMatrix& matrix, void* storage) const { + if (!this->validContext(device, paint, matrix)) { + return NULL; + } + + return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, device, paint, matrix)); +} + +SkSweepGradient::SweepGradientContext::SweepGradientContext( + const SkSweepGradient& shader, const SkBitmap& device, + const SkPaint& paint, const SkMatrix& matrix) + : INHERITED(shader, device, paint, matrix) {} + // returns angle in a circle [0..2PI) -> [0..255] static unsigned SkATan2_255(float y, float x) { // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); @@ -69,11 +87,11 @@ static unsigned SkATan2_255(float y, float x) { return ir; } -void SkSweepGradient::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC, - int count) { +void SkSweepGradient::SweepGradientContext::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC, + int count) { SkMatrix::MapXYProc proc = fDstToIndexProc; const SkMatrix& matrix = fDstToIndex; - const SkPMColor* SK_RESTRICT cache = this->getCache32(); + const SkPMColor* SK_RESTRICT cache = fCache->getCache32(); int toggle = init_dither_toggle(x, y); SkPoint srcPt; @@ -111,11 +129,11 @@ void SkSweepGradient::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC, } } -void SkSweepGradient::shadeSpan16(int x, int y, uint16_t* SK_RESTRICT dstC, - int count) { +void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t* SK_RESTRICT dstC, + int count) { SkMatrix::MapXYProc proc = fDstToIndexProc; const SkMatrix& matrix = fDstToIndex; - const uint16_t* SK_RESTRICT cache = this->getCache16(); + const uint16_t* SK_RESTRICT cache = fCache->getCache16(); int toggle = init_dither_toggle16(x, y); SkPoint srcPt; -- cgit v1.2.3