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" |
11 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
12 #include "SkDisplacementMapEffect.h" | 12 #include "SkDisplacementMapEffect.h" |
13 #include "SkDropShadowImageFilter.h" | 13 #include "SkDropShadowImageFilter.h" |
14 #include "SkGradientShader.h" | 14 #include "SkGradientShader.h" |
15 #include "SkMorphologyImageFilter.h" | 15 #include "SkMorphologyImageFilter.h" |
16 #include "SkOffsetImageFilter.h" | 16 #include "SkOffsetImageFilter.h" |
| 17 #include "SkPerlinNoiseShader.h" |
| 18 #include "SkRectShaderImageFilter.h" |
17 #include "SkResizeImageFilter.h" | 19 #include "SkResizeImageFilter.h" |
18 #include "SkScalar.h" | 20 #include "SkScalar.h" |
19 | 21 |
20 #define RESIZE_FACTOR_X SkIntToScalar(2) | 22 #define RESIZE_FACTOR_X SkIntToScalar(2) |
21 #define RESIZE_FACTOR_Y SkIntToScalar(5) | 23 #define RESIZE_FACTOR_Y SkIntToScalar(5) |
22 | 24 |
23 namespace skiagm { | 25 namespace skiagm { |
24 | 26 |
25 class ImageFiltersClippedGM : public GM { | 27 class ImageFiltersClippedGM : public GM { |
26 public: | 28 public: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 virtual void onDraw(SkCanvas* canvas) { | 82 virtual void onDraw(SkCanvas* canvas) { |
81 if (!fInitialized) { | 83 if (!fInitialized) { |
82 this->make_checkerboard(); | 84 this->make_checkerboard(); |
83 this->make_gradient_circle(64, 64); | 85 this->make_gradient_circle(64, 64); |
84 fInitialized = true; | 86 fInitialized = true; |
85 } | 87 } |
86 canvas->clear(0x00000000); | 88 canvas->clear(0x00000000); |
87 | 89 |
88 SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle)
); | 90 SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle)
); |
89 SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboar
d)); | 91 SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboar
d)); |
| 92 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( |
| 93 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); |
90 | 94 |
91 SkImageFilter* filters[] = { | 95 SkImageFilter* filters[] = { |
92 new SkBlurImageFilter(SkIntToScalar(12), SkIntToScalar(12)), | 96 new SkBlurImageFilter(SkIntToScalar(12), SkIntToScalar(12)), |
93 new SkDropShadowImageFilter(SkIntToScalar(10), SkIntToScalar(10), Sk
IntToScalar(3), | 97 new SkDropShadowImageFilter(SkIntToScalar(10), SkIntToScalar(10), Sk
IntToScalar(3), |
94 SK_ColorGREEN), | 98 SK_ColorGREEN), |
95 new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelec
torType, | 99 new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelec
torType, |
96 SkDisplacementMapEffect::kR_ChannelSelec
torType, | 100 SkDisplacementMapEffect::kR_ChannelSelec
torType, |
97 SkIntToScalar(12), | 101 SkIntToScalar(12), |
98 gradient.get(), | 102 gradient.get(), |
99 checkerboard.get()), | 103 checkerboard.get()), |
100 new SkDilateImageFilter(2, 2, checkerboard.get()), | 104 new SkDilateImageFilter(2, 2, checkerboard.get()), |
101 new SkErodeImageFilter(2, 2, checkerboard.get()), | 105 new SkErodeImageFilter(2, 2, checkerboard.get()), |
102 new SkOffsetImageFilter(SkIntToScalar(-16), SkIntToScalar(32)), | 106 new SkOffsetImageFilter(SkIntToScalar(-16), SkIntToScalar(32)), |
103 new SkResizeImageFilter(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::k
None_FilterLevel), | 107 new SkResizeImageFilter(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::k
None_FilterLevel), |
| 108 SkRectShaderImageFilter::Create(noise), |
104 }; | 109 }; |
105 | 110 |
106 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 111 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
107 SkScalar margin = SkIntToScalar(16); | 112 SkScalar margin = SkIntToScalar(16); |
108 SkRect bounds = r; | 113 SkRect bounds = r; |
109 bounds.outset(margin, margin); | 114 bounds.outset(margin, margin); |
110 | 115 |
111 for (int xOffset = 0; xOffset < 80; xOffset += 16) { | 116 for (int xOffset = 0; xOffset < 80; xOffset += 16) { |
112 canvas->save(); | 117 canvas->save(); |
113 bounds.fLeft = SkIntToScalar(xOffset); | 118 bounds.fLeft = SkIntToScalar(xOffset); |
(...skipping 30 matching lines...) Expand all Loading... |
144 SkBitmap fGradientCircle; | 149 SkBitmap fGradientCircle; |
145 typedef GM INHERITED; | 150 typedef GM INHERITED; |
146 }; | 151 }; |
147 | 152 |
148 ////////////////////////////////////////////////////////////////////////////// | 153 ////////////////////////////////////////////////////////////////////////////// |
149 | 154 |
150 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } | 155 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } |
151 static GMRegistry reg(MyFactory); | 156 static GMRegistry reg(MyFactory); |
152 | 157 |
153 } | 158 } |
OLD | NEW |