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

Side by Side Diff: gm/samplerstress.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on 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
« no previous file with comments | « gm/roundrects.cpp ('k') | gm/shaderbounds.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"
11 #include "SkPath.h" 11 #include "SkPath.h"
12 #include "SkShader.h" 12 #include "SkShader.h"
13 13
14 namespace skiagm { 14 namespace skiagm {
15 15
16 /** 16 /**
17 * Stress test the GPU samplers by rendering a textured glyph with a mask and 17 * Stress test the GPU samplers by rendering a textured glyph with a mask and
18 * an AA clip 18 * an AA clip
19 */ 19 */
20 class SamplerStressGM : public GM { 20 class SamplerStressGM : public GM {
21 public: 21 public:
22 SamplerStressGM() 22 SamplerStressGM()
23 : fTextureCreated(false) 23 : fTextureCreated(false)
24 , fShader(nullptr)
25 , fMaskFilter(nullptr) { 24 , fMaskFilter(nullptr) {
26 } 25 }
27 26
28 virtual ~SamplerStressGM() {
29 }
30
31 protected: 27 protected:
32 28
33 SkString onShortName() override { 29 SkString onShortName() override {
34 return SkString("gpusamplerstress"); 30 return SkString("gpusamplerstress");
35 } 31 }
36 32
37 SkISize onISize() override { 33 SkISize onISize() override {
38 return SkISize::Make(640, 480); 34 return SkISize::Make(640, 480);
39 } 35 }
40 36
(...skipping 21 matching lines...) Expand all
62 if ((x % 7) == 0) { 58 if ((x % 7) == 0) {
63 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN); 59 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN);
64 } 60 }
65 } 61 }
66 } 62 }
67 63
68 fTextureCreated = true; 64 fTextureCreated = true;
69 } 65 }
70 66
71 void createShader() { 67 void createShader() {
72 if (fShader.get()) { 68 if (fShader) {
73 return; 69 return;
74 } 70 }
75 71
76 createTexture(); 72 createTexture();
77 73
78 fShader.reset(SkShader::CreateBitmapShader(fTexture, 74 fShader = SkShader::MakeBitmapShader(fTexture, SkShader::kRepeat_TileMod e,
79 SkShader::kRepeat_TileMode, 75 SkShader::kRepeat_TileMode);
80 SkShader::kRepeat_TileMode));
81 } 76 }
82 77
83 void createMaskFilter() { 78 void createMaskFilter() {
84 if (fMaskFilter.get()) { 79 if (fMaskFilter.get()) {
85 return; 80 return;
86 } 81 }
87 82
88 const SkScalar sigma = 1; 83 const SkScalar sigma = 1;
89 fMaskFilter.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma)); 84 fMaskFilter.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma));
90 } 85 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 canvas->drawText("M", 1, 128 canvas->drawText("M", 1,
134 SkIntToScalar(100), SkIntToScalar(100), 129 SkIntToScalar(100), SkIntToScalar(100),
135 paint2); 130 paint2);
136 131
137 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); 132 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY));
138 133
139 canvas->drawPath(path, paint2); 134 canvas->drawPath(path, paint2);
140 } 135 }
141 136
142 private: 137 private:
143 SkBitmap fTexture; 138 SkBitmap fTexture;
144 bool fTextureCreated; 139 bool fTextureCreated;
145 SkAutoTUnref<SkShader> fShader; 140 sk_sp<SkShader> fShader;
146 SkAutoTUnref<SkMaskFilter> fMaskFilter; 141 SkAutoTUnref<SkMaskFilter> fMaskFilter;
147 142
148 typedef GM INHERITED; 143 typedef GM INHERITED;
149 }; 144 };
150 145
151 ////////////////////////////////////////////////////////////////////////////// 146 //////////////////////////////////////////////////////////////////////////////
152 147
153 static GM* MyFactory(void*) { return new SamplerStressGM; } 148 static GM* MyFactory(void*) { return new SamplerStressGM; }
154 static GMRegistry reg(MyFactory); 149 static GMRegistry reg(MyFactory);
155 150
156 } 151 }
OLDNEW
« no previous file with comments | « gm/roundrects.cpp ('k') | gm/shaderbounds.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698