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

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

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: fix Created 6 years, 3 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
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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
(...skipping 18 matching lines...) Expand all
29 29
30 memcpy(fFixedFunctionVertexAttribIndices, 30 memcpy(fFixedFunctionVertexAttribIndices,
31 drawState.getFixedFunctionVertexAttribIndices(), 31 drawState.getFixedFunctionVertexAttribIndices(),
32 sizeof(fFixedFunctionVertexAttribIndices)); 32 sizeof(fFixedFunctionVertexAttribIndices));
33 33
34 34
35 fInputColorIsUsed = true; 35 fInputColorIsUsed = true;
36 fInputCoverageIsUsed = true; 36 fInputCoverageIsUsed = true;
37 37
38 if (drawState.hasGeometryProcessor()) { 38 if (drawState.hasGeometryProcessor()) {
39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor()))); 39 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom etryProcessor())));
40 } else { 40 } else {
41 fGeometryProcessor.reset(NULL); 41 fGeometryProcessor.reset(NULL);
42 } 42 }
43 43
44 this->copyEffectiveColorStages(drawState); 44 this->copyEffectiveColorStages(drawState);
45 this->copyEffectiveCoverageStages(drawState); 45 this->copyEffectiveCoverageStages(drawState);
46 this->adjustFromBlendOpts(); 46 this->adjustFromBlendOpts();
47 this->getStageStats(); 47 this->getStageStats();
48 }; 48 };
49 49
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (ds.vertexColorsAreOpaque()) { 126 if (ds.vertexColorsAreOpaque()) {
127 color = 0xFF << GrColor_SHIFT_A; 127 color = 0xFF << GrColor_SHIFT_A;
128 validComponentFlags = kA_GrColorComponentFlag; 128 validComponentFlags = kA_GrColorComponentFlag;
129 } else { 129 } else {
130 validComponentFlags = 0; 130 validComponentFlags = 0;
131 color = 0; // not strictly necessary but we get false alarms from to ols about uninit. 131 color = 0; // not strictly necessary but we get false alarms from to ols about uninit.
132 } 132 }
133 } 133 }
134 134
135 for (int i = 0; i < ds.numColorStages(); ++i) { 135 for (int i = 0; i < ds.numColorStages(); ++i) {
136 const GrEffect* effect = ds.getColorStage(i).getEffect(); 136 const GrFragmentProcessor* fp = ds.getColorStage(i).getFragmentProcessor ();
137 if (!effect->willUseInputColor()) { 137 if (!fp->willUseInputColor()) {
138 firstColorStage = i; 138 firstColorStage = i;
139 fInputColorIsUsed = false; 139 fInputColorIsUsed = false;
140 } 140 }
141 effect->getConstantColorComponents(&color, &validComponentFlags); 141 fp->getConstantColorComponents(&color, &validComponentFlags);
142 if (kRGBA_GrColorComponentFlags == validComponentFlags) { 142 if (kRGBA_GrColorComponentFlags == validComponentFlags) {
143 firstColorStage = i + 1; 143 firstColorStage = i + 1;
144 fColor = color; 144 fColor = color;
145 fInputColorIsUsed = true; 145 fInputColorIsUsed = true;
146 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB inding); 146 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB inding);
147 } 147 }
148 } 148 }
149 if (firstColorStage < ds.numColorStages()) { 149 if (firstColorStage < ds.numColorStages()) {
150 fColorStages.reset(&ds.getColorStage(firstColorStage), 150 fColorStages.reset(&ds.getColorStage(firstColorStage),
151 ds.numColorStages() - firstColorStage); 151 ds.numColorStages() - firstColorStage);
152 } else { 152 } else {
153 fColorStages.reset(); 153 fColorStages.reset();
154 } 154 }
155 } 155 }
156 156
157 void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) { 157 void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
158 int firstCoverageStage = 0; 158 int firstCoverageStage = 0;
159 159
160 // We do not try to optimize out constantColor coverage effects here. It is extremely rare 160 // We do not try to optimize out constantColor coverage effects here. It is extremely rare
161 // to have a coverage effect that returns a constant value for all four chan nels. Thus we 161 // to have a coverage effect that returns a constant value for all four chan nels. Thus we
162 // save having to make extra virtual calls by not checking for it. 162 // save having to make extra virtual calls by not checking for it.
163 163
164 // Don't do any optimizations on coverage stages. It should not be the case where we do not use 164 // Don't do any optimizations on coverage stages. It should not be the case where we do not use
165 // input coverage in an effect 165 // input coverage in an effect
166 #ifdef OptCoverageStages 166 #ifdef OptCoverageStages
167 for (int i = 0; i < ds.numCoverageStages(); ++i) { 167 for (int i = 0; i < ds.numCoverageStages(); ++i) {
168 const GrEffect* effect = ds.getCoverageStage(i).getEffect(); 168 const GrProcessor* processor = ds.getCoverageStage(i).getProcessor();
169 if (!effect->willUseInputColor()) { 169 if (!processor->willUseInputColor()) {
170 firstCoverageStage = i; 170 firstCoverageStage = i;
171 fInputCoverageIsUsed = false; 171 fInputCoverageIsUsed = false;
172 } 172 }
173 } 173 }
174 #endif 174 #endif
175 if (ds.numCoverageStages() > 0) { 175 if (ds.numCoverageStages() > 0) {
176 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage), 176 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage),
177 ds.numCoverageStages() - firstCoverageStage); 177 ds.numCoverageStages() - firstCoverageStage);
178 } else { 178 } else {
179 fCoverageStages.reset(); 179 fCoverageStages.reset();
180 } 180 }
181 } 181 }
182 182
183 static void get_stage_stats(const GrEffectStage& stage, bool* readsDst, bool* re adsFragPosition) { 183 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool* readsFragPosition) {
184 if (stage.getEffect()->willReadDstColor()) { 184 if (stage.getFragmentProcessor()->willReadDstColor()) {
185 *readsDst = true; 185 *readsDst = true;
186 } 186 }
187 if (stage.getEffect()->willReadFragmentPosition()) { 187 if (stage.getFragmentProcessor()->willReadFragmentPosition()) {
188 *readsFragPosition = true; 188 *readsFragPosition = true;
189 } 189 }
190 } 190 }
191
191 void GrOptDrawState::getStageStats() { 192 void GrOptDrawState::getStageStats() {
192 // We will need a local coord attrib if there is one currently set on the op tState and we are 193 // We will need a local coord attrib if there is one currently set on the op tState and we are
193 // actually generating some effect code 194 // actually generating some effect code
194 fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotal Stages() > 0; 195 fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotal Stages() > 0;
195 196
196 // if 1 == fVACount then that VA must be position, otherwise it contains som e attribute which 197 // if 1 == fVACount then that VA must be position, otherwise it contains som e attribute which
197 // will require a vertexShader 198 // will require a vertexShader
198 fRequiresVertexShader = fVACount > 1; 199 fRequiresVertexShader = fVACount > 1;
199 200
200 fReadsDst = false; 201 fReadsDst = false;
201 fReadsFragPosition = false; 202 fReadsFragPosition = false;
202 203
203 for (int s = 0; s < this->numColorStages(); ++s) { 204 for (int s = 0; s < this->numColorStages(); ++s) {
204 const GrEffectStage& stage = this->getColorStage(s); 205 const GrFragmentStage& stage = this->getColorStage(s);
205 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); 206 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
206 } 207 }
207 for (int s = 0; s < this->numCoverageStages(); ++s) { 208 for (int s = 0; s < this->numCoverageStages(); ++s) {
208 const GrEffectStage& stage = this->getCoverageStage(s); 209 const GrFragmentStage& stage = this->getCoverageStage(s);
209 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); 210 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
210 } 211 }
211 if (this->hasGeometryProcessor()) { 212 if (this->hasGeometryProcessor()) {
212 const GrEffectStage& stage = *this->getGeometryProcessor(); 213 const GrGeometryStage& stage = *this->getGeometryProcessor();
213 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); 214 fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willRea dFragmentPosition();
214 SkASSERT(fRequiresVertexShader); 215 SkASSERT(fRequiresVertexShader);
215 } 216 }
216 } 217 }
217 218
218 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { 219 bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
219 return this->isEqual(that); 220 return this->isEqual(that);
220 } 221 }
221 222
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698