Chromium Code Reviews| Index: src/effects/SkBlurDrawLooper.cpp |
| diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp |
| index 3a5c6973715704d837222ef77fb1a1670a9e91a9..7bc42073ec57196d0592939fc49e5aca6be8a528 100644 |
| --- a/src/effects/SkBlurDrawLooper.cpp |
| +++ b/src/effects/SkBlurDrawLooper.cpp |
| @@ -33,7 +33,6 @@ void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, |
| fDy = dy; |
| fBlurColor = color; |
| fBlurFlags = flags; |
| - fState = kDone; |
| SkASSERT(flags <= kAll_BlurFlag); |
| if (sigma > 0) { |
| @@ -90,16 +89,20 @@ void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { |
| buffer.writeUInt(fBlurFlags); |
| } |
| -void SkBlurDrawLooper::init(SkCanvas*) { |
| - fState = kBeforeEdge; |
| +SkDrawLooper::DrawContext* SkBlurDrawLooper::init(SkCanvas*) const { |
| + return new SkBlurDrawLooperContext; |
|
scroggo
2014/02/06 17:57:13
SkNEW
|
| } |
| -bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { |
| - switch (fState) { |
| +bool SkBlurDrawLooper::next_internal(SkCanvas* canvas, SkPaint* paint, |
| + SkDrawLooper::DrawContext* context) { |
| + SkBlurDrawLooperContext* blurContext = |
| + static_cast<SkBlurDrawLooperContext*>(context); |
| + |
| + switch (blurContext->fState) { |
| case kBeforeEdge: |
| // we do nothing if a maskfilter is already installed |
| if (paint->getMaskFilter()) { |
| - fState = kDone; |
| + blurContext->fState = kDone; |
| return false; |
| } |
| #ifdef SK_BUILD_FOR_ANDROID |
| @@ -122,18 +125,21 @@ bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { |
| } else { |
| canvas->translate(fDx, fDy); |
| } |
| - fState = kAfterEdge; |
| + blurContext->fState = kAfterEdge; |
| return true; |
| case kAfterEdge: |
| canvas->restore(); |
| - fState = kDone; |
| + blurContext->fState = kDone; |
| return true; |
| default: |
| - SkASSERT(kDone == fState); |
| + SkASSERT(kDone == blurContext->fState); |
| return false; |
| } |
| } |
| +SkBlurDrawLooper::SkBlurDrawLooperContext::SkBlurDrawLooperContext() |
| + : fState(SkBlurDrawLooper::kBeforeEdge) {} |
| + |
| #ifdef SK_DEVELOPER |
| void SkBlurDrawLooper::toString(SkString* str) const { |
| str->append("SkBlurDrawLooper: "); |