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

Side by Side Diff: gm/composeshader.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
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 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 12 matching lines...) Expand all
23 colors[0] = SK_ColorRED; 23 colors[0] = SK_ColorRED;
24 colors[1] = SK_ColorBLUE; 24 colors[1] = SK_ColorBLUE;
25 auto shaderA = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShade r::kClamp_TileMode); 25 auto shaderA = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShade r::kClamp_TileMode);
26 26
27 pts[0].set(0, 0); 27 pts[0].set(0, 0);
28 pts[1].set(0, SkIntToScalar(100)); 28 pts[1].set(0, SkIntToScalar(100));
29 colors[0] = SK_ColorBLACK; 29 colors[0] = SK_ColorBLACK;
30 colors[1] = SkColorSetARGB(0x80, 0, 0, 0); 30 colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
31 auto shaderB = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShade r::kClamp_TileMode); 31 auto shaderB = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShade r::kClamp_TileMode);
32 32
33 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode)); 33 return SkShader::MakeComposeShader(std::move(shaderA), std::move(shaderB),
34 34 SkXfermode::Make(mode));
35 return SkShader::MakeComposeShader(std::move(shaderA), std::move(shaderB), x fer);
36 } 35 }
37 36
38 class ComposeShaderGM : public skiagm::GM { 37 class ComposeShaderGM : public skiagm::GM {
39 public: 38 public:
40 ComposeShaderGM() { 39 ComposeShaderGM() {
41 fShader = make_shader(SkXfermode::kDstIn_Mode); 40 fShader = make_shader(SkXfermode::kDstIn_Mode);
42 } 41 }
43 42
44 protected: 43 protected:
45 SkString onShortName() override { 44 SkString onShortName() override {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 168
170 SkString onShortName() override { 169 SkString onShortName() override {
171 return SkString("composeshader_bitmap"); 170 return SkString("composeshader_bitmap");
172 } 171 }
173 172
174 SkISize onISize() override { 173 SkISize onISize() override {
175 return SkISize::Make(7 * (squareLength + 5), 2 * (squareLength + 5)); 174 return SkISize::Make(7 * (squareLength + 5), 2 * (squareLength + 5));
176 } 175 }
177 176
178 void onDraw(SkCanvas* canvas) override { 177 void onDraw(SkCanvas* canvas) override {
179 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kDstOver_Mo de)); 178 auto xfer(SkXfermode::Make(SkXfermode::kDstOver_Mode));
180 179
181 sk_sp<SkShader> shaders[] = { 180 sk_sp<SkShader> shaders[] = {
182 // gradient should appear over color bitmap 181 // gradient should appear over color bitmap
183 SkShader::MakeComposeShader(fLinearGradientShader, fColorBitmapShade r, xfer), 182 SkShader::MakeComposeShader(fLinearGradientShader, fColorBitmapShade r, xfer),
184 // gradient should appear over alpha8 bitmap colorized by the paint color 183 // gradient should appear over alpha8 bitmap colorized by the paint color
185 SkShader::MakeComposeShader(fLinearGradientShader, fAlpha8BitmapShad er, xfer), 184 SkShader::MakeComposeShader(fLinearGradientShader, fAlpha8BitmapShad er, xfer),
186 }; 185 };
187 186
188 SkPaint paint; 187 SkPaint paint;
189 paint.setColor(SK_ColorYELLOW); 188 paint.setColor(SK_ColorYELLOW);
(...skipping 30 matching lines...) Expand all
220 sk_sp<SkShader> fLinearGradientShader; 219 sk_sp<SkShader> fLinearGradientShader;
221 220
222 typedef GM INHERITED; 221 typedef GM INHERITED;
223 }; 222 };
224 223
225 ////////////////////////////////////////////////////////////////////////////// 224 //////////////////////////////////////////////////////////////////////////////
226 225
227 DEF_GM( return new ComposeShaderGM; ) 226 DEF_GM( return new ComposeShaderGM; )
228 DEF_GM( return new ComposeShaderAlphaGM; ) 227 DEF_GM( return new ComposeShaderAlphaGM; )
229 DEF_GM( return new ComposeShaderBitmapGM; ) 228 DEF_GM( return new ComposeShaderBitmapGM; )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698