OLD | NEW |
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) |
24 , fMaskFilter(nullptr) { | 25 , fMaskFilter(nullptr) { |
25 } | 26 } |
26 | 27 |
| 28 virtual ~SamplerStressGM() { |
| 29 } |
| 30 |
27 protected: | 31 protected: |
28 | 32 |
29 SkString onShortName() override { | 33 SkString onShortName() override { |
30 return SkString("gpusamplerstress"); | 34 return SkString("gpusamplerstress"); |
31 } | 35 } |
32 | 36 |
33 SkISize onISize() override { | 37 SkISize onISize() override { |
34 return SkISize::Make(640, 480); | 38 return SkISize::Make(640, 480); |
35 } | 39 } |
36 | 40 |
(...skipping 21 matching lines...) Expand all Loading... |
58 if ((x % 7) == 0) { | 62 if ((x % 7) == 0) { |
59 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN); | 63 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN); |
60 } | 64 } |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
64 fTextureCreated = true; | 68 fTextureCreated = true; |
65 } | 69 } |
66 | 70 |
67 void createShader() { | 71 void createShader() { |
68 if (fShader) { | 72 if (fShader.get()) { |
69 return; | 73 return; |
70 } | 74 } |
71 | 75 |
72 createTexture(); | 76 createTexture(); |
73 | 77 |
74 fShader = SkShader::MakeBitmapShader(fTexture, SkShader::kRepeat_TileMod
e, | 78 fShader.reset(SkShader::CreateBitmapShader(fTexture, |
75 SkShader::kRepeat_TileMode); | 79 SkShader::kRepeat_TileMode, |
| 80 SkShader::kRepeat_TileMode)); |
76 } | 81 } |
77 | 82 |
78 void createMaskFilter() { | 83 void createMaskFilter() { |
79 if (fMaskFilter.get()) { | 84 if (fMaskFilter.get()) { |
80 return; | 85 return; |
81 } | 86 } |
82 | 87 |
83 const SkScalar sigma = 1; | 88 const SkScalar sigma = 1; |
84 fMaskFilter.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma)); | 89 fMaskFilter.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma)); |
85 } | 90 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 canvas->drawText("M", 1, | 133 canvas->drawText("M", 1, |
129 SkIntToScalar(100), SkIntToScalar(100), | 134 SkIntToScalar(100), SkIntToScalar(100), |
130 paint2); | 135 paint2); |
131 | 136 |
132 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); | 137 paint2.setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); |
133 | 138 |
134 canvas->drawPath(path, paint2); | 139 canvas->drawPath(path, paint2); |
135 } | 140 } |
136 | 141 |
137 private: | 142 private: |
138 SkBitmap fTexture; | 143 SkBitmap fTexture; |
139 bool fTextureCreated; | 144 bool fTextureCreated; |
140 sk_sp<SkShader> fShader; | 145 SkAutoTUnref<SkShader> fShader; |
141 SkAutoTUnref<SkMaskFilter> fMaskFilter; | 146 SkAutoTUnref<SkMaskFilter> fMaskFilter; |
142 | 147 |
143 typedef GM INHERITED; | 148 typedef GM INHERITED; |
144 }; | 149 }; |
145 | 150 |
146 ////////////////////////////////////////////////////////////////////////////// | 151 ////////////////////////////////////////////////////////////////////////////// |
147 | 152 |
148 static GM* MyFactory(void*) { return new SamplerStressGM; } | 153 static GM* MyFactory(void*) { return new SamplerStressGM; } |
149 static GMRegistry reg(MyFactory); | 154 static GMRegistry reg(MyFactory); |
150 | 155 |
151 } | 156 } |
OLD | NEW |