OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 60 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; |
61 | 61 |
62 protected: | 62 protected: |
63 enum { | 63 enum { |
64 kPOTSize = 4, | 64 kPOTSize = 4, |
65 kNPOTSize = 3, | 65 kNPOTSize = 3, |
66 }; | 66 }; |
67 | 67 |
68 SkString onShortName() SK_OVERRIDE { | 68 SkString onShortName() override { |
69 SkString name("scaled_tilemodes"); | 69 SkString name("scaled_tilemodes"); |
70 if (!fPowerOfTwoSize) { | 70 if (!fPowerOfTwoSize) { |
71 name.append("_npot"); | 71 name.append("_npot"); |
72 } | 72 } |
73 return name; | 73 return name; |
74 } | 74 } |
75 | 75 |
76 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 760); } | 76 SkISize onISize() override { return SkISize::Make(880, 760); } |
77 | 77 |
78 void onOnceBeforeDraw() SK_OVERRIDE { | 78 void onOnceBeforeDraw() override { |
79 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; | 79 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; |
80 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { | 80 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { |
81 makebm(&fTexture[i], gColorTypes[i], size, size); | 81 makebm(&fTexture[i], gColorTypes[i], size, size); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 85 void onDraw(SkCanvas* canvas) override { |
86 float scale = 32.f/kPOTSize; | 86 float scale = 32.f/kPOTSize; |
87 | 87 |
88 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; | 88 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; |
89 | 89 |
90 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; | 90 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; |
91 | 91 |
92 static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; | 92 static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; |
93 | 93 |
94 static const SkFilterQuality gFilterQualitys[] = | 94 static const SkFilterQuality gFilterQualitys[] = |
95 { kNone_SkFilterQuality, | 95 { kNone_SkFilterQuality, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 class ScaledTiling2GM : public skiagm::GM { | 200 class ScaledTiling2GM : public skiagm::GM { |
201 ShaderProc fProc; | 201 ShaderProc fProc; |
202 SkString fName; | 202 SkString fName; |
203 public: | 203 public: |
204 ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { | 204 ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { |
205 fName.printf("scaled_tilemode_%s", name); | 205 fName.printf("scaled_tilemode_%s", name); |
206 } | 206 } |
207 | 207 |
208 protected: | 208 protected: |
209 | 209 |
210 SkString onShortName() SK_OVERRIDE { | 210 SkString onShortName() override { |
211 return fName; | 211 return fName; |
212 } | 212 } |
213 | 213 |
214 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 560); } | 214 SkISize onISize() override { return SkISize::Make(880, 560); } |
215 | 215 |
216 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 216 void onDraw(SkCanvas* canvas) override { |
217 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); | 217 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); |
218 | 218 |
219 const SkScalar w = SkIntToScalar(gWidth); | 219 const SkScalar w = SkIntToScalar(gWidth); |
220 const SkScalar h = SkIntToScalar(gHeight); | 220 const SkScalar h = SkIntToScalar(gHeight); |
221 SkRect r = { -w, -h, w*2, h*2 }; | 221 SkRect r = { -w, -h, w*2, h*2 }; |
222 | 222 |
223 static const SkShader::TileMode gModes[] = { | 223 static const SkShader::TileMode gModes[] = { |
224 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode | 224 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode |
225 }; | 225 }; |
226 static const char* gModeNames[] = { | 226 static const char* gModeNames[] = { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 private: | 269 private: |
270 typedef skiagm::GM INHERITED; | 270 typedef skiagm::GM INHERITED; |
271 }; | 271 }; |
272 | 272 |
273 ////////////////////////////////////////////////////////////////////////////// | 273 ////////////////////////////////////////////////////////////////////////////// |
274 | 274 |
275 DEF_GM( return new ScaledTilingGM(true); ) | 275 DEF_GM( return new ScaledTilingGM(true); ) |
276 DEF_GM( return new ScaledTilingGM(false); ) | 276 DEF_GM( return new ScaledTilingGM(false); ) |
277 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) | 277 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) |
278 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) | 278 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) |
OLD | NEW |