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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 virtual void onDraw(SkCanvas* canvas) { | 81 virtual void onDraw(SkCanvas* canvas) { |
82 if (!fInitialized) { | 82 if (!fInitialized) { |
83 this->make_checkerboard(); | 83 this->make_checkerboard(); |
84 this->make_gradient_circle(64, 64); | 84 this->make_gradient_circle(64, 64); |
85 fInitialized = true; | 85 fInitialized = true; |
86 } | 86 } |
87 canvas->clear(0x00000000); | 87 canvas->clear(0x00000000); |
88 | 88 |
89 SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle)
); | 89 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir
cle)); |
90 SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboar
d)); | 90 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker
board)); |
91 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( | 91 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( |
92 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); | 92 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); |
93 | 93 |
94 SkImageFilter* filters[] = { | 94 SkImageFilter* filters[] = { |
95 new SkBlurImageFilter(SkIntToScalar(4), SkIntToScalar(4)), | 95 SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)), |
96 new SkDropShadowImageFilter(SkIntToScalar(5), SkIntToScalar(10), SkI
ntToScalar(3), | 96 SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10),
SkIntToScalar(3), |
97 SK_ColorYELLOW), | 97 SK_ColorYELLOW), |
98 new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelec
torType, | 98 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS
electorType, |
99 SkDisplacementMapEffect::kR_ChannelSelec
torType, | 99 SkDisplacementMapEffect::kR_ChannelS
electorType, |
100 SkIntToScalar(12), | 100 SkIntToScalar(12), |
101 gradient.get(), | 101 gradient.get(), |
102 checkerboard.get()), | 102 checkerboard.get()), |
103 new SkDilateImageFilter(1, 1, checkerboard.get()), | 103 SkDilateImageFilter::Create(1, 1, checkerboard.get()), |
104 new SkErodeImageFilter(1, 1, checkerboard.get()), | 104 SkErodeImageFilter::Create(1, 1, checkerboard.get()), |
105 new SkOffsetImageFilter(SkIntToScalar(32), 0), | 105 SkOffsetImageFilter::Create(SkIntToScalar(32), 0), |
106 new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone
_FilterLevel), | 106 SkResizeImageFilter::Create(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::k
None_FilterLevel), |
107 SkRectShaderImageFilter::Create(noise), | 107 SkRectShaderImageFilter::Create(noise), |
108 }; | 108 }; |
109 | 109 |
110 SkVector scales[] = { | 110 SkVector scales[] = { |
111 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)), | 111 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)), |
112 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)), | 112 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)), |
113 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)), | 113 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)), |
114 SkVector::Make(SkIntToScalar(2), SkIntToScalar(1)), | 114 SkVector::Make(SkIntToScalar(2), SkIntToScalar(1)), |
115 SkVector::Make(SkIntToScalar(2), SkIntToScalar(2)), | 115 SkVector::Make(SkIntToScalar(2), SkIntToScalar(2)), |
116 }; | 116 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 SkBitmap fGradientCircle; | 155 SkBitmap fGradientCircle; |
156 typedef GM INHERITED; | 156 typedef GM INHERITED; |
157 }; | 157 }; |
158 | 158 |
159 ////////////////////////////////////////////////////////////////////////////// | 159 ////////////////////////////////////////////////////////////////////////////// |
160 | 160 |
161 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } | 161 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } |
162 static GMRegistry reg(MyFactory); | 162 static GMRegistry reg(MyFactory); |
163 | 163 |
164 } | 164 } |
OLD | NEW |