Chromium Code Reviews| Index: src/effects/SkLayerDrawLooper.cpp |
| diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp |
| index 6c7c3cef0cb04f2529fc3e21fd5688d3a7b19fed..bb1b887fa8b987984f57f9725d3e2d9b7289ec9d 100644 |
| --- a/src/effects/SkLayerDrawLooper.cpp |
| +++ b/src/effects/SkLayerDrawLooper.cpp |
| @@ -25,8 +25,7 @@ SkLayerDrawLooper::LayerInfo::LayerInfo() { |
| SkLayerDrawLooper::SkLayerDrawLooper() |
| : fRecs(NULL), |
| fTopRec(NULL), |
| - fCount(0), |
| - fCurrRec(NULL) { |
| + fCount(0) { |
| } |
| SkLayerDrawLooper::~SkLayerDrawLooper() { |
| @@ -76,9 +75,11 @@ SkPaint* SkLayerDrawLooper::addLayerOnTop(const LayerInfo& info) { |
| return &rec->fPaint; |
| } |
| -void SkLayerDrawLooper::init(SkCanvas* canvas) { |
| - fCurrRec = fRecs; |
| +SkLayerDrawLooper::DrawContext* SkLayerDrawLooper::init(SkCanvas* canvas) |
| + const { |
| + SkLayerDrawLooperContext* context = new SkLayerDrawLooperContext(this); |
|
scroggo
2014/02/06 17:57:13
SkNEW_ARGS
|
| canvas->save(SkCanvas::kMatrix_SaveFlag); |
| + return context; |
| } |
| static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) { |
| @@ -96,6 +97,9 @@ static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) { |
| } |
| } |
| +SkLayerDrawLooper::SkLayerDrawLooperContext::SkLayerDrawLooperContext( |
| + const SkLayerDrawLooper* looper) : fCurrRec(looper->fRecs) {} |
| + |
| // 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. |
| @@ -170,22 +174,28 @@ static void postTranslate(SkCanvas* canvas, SkScalar dx, SkScalar dy) { |
| canvas->setMatrix(m); |
| } |
| -bool SkLayerDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { |
| +bool SkLayerDrawLooper::next_internal(SkCanvas* canvas, SkPaint* paint, |
| + SkDrawLooper::DrawContext* context) const { |
| + SkLayerDrawLooperContext* layerContext = |
| + static_cast<SkLayerDrawLooperContext*>(context); |
| + |
| canvas->restore(); |
| - if (NULL == fCurrRec) { |
| + if (NULL == layerContext->fCurrRec) { |
| return false; |
| } |
| - ApplyInfo(paint, fCurrRec->fPaint, fCurrRec->fInfo); |
| + ApplyInfo(paint, layerContext->fCurrRec->fPaint, |
| + layerContext->fCurrRec->fInfo); |
| canvas->save(SkCanvas::kMatrix_SaveFlag); |
| - if (fCurrRec->fInfo.fPostTranslate) { |
| - postTranslate(canvas, fCurrRec->fInfo.fOffset.fX, |
| - fCurrRec->fInfo.fOffset.fY); |
| + if (layerContext->fCurrRec->fInfo.fPostTranslate) { |
| + postTranslate(canvas, layerContext->fCurrRec->fInfo.fOffset.fX, |
| + layerContext->fCurrRec->fInfo.fOffset.fY); |
| } else { |
| - canvas->translate(fCurrRec->fInfo.fOffset.fX, fCurrRec->fInfo.fOffset.fY); |
| + canvas->translate(layerContext->fCurrRec->fInfo.fOffset.fX, |
| + layerContext->fCurrRec->fInfo.fOffset.fY); |
| } |
| - fCurrRec = fCurrRec->fNext; |
| + layerContext->fCurrRec = layerContext->fCurrRec->fNext; |
| return true; |
| } |
| @@ -225,8 +235,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++) { |