OLD | NEW |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 * 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. |
31 * 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 |
32 * 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 |
33 * 2d vector. | 33 * 2d vector. |
34 * | 34 * |
35 * 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 |
36 * 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 |
37 * 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 |
38 * to the view matrix or untransformed positions in the fragment shader). | 38 * to the view matrix or untransformed positions in the fragment shader). |
39 */ | 39 */ |
40 static GrEffectRef* Create(GrEffectEdgeType edgeType, int n, const SkScalar
edges[]) { | 40 static GrEffect* Create(GrEffectEdgeType edgeType, int n, const SkScalar edg
es[]) { |
41 if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType)
{ | 41 if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType)
{ |
42 return NULL; | 42 return NULL; |
43 } | 43 } |
44 return SkNEW_ARGS(GrConvexPolyEffect, (edgeType, n, edges)); | 44 return SkNEW_ARGS(GrConvexPolyEffect, (edgeType, n, edges)); |
45 } | 45 } |
46 | 46 |
47 /** | 47 /** |
48 * Creates an effect that clips against the path. If the path is not a conve
x polygon, is | 48 * Creates an effect that clips against the path. If the path is not a conve
x polygon, is |
49 * inverse filled, or has too many edges, this will return NULL. If offset i
s non-NULL, then | 49 * inverse filled, or has too many edges, this will return NULL. If offset i
s non-NULL, then |
50 * the path is translated by the vector. | 50 * the path is translated by the vector. |
51 */ | 51 */ |
52 static GrEffectRef* Create(GrEffectEdgeType, const SkPath&, const SkVector*
offset = NULL); | 52 static GrEffect* Create(GrEffectEdgeType, const SkPath&, const SkVector* off
set = NULL); |
53 | 53 |
54 /** | 54 /** |
55 * Creates an effect that fills inside the rect with AA edges.. | 55 * Creates an effect that fills inside the rect with AA edges.. |
56 */ | 56 */ |
57 static GrEffectRef* Create(GrEffectEdgeType, const SkRect&); | 57 static GrEffect* Create(GrEffectEdgeType, const SkRect&); |
58 | 58 |
59 virtual ~GrConvexPolyEffect(); | 59 virtual ~GrConvexPolyEffect(); |
60 | 60 |
61 static const char* Name() { return "ConvexPoly"; } | 61 static const char* Name() { return "ConvexPoly"; } |
62 | 62 |
63 GrEffectEdgeType getEdgeType() const { return fEdgeType; } | 63 GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
64 | 64 |
65 int getEdgeCount() const { return fEdgeCount; } | 65 int getEdgeCount() const { return fEdgeCount; } |
66 | 66 |
67 const SkScalar* getEdges() const { return fEdges; } | 67 const SkScalar* getEdges() const { return fEdges; } |
(...skipping 13 matching lines...) Expand all Loading... |
81 int fEdgeCount; | 81 int fEdgeCount; |
82 SkScalar fEdges[3 * kMaxEdges]; | 82 SkScalar fEdges[3 * kMaxEdges]; |
83 | 83 |
84 GR_DECLARE_EFFECT_TEST; | 84 GR_DECLARE_EFFECT_TEST; |
85 | 85 |
86 typedef GrEffect INHERITED; | 86 typedef GrEffect INHERITED; |
87 }; | 87 }; |
88 | 88 |
89 | 89 |
90 #endif | 90 #endif |
OLD | NEW |