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 "SkBlurMask.h" |
9 #include "SkBlurDrawLooper.h" | 10 #include "SkBlurDrawLooper.h" |
10 | 11 |
11 namespace skiagm { | 12 namespace skiagm { |
12 | 13 |
13 /////////////////////////////////////////////////////////////////////////////// | 14 /////////////////////////////////////////////////////////////////////////////// |
14 | 15 |
15 static void setup(SkPaint* paint, SkColor c, SkScalar strokeWidth) { | 16 static void setup(SkPaint* paint, SkColor c, SkScalar strokeWidth) { |
16 paint->setColor(c); | 17 paint->setColor(c); |
17 if (strokeWidth < 0) { | 18 if (strokeWidth < 0) { |
18 paint->setStyle(SkPaint::kFill_Style); | 19 paint->setStyle(SkPaint::kFill_Style); |
(...skipping 20 matching lines...) Expand all Loading... |
39 return SkString("shadows"); | 40 return SkString("shadows"); |
40 } | 41 } |
41 | 42 |
42 virtual SkISize onISize() { | 43 virtual SkISize onISize() { |
43 return make_isize(200, 120); | 44 return make_isize(200, 120); |
44 } | 45 } |
45 | 46 |
46 virtual void onDraw(SkCanvas* canvas) { | 47 virtual void onDraw(SkCanvas* canvas) { |
47 SkBlurDrawLooper* shadowLoopers[5]; | 48 SkBlurDrawLooper* shadowLoopers[5]; |
48 shadowLoopers[0] = | 49 shadowLoopers[0] = |
49 new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5), | 50 new SkBlurDrawLooper (SK_ColorBLUE, |
50 SkIntToScalar(10), 0xFF0000FF, | 51 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)
), |
| 52 SkIntToScalar(5), SkIntToScalar(10), |
51 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | | 53 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | |
52 SkBlurDrawLooper::kOverrideColor_BlurFlag | | 54 SkBlurDrawLooper::kOverrideColor_BlurFlag | |
53 SkBlurDrawLooper::kHighQuality_BlurFlag); | 55 SkBlurDrawLooper::kHighQuality_BlurFlag); |
54 SkAutoUnref aurL0(shadowLoopers[0]); | 56 SkAutoUnref aurL0(shadowLoopers[0]); |
55 shadowLoopers[1] = | 57 shadowLoopers[1] = |
56 new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5), | 58 new SkBlurDrawLooper (SK_ColorBLUE, |
57 SkIntToScalar(10), 0xFF0000FF, | 59 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)
), |
| 60 SkIntToScalar(5), SkIntToScalar(10), |
58 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | | 61 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | |
59 SkBlurDrawLooper::kOverrideColor_BlurFlag); | 62 SkBlurDrawLooper::kOverrideColor_BlurFlag); |
60 SkAutoUnref aurL1(shadowLoopers[1]); | 63 SkAutoUnref aurL1(shadowLoopers[1]); |
61 shadowLoopers[2] = | 64 shadowLoopers[2] = |
62 new SkBlurDrawLooper (SkIntToScalar(5), SkIntToScalar(5), | 65 new SkBlurDrawLooper (SK_ColorBLACK, |
63 SkIntToScalar(10), 0xFF000000, | 66 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5))
, |
| 67 SkIntToScalar(5), |
| 68 SkIntToScalar(10), |
64 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | | 69 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | |
65 SkBlurDrawLooper::kHighQuality_BlurFlag); | 70 SkBlurDrawLooper::kHighQuality_BlurFlag); |
66 SkAutoUnref aurL2(shadowLoopers[2]); | 71 SkAutoUnref aurL2(shadowLoopers[2]); |
67 shadowLoopers[3] = | 72 shadowLoopers[3] = |
68 new SkBlurDrawLooper (SkIntToScalar(5), SkIntToScalar(-5), | 73 new SkBlurDrawLooper (0x7FFF0000, |
69 SkIntToScalar(-10), 0x7FFF0000, | 74 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5))
, |
| 75 SkIntToScalar(-5), SkIntToScalar(-10), |
70 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | | 76 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | |
71 SkBlurDrawLooper::kOverrideColor_BlurFlag | | 77 SkBlurDrawLooper::kOverrideColor_BlurFlag | |
72 SkBlurDrawLooper::kHighQuality_BlurFlag); | 78 SkBlurDrawLooper::kHighQuality_BlurFlag); |
73 SkAutoUnref aurL3(shadowLoopers[3]); | 79 SkAutoUnref aurL3(shadowLoopers[3]); |
74 shadowLoopers[4] = | 80 shadowLoopers[4] = |
75 new SkBlurDrawLooper (SkIntToScalar(0), SkIntToScalar(5), | 81 new SkBlurDrawLooper (SK_ColorBLACK, SkIntToScalar(0), |
76 SkIntToScalar(5), 0xFF000000, | 82 SkIntToScalar(5), SkIntToScalar(5), |
77 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | | 83 SkBlurDrawLooper::kIgnoreTransform_BlurFlag | |
78 SkBlurDrawLooper::kOverrideColor_BlurFlag | | 84 SkBlurDrawLooper::kOverrideColor_BlurFlag | |
79 SkBlurDrawLooper::kHighQuality_BlurFlag); | 85 SkBlurDrawLooper::kHighQuality_BlurFlag); |
80 SkAutoUnref aurL4(shadowLoopers[4]); | 86 SkAutoUnref aurL4(shadowLoopers[4]); |
81 | 87 |
82 static const struct { | 88 static const struct { |
83 SkColor fColor; | 89 SkColor fColor; |
84 SkScalar fStrokeWidth; | 90 SkScalar fStrokeWidth; |
85 } gRec[] = { | 91 } gRec[] = { |
86 { SK_ColorRED, -SK_Scalar1 }, | 92 { SK_ColorRED, -SK_Scalar1 }, |
(...skipping 25 matching lines...) Expand all Loading... |
112 private: | 118 private: |
113 typedef GM INHERITED; | 119 typedef GM INHERITED; |
114 }; | 120 }; |
115 | 121 |
116 /////////////////////////////////////////////////////////////////////////////// | 122 /////////////////////////////////////////////////////////////////////////////// |
117 | 123 |
118 static GM* MyFactory(void*) { return new ShadowsGM; } | 124 static GM* MyFactory(void*) { return new ShadowsGM; } |
119 static GMRegistry reg(MyFactory); | 125 static GMRegistry reg(MyFactory); |
120 | 126 |
121 } | 127 } |
OLD | NEW |