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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 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
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDefaultPathRenderer.h » ('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 "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 16 matching lines...) Expand all
27 bool opaqueVertexColors, 27 bool opaqueVertexColors,
28 uint8_t coverage) { 28 uint8_t coverage) {
29 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, 29 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags,
30 color, 30 color,
31 viewMatrix, 31 viewMatrix,
32 localMatrix, 32 localMatrix,
33 opaqueVertexColors, 33 opaqueVertexColors,
34 coverage)); 34 coverage));
35 } 35 }
36 36
37 const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } 37 const char* name() const override { return "DefaultGeometryProcessor"; }
38 38
39 const Attribute* inPosition() const { return fInPosition; } 39 const Attribute* inPosition() const { return fInPosition; }
40 const Attribute* inColor() const { return fInColor; } 40 const Attribute* inColor() const { return fInColor; }
41 const Attribute* inLocalCoords() const { return fInLocalCoords; } 41 const Attribute* inLocalCoords() const { return fInLocalCoords; }
42 const Attribute* inCoverage() const { return fInCoverage; } 42 const Attribute* inCoverage() const { return fInCoverage; }
43 uint8_t coverage() const { return fCoverage; } 43 uint8_t coverage() const { return fCoverage; }
44 44
45 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const SK_OVERRIDE { 45 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
46 BatchTracker* local = bt->cast<BatchTracker>(); 46 BatchTracker* local = bt->cast<BatchTracker>();
47 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, 47 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init,
48 SkToBool(fInColor)); 48 SkToBool(fInColor));
49 49
50 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored ; 50 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored ;
51 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage(); 51 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage();
52 if (covIsSolidWhite) { 52 if (covIsSolidWhite) {
53 local->fInputCoverageType = kAllOnes_GrGPInput; 53 local->fInputCoverageType = kAllOnes_GrGPInput;
54 } else if (!hasVertexCoverage) { 54 } else if (!hasVertexCoverage) {
55 local->fInputCoverageType = kUniform_GrGPInput; 55 local->fInputCoverageType = kUniform_GrGPInput;
56 local->fCoverage = this->coverage(); 56 local->fCoverage = this->coverage();
57 } else if (hasVertexCoverage) { 57 } else if (hasVertexCoverage) {
58 SkASSERT(fInCoverage); 58 SkASSERT(fInCoverage);
59 local->fInputCoverageType = kAttribute_GrGPInput; 59 local->fInputCoverageType = kAttribute_GrGPInput;
60 } else { 60 } else {
61 local->fInputCoverageType = kIgnored_GrGPInput; 61 local->fInputCoverageType = kIgnored_GrGPInput;
62 } 62 }
63 63
64 local->fUsesLocalCoords = init.fUsesLocalCoords; 64 local->fUsesLocalCoords = init.fUsesLocalCoords;
65 } 65 }
66 66
67 bool onCanMakeEqual(const GrBatchTracker& m, 67 bool onCanMakeEqual(const GrBatchTracker& m,
68 const GrGeometryProcessor& that, 68 const GrGeometryProcessor& that,
69 const GrBatchTracker& t) const SK_OVERRIDE { 69 const GrBatchTracker& t) const override {
70 const BatchTracker& mine = m.cast<BatchTracker>(); 70 const BatchTracker& mine = m.cast<BatchTracker>();
71 const BatchTracker& theirs = t.cast<BatchTracker>(); 71 const BatchTracker& theirs = t.cast<BatchTracker>();
72 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, 72 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
73 that, theirs.fUsesLocalCoords) && 73 that, theirs.fUsesLocalCoords) &&
74 CanCombineOutput(mine.fInputColorType, mine.fColor, 74 CanCombineOutput(mine.fInputColorType, mine.fColor,
75 theirs.fInputColorType, theirs.fColor) && 75 theirs.fInputColorType, theirs.fColor) &&
76 CanCombineOutput(mine.fInputCoverageType, mine.fCoverage, 76 CanCombineOutput(mine.fInputCoverageType, mine.fCoverage,
77 theirs.fInputCoverageType, theirs.fCoverage); 77 theirs.fInputCoverageType, theirs.fCoverage);
78 } 78 }
79 79
80 class GLProcessor : public GrGLGeometryProcessor { 80 class GLProcessor : public GrGLGeometryProcessor {
81 public: 81 public:
82 GLProcessor(const GrGeometryProcessor& gp, const GrBatchTracker&) 82 GLProcessor(const GrGeometryProcessor& gp, const GrBatchTracker&)
83 : fColor(GrColor_ILLEGAL), fCoverage(0xff) {} 83 : fColor(GrColor_ILLEGAL), fCoverage(0xff) {}
84 84
85 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE { 85 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
86 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>(); 86 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
87 GrGLGPBuilder* pb = args.fPB; 87 GrGLGPBuilder* pb = args.fPB;
88 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 88 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
89 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder(); 89 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
90 const BatchTracker& local = args.fBT.cast<BatchTracker>(); 90 const BatchTracker& local = args.fBT.cast<BatchTracker>();
91 91
92 // emit attributes 92 // emit attributes
93 vsBuilder->emitAttributes(gp); 93 vsBuilder->emitAttributes(gp);
94 94
95 // Setup pass through color 95 // Setup pass through color
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const BatchTracker& local = bt.cast<BatchTracker>(); 135 const BatchTracker& local = bt.cast<BatchTracker>();
136 uint32_t key = def.fFlags; 136 uint32_t key = def.fFlags;
137 key |= local.fInputColorType << 8 | local.fInputCoverageType << 16; 137 key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
138 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0; 138 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
139 key |= ComputePosKey(gp.viewMatrix()) << 25; 139 key |= ComputePosKey(gp.viewMatrix()) << 25;
140 b->add32(key); 140 b->add32(key);
141 } 141 }
142 142
143 virtual void setData(const GrGLProgramDataManager& pdman, 143 virtual void setData(const GrGLProgramDataManager& pdman,
144 const GrPrimitiveProcessor& gp, 144 const GrPrimitiveProcessor& gp,
145 const GrBatchTracker& bt) SK_OVERRIDE { 145 const GrBatchTracker& bt) override {
146 this->setUniformViewMatrix(pdman, gp.viewMatrix()); 146 this->setUniformViewMatrix(pdman, gp.viewMatrix());
147 147
148 const BatchTracker& local = bt.cast<BatchTracker>(); 148 const BatchTracker& local = bt.cast<BatchTracker>();
149 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f Color) { 149 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f Color) {
150 GrGLfloat c[4]; 150 GrGLfloat c[4];
151 GrColorToRGBAFloat(local.fColor, c); 151 GrColorToRGBAFloat(local.fColor, c);
152 pdman.set4fv(fColorUniform, 1, c); 152 pdman.set4fv(fColorUniform, 1, c);
153 fColor = local.fColor; 153 fColor = local.fColor;
154 } 154 }
155 if (kUniform_GrGPInput == local.fInputCoverageType && local.fCoverag e != fCoverage) { 155 if (kUniform_GrGPInput == local.fInputCoverageType && local.fCoverag e != fCoverage) {
156 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(local.fCove rage)); 156 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(local.fCove rage));
157 fCoverage = local.fCoverage; 157 fCoverage = local.fCoverage;
158 } 158 }
159 } 159 }
160 160
161 private: 161 private:
162 GrColor fColor; 162 GrColor fColor;
163 uint8_t fCoverage; 163 uint8_t fCoverage;
164 UniformHandle fColorUniform; 164 UniformHandle fColorUniform;
165 UniformHandle fCoverageUniform; 165 UniformHandle fCoverageUniform;
166 166
167 typedef GrGLGeometryProcessor INHERITED; 167 typedef GrGLGeometryProcessor INHERITED;
168 }; 168 };
169 169
170 virtual void getGLProcessorKey(const GrBatchTracker& bt, 170 virtual void getGLProcessorKey(const GrBatchTracker& bt,
171 const GrGLCaps& caps, 171 const GrGLCaps& caps,
172 GrProcessorKeyBuilder* b) const SK_OVERRIDE { 172 GrProcessorKeyBuilder* b) const override {
173 GLProcessor::GenKey(*this, bt, caps, b); 173 GLProcessor::GenKey(*this, bt, caps, b);
174 } 174 }
175 175
176 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 176 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
177 const GrGLCaps&) const SK_O VERRIDE { 177 const GrGLCaps&) const over ride {
178 return SkNEW_ARGS(GLProcessor, (*this, bt)); 178 return SkNEW_ARGS(GLProcessor, (*this, bt));
179 } 179 }
180 180
181 private: 181 private:
182 DefaultGeoProc(uint32_t gpTypeFlags, 182 DefaultGeoProc(uint32_t gpTypeFlags,
183 GrColor color, 183 GrColor color,
184 const SkMatrix& viewMatrix, 184 const SkMatrix& viewMatrix,
185 const SkMatrix& localMatrix, 185 const SkMatrix& localMatrix,
186 bool opaqueVertexColors, 186 bool opaqueVertexColors,
187 uint8_t coverage) 187 uint8_t coverage)
(...skipping 17 matching lines...) Expand all
205 fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord", 205 fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord",
206 kVec2f_GrVertexA ttribType)); 206 kVec2f_GrVertexA ttribType));
207 this->setHasLocalCoords(); 207 this->setHasLocalCoords();
208 } 208 }
209 if (hasCoverage) { 209 if (hasCoverage) {
210 fInCoverage = &this->addVertexAttrib(Attribute("inCoverage", 210 fInCoverage = &this->addVertexAttrib(Attribute("inCoverage",
211 kFloat_GrVertexAttr ibType)); 211 kFloat_GrVertexAttr ibType));
212 } 212 }
213 } 213 }
214 214
215 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 215 bool onIsEqual(const GrGeometryProcessor& other) const override {
216 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); 216 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>();
217 return gp.fFlags == this->fFlags; 217 return gp.fFlags == this->fFlags;
218 } 218 }
219 219
220 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR IDE { 220 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
221 if (fInCoverage) { 221 if (fInCoverage) {
222 out->setUnknownSingleComponent(); 222 out->setUnknownSingleComponent();
223 } else { 223 } else {
224 // uniform coverage 224 // uniform coverage
225 out->setKnownSingleComponent(this->coverage()); 225 out->setKnownSingleComponent(this->coverage());
226 } 226 }
227 } 227 }
228 228
229 struct BatchTracker { 229 struct BatchTracker {
230 GrGPInput fInputColorType; 230 GrGPInput fInputColorType;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const SkMatrix& local Matrix, 277 const SkMatrix& local Matrix,
278 bool opaqueVertexColo rs, 278 bool opaqueVertexColo rs,
279 uint8_t coverage) { 279 uint8_t coverage) {
280 return DefaultGeoProc::Create(gpTypeFlags, 280 return DefaultGeoProc::Create(gpTypeFlags,
281 color, 281 color,
282 viewMatrix, 282 viewMatrix,
283 localMatrix, 283 localMatrix,
284 opaqueVertexColors, 284 opaqueVertexColors,
285 coverage); 285 coverage);
286 } 286 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDefaultPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698