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

Unified Diff: samplecode/SampleTiling.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: 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
Index: samplecode/SampleTiling.cpp
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index 735b9907ef4e784776955cb59fef322189937192..7bacb8b81eb9b5c436b4cc090c6bf979fa293c01 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -62,23 +62,19 @@ static const int gWidth = 32;
static const int gHeight = 32;
class TilingView : public SampleView {
- SkPicture* fTextPicture;
- SkBlurDrawLooper fLooper;
+ SkAutoTUnref<SkPicture> fTextPicture;
+ SkAutoTUnref<SkBlurDrawLooper> fLooper;
public:
TilingView()
- : fLooper(0x88000000,
- SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
- SkIntToScalar(2), SkIntToScalar(2)) {
- fTextPicture = new SkPicture();
+ : fTextPicture(new SkPicture)
+ , fLooper(SkBlurDrawLooper::Create(0x88000000,
+ SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
+ SkIntToScalar(2), SkIntToScalar(2))) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight);
}
}
- ~TilingView() {
- fTextPicture->unref();
- }
-
SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
protected:
@@ -117,7 +113,7 @@ protected:
SkString str;
p.setAntiAlias(true);
p.setDither(true);
- p.setLooper(&fLooper);
+ p.setLooper(fLooper);
str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
p.setTextAlign(SkPaint::kCenter_Align);
@@ -151,7 +147,7 @@ protected:
SkPaint p;
SkString str;
p.setAntiAlias(true);
- p.setLooper(&fLooper);
+ p.setLooper(fLooper);
str.printf("%s, %s", gConfigNames[i], gFilterNames[j]);
textCanvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p);
}

Powered by Google App Engine
This is Rietveld 408576698