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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 55 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; |
56 | 56 |
57 protected: | 57 protected: |
58 | 58 |
59 enum { | 59 enum { |
60 kPOTSize = 32, | 60 kPOTSize = 32, |
61 kNPOTSize = 21, | 61 kNPOTSize = 21, |
62 }; | 62 }; |
63 | 63 |
64 SkString onShortName() { | 64 SkString onShortName() SK_OVERRIDE { |
65 SkString name("tilemodes"); | 65 SkString name("tilemodes"); |
66 if (!fPowerOfTwoSize) { | 66 if (!fPowerOfTwoSize) { |
67 name.append("_npot"); | 67 name.append("_npot"); |
68 } | 68 } |
69 return name; | 69 return name; |
70 } | 70 } |
71 | 71 |
72 SkISize onISize() { return SkISize::Make(880, 560); } | 72 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 560); } |
73 | 73 |
74 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 74 virtual void onOnceBeforeDraw() SK_OVERRIDE { |
75 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; | 75 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; |
76 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { | 76 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { |
77 makebm(&fTexture[i], gColorTypes[i], size, size); | 77 makebm(&fTexture[i], gColorTypes[i], size, size); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 81 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
82 | 82 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 public: | 191 public: |
192 Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { | 192 Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { |
193 fName.printf("tilemode_%s", name); | 193 fName.printf("tilemode_%s", name); |
194 } | 194 } |
195 | 195 |
196 protected: | 196 protected: |
197 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 197 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
198 return kSkipTiled_Flag; | 198 return kSkipTiled_Flag; |
199 } | 199 } |
200 | 200 |
201 SkString onShortName() { | 201 SkString onShortName() SK_OVERRIDE { |
202 return fName; | 202 return fName; |
203 } | 203 } |
204 | 204 |
205 SkISize onISize() { return SkISize::Make(880, 560); } | 205 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 560); } |
206 | 206 |
207 virtual void onDraw(SkCanvas* canvas) { | 207 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
208 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); | 208 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); |
209 | 209 |
210 const SkScalar w = SkIntToScalar(gWidth); | 210 const SkScalar w = SkIntToScalar(gWidth); |
211 const SkScalar h = SkIntToScalar(gHeight); | 211 const SkScalar h = SkIntToScalar(gHeight); |
212 SkRect r = { -w, -h, w*2, h*2 }; | 212 SkRect r = { -w, -h, w*2, h*2 }; |
213 | 213 |
214 static const SkShader::TileMode gModes[] = { | 214 static const SkShader::TileMode gModes[] = { |
215 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode | 215 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode |
216 }; | 216 }; |
217 static const char* gModeNames[] = { | 217 static const char* gModeNames[] = { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 private: | 260 private: |
261 typedef skiagm::GM INHERITED; | 261 typedef skiagm::GM INHERITED; |
262 }; | 262 }; |
263 | 263 |
264 ////////////////////////////////////////////////////////////////////////////// | 264 ////////////////////////////////////////////////////////////////////////////// |
265 | 265 |
266 DEF_GM( return new TilingGM(true); ) | 266 DEF_GM( return new TilingGM(true); ) |
267 DEF_GM( return new TilingGM(false); ) | 267 DEF_GM( return new TilingGM(false); ) |
268 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) | 268 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) |
269 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) | 269 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) |
OLD | NEW |