Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: src/effects/SkBlurDrawLooper.cpp

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkSmallAllocator.h ('k') | src/effects/SkLayerDrawLooper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBlurDrawLooper.cpp
diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp
index 3a5c6973715704d837222ef77fb1a1670a9e91a9..0bbc184049aeb8d733cb5d4e0bce28d97c628370 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,11 +89,16 @@ void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
buffer.writeUInt(fBlurFlags);
}
-void SkBlurDrawLooper::init(SkCanvas*) {
- fState = kBeforeEdge;
+SkDrawLooper::Context* SkBlurDrawLooper::createContext(SkCanvas*, void* storage) const {
+ return SkNEW_PLACEMENT_ARGS(storage, BlurDrawLooperContext, (this));
}
-bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) {
+SkBlurDrawLooper::BlurDrawLooperContext::BlurDrawLooperContext(
+ const SkBlurDrawLooper* looper)
+ : fLooper(looper), fState(SkBlurDrawLooper::kBeforeEdge) {}
+
+bool SkBlurDrawLooper::BlurDrawLooperContext::next(SkCanvas* canvas,
+ SkPaint* paint) {
switch (fState) {
case kBeforeEdge:
// we do nothing if a maskfilter is already installed
@@ -104,23 +108,23 @@ bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) {
}
#ifdef SK_BUILD_FOR_ANDROID
SkColor blurColor;
- blurColor = fBlurColor;
+ blurColor = fLooper->fBlurColor;
if (SkColorGetA(blurColor) == 255) {
blurColor = SkColorSetA(blurColor, paint->getAlpha());
}
paint->setColor(blurColor);
#else
- paint->setColor(fBlurColor);
+ paint->setColor(fLooper->fBlurColor);
#endif
- paint->setMaskFilter(fBlur);
- paint->setColorFilter(fColorFilter);
+ paint->setMaskFilter(fLooper->fBlur);
+ paint->setColorFilter(fLooper->fColorFilter);
canvas->save(SkCanvas::kMatrix_SaveFlag);
- if (fBlurFlags & kIgnoreTransform_BlurFlag) {
+ if (fLooper->fBlurFlags & kIgnoreTransform_BlurFlag) {
SkMatrix transform(canvas->getTotalMatrix());
- transform.postTranslate(fDx, fDy);
+ transform.postTranslate(fLooper->fDx, fLooper->fDy);
canvas->setMatrix(transform);
} else {
- canvas->translate(fDx, fDy);
+ canvas->translate(fLooper->fDx, fLooper->fDy);
}
fState = kAfterEdge;
return true;
« no previous file with comments | « src/core/SkSmallAllocator.h ('k') | src/effects/SkLayerDrawLooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698