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

Side by Side Diff: src/gpu/GrGeometryProcessor.h

Issue 1110993002: Revert of removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrGeometryProcessor.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 2013 Google Inc. 2 * Copyright 2013 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 GrGeometryProcessor_DEFINED 8 #ifndef GrGeometryProcessor_DEFINED
9 #define GrGeometryProcessor_DEFINED 9 #define GrGeometryProcessor_DEFINED
10 10
11 #include "GrPrimitiveProcessor.h" 11 #include "GrPrimitiveProcessor.h"
12 12
13 /** 13 /**
14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor 14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor
15 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it 15 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it
16 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and 16 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and
17 * coverage into the fragment shader. Where this color and coverage come from i s completely the 17 * coverage into the fragment shader. Where this color and coverage come from i s completely the
18 * responsibility of the GrGeometryProcessor. 18 * responsibility of the GrGeometryProcessor.
19 */ 19 */
20 class GrGeometryProcessor : public GrPrimitiveProcessor { 20 class GrGeometryProcessor : public GrPrimitiveProcessor {
21 public: 21 public:
22 // TODO the Hint can be handled in a much more clean way when we have deferr ed geometry or 22 // TODO the Hint can be handled in a much more clean way when we have deferr ed geometry or
23 // atleast bundles 23 // atleast bundles
24 GrGeometryProcessor(GrColor color, 24 GrGeometryProcessor(GrColor color,
25 const SkMatrix& viewMatrix = SkMatrix::I(), 25 const SkMatrix& viewMatrix = SkMatrix::I(),
26 const SkMatrix& localMatrix = SkMatrix::I()) 26 const SkMatrix& localMatrix = SkMatrix::I(),
27 bool opaqueVertexColors = false)
27 : INHERITED(viewMatrix, localMatrix, false) 28 : INHERITED(viewMatrix, localMatrix, false)
28 , fColor(color) 29 , fColor(color)
30 , fOpaqueVertexColors(opaqueVertexColors)
29 , fWillUseGeoShader(false) 31 , fWillUseGeoShader(false)
32 , fHasVertexColor(false)
30 , fHasLocalCoords(false) {} 33 , fHasLocalCoords(false) {}
31 34
32 bool willUseGeoShader() const { return fWillUseGeoShader; } 35 bool willUseGeoShader() const { return fWillUseGeoShader; }
33 36
34 // TODO delete this when paths are in batch 37 /*
38 * In an ideal world, two GrGeometryProcessors with the same class id and te xture accesses
39 * would ALWAYS be able to batch together. If two GrGeometryProcesosrs are the same then we
40 * will only keep one of them. The remaining GrGeometryProcessor then updat es its
41 * GrBatchTracker to incorporate the draw information from the GrGeometryPro cessor we discard.
42 * Any bundles associated with the discarded GrGeometryProcessor will be att ached to the
43 * remaining GrGeometryProcessor.
44 */
35 bool canMakeEqual(const GrBatchTracker& mine, 45 bool canMakeEqual(const GrBatchTracker& mine,
36 const GrPrimitiveProcessor& that, 46 const GrPrimitiveProcessor& that,
37 const GrBatchTracker& theirs) const override { 47 const GrBatchTracker& theirs) const override {
38 SkFAIL("Unsupported\n"); 48 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(t hat)) {
39 return false; 49 return false;
50 }
51
52 // TODO let the GPs decide this
53 if (!this->viewMatrix().cheapEqualTo(that.viewMatrix())) {
54 return false;
55 }
56
57 // TODO remove the hint
58 const GrGeometryProcessor& other = that.cast<GrGeometryProcessor>();
59 if (fHasVertexColor && fOpaqueVertexColors != other.fOpaqueVertexColors) {
60 return false;
61 }
62
63 // TODO this equality test should really be broken up, some of this can live on the batch
64 // tracker test and some of this should be in bundles
65 if (!this->onIsEqual(other)) {
66 return false;
67 }
68
69 return this->onCanMakeEqual(mine, other, theirs);
40 } 70 }
41 71
42 // TODO we can remove color from the GrGeometryProcessor base class once we have bundles of 72 // TODO we can remove color from the GrGeometryProcessor base class once we have bundles of
43 // primitive data 73 // primitive data
44 GrColor color() const { return fColor; } 74 GrColor color() const { return fColor; }
45 75
46 // TODO Delete when paths are in batch 76 // TODO this is a total hack until the gp can do deferred geometry
47 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 77 bool hasVertexColor() const { return fHasVertexColor; }
48 SkFAIL("Unsupported\n"); 78
49 } 79 void getInvariantOutputColor(GrInitInvariantOutput* out) const override;
50 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 80 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override;
51 SkFAIL("Unsupported\n");
52 }
53 81
54 protected: 82 protected:
55 /* 83 /*
56 * An optional simple helper function to determine by what means the GrGeome tryProcessor should 84 * An optional simple helper function to determine by what means the GrGeome tryProcessor should
57 * use to provide color. If we are given an override color(ie the given ove rridecolor is NOT 85 * use to provide color. If we are given an override color(ie the given ove rridecolor is NOT
58 * GrColor_ILLEGAL) then we must always emit that color(currently overrides are only supported 86 * GrColor_ILLEGAL) then we must always emit that color(currently overrides are only supported
59 * via uniform, but with deferred Geometry we could use attributes). Otherw ise, if our color is 87 * via uniform, but with deferred Geometry we could use attributes). Otherw ise, if our color is
60 * ignored then we should not emit a color. Lastly, if we don't have vertex colors then we must 88 * ignored then we should not emit a color. Lastly, if we don't have vertex colors then we must
61 * emit a color via uniform 89 * emit a color via uniform
62 * TODO this function changes quite a bit with deferred geometry. There the GrGeometryProcessor 90 * TODO this function changes quite a bit with deferred geometry. There the GrGeometryProcessor
(...skipping 30 matching lines...) Expand all
93 const Attribute& addVertexAttrib(const Attribute& attribute) { 121 const Attribute& addVertexAttrib(const Attribute& attribute) {
94 SkASSERT(fNumAttribs < kMaxVertexAttribs); 122 SkASSERT(fNumAttribs < kMaxVertexAttribs);
95 fVertexStride += attribute.fOffset; 123 fVertexStride += attribute.fOffset;
96 fAttribs[fNumAttribs] = attribute; 124 fAttribs[fNumAttribs] = attribute;
97 return fAttribs[fNumAttribs++]; 125 return fAttribs[fNumAttribs++];
98 } 126 }
99 127
100 void setWillUseGeoShader() { fWillUseGeoShader = true; } 128 void setWillUseGeoShader() { fWillUseGeoShader = true; }
101 129
102 // TODO hack see above 130 // TODO hack see above
131 void setHasVertexColor() { fHasVertexColor = true; }
103 void setHasLocalCoords() { fHasLocalCoords = true; } 132 void setHasLocalCoords() { fHasLocalCoords = true; }
104 133
134 virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {}
135 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0;
136
105 private: 137 private:
138 virtual bool onCanMakeEqual(const GrBatchTracker& mine,
139 const GrGeometryProcessor& that,
140 const GrBatchTracker& theirs) const = 0;
141
142 // TODO delete this when we have more advanced equality testing via bundles and the BT
143 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
144
106 bool hasExplicitLocalCoords() const override { return fHasLocalCoords; } 145 bool hasExplicitLocalCoords() const override { return fHasLocalCoords; }
107 146
108 GrColor fColor; 147 GrColor fColor;
148 bool fOpaqueVertexColors;
109 bool fWillUseGeoShader; 149 bool fWillUseGeoShader;
150 bool fHasVertexColor;
110 bool fHasLocalCoords; 151 bool fHasLocalCoords;
111 152
112 typedef GrPrimitiveProcessor INHERITED; 153 typedef GrPrimitiveProcessor INHERITED;
113 }; 154 };
114 155
115 #endif 156 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698