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

Side by Side Diff: gm/drawlooper.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 unified diff | Download patch
« no previous file with comments | « gm/circles.cpp ('k') | gm/megalooper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SkScalar fWidth; 65 SkScalar fWidth;
66 SkScalar fOffset; 66 SkScalar fOffset;
67 SkScalar fBlur; 67 SkScalar fBlur;
68 } gParams[] = { 68 } gParams[] = {
69 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 }, 69 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 },
70 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, 70 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 },
71 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, 71 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
72 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca lar(3) } 72 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca lar(3) }
73 }; 73 };
74 74
75 fLooper = new SkLayerDrawLooper; 75 SkLayerDrawLooper::Builder looperBuilder;
76 76
77 SkLayerDrawLooper::LayerInfo info; 77 SkLayerDrawLooper::LayerInfo info;
78 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa skFilter_Bit; 78 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa skFilter_Bit;
79 info.fColorMode = SkXfermode::kSrc_Mode; 79 info.fColorMode = SkXfermode::kSrc_Mode;
80 80
81 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { 81 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
82 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); 82 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset);
83 SkPaint* paint = fLooper->addLayer(info); 83 SkPaint* paint = looperBuilder.addLayer(info);
84 paint->setColor(gParams[i].fColor); 84 paint->setColor(gParams[i].fColor);
85 paint->setStyle(gParams[i].fStyle); 85 paint->setStyle(gParams[i].fStyle);
86 paint->setStrokeWidth(gParams[i].fWidth); 86 paint->setStrokeWidth(gParams[i].fWidth);
87 if (gParams[i].fBlur > 0) { 87 if (gParams[i].fBlur > 0) {
88 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN ormal_BlurStyle, 88 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN ormal_BlurStyle,
89 SkBlurMask::ConvertRadiusToSigma(gParam s[i].fBlur)); 89 SkBlurMask::ConvertRadiusToSigma(gParam s[i].fBlur));
90 paint->setMaskFilter(mf)->unref(); 90 paint->setMaskFilter(mf)->unref();
91 } 91 }
92 } 92 }
93 fLooper = looperBuilder.detachLooper();
93 } 94 }
94 95
95 typedef GM INHERITED; 96 typedef GM INHERITED;
96 }; 97 };
97 98
98 ////////////////////////////////////////////////////////////////////////////// 99 //////////////////////////////////////////////////////////////////////////////
99 100
100 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } 101 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; }
101 static skiagm::GMRegistry reg(MyFactory); 102 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/circles.cpp ('k') | gm/megalooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698