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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
11 #include "SkDisplacementMapEffect.h" | 11 #include "SkDisplacementMapEffect.h" |
12 #include "SkDropShadowImageFilter.h" | 12 #include "SkDropShadowImageFilter.h" |
13 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
14 #include "SkImage.h" | 14 #include "SkImage.h" |
15 #include "SkImageSource.h" | 15 #include "SkImageSource.h" |
16 #include "SkLightingImageFilter.h" | 16 #include "SkLightingImageFilter.h" |
17 #include "SkMorphologyImageFilter.h" | 17 #include "SkMorphologyImageFilter.h" |
18 #include "SkOffsetImageFilter.h" | 18 #include "SkOffsetImageFilter.h" |
| 19 #include "SkPaintImageFilter.h" |
19 #include "SkPerlinNoiseShader.h" | 20 #include "SkPerlinNoiseShader.h" |
20 #include "SkPoint3.h" | 21 #include "SkPoint3.h" |
21 #include "SkRectShaderImageFilter.h" | |
22 #include "SkScalar.h" | 22 #include "SkScalar.h" |
23 #include "SkSurface.h" | 23 #include "SkSurface.h" |
24 #include "gm.h" | 24 #include "gm.h" |
25 | 25 |
26 #define RESIZE_FACTOR SkIntToScalar(4) | 26 #define RESIZE_FACTOR SkIntToScalar(4) |
27 | 27 |
28 namespace skiagm { | 28 namespace skiagm { |
29 | 29 |
30 class ImageFiltersScaledGM : public GM { | 30 class ImageFiltersScaledGM : public GM { |
31 public: | 31 public: |
(...skipping 17 matching lines...) Expand all Loading... |
49 fGradientCircle.reset(MakeGradientCircle(64, 64)); | 49 fGradientCircle.reset(MakeGradientCircle(64, 64)); |
50 } | 50 } |
51 | 51 |
52 void onDraw(SkCanvas* canvas) override { | 52 void onDraw(SkCanvas* canvas) override { |
53 canvas->clear(SK_ColorBLACK); | 53 canvas->clear(SK_ColorBLACK); |
54 | 54 |
55 SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCirc
le)); | 55 SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCirc
le)); |
56 SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerb
oard)); | 56 SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerb
oard)); |
57 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( | 57 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( |
58 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); | 58 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); |
| 59 SkPaint noisePaint; |
| 60 noisePaint.setShader(noise); |
59 | 61 |
60 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); | 62 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); |
61 SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10), | 63 SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10), |
62 SkIntToScalar(-10), | 64 SkIntToScalar(-10), |
63 SkIntToScalar(20)); | 65 SkIntToScalar(20)); |
64 SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40
), 0); | 66 SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40
), 0); |
65 SkScalar spotExponent = SK_Scalar1; | 67 SkScalar spotExponent = SK_Scalar1; |
66 SkScalar cutoffAngle = SkIntToScalar(15); | 68 SkScalar cutoffAngle = SkIntToScalar(15); |
67 SkScalar kd = SkIntToScalar(2); | 69 SkScalar kd = SkIntToScalar(2); |
68 SkScalar surfaceScale = SkIntToScalar(1); | 70 SkScalar surfaceScale = SkIntToScalar(1); |
69 SkColor white(0xFFFFFFFF); | 71 SkColor white(0xFFFFFFFF); |
70 SkMatrix resizeMatrix; | 72 SkMatrix resizeMatrix; |
71 resizeMatrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR); | 73 resizeMatrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR); |
72 | 74 |
73 SkImageFilter* filters[] = { | 75 SkImageFilter* filters[] = { |
74 SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)), | 76 SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)), |
75 SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10), | 77 SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10), |
76 SkIntToScalar(3), SkIntToScalar(3), SK_ColorYELLOW, | 78 SkIntToScalar(3), SkIntToScalar(3), SK_ColorYELLOW, |
77 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), | 79 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
78 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS
electorType, | 80 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS
electorType, |
79 SkDisplacementMapEffect::kR_ChannelS
electorType, | 81 SkDisplacementMapEffect::kR_ChannelS
electorType, |
80 SkIntToScalar(12), | 82 SkIntToScalar(12), |
81 gradient.get(), | 83 gradient.get(), |
82 checkerboard.get()), | 84 checkerboard.get()), |
83 SkDilateImageFilter::Create(1, 1, checkerboard.get()), | 85 SkDilateImageFilter::Create(1, 1, checkerboard.get()), |
84 SkErodeImageFilter::Create(1, 1, checkerboard.get()), | 86 SkErodeImageFilter::Create(1, 1, checkerboard.get()), |
85 SkOffsetImageFilter::Create(SkIntToScalar(32), 0), | 87 SkOffsetImageFilter::Create(SkIntToScalar(32), 0), |
86 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit
y), | 88 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit
y), |
87 SkRectShaderImageFilter::Create(noise), | 89 SkPaintImageFilter::Create(noisePaint), |
88 SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, s
urfaceScale, kd), | 90 SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, s
urfaceScale, kd), |
89 SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget
, spotExponent, | 91 SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget
, spotExponent, |
90 cutoffAngle, white, surf
aceScale, kd), | 92 cutoffAngle, white, surf
aceScale, kd), |
91 }; | 93 }; |
92 | 94 |
93 SkVector scales[] = { | 95 SkVector scales[] = { |
94 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)), | 96 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)), |
95 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)), | 97 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)), |
96 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)), | 98 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)), |
97 SkVector::Make(SkIntToScalar(2), SkIntToScalar(1)), | 99 SkVector::Make(SkIntToScalar(2), SkIntToScalar(1)), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 158 |
157 SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle; | 159 SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle; |
158 | 160 |
159 typedef GM INHERITED; | 161 typedef GM INHERITED; |
160 }; | 162 }; |
161 | 163 |
162 ////////////////////////////////////////////////////////////////////////////// | 164 ////////////////////////////////////////////////////////////////////////////// |
163 | 165 |
164 DEF_GM(return new ImageFiltersScaledGM;) | 166 DEF_GM(return new ImageFiltersScaledGM;) |
165 } | 167 } |
OLD | NEW |