OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace skiagm { | 25 namespace skiagm { |
26 | 26 |
27 class ImageFiltersClippedGM : public GM { | 27 class ImageFiltersClippedGM : public GM { |
28 public: | 28 public: |
29 ImageFiltersClippedGM() : fInitialized(false) { | 29 ImageFiltersClippedGM() : fInitialized(false) { |
30 this->setBGColor(0x00000000); | 30 this->setBGColor(0x00000000); |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 34 uint32_t onGetFlags() const SK_OVERRIDE { |
35 return kSkipTiled_Flag; | 35 return kSkipTiled_Flag; |
36 } | 36 } |
37 | 37 |
38 virtual SkString onShortName() SK_OVERRIDE { | 38 SkString onShortName() SK_OVERRIDE { |
39 return SkString("imagefiltersclipped"); | 39 return SkString("imagefiltersclipped"); |
40 } | 40 } |
41 | 41 |
42 virtual SkISize onISize() SK_OVERRIDE { | 42 SkISize onISize() SK_OVERRIDE { |
43 return SkISize::Make(860, 500); | 43 return SkISize::Make(860, 500); |
44 } | 44 } |
45 | 45 |
46 void make_checkerboard() { | 46 void make_checkerboard() { |
47 fCheckerboard.allocN32Pixels(64, 64); | 47 fCheckerboard.allocN32Pixels(64, 64); |
48 SkCanvas canvas(fCheckerboard); | 48 SkCanvas canvas(fCheckerboard); |
49 canvas.clear(0x00000000); | 49 canvas.clear(0x00000000); |
50 SkPaint darkPaint; | 50 SkPaint darkPaint; |
51 darkPaint.setColor(0xFF404040); | 51 darkPaint.setColor(0xFF404040); |
52 SkPaint lightPaint; | 52 SkPaint lightPaint; |
(...skipping 23 matching lines...) Expand all Loading... |
76 colors[1] = SK_ColorBLACK; | 76 colors[1] = SK_ColorBLACK; |
77 SkAutoTUnref<SkShader> shader( | 77 SkAutoTUnref<SkShader> shader( |
78 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, | 78 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, |
79 SkShader::kClamp_TileMode) | 79 SkShader::kClamp_TileMode) |
80 ); | 80 ); |
81 SkPaint paint; | 81 SkPaint paint; |
82 paint.setShader(shader); | 82 paint.setShader(shader); |
83 canvas.drawCircle(x, y, radius, paint); | 83 canvas.drawCircle(x, y, radius, paint); |
84 } | 84 } |
85 | 85 |
86 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 86 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
87 if (!fInitialized) { | 87 if (!fInitialized) { |
88 this->make_checkerboard(); | 88 this->make_checkerboard(); |
89 this->make_gradient_circle(64, 64); | 89 this->make_gradient_circle(64, 64); |
90 fInitialized = true; | 90 fInitialized = true; |
91 } | 91 } |
92 canvas->clear(0x00000000); | 92 canvas->clear(0x00000000); |
93 | 93 |
94 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir
cle)); | 94 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir
cle)); |
95 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker
board)); | 95 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker
board)); |
96 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( | 96 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkBitmap fGradientCircle; | 156 SkBitmap fGradientCircle; |
157 typedef GM INHERITED; | 157 typedef GM INHERITED; |
158 }; | 158 }; |
159 | 159 |
160 ////////////////////////////////////////////////////////////////////////////// | 160 ////////////////////////////////////////////////////////////////////////////// |
161 | 161 |
162 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } | 162 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } |
163 static GMRegistry reg(MyFactory); | 163 static GMRegistry reg(MyFactory); |
164 | 164 |
165 } | 165 } |
OLD | NEW |