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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 SkString onShortName() SK_OVERRIDE { | 68 SkString onShortName() SK_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 #ifdef SK_CPU_ARM64 | 76 #ifdef SK_CPU_ARM64 |
77 // Skip tiled drawing on 64-bit ARM until https://skbug.com/2908 is fixed. | 77 // Skip tiled drawing on 64-bit ARM until https://skbug.com/2908 is fixed. |
78 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 78 uint32_t onGetFlags() const SK_OVERRIDE { |
79 return kSkipTiled_Flag; | 79 return kSkipTiled_Flag; |
80 } | 80 } |
81 #endif | 81 #endif |
82 | 82 |
83 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 760); } | 83 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 760); } |
84 | 84 |
85 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 85 void onOnceBeforeDraw() SK_OVERRIDE { |
86 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; | 86 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; |
87 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { | 87 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { |
88 makebm(&fTexture[i], gColorTypes[i], size, size); | 88 makebm(&fTexture[i], gColorTypes[i], size, size); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 92 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
93 float scale = 32.f/kPOTSize; | 93 float scale = 32.f/kPOTSize; |
94 | 94 |
95 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; | 95 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; |
96 | 96 |
97 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; | 97 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; |
98 | 98 |
99 static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; | 99 static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; |
100 | 100 |
101 static const SkPaint::FilterLevel gFilterLevels[] = | 101 static const SkPaint::FilterLevel gFilterLevels[] = |
102 { SkPaint::kNone_FilterLevel, | 102 { SkPaint::kNone_FilterLevel, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 class ScaledTiling2GM : public skiagm::GM { | 207 class ScaledTiling2GM : public skiagm::GM { |
208 ShaderProc fProc; | 208 ShaderProc fProc; |
209 SkString fName; | 209 SkString fName; |
210 public: | 210 public: |
211 ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { | 211 ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { |
212 fName.printf("scaled_tilemode_%s", name); | 212 fName.printf("scaled_tilemode_%s", name); |
213 } | 213 } |
214 | 214 |
215 protected: | 215 protected: |
216 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 216 uint32_t onGetFlags() const SK_OVERRIDE { |
217 return kSkipTiled_Flag; | 217 return kSkipTiled_Flag; |
218 } | 218 } |
219 | 219 |
220 SkString onShortName() SK_OVERRIDE { | 220 SkString onShortName() SK_OVERRIDE { |
221 return fName; | 221 return fName; |
222 } | 222 } |
223 | 223 |
224 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 560); } | 224 SkISize onISize() SK_OVERRIDE { return SkISize::Make(880, 560); } |
225 | 225 |
226 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 226 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
227 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); | 227 canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2); |
228 | 228 |
229 const SkScalar w = SkIntToScalar(gWidth); | 229 const SkScalar w = SkIntToScalar(gWidth); |
230 const SkScalar h = SkIntToScalar(gHeight); | 230 const SkScalar h = SkIntToScalar(gHeight); |
231 SkRect r = { -w, -h, w*2, h*2 }; | 231 SkRect r = { -w, -h, w*2, h*2 }; |
232 | 232 |
233 static const SkShader::TileMode gModes[] = { | 233 static const SkShader::TileMode gModes[] = { |
234 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode | 234 SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMi
rror_TileMode |
235 }; | 235 }; |
236 static const char* gModeNames[] = { | 236 static const char* gModeNames[] = { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 private: | 279 private: |
280 typedef skiagm::GM INHERITED; | 280 typedef skiagm::GM INHERITED; |
281 }; | 281 }; |
282 | 282 |
283 ////////////////////////////////////////////////////////////////////////////// | 283 ////////////////////////////////////////////////////////////////////////////// |
284 | 284 |
285 DEF_GM( return new ScaledTilingGM(true); ) | 285 DEF_GM( return new ScaledTilingGM(true); ) |
286 DEF_GM( return new ScaledTilingGM(false); ) | 286 DEF_GM( return new ScaledTilingGM(false); ) |
287 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) | 287 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) |
288 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) | 288 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) |
OLD | NEW |