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

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

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

Powered by Google App Engine
This is Rietveld 408576698