OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 void onDraw(SkCanvas* canvas) override { | 48 void onDraw(SkCanvas* canvas) override { |
49 SkLayerDrawLooper::Builder looperBuilder; | 49 SkLayerDrawLooper::Builder looperBuilder; |
50 { | 50 { |
51 SkLayerDrawLooper::LayerInfo info; | 51 SkLayerDrawLooper::LayerInfo info; |
52 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit | 52 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit |
53 | SkLayerDrawLooper::kColorFilter_Bit; | 53 | SkLayerDrawLooper::kColorFilter_Bit; |
54 info.fColorMode = SkXfermode::kSrc_Mode; | 54 info.fColorMode = SkXfermode::kSrc_Mode; |
55 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); | 55 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); |
56 info.fPostTranslate = false; | 56 info.fPostTranslate = false; |
57 SkPaint* paint = looperBuilder.addLayerOnTop(info); | 57 SkPaint* paint = looperBuilder.addLayerOnTop(info); |
58 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( | 58 paint->setMaskFilter(SkBlurMaskFilter::Make( |
59 kNormal_SkBlurStyle, | 59 kNormal_SkBlurStyle, |
60 SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), | 60 SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), |
61 SkBlurMaskFilter::kHighQuality_BlurFlag); | 61 SkBlurMaskFilter::kHighQuality_BlurFlag)); |
62 paint->setMaskFilter(maskFilter)->unref(); | |
63 paint->setColorFilter(SkColorFilter::MakeModeFilter( | 62 paint->setColorFilter(SkColorFilter::MakeModeFilter( |
64 sk_tool_utils::color_to_565(SK_ColorLTGRAY), | 63 sk_tool_utils::color_to_565(SK_ColorLTGRAY), |
65 SkXfermode::kSrcIn_Mode)); | 64 SkXfermode::kSrcIn_Mode)); |
66 paint->setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); | 65 paint->setColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); |
67 } | 66 } |
68 { | 67 { |
69 SkLayerDrawLooper::LayerInfo info; | 68 SkLayerDrawLooper::LayerInfo info; |
70 looperBuilder.addLayerOnTop(info); | 69 looperBuilder.addLayerOnTop(info); |
71 } | 70 } |
72 SkPaint paint; | 71 SkPaint paint; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 canvas->translate(50,50); | 134 canvas->translate(50,50); |
136 | 135 |
137 const float blurRadii[] = { 1,5,10,20 }; | 136 const float blurRadii[] = { 1,5,10,20 }; |
138 const int cornerRadii[] = { 1,5,10,20 }; | 137 const int cornerRadii[] = { 1,5,10,20 }; |
139 const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25)); | 138 const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25)); |
140 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { | 139 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { |
141 SkAutoCanvasRestore autoRestore(canvas, true); | 140 SkAutoCanvasRestore autoRestore(canvas, true); |
142 canvas->translate(0, (r.height() + SkIntToScalar(50)) * i); | 141 canvas->translate(0, (r.height() + SkIntToScalar(50)) * i); |
143 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { | 142 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { |
144 for (int k = 0; k <= 1; k++) { | 143 for (int k = 0; k <= 1; k++) { |
145 SkMaskFilter* filter = SkBlurMaskFilter::Create( | |
146 kNormal_SkBlurStyle, | |
147 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii
[i])), | |
148 SkBlurMaskFilter::kHighQuality_BlurFlag); | |
149 SkPaint paint; | 144 SkPaint paint; |
150 paint.setColor(SK_ColorBLACK); | 145 paint.setColor(SK_ColorBLACK); |
151 paint.setMaskFilter(filter)->unref(); | 146 paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurSty
le, |
| 147 SkBlurMask::ConvertRadiusToSigma(SkIntToScala
r(blurRadii[i])), |
| 148 SkBlurMaskFilter::kHighQuality_BlurFlag)); |
152 | 149 |
153 bool useRadial = SkToBool(k); | 150 bool useRadial = SkToBool(k); |
154 if (useRadial) { | 151 if (useRadial) { |
155 paint.setShader(MakeRadial()); | 152 paint.setShader(MakeRadial()); |
156 } | 153 } |
157 | 154 |
158 SkRRect rrect; | 155 SkRRect rrect; |
159 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), | 156 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), |
160 SkIntToScalar(cornerRadii[j])); | 157 SkIntToScalar(cornerRadii[j])); |
161 canvas->drawRRect(rrect, paint); | 158 canvas->drawRRect(rrect, paint); |
(...skipping 13 matching lines...) Expand all Loading... |
175 // TODO(scroggo): Disabled in an attempt to rememdy | 172 // TODO(scroggo): Disabled in an attempt to rememdy |
176 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: | 173 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: |
177 // ran wrong number of tests') | 174 // ran wrong number of tests') |
178 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) | 175 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) |
179 | 176 |
180 // Rounded rect with two opposite corners with large radii, the other two | 177 // Rounded rect with two opposite corners with large radii, the other two |
181 // small. | 178 // small. |
182 DEF_GM(return new BlurRoundRectGM(100, 100);) | 179 DEF_GM(return new BlurRoundRectGM(100, 100);) |
183 | 180 |
184 DEF_GM(return new SimpleBlurRoundRectGM();) | 181 DEF_GM(return new SimpleBlurRoundRectGM();) |
OLD | NEW |