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" |
11 #include "SkShader.h" | 11 #include "SkShader.h" |
12 #include "SkUtils.h" | 12 #include "SkUtils.h" |
13 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
14 #include "SkColorFilter.h" | 14 #include "SkColorFilter.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 // effects | 17 // effects |
18 #include "SkGradientShader.h" | 18 #include "SkGradientShader.h" |
| 19 #include "SkUnitMappers.h" |
19 #include "SkBlurDrawLooper.h" | 20 #include "SkBlurDrawLooper.h" |
20 | 21 |
21 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { | 22 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { |
22 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); | 23 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); |
23 bm->eraseColor(SK_ColorTRANSPARENT); | 24 bm->eraseColor(SK_ColorTRANSPARENT); |
24 | 25 |
25 SkCanvas canvas(*bm); | 26 SkCanvas canvas(*bm); |
26 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} }; | 27 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} }; |
27 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; | 28 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; |
28 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; | 29 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; |
29 SkPaint paint; | 30 SkPaint paint; |
30 | 31 |
| 32 SkUnitMapper* um = NULL; |
| 33 |
| 34 um = new SkCosineMapper; |
| 35 // um = new SkDiscreteMapper(12); |
| 36 |
| 37 SkAutoUnref au(um); |
| 38 |
31 paint.setDither(true); | 39 paint.setDither(true); |
32 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, | 40 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, |
33 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); | 41 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref()
; |
34 canvas.drawPaint(paint); | 42 canvas.drawPaint(paint); |
35 } | 43 } |
36 | 44 |
37 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, | 45 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, |
38 SkShader::TileMode tmx, SkShader::TileMode tmy) { | 46 SkShader::TileMode tmx, SkShader::TileMode tmy) { |
39 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); | 47 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); |
40 paint->setShader(shader)->unref(); | 48 paint->setShader(shader)->unref(); |
41 paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi
lterLevel); | 49 paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi
lterLevel); |
42 } | 50 } |
43 | 51 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 private: | 265 private: |
258 typedef skiagm::GM INHERITED; | 266 typedef skiagm::GM INHERITED; |
259 }; | 267 }; |
260 | 268 |
261 ////////////////////////////////////////////////////////////////////////////// | 269 ////////////////////////////////////////////////////////////////////////////// |
262 | 270 |
263 DEF_GM( return new TilingGM(true); ) | 271 DEF_GM( return new TilingGM(true); ) |
264 DEF_GM( return new TilingGM(false); ) | 272 DEF_GM( return new TilingGM(false); ) |
265 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) | 273 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) |
266 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) | 274 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) |
OLD | NEW |