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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 SkRRect fRRect; | 85 SkRRect fRRect; |
86 int fWidth, fHeight; | 86 int fWidth, fHeight; |
87 | 87 |
88 typedef skiagm::GM INHERITED; | 88 typedef skiagm::GM INHERITED; |
89 }; | 89 }; |
90 | 90 |
91 #include "SkGradientShader.h" | 91 #include "SkGradientShader.h" |
92 /* | 92 /* |
93 * Spits out a dummy gradient to test blur with shader on paint | 93 * Spits out a dummy gradient to test blur with shader on paint |
94 */ | 94 */ |
95 static SkShader* MakeRadial() { | 95 static sk_sp<SkShader> MakeRadial() { |
96 SkPoint pts[2] = { | 96 SkPoint pts[2] = { |
97 { 0, 0 }, | 97 { 0, 0 }, |
98 { SkIntToScalar(100), SkIntToScalar(100) } | 98 { SkIntToScalar(100), SkIntToScalar(100) } |
99 }; | 99 }; |
100 SkShader::TileMode tm = SkShader::kClamp_TileMode; | 100 SkShader::TileMode tm = SkShader::kClamp_TileMode; |
101 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, }; | 101 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, }; |
102 const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; | 102 const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; |
103 SkMatrix scale; | 103 SkMatrix scale; |
104 scale.setScale(0.5f, 0.5f); | 104 scale.setScale(0.5f, 0.5f); |
105 scale.postTranslate(5.f, 5.f); | 105 scale.postTranslate(5.f, 5.f); |
106 SkPoint center0, center1; | 106 SkPoint center0, center1; |
107 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), | 107 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
108 SkScalarAve(pts[0].fY, pts[1].fY)); | 108 SkScalarAve(pts[0].fY, pts[1].fY)); |
109 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), | 109 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), |
110 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); | 110 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
111 return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].
fX) / 7, | 111 return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX
) / 7, |
112 center0, (pts[1].fX - pts[0].
fX) / 2, | 112 center0, (pts[1].fX - pts[0].fX
) / 2, |
113 colors, pos, SK_ARRAY_COUNT(c
olors), tm, | 113 colors, pos, SK_ARRAY_COUNT(col
ors), tm, |
114 0, &scale); | 114 0, &scale); |
115 } | 115 } |
116 | 116 |
117 // Simpler blurred RR test cases where all the radii are the same. | 117 // Simpler blurred RR test cases where all the radii are the same. |
118 class SimpleBlurRoundRectGM : public skiagm::GM { | 118 class SimpleBlurRoundRectGM : public skiagm::GM { |
119 public: | 119 public: |
120 SimpleBlurRoundRectGM() | 120 SimpleBlurRoundRectGM() |
121 : fName("simpleblurroundrect") { | 121 : fName("simpleblurroundrect") { |
122 } | 122 } |
123 | 123 |
124 protected: | 124 protected: |
(...skipping 21 matching lines...) Expand all Loading... |
146 SkMaskFilter* filter = SkBlurMaskFilter::Create( | 146 SkMaskFilter* filter = SkBlurMaskFilter::Create( |
147 kNormal_SkBlurStyle, | 147 kNormal_SkBlurStyle, |
148 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii
[i])), | 148 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii
[i])), |
149 SkBlurMaskFilter::kHighQuality_BlurFlag); | 149 SkBlurMaskFilter::kHighQuality_BlurFlag); |
150 SkPaint paint; | 150 SkPaint paint; |
151 paint.setColor(SK_ColorBLACK); | 151 paint.setColor(SK_ColorBLACK); |
152 paint.setMaskFilter(filter)->unref(); | 152 paint.setMaskFilter(filter)->unref(); |
153 | 153 |
154 bool useRadial = SkToBool(k); | 154 bool useRadial = SkToBool(k); |
155 if (useRadial) { | 155 if (useRadial) { |
156 paint.setShader(MakeRadial())->unref(); | 156 paint.setShader(MakeRadial()); |
157 } | 157 } |
158 | 158 |
159 SkRRect rrect; | 159 SkRRect rrect; |
160 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), | 160 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), |
161 SkIntToScalar(cornerRadii[j])); | 161 SkIntToScalar(cornerRadii[j])); |
162 canvas->drawRRect(rrect, paint); | 162 canvas->drawRRect(rrect, paint); |
163 canvas->translate(r.width() + SkIntToScalar(50), 0); | 163 canvas->translate(r.width() + SkIntToScalar(50), 0); |
164 } | 164 } |
165 } | 165 } |
166 } | 166 } |
167 } | 167 } |
168 private: | 168 private: |
169 const SkString fName; | 169 const SkString fName; |
170 | 170 |
171 typedef skiagm::GM INHERITED; | 171 typedef skiagm::GM INHERITED; |
172 }; | 172 }; |
173 | 173 |
174 // Create one with dimensions/rounded corners based on the skp | 174 // Create one with dimensions/rounded corners based on the skp |
175 // | 175 // |
176 // TODO(scroggo): Disabled in an attempt to rememdy | 176 // TODO(scroggo): Disabled in an attempt to rememdy |
177 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: | 177 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: |
178 // ran wrong number of tests') | 178 // ran wrong number of tests') |
179 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) | 179 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) |
180 | 180 |
181 // Rounded rect with two opposite corners with large radii, the other two | 181 // Rounded rect with two opposite corners with large radii, the other two |
182 // small. | 182 // small. |
183 DEF_GM(return new BlurRoundRectGM(100, 100);) | 183 DEF_GM(return new BlurRoundRectGM(100, 100);) |
184 | 184 |
185 DEF_GM(return new SimpleBlurRoundRectGM();) | 185 DEF_GM(return new SimpleBlurRoundRectGM();) |
OLD | NEW |