Index: src/effects/SkLayerDrawLooper.cpp |
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp |
index 449361edc03c60771bfd570efc5b79bbab2bc1e6..4bd4c40c81a30752791913c9fdeb4bfabce5098d 100644 |
--- a/src/effects/SkLayerDrawLooper.cpp |
+++ b/src/effects/SkLayerDrawLooper.cpp |
@@ -354,4 +354,71 @@ void SkLayerDrawLooper::toString(SkString* str) const { |
rec = rec->fNext; |
} |
} |
+ |
+SkLayerDrawLooperBuilder::SkLayerDrawLooperBuilder() |
+ : fRecs(NULL), |
+ fTopRec(NULL), |
+ fCount(0) { |
+} |
+ |
+SkLayerDrawLooperBuilder::~SkLayerDrawLooperBuilder() { |
+ SkLayerDrawLooper::Rec* rec = fRecs; |
+ while (rec) { |
+ SkLayerDrawLooper::Rec* next = rec->fNext; |
+ SkDELETE(rec); |
+ rec = next; |
+ } |
+} |
+ |
+SkPaint* SkLayerDrawLooperBuilder::addLayer( |
+ const SkLayerDrawLooper::LayerInfo& info) { |
+ fCount += 1; |
+ |
+ SkLayerDrawLooper::Rec* rec = SkNEW(SkLayerDrawLooper::Rec); |
+ rec->fNext = fRecs; |
+ rec->fInfo = info; |
+ fRecs = rec; |
+ if (NULL == fTopRec) { |
+ fTopRec = rec; |
+ } |
+ |
+ return &rec->fPaint; |
+} |
+ |
+void SkLayerDrawLooperBuilder::addLayer(SkScalar dx, SkScalar dy) { |
+ SkLayerDrawLooper::LayerInfo info; |
+ |
+ info.fOffset.set(dx, dy); |
+ (void)this->addLayer(info); |
+} |
+ |
+SkPaint* SkLayerDrawLooperBuilder::addLayerOnTop( |
+ const SkLayerDrawLooper::LayerInfo& info) { |
+ fCount += 1; |
+ |
+ SkLayerDrawLooper::Rec* rec = SkNEW(SkLayerDrawLooper::Rec); |
+ rec->fNext = NULL; |
+ rec->fInfo = info; |
+ if (NULL == fRecs) { |
+ fRecs = rec; |
+ } else { |
+ SkASSERT(NULL != fTopRec); |
+ fTopRec->fNext = rec; |
+ } |
+ fTopRec = rec; |
+ |
+ return &rec->fPaint; |
+} |
+ |
+SkDrawLooper* SkLayerDrawLooperBuilder::createLooper() { |
+ SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); |
+ looper->fCount = fCount; |
+ looper->fRecs = fRecs; |
+ |
+ fCount = 0; |
+ fRecs = NULL; |
+ fTopRec = NULL; |
+ |
+ return looper; |
+} |
#endif |