Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: src/gpu/effects/GrConvexPolyEffect.h

Issue 183893023: Unify edge type enums across GrEffect subclasses that clip rendering to a geometry. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tot again Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 #ifndef GrConvexPolyEffect_DEFINED 8 #ifndef GrConvexPolyEffect_DEFINED
9 #define GrConvexPolyEffect_DEFINED 9 #define GrConvexPolyEffect_DEFINED
10 10
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrEffect.h" 12 #include "GrEffect.h"
13 #include "GrTypesPriv.h"
13 14
14 class GrGLConvexPolyEffect; 15 class GrGLConvexPolyEffect;
15 class SkPath; 16 class SkPath;
16 17
17 /** 18 /**
18 * An effect that renders a convex polygon. It is intended to be used as a cover age effect. 19 * An effect that renders a convex polygon. It is intended to be used as a cover age effect.
19 * Bounding geometry is rendered and the effect computes coverage based on the f ragment's 20 * Bounding geometry is rendered and the effect computes coverage based on the f ragment's
20 * position relative to the polygon. 21 * position relative to the polygon.
21 */ 22 */
22 class GrConvexPolyEffect : public GrEffect { 23 class GrConvexPolyEffect : public GrEffect {
23 public: 24 public:
24 enum EdgeType {
25 kFillNoAA_EdgeType,
26 kFillAA_EdgeType,
27 kInverseFillNoAA_EdgeType,
28 kInverseFillAA_EdgeType,
29
30 kLastEdgeType = kInverseFillAA_EdgeType,
31 };
32
33 enum { 25 enum {
34 kEdgeTypeCnt = kLastEdgeType + 1,
35 kMaxEdges = 8, 26 kMaxEdges = 8,
36 }; 27 };
37 28
38 /** 29 /**
39 * edges is a set of n edge equations where n is limited to kMaxEdges. It co ntains 3*n values. 30 * edges is a set of n edge equations where n is limited to kMaxEdges. It co ntains 3*n values.
40 * The edges should form a convex polygon. The positive half-plane is consid ered to be the 31 * The edges should form a convex polygon. The positive half-plane is consid ered to be the
41 * inside. The equations should be normalized such that the first two coeffi cients are a unit 32 * inside. The equations should be normalized such that the first two coeffi cients are a unit
42 * 2d vector. 33 * 2d vector.
43 * 34 *
44 * Currently the edges are specified in device space. In the future we may p refer to specify 35 * Currently the edges are specified in device space. In the future we may p refer to specify
45 * them in src space. There are a number of ways this could be accomplished but we'd probably 36 * them in src space. There are a number of ways this could be accomplished but we'd probably
46 * have to modify the effect/shaderbuilder interface to make it possible (e. g. give access 37 * have to modify the effect/shaderbuilder interface to make it possible (e. g. give access
47 * to the view matrix or untransformed positions in the fragment shader). 38 * to the view matrix or untransformed positions in the fragment shader).
48 */ 39 */
49 static GrEffectRef* Create(EdgeType edgeType, int n, const SkScalar edges[]) { 40 static GrEffectRef* Create(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) {
50 if (n <= 0 || n > kMaxEdges) { 41 if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType) {
51 return NULL; 42 return NULL;
52 } 43 }
53 return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrConvexPolyEffect, 44 return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrConvexPolyEffect,
54 (edgeType, n, edges))) ); 45 (edgeType, n, edges))) );
55 } 46 }
56 47
57 /** 48 /**
58 * Creates an effect that clips against the path. If the path is not a conve x polygon, is 49 * Creates an effect that clips against the path. If the path is not a conve x polygon, is
59 * inverse filled, or has too many edges, this will return NULL. If offset i s non-NULL, then 50 * inverse filled, or has too many edges, this will return NULL. If offset i s non-NULL, then
60 * the path is translated by the vector. 51 * the path is translated by the vector.
61 */ 52 */
62 static GrEffectRef* Create(EdgeType, const SkPath&, const SkVector* offset= NULL); 53 static GrEffectRef* Create(GrEffectEdgeType, const SkPath&, const SkVector* offset = NULL);
63 54
64 /** 55 /**
65 * Creates an effect that fills inside the rect with AA edges.. 56 * Creates an effect that fills inside the rect with AA edges..
66 */ 57 */
67 static GrEffectRef* Create(EdgeType, const SkRect&); 58 static GrEffectRef* Create(GrEffectEdgeType, const SkRect&);
68 59
69 virtual ~GrConvexPolyEffect(); 60 virtual ~GrConvexPolyEffect();
70 61
71 static const char* Name() { return "ConvexPoly"; } 62 static const char* Name() { return "ConvexPoly"; }
72 63
73 EdgeType getEdgeType() const { return fEdgeType; } 64 GrEffectEdgeType getEdgeType() const { return fEdgeType; }
74 65
75 int getEdgeCount() const { return fEdgeCount; } 66 int getEdgeCount() const { return fEdgeCount; }
76 67
77 const SkScalar* getEdges() const { return fEdges; } 68 const SkScalar* getEdges() const { return fEdges; }
78 69
79 typedef GrGLConvexPolyEffect GLEffect; 70 typedef GrGLConvexPolyEffect GLEffect;
80 71
81 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 72 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
82 73
83 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 74 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
84 75
85 private: 76 private:
86 GrConvexPolyEffect(EdgeType edgeType, int n, const SkScalar edges[]); 77 GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) ;
87 78
88 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; 79 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
89 80
90 EdgeType fEdgeType; 81 GrEffectEdgeType fEdgeType;
91 int fEdgeCount; 82 int fEdgeCount;
92 SkScalar fEdges[3 * kMaxEdges]; 83 SkScalar fEdges[3 * kMaxEdges];
93 84
94 GR_DECLARE_EFFECT_TEST; 85 GR_DECLARE_EFFECT_TEST;
95 86
96 typedef GrEffect INHERITED; 87 typedef GrEffect INHERITED;
97 }; 88 };
98 89
99 90
100 #endif 91 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698