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

Side by Side Diff: gm/blurcircles.cpp

Issue 1852113003: switch maskfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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/bleed.cpp ('k') | gm/blurquickreject.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 2014 Google Inc. 2 * Copyright 2014 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 13 matching lines...) Expand all
24 } 24 }
25 25
26 SkISize onISize() override { 26 SkISize onISize() override {
27 return SkISize::Make(950, 950); 27 return SkISize::Make(950, 950);
28 } 28 }
29 29
30 void onOnceBeforeDraw() override { 30 void onOnceBeforeDraw() override {
31 const float blurRadii[kNumBlurs] = { 1,5,10,20 }; 31 const float blurRadii[kNumBlurs] = { 1,5,10,20 };
32 32
33 for (int i = 0; i < kNumBlurs; ++i) { 33 for (int i = 0; i < kNumBlurs; ++i) {
34 fBlurFilters[i].reset(SkBlurMaskFilter::Create( 34 fBlurFilters[i] = SkBlurMaskFilter::Make(
35 kNormal_SkBlurStyle, 35 kNormal_SkBlurStyle,
36 SkBlurMask::ConvertRadiusToSigma(SkIntToScal ar(blurRadii[i])), 36 SkBlurMask::ConvertRadiusToSigma(SkIntToScal ar(blurRadii[i])),
37 SkBlurMaskFilter::kHighQuality_BlurFlag)); 37 SkBlurMaskFilter::kHighQuality_BlurFlag);
38 } 38 }
39 } 39 }
40 40
41 void onDraw(SkCanvas* canvas) override { 41 void onDraw(SkCanvas* canvas) override {
42 canvas->scale(1.5f, 1.5f); 42 canvas->scale(1.5f, 1.5f);
43 canvas->translate(50,50); 43 canvas->translate(50,50);
44 44
45 const int circleRadii[] = { 5,10,25,50 }; 45 const int circleRadii[] = { 5,10,25,50 };
46 46
47 for (size_t i = 0; i < kNumBlurs; ++i) { 47 for (size_t i = 0; i < kNumBlurs; ++i) {
48 SkAutoCanvasRestore autoRestore(canvas, true); 48 SkAutoCanvasRestore autoRestore(canvas, true);
49 canvas->translate(0, SkIntToScalar(150*i)); 49 canvas->translate(0, SkIntToScalar(150*i));
50 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) { 50 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) {
51 SkPaint paint; 51 SkPaint paint;
52 paint.setColor(SK_ColorBLACK); 52 paint.setColor(SK_ColorBLACK);
53 paint.setMaskFilter(fBlurFilters[i]); 53 paint.setMaskFilter(fBlurFilters[i]);
54 54
55 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc alar(circleRadii[j]),paint); 55 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc alar(circleRadii[j]),paint);
56 canvas->translate(SkIntToScalar(150), 0); 56 canvas->translate(SkIntToScalar(150), 0);
57 } 57 }
58 } 58 }
59 } 59 }
60 private: 60 private:
61 static const int kNumBlurs = 4; 61 static const int kNumBlurs = 4;
62 62
63 SkAutoTUnref<SkMaskFilter> fBlurFilters[kNumBlurs]; 63 sk_sp<SkMaskFilter> fBlurFilters[kNumBlurs];
64 64
65 typedef skiagm::GM INHERITED; 65 typedef skiagm::GM INHERITED;
66 }; 66 };
67 67
68 DEF_GM(return new BlurCirclesGM();) 68 DEF_GM(return new BlurCirclesGM();)
OLDNEW
« no previous file with comments | « gm/bleed.cpp ('k') | gm/blurquickreject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698