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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte
r_level, | 45 static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte
r_level, |
46 SkShader::TileMode tmx, SkShader::TileMode tmy) { | 46 SkShader::TileMode tmx, SkShader::TileMode tmy) { |
47 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); | 47 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); |
48 paint->setShader(shader)->unref(); | 48 paint->setShader(shader)->unref(); |
49 paint->setFilterLevel(filter_level); | 49 paint->setFilterLevel(filter_level); |
50 } | 50 } |
51 | 51 |
52 static const SkColorType gColorTypes[] = { | 52 static const SkColorType gColorTypes[] = { |
53 kPMColor_SkColorType, | 53 kN32_SkColorType, |
54 kRGB_565_SkColorType, | 54 kRGB_565_SkColorType, |
55 }; | 55 }; |
56 | 56 |
57 class ScaledTilingGM : public skiagm::GM { | 57 class ScaledTilingGM : public skiagm::GM { |
58 SkBlurDrawLooper fLooper; | 58 SkBlurDrawLooper fLooper; |
59 public: | 59 public: |
60 ScaledTilingGM(bool powerOfTwoSize) | 60 ScaledTilingGM(bool powerOfTwoSize) |
61 : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88
000000) | 61 : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88
000000) |
62 , fPowerOfTwoSize(powerOfTwoSize) { | 62 , fPowerOfTwoSize(powerOfTwoSize) { |
63 } | 63 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 private: | 170 private: |
171 bool fPowerOfTwoSize; | 171 bool fPowerOfTwoSize; |
172 typedef skiagm::GM INHERITED; | 172 typedef skiagm::GM INHERITED; |
173 }; | 173 }; |
174 | 174 |
175 static const int gWidth = 32; | 175 static const int gWidth = 32; |
176 static const int gHeight = 32; | 176 static const int gHeight = 32; |
177 | 177 |
178 static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { | 178 static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { |
179 SkBitmap bm; | 179 SkBitmap bm; |
180 makebm(&bm, kPMColor_SkColorType, gWidth, gHeight); | 180 makebm(&bm, kN32_SkColorType, gWidth, gHeight); |
181 return SkShader::CreateBitmapShader(bm, tx, ty); | 181 return SkShader::CreateBitmapShader(bm, tx, ty); |
182 } | 182 } |
183 | 183 |
184 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { | 184 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { |
185 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; | 185 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; |
186 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; | 186 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; |
187 SkScalar rad = SkIntToScalar(gWidth)/2; | 187 SkScalar rad = SkIntToScalar(gWidth)/2; |
188 SkColor colors[] = { 0xFFFF0000, 0xFF0044FF }; | 188 SkColor colors[] = { 0xFFFF0000, 0xFF0044FF }; |
189 | 189 |
190 int index = (int)ty; | 190 int index = (int)ty; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 private: | 272 private: |
273 typedef skiagm::GM INHERITED; | 273 typedef skiagm::GM INHERITED; |
274 }; | 274 }; |
275 | 275 |
276 ////////////////////////////////////////////////////////////////////////////// | 276 ////////////////////////////////////////////////////////////////////////////// |
277 | 277 |
278 DEF_GM( return new ScaledTilingGM(true); ) | 278 DEF_GM( return new ScaledTilingGM(true); ) |
279 DEF_GM( return new ScaledTilingGM(false); ) | 279 DEF_GM( return new ScaledTilingGM(false); ) |
280 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) | 280 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) |
281 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) | 281 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) |
OLD | NEW |