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

Unified Diff: src/effects/SkLayerDrawLooper.cpp

Issue 133813005: Builder class for SkLayerDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@draw_looper_context
Patch Set: Created 6 years, 10 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
« include/effects/SkLayerDrawLooper.h ('K') | « include/effects/SkLayerDrawLooper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« include/effects/SkLayerDrawLooper.h ('K') | « include/effects/SkLayerDrawLooper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698