| 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
| 9 | 9 |
| 10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 /////////////////////////////////////////////////////////////////////////////// | 44 /////////////////////////////////////////////////////////////////////////////// |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * The output of this effect is a modulation of the input color and coverage for
a circle, | 47 * The output of this effect is a modulation of the input color and coverage for
a circle, |
| 48 * specified as offset_x, offset_y (both from center point), outer radius and in
ner radius. | 48 * specified as offset_x, offset_y (both from center point), outer radius and in
ner radius. |
| 49 */ | 49 */ |
| 50 | 50 |
| 51 class CircleEdgeEffect : public GrEffect { | 51 class CircleEdgeEffect : public GrEffect { |
| 52 public: | 52 public: |
| 53 static GrEffectRef* Create(bool stroke) { | 53 static GrEffectRef* Create(bool stroke) { |
| 54 // we go through this so we only have one copy of each effect (stroked/f
illed) | 54 GR_CREATE_STATIC_EFFECT(gCircleStrokeEdge, CircleEdgeEffect, (true)); |
| 55 static SkAutoTUnref<GrEffectRef> gCircleStrokeEdgeEffectRef( | 55 GR_CREATE_STATIC_EFFECT(gCircleFillEdge, CircleEdgeEffect, (false)); |
| 56 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(CircleEdgeEff
ect, (true))))); | |
| 57 static SkAutoTUnref<GrEffectRef> gCircleFillEdgeEffectRef( | |
| 58 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(CircleEdgeEff
ect, (false))))); | |
| 59 | 56 |
| 60 if (stroke) { | 57 if (stroke) { |
| 61 gCircleStrokeEdgeEffectRef.get()->ref(); | 58 gCircleStrokeEdge->ref(); |
| 62 return gCircleStrokeEdgeEffectRef; | 59 return gCircleStrokeEdge; |
| 63 } else { | 60 } else { |
| 64 gCircleFillEdgeEffectRef.get()->ref(); | 61 gCircleFillEdge->ref(); |
| 65 return gCircleFillEdgeEffectRef; | 62 return gCircleFillEdge; |
| 66 } | 63 } |
| 67 } | 64 } |
| 68 | 65 |
| 69 virtual void getConstantColorComponents(GrColor* color, | 66 virtual void getConstantColorComponents(GrColor* color, |
| 70 uint32_t* validFlags) const SK_OVERR
IDE { | 67 uint32_t* validFlags) const SK_OVERR
IDE { |
| 71 *validFlags = 0; | 68 *validFlags = 0; |
| 72 } | 69 } |
| 73 | 70 |
| 74 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 71 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
| 75 return GrTBackendEffectFactory<CircleEdgeEffect>::getInstance(); | 72 return GrTBackendEffectFactory<CircleEdgeEffect>::getInstance(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 /////////////////////////////////////////////////////////////////////////////// | 152 /////////////////////////////////////////////////////////////////////////////// |
| 156 | 153 |
| 157 /** | 154 /** |
| 158 * The output of this effect is a modulation of the input color and coverage for
an axis-aligned | 155 * The output of this effect is a modulation of the input color and coverage for
an axis-aligned |
| 159 * ellipse, specified as outer and inner radii, and outer and inner offsets fro
m center. | 156 * ellipse, specified as outer and inner radii, and outer and inner offsets fro
m center. |
| 160 */ | 157 */ |
| 161 | 158 |
| 162 class EllipseEdgeEffect : public GrEffect { | 159 class EllipseEdgeEffect : public GrEffect { |
| 163 public: | 160 public: |
| 164 static GrEffectRef* Create(bool stroke) { | 161 static GrEffectRef* Create(bool stroke) { |
| 165 // we go through this so we only have one copy of each effect (stroked/f
illed) | 162 GR_CREATE_STATIC_EFFECT(gEllipseStrokeEdge, EllipseEdgeEffect, (true)); |
| 166 static SkAutoTUnref<GrEffectRef> gEllipseStrokeEdgeEffectRef( | 163 GR_CREATE_STATIC_EFFECT(gEllipseFillEdge, EllipseEdgeEffect, (false)); |
| 167 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipseEdgeEf
fect, (true))))); | |
| 168 static SkAutoTUnref<GrEffectRef> gEllipseFillEdgeEffectRef( | |
| 169 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipseEdgeEf
fect, (false))))); | |
| 170 | 164 |
| 171 if (stroke) { | 165 if (stroke) { |
| 172 gEllipseStrokeEdgeEffectRef.get()->ref(); | 166 gEllipseStrokeEdge->ref(); |
| 173 return gEllipseStrokeEdgeEffectRef; | 167 return gEllipseStrokeEdge; |
| 174 } else { | 168 } else { |
| 175 gEllipseFillEdgeEffectRef.get()->ref(); | 169 gEllipseFillEdge->ref(); |
| 176 return gEllipseFillEdgeEffectRef; | 170 return gEllipseFillEdge; |
| 177 } | 171 } |
| 178 } | 172 } |
| 179 | 173 |
| 180 virtual void getConstantColorComponents(GrColor* color, | 174 virtual void getConstantColorComponents(GrColor* color, |
| 181 uint32_t* validFlags) const SK_OVERR
IDE { | 175 uint32_t* validFlags) const SK_OVERR
IDE { |
| 182 *validFlags = 0; | 176 *validFlags = 0; |
| 183 } | 177 } |
| 184 | 178 |
| 185 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 179 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
| 186 return GrTBackendEffectFactory<EllipseEdgeEffect>::getInstance(); | 180 return GrTBackendEffectFactory<EllipseEdgeEffect>::getInstance(); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); | 545 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); |
| 552 verts[3].fOuterXRadius = xRadius; | 546 verts[3].fOuterXRadius = xRadius; |
| 553 verts[3].fInnerXRadius = innerXRadius; | 547 verts[3].fInnerXRadius = innerXRadius; |
| 554 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius); | 548 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius); |
| 555 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius); | 549 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius); |
| 556 | 550 |
| 557 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); | 551 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); |
| 558 | 552 |
| 559 return true; | 553 return true; |
| 560 } | 554 } |
| OLD | NEW |