Index: src/effects/SkLayerDrawLooper.cpp |
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp |
index 6c7c3cef0cb04f2529fc3e21fd5688d3a7b19fed..464976ef38060db27dcf6c766a0f48ce47691038 100644 |
--- a/src/effects/SkLayerDrawLooper.cpp |
+++ b/src/effects/SkLayerDrawLooper.cpp |
@@ -12,6 +12,7 @@ |
#include "SkLayerDrawLooper.h" |
#include "SkString.h" |
#include "SkStringUtils.h" |
+#include "SkTemplatesPriv.h" |
#include "SkUnPreMultiply.h" |
SkLayerDrawLooper::LayerInfo::LayerInfo() { |
@@ -25,8 +26,7 @@ SkLayerDrawLooper::LayerInfo::LayerInfo() { |
SkLayerDrawLooper::SkLayerDrawLooper() |
: fRecs(NULL), |
fTopRec(NULL), |
- fCount(0), |
- fCurrRec(NULL) { |
+ fCount(0) { |
} |
SkLayerDrawLooper::~SkLayerDrawLooper() { |
@@ -76,9 +76,13 @@ SkPaint* SkLayerDrawLooper::addLayerOnTop(const LayerInfo& info) { |
return &rec->fPaint; |
} |
-void SkLayerDrawLooper::init(SkCanvas* canvas) { |
- fCurrRec = fRecs; |
+SkLayerDrawLooper::DrawContext* SkLayerDrawLooper::init( |
+ SkCanvas* canvas, void* storage, size_t storageSize) const { |
+ LayerDrawLooperContext* context; |
+ SK_PLACEMENT_NEW_ARGS(context, LayerDrawLooperContext, storage, |
+ storageSize, (this)); |
canvas->save(SkCanvas::kMatrix_SaveFlag); |
+ return context; |
} |
static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) { |
@@ -99,8 +103,8 @@ static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) { |
// Even with kEntirePaint_Bits, we always ensure that the master paint's |
// text-encoding is respected, since that controls how we interpret the |
// text/length parameters of a draw[Pos]Text call. |
-void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src, |
- const LayerInfo& info) { |
+void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo( |
+ SkPaint* dst, const SkPaint& src, const LayerInfo& info) { |
uint32_t mask = info.fFlagsMask; |
dst->setFlags((dst->getFlags() & ~mask) | (src.getFlags() & mask)); |
@@ -170,7 +174,11 @@ static void postTranslate(SkCanvas* canvas, SkScalar dx, SkScalar dy) { |
canvas->setMatrix(m); |
} |
-bool SkLayerDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { |
+SkLayerDrawLooper::LayerDrawLooperContext::LayerDrawLooperContext( |
+ const SkLayerDrawLooper* looper) : fCurrRec(looper->fRecs) {} |
+ |
+bool SkLayerDrawLooper::LayerDrawLooperContext::next(SkCanvas* canvas, |
+ SkPaint* paint) { |
canvas->restore(); |
if (NULL == fCurrRec) { |
return false; |
@@ -183,7 +191,8 @@ bool SkLayerDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { |
postTranslate(canvas, fCurrRec->fInfo.fOffset.fX, |
fCurrRec->fInfo.fOffset.fY); |
} else { |
- canvas->translate(fCurrRec->fInfo.fOffset.fX, fCurrRec->fInfo.fOffset.fY); |
+ canvas->translate(fCurrRec->fInfo.fOffset.fX, |
+ fCurrRec->fInfo.fOffset.fY); |
} |
fCurrRec = fCurrRec->fNext; |
@@ -225,8 +234,7 @@ SkLayerDrawLooper::SkLayerDrawLooper(SkReadBuffer& buffer) |
: INHERITED(buffer), |
fRecs(NULL), |
fTopRec(NULL), |
- fCount(0), |
- fCurrRec(NULL) { |
+ fCount(0) { |
int count = buffer.readInt(); |
for (int i = 0; i < count; i++) { |