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

Side by Side Diff: samplecode/SampleUnpremul.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 | « samplecode/SampleTiling.cpp ('k') | src/effects/SkBlurDrawLooper.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 2013 Google Inc. 2 * Copyright 2013 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 #include "gm.h" 7 #include "gm.h"
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurDrawLooper.h" 10 #include "SkBlurDrawLooper.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SkPaint paint; 78 SkPaint paint;
79 SkAutoTUnref<SkShader> shader(createChecker()); 79 SkAutoTUnref<SkShader> shader(createChecker());
80 paint.setShader(shader.get()); 80 paint.setShader(shader.get());
81 canvas->drawPaint(paint); 81 canvas->drawPaint(paint);
82 } 82 }
83 83
84 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 84 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
85 SkPaint paint; 85 SkPaint paint;
86 paint.setAntiAlias(true); 86 paint.setAntiAlias(true);
87 paint.setTextSize(SkIntToScalar(24)); 87 paint.setTextSize(SkIntToScalar(24));
88 SkAutoTUnref<SkBlurDrawLooper> looper(SkNEW_ARGS(SkBlurDrawLooper, 88 SkAutoTUnref<SkBlurDrawLooper> looper(
89 (SK_ColorBLUE, 89 SkBlurDrawLooper::Create(SK_ColorBLUE,
90 SkBlurMask::ConvertRadiusToSigma( SkIntToScalar(2)), 90 SkBlurMask::ConvertRadiusToSigma(SkIntToSca lar(2)),
91 0, 0))); 91 0, 0));
92 paint.setLooper(looper); 92 paint.setLooper(looper);
93 SkScalar height = paint.getFontMetrics(NULL); 93 SkScalar height = paint.getFontMetrics(NULL);
94 if (!fDecodeSucceeded) { 94 if (!fDecodeSucceeded) {
95 SkString failure; 95 SkString failure;
96 if (fResPath.size() == 0) { 96 if (fResPath.size() == 0) {
97 failure.printf("resource path is required!"); 97 failure.printf("resource path is required!");
98 } else { 98 } else {
99 failure.printf("Failed to decode %s", fCurrFile.c_str()); 99 failure.printf("Failed to decode %s", fCurrFile.c_str());
100 } 100 }
101 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint); 101 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 typedef SampleView INHERITED; 196 typedef SampleView INHERITED;
197 }; 197 };
198 198
199 ////////////////////////////////////////////////////////////////////////////// 199 //////////////////////////////////////////////////////////////////////////////
200 200
201 static SkView* MyFactory() { 201 static SkView* MyFactory() {
202 return new UnpremulView(skiagm::GM::GetResourcePath()); 202 return new UnpremulView(skiagm::GM::GetResourcePath());
203 } 203 }
204 static SkViewRegister reg(MyFactory); 204 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | src/effects/SkBlurDrawLooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698