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, bool filter, | 45 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, |
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 ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi
lterLevel); | 49 paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi
lterLevel); |
50 } | 50 } |
51 | 51 |
52 static const SkColorType gColorTypes[] = { | 52 static const SkColorType gColorTypes[] = { |
53 kN32_SkColorType, | 53 kPMColor_SkColorType, |
54 kRGB_565_SkColorType, | 54 kRGB_565_SkColorType, |
55 }; | 55 }; |
56 | 56 |
57 class TilingGM : public skiagm::GM { | 57 class TilingGM : public skiagm::GM { |
58 public: | 58 public: |
59 TilingGM(bool powerOfTwoSize) | 59 TilingGM(bool powerOfTwoSize) |
60 : fPowerOfTwoSize(powerOfTwoSize) { | 60 : fPowerOfTwoSize(powerOfTwoSize) { |
61 } | 61 } |
62 | 62 |
63 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 63 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 private: | 159 private: |
160 bool fPowerOfTwoSize; | 160 bool fPowerOfTwoSize; |
161 typedef skiagm::GM INHERITED; | 161 typedef skiagm::GM INHERITED; |
162 }; | 162 }; |
163 | 163 |
164 static const int gWidth = 32; | 164 static const int gWidth = 32; |
165 static const int gHeight = 32; | 165 static const int gHeight = 32; |
166 | 166 |
167 static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { | 167 static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { |
168 SkBitmap bm; | 168 SkBitmap bm; |
169 makebm(&bm, kN32_SkColorType, gWidth, gHeight); | 169 makebm(&bm, kPMColor_SkColorType, gWidth, gHeight); |
170 return SkShader::CreateBitmapShader(bm, tx, ty); | 170 return SkShader::CreateBitmapShader(bm, tx, ty); |
171 } | 171 } |
172 | 172 |
173 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { | 173 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { |
174 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; | 174 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; |
175 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; | 175 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; |
176 SkScalar rad = SkIntToScalar(gWidth)/2; | 176 SkScalar rad = SkIntToScalar(gWidth)/2; |
177 SkColor colors[] = { 0xFFFF0000, 0xFF0044FF }; | 177 SkColor colors[] = { 0xFFFF0000, 0xFF0044FF }; |
178 | 178 |
179 int index = (int)ty; | 179 int index = (int)ty; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 private: | 261 private: |
262 typedef skiagm::GM INHERITED; | 262 typedef skiagm::GM INHERITED; |
263 }; | 263 }; |
264 | 264 |
265 ////////////////////////////////////////////////////////////////////////////// | 265 ////////////////////////////////////////////////////////////////////////////// |
266 | 266 |
267 DEF_GM( return new TilingGM(true); ) | 267 DEF_GM( return new TilingGM(true); ) |
268 DEF_GM( return new TilingGM(false); ) | 268 DEF_GM( return new TilingGM(false); ) |
269 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) | 269 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) |
270 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) | 270 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) |
OLD | NEW |