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

Side by Side Diff: gm/samplerstress.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/rects.cpp ('k') | gm/skbug1719.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return; 69 return;
70 } 70 }
71 71
72 createTexture(); 72 createTexture();
73 73
74 fShader = SkShader::MakeBitmapShader(fTexture, SkShader::kRepeat_TileMod e, 74 fShader = SkShader::MakeBitmapShader(fTexture, SkShader::kRepeat_TileMod e,
75 SkShader::kRepeat_TileMode); 75 SkShader::kRepeat_TileMode);
76 } 76 }
77 77
78 void createMaskFilter() { 78 void createMaskFilter() {
79 if (fMaskFilter.get()) { 79 if (fMaskFilter) {
80 return; 80 return;
81 } 81 }
82 82
83 const SkScalar sigma = 1; 83 const SkScalar sigma = 1;
84 fMaskFilter.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma)); 84 fMaskFilter = SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma);
85 } 85 }
86 86
87 void onDraw(SkCanvas* canvas) override { 87 void onDraw(SkCanvas* canvas) override {
88 createShader(); 88 createShader();
89 createMaskFilter(); 89 createMaskFilter();
90 90
91 canvas->save(); 91 canvas->save();
92 92
93 // draw a letter "M" with a green & red striped texture and a 93 // draw a letter "M" with a green & red striped texture and a
94 // stipple mask with a round rect soft clip 94 // stipple mask with a round rect soft clip
95 SkPaint paint; 95 SkPaint paint;
96 paint.setAntiAlias(true); 96 paint.setAntiAlias(true);
97 paint.setTextSize(72); 97 paint.setTextSize(72);
98 paint.setShader(fShader); 98 paint.setShader(fShader);
99 paint.setMaskFilter(fMaskFilter.get()); 99 paint.setMaskFilter(fMaskFilter);
100 sk_tool_utils::set_portable_typeface(&paint); 100 sk_tool_utils::set_portable_typeface(&paint);
101 101
102 SkRect temp; 102 SkRect temp;
103 temp.set(SkIntToScalar(115), 103 temp.set(SkIntToScalar(115),
104 SkIntToScalar(75), 104 SkIntToScalar(75),
105 SkIntToScalar(144), 105 SkIntToScalar(144),
106 SkIntToScalar(110)); 106 SkIntToScalar(110));
107 107
108 SkPath path; 108 SkPath path;
109 path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5)); 109 path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5));
(...skipping 21 matching lines...) Expand all
131 131
132 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); 132 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY));
133 133
134 canvas->drawPath(path, paint2); 134 canvas->drawPath(path, paint2);
135 } 135 }
136 136
137 private: 137 private:
138 SkBitmap fTexture; 138 SkBitmap fTexture;
139 bool fTextureCreated; 139 bool fTextureCreated;
140 sk_sp<SkShader> fShader; 140 sk_sp<SkShader> fShader;
141 SkAutoTUnref<SkMaskFilter> fMaskFilter; 141 sk_sp<SkMaskFilter> fMaskFilter;
142 142
143 typedef GM INHERITED; 143 typedef GM INHERITED;
144 }; 144 };
145 145
146 ////////////////////////////////////////////////////////////////////////////// 146 //////////////////////////////////////////////////////////////////////////////
147 147
148 static GM* MyFactory(void*) { return new SamplerStressGM; } 148 static GM* MyFactory(void*) { return new SamplerStressGM; }
149 static GMRegistry reg(MyFactory); 149 static GMRegistry reg(MyFactory);
150 150
151 } 151 }
OLDNEW
« no previous file with comments | « gm/rects.cpp ('k') | gm/skbug1719.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698