blob: 868d18cd99da49b4ef608bb40e4850160a506f9a [file] [log] [blame]
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +00001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "GrRRectEffect.h"
9
10#include "gl/GrGLEffect.h"
11#include "gl/GrGLSL.h"
12#include "GrTBackendEffectFactory.h"
13
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000014#include "SkRRect.h"
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +000015
commit-bot@chromium.orgfbde87f2014-03-04 16:25:34 +000016using namespace GrRRectEffect;
17
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000018class GLRRectEffect;
19
20class RRectEffect : public GrEffect {
21public:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +000022 // This effect only supports circular corner rrects where the radius is >= kRadiusMin.
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000023 static const SkScalar kRadiusMin;
skia.committer@gmail.comf1f66c02014-03-05 03:02:06 +000024
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000025 enum CornerFlags {
26 kTopLeft_CornerFlag = (1 << SkRRect::kUpperLeft_Corner),
27 kTopRight_CornerFlag = (1 << SkRRect::kUpperRight_Corner),
28 kBottomRight_CornerFlag = (1 << SkRRect::kLowerRight_Corner),
29 kBottomLeft_CornerFlag = (1 << SkRRect::kLowerLeft_Corner),
30
31 kLeft_CornerFlags = kTopLeft_CornerFlag | kBottomLeft_CornerFlag,
32 kTop_CornerFlags = kTopLeft_CornerFlag | kTopRight_CornerFlag,
33 kRight_CornerFlags = kTopRight_CornerFlag | kBottomRight_CornerFlag,
34 kBottom_CornerFlags = kBottomLeft_CornerFlag | kBottomRight_CornerFlag,
35
36 kAll_CornerFlags = kTopLeft_CornerFlag | kTopRight_CornerFlag |
37 kBottomLeft_CornerFlag | kBottomRight_CornerFlag,
38
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +000039 };
40
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000041 // The flags are used to indicate which corners are circluar (unflagged corners are assumed to
42 // be square).
43 static GrEffectRef* Create(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000044
45 virtual ~RRectEffect() {};
46 static const char* Name() { return "RRect"; }
47
48 const SkRRect& getRRect() const { return fRRect; }
49
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000050 uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; }
skia.committer@gmail.com06acb582014-03-06 03:02:32 +000051
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +000052 GrEffectEdgeType getEdgeType() const { return fEdgeType; }
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +000053
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000054 typedef GLRRectEffect GLEffect;
55
56 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
57
58 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
59
60private:
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000061 RRectEffect(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000062
63 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
64
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +000065 SkRRect fRRect;
66 GrEffectEdgeType fEdgeType;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000067 uint32_t fCircularCornerFlags;
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000068
69 GR_DECLARE_EFFECT_TEST;
70
71 typedef GrEffect INHERITED;
72};
73
74const SkScalar RRectEffect::kRadiusMin = 0.5f;
75
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +000076GrEffectRef* RRectEffect::Create(GrEffectEdgeType edgeType,
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000077 uint32_t circularCornerFlags,
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +000078 const SkRRect& rrect) {
commit-bot@chromium.orge5a041c2014-03-07 19:43:43 +000079 SkASSERT(kFillAA_GrEffectEdgeType == edgeType || kInverseFillAA_GrEffectEdgeType == edgeType);
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000080 return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(RRectEffect,
81 (edgeType, circularCornerFlags, rrect))));
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000082}
83
84void RRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
85 *validFlags = 0;
86}
87
88const GrBackendEffectFactory& RRectEffect::getFactory() const {
89 return GrTBackendEffectFactory<RRectEffect>::getInstance();
90}
91
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000092RRectEffect::RRectEffect(GrEffectEdgeType edgeType, uint32_t circularCornerFlags,
93 const SkRRect& rrect)
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +000094 : fRRect(rrect)
commit-bot@chromium.orgfbde87f2014-03-04 16:25:34 +000095 , fEdgeType(edgeType)
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +000096 , fCircularCornerFlags(circularCornerFlags) {
commit-bot@chromium.orge5280892014-02-21 17:52:29 +000097 this->setWillReadFragmentPosition();
98}
99
100bool RRectEffect::onIsEqual(const GrEffect& other) const {
101 const RRectEffect& rre = CastEffect<RRectEffect>(other);
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000102 // type is derived from fRRect, so no need to check it.
commit-bot@chromium.orgfbde87f2014-03-04 16:25:34 +0000103 return fEdgeType == rre.fEdgeType && fRRect == rre.fRRect;
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000104}
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000105
106//////////////////////////////////////////////////////////////////////////////
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000107
108GR_DEFINE_EFFECT_TEST(RRectEffect);
109
110GrEffectRef* RRectEffect::TestCreate(SkRandom* random,
111 GrContext*,
112 const GrDrawTargetCaps& caps,
113 GrTexture*[]) {
114 SkScalar w = random->nextRangeScalar(20.f, 1000.f);
115 SkScalar h = random->nextRangeScalar(20.f, 1000.f);
116 SkScalar r = random->nextRangeF(kRadiusMin, 9.f);
117 SkRRect rrect;
118 rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +0000119 GrEffectRef* effect;
120 do {
121 GrEffectEdgeType et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
122 effect = GrRRectEffect::Create(et, rrect);
123 } while (NULL == effect);
124 return effect;
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000125}
126
127//////////////////////////////////////////////////////////////////////////////
128
129class GLRRectEffect : public GrGLEffect {
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000130public:
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000131 GLRRectEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000132
133 virtual void emitCode(GrGLShaderBuilder* builder,
134 const GrDrawEffect& drawEffect,
135 EffectKey key,
136 const char* outputColor,
137 const char* inputColor,
138 const TransformedCoordsArray&,
139 const TextureSamplerArray&) SK_OVERRIDE;
140
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000141 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000142
143 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
144
145private:
146 GrGLUniformManager::UniformHandle fInnerRectUniform;
147 GrGLUniformManager::UniformHandle fRadiusPlusHalfUniform;
148 SkRRect fPrevRRect;
149 typedef GrGLEffect INHERITED;
150};
151
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000152GLRRectEffect::GLRRectEffect(const GrBackendEffectFactory& factory,
153 const GrDrawEffect& drawEffect)
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000154 : INHERITED (factory) {
155 fPrevRRect.setEmpty();
156}
157
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000158void GLRRectEffect::emitCode(GrGLShaderBuilder* builder,
159 const GrDrawEffect& drawEffect,
160 EffectKey key,
161 const char* outputColor,
162 const char* inputColor,
163 const TransformedCoordsArray&,
164 const TextureSamplerArray& samplers) {
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000165 const RRectEffect& rre = drawEffect.castEffect<RRectEffect>();
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000166 const char *rectName;
167 const char *radiusPlusHalfName;
168 // The inner rect is the rrect bounds inset by the radius. Its top, left, right, and bottom
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000169 // edges correspond to components x, y, z, and w, respectively. When one side of the rrect has
170 // rectangular corners, that side's value corresponds to the rect edge's value outset by half a
171 // pixel.
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000172 fInnerRectUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
173 kVec4f_GrSLType,
174 "innerRect",
175 &rectName);
176 fRadiusPlusHalfUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
177 kFloat_GrSLType,
178 "radiusPlusHalf",
179 &radiusPlusHalfName);
180 const char* fragmentPos = builder->fragmentPosition();
181 // At each quarter-circle corner we compute a vector that is the offset of the fragment position
182 // from the circle center. The vector is pinned in x and y to be in the quarter-plane relevant
183 // to that corner. This means that points near the interior near the rrect top edge will have
184 // a vector that points straight up for both the TL left and TR corners. Computing an
185 // alpha from this vector at either the TR or TL corner will give the correct result. Similarly,
186 // fragments near the other three edges will get the correct AA. Fragments in the interior of
187 // the rrect will have a (0,0) vector at all four corners. So long as the radius > 0.5 they will
188 // correctly produce an alpha value of 1 at all four corners. We take the min of all the alphas.
189 // The code below is a simplified version of the above that performs maxs on the vector
190 // components before computing distances and alpha values so that only one distance computation
191 // need be computed to determine the min alpha.
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000192 //
193 // For the cases where one half of the rrect is rectangular we drop one of the x or y
194 // computations, compute a separate rect edge alpha for the rect side, and mul the two computed
195 // alphas together.
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000196 switch (rre.getCircularCornerFlags()) {
197 case RRectEffect::kAll_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000198 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
199 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
200 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");
201 builder->fsCodeAppendf("\t\tfloat alpha = clamp(%s - length(dxy), 0.0, 1.0);\n",
202 radiusPlusHalfName);
203 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000204 case RRectEffect::kLeft_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000205 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
206 builder->fsCodeAppendf("\t\tfloat dy1 = %s.y - %s.w;\n", fragmentPos, rectName);
207 builder->fsCodeAppend("\t\tvec2 dxy = max(vec2(dxy0.x, max(dxy0.y, dy1)), 0.0);\n");
208 builder->fsCodeAppendf("\t\tfloat rightAlpha = clamp(%s.z - %s.x, 0.0, 1.0);\n",
209 rectName, fragmentPos);
210 builder->fsCodeAppendf("\t\tfloat alpha = rightAlpha * clamp(%s - length(dxy), 0.0, 1.0);\n",
211 radiusPlusHalfName);
212 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000213 case RRectEffect::kTop_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000214 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
215 builder->fsCodeAppendf("\t\tfloat dx1 = %s.x - %s.z;\n", fragmentPos, rectName);
216 builder->fsCodeAppend("\t\tvec2 dxy = max(vec2(max(dxy0.x, dx1), dxy0.y), 0.0);\n");
217 builder->fsCodeAppendf("\t\tfloat bottomAlpha = clamp(%s.w - %s.y, 0.0, 1.0);\n",
218 rectName, fragmentPos);
219 builder->fsCodeAppendf("\t\tfloat alpha = bottomAlpha * clamp(%s - length(dxy), 0.0, 1.0);\n",
220 radiusPlusHalfName);
221 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000222 case RRectEffect::kRight_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000223 builder->fsCodeAppendf("\t\tfloat dy0 = %s.y - %s.y;\n", rectName, fragmentPos);
224 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
225 builder->fsCodeAppend("\t\tvec2 dxy = max(vec2(dxy1.x, max(dy0, dxy1.y)), 0.0);\n");
226 builder->fsCodeAppendf("\t\tfloat leftAlpha = clamp(%s.x - %s.x, 0.0, 1.0);\n",
227 fragmentPos, rectName);
228 builder->fsCodeAppendf("\t\tfloat alpha = leftAlpha * clamp(%s - length(dxy), 0.0, 1.0);\n",
229 radiusPlusHalfName);
230 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000231 case RRectEffect::kBottom_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000232 builder->fsCodeAppendf("\t\tfloat dx0 = %s.x - %s.x;\n", rectName, fragmentPos);
233 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
234 builder->fsCodeAppend("\t\tvec2 dxy = max(vec2(max(dx0, dxy1.x), dxy1.y), 0.0);\n");
235 builder->fsCodeAppendf("\t\tfloat topAlpha = clamp(%s.y - %s.y, 0.0, 1.0);\n",
236 fragmentPos, rectName);
237 builder->fsCodeAppendf("\t\tfloat alpha = topAlpha * clamp(%s - length(dxy), 0.0, 1.0);\n",
238 radiusPlusHalfName);
239 break;
240 }
skia.committer@gmail.com06acb582014-03-06 03:02:32 +0000241
commit-bot@chromium.orge5a041c2014-03-07 19:43:43 +0000242 if (kInverseFillAA_GrEffectEdgeType == rre.getEdgeType()) {
commit-bot@chromium.orgfbde87f2014-03-04 16:25:34 +0000243 builder->fsCodeAppend("\t\talpha = 1.0 - alpha;\n");
244 }
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000245
246 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor,
247 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
248}
249
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000250GrGLEffect::EffectKey GLRRectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
251 const RRectEffect& rre = drawEffect.castEffect<RRectEffect>();
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +0000252 GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000253 return (rre.getCircularCornerFlags() << 3) | rre.getEdgeType();
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000254}
255
commit-bot@chromium.orge5280892014-02-21 17:52:29 +0000256void GLRRectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
257 const RRectEffect& rre = drawEffect.castEffect<RRectEffect>();
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000258 const SkRRect& rrect = rre.getRRect();
259 if (rrect != fPrevRRect) {
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000260 SkRect rect = rrect.getBounds();
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000261 SkScalar radius = 0;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000262 switch (rre.getCircularCornerFlags()) {
263 case RRectEffect::kAll_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000264 SkASSERT(rrect.isSimpleCircular());
265 radius = rrect.getSimpleRadii().fX;
266 SkASSERT(radius >= RRectEffect::kRadiusMin);
267 rect.inset(radius, radius);
268 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000269 case RRectEffect::kLeft_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000270 radius = rrect.radii(SkRRect::kUpperLeft_Corner).fX;
271 rect.fLeft += radius;
272 rect.fTop += radius;
273 rect.fRight += 0.5f;
274 rect.fBottom -= radius;
275 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000276 case RRectEffect::kTop_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000277 radius = rrect.radii(SkRRect::kUpperLeft_Corner).fX;
278 rect.fLeft += radius;
279 rect.fTop += radius;
280 rect.fRight -= radius;
281 rect.fBottom += 0.5f;
282 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000283 case RRectEffect::kRight_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000284 radius = rrect.radii(SkRRect::kUpperRight_Corner).fX;
285 rect.fLeft -= 0.5f;
286 rect.fTop += radius;
287 rect.fRight -= radius;
288 rect.fBottom -= radius;
289 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000290 case RRectEffect::kBottom_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000291 radius = rrect.radii(SkRRect::kLowerLeft_Corner).fX;
292 rect.fLeft += radius;
293 rect.fTop -= 0.5f;
294 rect.fRight -= radius;
295 rect.fBottom -= radius;
296 break;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000297 default:
298 GrCrash("Should have been one of the above cases.");
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000299 }
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000300 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
301 uman.set1f(fRadiusPlusHalfUniform, radius + 0.5f);
302 fPrevRRect = rrect;
303 }
304}
305
306//////////////////////////////////////////////////////////////////////////////
307
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +0000308GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
commit-bot@chromium.orge5a041c2014-03-07 19:43:43 +0000309 if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) {
commit-bot@chromium.orgcabf4b22014-03-05 18:27:43 +0000310 return NULL;
311 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000312 uint32_t cornerFlags;
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000313 if (rrect.isSimpleCircular()) {
314 if (rrect.getSimpleRadii().fX < RRectEffect::kRadiusMin) {
315 return NULL;
316 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000317 cornerFlags = RRectEffect::kAll_CornerFlags;
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000318 } else if (rrect.isComplex()) {
319 // Check for the "tab" cases - two adjacent circular corners and two square corners.
320 SkScalar radius = 0;
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000321 cornerFlags = 0;
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000322 for (int c = 0; c < 4; ++c) {
323 const SkVector& r = rrect.radii((SkRRect::Corner)c);
324 SkASSERT((0 == r.fX) == (0 == r.fY));
325 if (0 == r.fX) {
326 continue;
327 }
328 if (r.fX != r.fY) {
329 return NULL;
330 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000331 if (!cornerFlags) {
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000332 radius = r.fX;
333 if (radius < RRectEffect::kRadiusMin) {
334 return NULL;
335 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000336 cornerFlags = 1 << c;
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000337 } else {
338 if (r.fX != radius) {
339 return NULL;
340 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000341 cornerFlags |= 1 << c;
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000342 }
343 }
344
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000345 switch (cornerFlags) {
346 case RRectEffect::kLeft_CornerFlags:
347 case RRectEffect::kTop_CornerFlags:
348 case RRectEffect::kRight_CornerFlags:
349 case RRectEffect::kBottom_CornerFlags:
350 case RRectEffect::kAll_CornerFlags:
commit-bot@chromium.orgcb3672e2014-02-21 22:41:56 +0000351 break;
352 default:
353 return NULL;
354 }
355 } else {
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000356 return NULL;
357 }
commit-bot@chromium.orgdd584222014-03-10 16:08:22 +0000358 return RRectEffect::Create(edgeType, cornerFlags, rrect);
commit-bot@chromium.orgc2f78242014-02-19 15:18:05 +0000359}