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

Side by Side Diff: samplecode/SampleUnpremul.cpp

Issue 1821533002: guard rasterizer and drawlooper setters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update android sdk Created 4 years, 9 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
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 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "sk_tool_utils.h" 10 #include "sk_tool_utils.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void onDrawBackground(SkCanvas* canvas) override { 75 void onDrawBackground(SkCanvas* canvas) override {
76 sk_tool_utils::draw_checkerboard(canvas, 0xFFCCCCCC, 0xFFFFFFFF, 12); 76 sk_tool_utils::draw_checkerboard(canvas, 0xFFCCCCCC, 0xFFFFFFFF, 12);
77 } 77 }
78 78
79 void onDrawContent(SkCanvas* canvas) override { 79 void onDrawContent(SkCanvas* canvas) override {
80 SkPaint paint; 80 SkPaint paint;
81 paint.setAntiAlias(true); 81 paint.setAntiAlias(true);
82 paint.setTextSize(SkIntToScalar(24)); 82 paint.setTextSize(SkIntToScalar(24));
83 SkAutoTUnref<SkDrawLooper> looper( 83 auto looper(
84 SkBlurDrawLooper::Create(SK_ColorBLUE, 84 SkBlurDrawLooper::Make(SK_ColorBLUE, SkBlurMask::ConvertRadiusToSigm a(SkIntToScalar(2)),
85 SkBlurMask::ConvertRadiusToSigma(SkIntToSca lar(2)), 85 0, 0));
86 0, 0));
87 paint.setLooper(looper); 86 paint.setLooper(looper);
88 SkScalar height = paint.getFontMetrics(nullptr); 87 SkScalar height = paint.getFontMetrics(nullptr);
89 if (!fDecodeSucceeded) { 88 if (!fDecodeSucceeded) {
90 SkString failure; 89 SkString failure;
91 if (fResPath.size() == 0) { 90 if (fResPath.size() == 0) {
92 failure.printf("resource path is required!"); 91 failure.printf("resource path is required!");
93 } else { 92 } else {
94 failure.printf("Failed to decode %s", fCurrFile.c_str()); 93 failure.printf("Failed to decode %s", fCurrFile.c_str());
95 } 94 }
96 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint); 95 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 174
176 typedef SampleView INHERITED; 175 typedef SampleView INHERITED;
177 }; 176 };
178 177
179 ////////////////////////////////////////////////////////////////////////////// 178 //////////////////////////////////////////////////////////////////////////////
180 179
181 static SkView* MyFactory() { 180 static SkView* MyFactory() {
182 return new UnpremulView(GetResourcePath()); 181 return new UnpremulView(GetResourcePath());
183 } 182 }
184 static SkViewRegister reg(MyFactory); 183 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698