OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2013 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 #ifndef GrCircleEdgeEffect_DEFINED | |
9 #define GrCircleEdgeEffect_DEFINED | |
10 | |
11 #include "GrEffect.h" | |
12 | |
13 class GrGLCircleEdgeEffect; | |
14 | |
15 /** | |
16 * The output of this effect is a modulation of the input color and coverage for
a circle, | |
17 * specified as center_x, center_y, x_radius, inner radius and outer radius in w
indow space | |
18 * (y-down). | |
19 */ | |
20 | |
21 class GrCircleEdgeEffect : public GrEffect { | |
22 public: | |
23 static GrEffectRef* Create(bool stroke) { | |
24 // we go through this so we only have one copy of each effect (stroked/f
illed) | |
25 static SkAutoTUnref<GrEffectRef> gCircleStrokeEdgeEffectRef( | |
26 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrCircleEdgeE
ffect, (true))))); | |
27 static SkAutoTUnref<GrEffectRef> gCircleFillEdgeEffectRef( | |
28 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrCircleEdgeE
ffect, (false))))); | |
29 | |
30 if (stroke) { | |
31 gCircleStrokeEdgeEffectRef.get()->ref(); | |
32 return gCircleStrokeEdgeEffectRef; | |
33 } else { | |
34 gCircleFillEdgeEffectRef.get()->ref(); | |
35 return gCircleFillEdgeEffectRef; | |
36 } | |
37 } | |
38 | |
39 virtual ~GrCircleEdgeEffect() {} | |
40 | |
41 static const char* Name() { return "CircleEdge"; } | |
42 | |
43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
44 | |
45 typedef GrGLCircleEdgeEffect GLEffect; | |
46 | |
47 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | |
48 | |
49 inline bool isStroked() const { return fStroke; } | |
50 | |
51 private: | |
52 GrCircleEdgeEffect(bool stroke); | |
53 | |
54 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { | |
55 const GrCircleEdgeEffect& cee = CastEffect<GrCircleEdgeEffect>(other); | |
56 return cee.fStroke == fStroke; | |
57 } | |
58 | |
59 bool fStroke; | |
60 | |
61 GR_DECLARE_EFFECT_TEST; | |
62 | |
63 typedef GrEffect INHERITED; | |
64 }; | |
65 | |
66 #endif | |
OLD | NEW |