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

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

Issue 12676027: Replace edge types with GrEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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/GrDrawState.cpp ('k') | src/gpu/effects/GrEdgeEffect.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 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 GrEdgeEffect_DEFINED
9 #define GrEdgeEffect_DEFINED
10
11 #include "GrEffect.h"
12
13 class GrGLEdgeEffect;
14
15 /**
16 * The output of this effect is one of three different edge types: hairlines, qu ads,
17 * and hairline quads.
18 *
19 * TODO: Fix the fact that HairLine edge types use y-down coords.
bsalomon 2013/03/25 13:35:54 I think this copied comment is out-of-date. We're
20 * (either adjust in VS or use origin_upper_left in GLSL)
21 */
22
23 class GrEdgeEffect : public GrEffect {
24 public:
25 enum EdgeType {
26 /* 1-pixel wide line
27 2D implicit line eq (a*x + b*y +c = 0). 4th component unused. */
28 kHairLine_EdgeType = 0,
29 /* Quadratic specified by u^2-v canonical coords (only 2
30 components used). Coverage based on signed distance with negative
31 being inside, positive outside. Edge specified in window space
32 (y-down) */
33 kQuad_EdgeType,
34 /* Same as above but for hairline quadratics. Uses unsigned distance.
35 Coverage is min(0, 1-distance). 3rd & 4th component unused. */
36 kHairQuad_EdgeType,
37
38 kLast_EdgeType = kHairQuad_EdgeType
39 };
40 static const int kEdgeTypeCount = kLast_EdgeType + 1;
41
42 static GrEffectRef* Create(EdgeType type) {
43 // we go through this so we only have one copy of each effect (stroked/f illed)
44 static SkAutoTUnref<GrEffectRef> gEdgeEffectRef[kEdgeTypeCount] = {
45 SkAutoTUnref<GrEffectRef>(
46 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrEdgeEffect, (kHairL ine_EdgeType))))),
47 SkAutoTUnref<GrEffectRef>(
48 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrEdgeEffect, (kQuad_ EdgeType))))),
49 SkAutoTUnref<GrEffectRef>(
50 CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrEdgeEffect, (kHairQ uad_EdgeType)))))
51 };
52
53 gEdgeEffectRef[type].get()->ref();
54 return gEdgeEffectRef[type];
55 }
56
57 virtual ~GrEdgeEffect() {}
58
59 static const char* Name() { return "Edge"; }
60
61 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
62
63 typedef GrGLEdgeEffect GLEffect;
64
65 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
66
67 inline EdgeType edgeType() const { return fEdgeType; }
68
69 private:
70 GrEdgeEffect(EdgeType edgeType);
71
72 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
73 const GrEdgeEffect& qee = CastEffect<GrEdgeEffect>(other);
74 return qee.fEdgeType == fEdgeType;
75 }
76
77 EdgeType fEdgeType;
78
79 GR_DECLARE_EFFECT_TEST;
80
81 typedef GrEffect INHERITED;
82 };
83
84 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/effects/GrEdgeEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698