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

Side by Side Diff: src/gpu/GrDefaultGeoProcFactory.cpp

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years 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/GrDefaultGeoProcFactory.h ('k') | src/gpu/GrDefaultPathRenderer.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 #include "GrDefaultGeoProcFactory.h" 8 #include "GrDefaultGeoProcFactory.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
11 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
12 #include "gl/GrGLGeometryProcessor.h" 12 #include "gl/GrGLGeometryProcessor.h"
13 #include "gl/builders/GrGLProgramBuilder.h" 13 #include "gl/builders/GrGLProgramBuilder.h"
14 14
15 /* 15 /*
16 * The default Geometry Processor simply takes position and multiplies it by the uniform view 16 * The default Geometry Processor simply takes position and multiplies it by the uniform view
17 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per vertex color or 17 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per vertex color or
18 * local coords. 18 * local coords.
19 */ 19 */
20 typedef GrDefaultGeoProcFactory Flag; 20 typedef GrDefaultGeoProcFactory Flag;
21 21
22 class DefaultGeoProc : public GrGeometryProcessor { 22 class DefaultGeoProc : public GrGeometryProcessor {
23 public: 23 public:
24 static GrGeometryProcessor* Create(GrColor color, uint8_t coverage, uint32_t gpTypeFlags) { 24 static GrGeometryProcessor* Create(GrColor color, uint8_t coverage, uint32_t gpTypeFlags,
25 return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags)); 25 bool opaqueVertexColors) {
26 return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueV ertexColors));
26 } 27 }
27 28
28 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces sor"; } 29 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces sor"; }
29 30
30 const GrAttribute* inPosition() const { return fInPosition; } 31 const GrAttribute* inPosition() const { return fInPosition; }
31 const GrAttribute* inColor() const { return fInColor; } 32 const GrAttribute* inColor() const { return fInColor; }
32 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } 33 const GrAttribute* inLocalCoords() const { return fInLocalCoords; }
33 const GrAttribute* inCoverage() const { return fInCoverage; } 34 const GrAttribute* inCoverage() const { return fInCoverage; }
34 35
35 class GLProcessor : public GrGLGeometryProcessor { 36 class GLProcessor : public GrGLGeometryProcessor {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const GrGLCaps& caps, 89 const GrGLCaps& caps,
89 GrProcessorKeyBuilder* b) const SK_OVERRIDE { 90 GrProcessorKeyBuilder* b) const SK_OVERRIDE {
90 GLProcessor::GenKey(*this, bt, caps, b); 91 GLProcessor::GenKey(*this, bt, caps, b);
91 } 92 }
92 93
93 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE { 94 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE {
94 return SkNEW_ARGS(GLProcessor, (*this, bt)); 95 return SkNEW_ARGS(GLProcessor, (*this, bt));
95 } 96 }
96 97
97 private: 98 private:
98 DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags) 99 DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool o paqueVertexColors)
99 : INHERITED(color, coverage) 100 : INHERITED(color, opaqueVertexColors, coverage)
100 , fInPosition(NULL) 101 , fInPosition(NULL)
101 , fInColor(NULL) 102 , fInColor(NULL)
102 , fInLocalCoords(NULL) 103 , fInLocalCoords(NULL)
103 , fInCoverage(NULL) 104 , fInCoverage(NULL)
104 , fFlags(gpTypeFlags) { 105 , fFlags(gpTypeFlags) {
105 this->initClassID<DefaultGeoProc>(); 106 this->initClassID<DefaultGeoProc>();
106 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G PType); 107 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G PType);
107 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo calCoord_GPType); 108 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo calCoord_GPType);
108 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove rage_GPType); 109 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove rage_GPType);
109 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr VertexAttribType)); 110 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr VertexAttribType));
(...skipping 11 matching lines...) Expand all
121 kFloat_GrVertexAttr ibType)); 122 kFloat_GrVertexAttr ibType));
122 this->setHasVertexCoverage(); 123 this->setHasVertexCoverage();
123 } 124 }
124 } 125 }
125 126
126 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 127 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE {
127 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); 128 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>();
128 return gp.fFlags == this->fFlags; 129 return gp.fFlags == this->fFlags;
129 } 130 }
130 131
131 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE { 132 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
132 if (fInCoverage) { 133 if (fInCoverage) {
133 inout->mulByUnknownAlpha(); 134 out->setUnknownSingleComponent();
134 } else { 135 } else {
135 inout->mulByKnownAlpha(255); 136 // uniform coverage
137 out->setKnownSingleComponent(this->coverage());
136 } 138 }
137 } 139 }
138 140
139 const GrAttribute* fInPosition; 141 const GrAttribute* fInPosition;
140 const GrAttribute* fInColor; 142 const GrAttribute* fInColor;
141 const GrAttribute* fInLocalCoords; 143 const GrAttribute* fInLocalCoords;
142 const GrAttribute* fInCoverage; 144 const GrAttribute* fInCoverage;
143 uint32_t fFlags; 145 uint32_t fFlags;
144 146
145 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 147 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
(...skipping 11 matching lines...) Expand all
157 if (random->nextBool()) { 159 if (random->nextBool()) {
158 flags |= GrDefaultGeoProcFactory::kColor_GPType; 160 flags |= GrDefaultGeoProcFactory::kColor_GPType;
159 } 161 }
160 if (random->nextBool()) { 162 if (random->nextBool()) {
161 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; 163 flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
162 } 164 }
163 if (random->nextBool()) { 165 if (random->nextBool()) {
164 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; 166 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
165 } 167 }
166 168
167 return DefaultGeoProc::Create(GrRandomColor(random), GrRandomCoverage(random ), flags); 169 return DefaultGeoProc::Create(GrRandomColor(random), GrRandomCoverage(random ),
170 flags, random->nextBool());
168 } 171 }
169 172
170 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(GrColor color, uint32 _t gpTypeFlags, 173 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(GrColor color,
174 uint32_t gpTypeFlags,
175 bool opaqueVertexColo rs,
171 uint8_t coverage) { 176 uint8_t coverage) {
172 return DefaultGeoProc::Create(color, coverage, gpTypeFlags); 177 return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColo rs);
173 } 178 }
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.h ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698