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

Unified Diff: gm/megalooper.cpp

Issue 232913003: Make sure SkDrawLooper objects can only be allocated on the heap. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 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 | « gm/drawlooper.cpp ('k') | gm/rects.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/megalooper.cpp
diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp
index 12ccf2db5fd84e7c7b573b64580ddf298efd9a6d..e8255502a12c0b5de702c721cc41136942a6dda0 100644
--- a/gm/megalooper.cpp
+++ b/gm/megalooper.cpp
@@ -163,7 +163,7 @@ private:
// Create a 1-tier drawlooper
SkLayerDrawLooper* create1Looper(SkScalar xOff, SkScalar yOff, SkColor color) {
- SkLayerDrawLooper* looper = new SkLayerDrawLooper;
+ SkLayerDrawLooper::Builder looperBuilder;
SkLayerDrawLooper::LayerInfo info;
info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit |
@@ -172,14 +172,14 @@ private:
info.fOffset.set(xOff, yOff);
info.fPostTranslate = false;
- SkPaint* paint = looper->addLayer(info);
+ SkPaint* paint = looperBuilder.addLayer(info);
paint->setMaskFilter(this->createBlur())->unref();
SkColorFilter* cf = SkColorFilter::CreateModeFilter(color, SkXfermode::kSrcIn_Mode);
paint->setColorFilter(cf)->unref();
- return looper;
+ return looperBuilder.detachLooper();
}
void draw1x4(SkCanvas* canvas, SkScalar x, SkScalar y) {
@@ -207,7 +207,7 @@ private:
// Create a 4-tier draw looper
SkLayerDrawLooper* create4Looper(SkScalar xOff, SkScalar yOff) {
- SkLayerDrawLooper* looper = new SkLayerDrawLooper;
+ SkLayerDrawLooper::Builder looperBuilder;
SkLayerDrawLooper::LayerInfo info;
info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit |
@@ -219,7 +219,7 @@ private:
for (int i = 3; i >= 0; --i) {
info.fOffset.set(xOff+gBlurOffsets[i].fX, yOff+gBlurOffsets[i].fY);
- paint = looper->addLayer(info);
+ paint = looperBuilder.addLayer(info);
paint->setMaskFilter(this->createBlur())->unref();
@@ -227,7 +227,7 @@ private:
paint->setColorFilter(cf)->unref();
}
- return looper;
+ return looperBuilder.detachLooper();
}
typedef GM INHERITED;
« no previous file with comments | « gm/drawlooper.cpp ('k') | gm/rects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698