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

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

Issue 699943003: Move GrInvariantOutput out of GrProcessor and into its own class. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanup Created 6 years, 1 month 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/GrInvariantOutput.cpp ('k') | src/gpu/GrOvalRenderer.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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
11 #include "GrDrawState.h" 11 #include "GrDrawState.h"
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrInvariantOutput.h"
14 15
15 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
16 BlendOptFlags blendOptFlags, 17 BlendOptFlags blendOptFlags,
17 GrBlendCoeff optSrcCoeff, 18 GrBlendCoeff optSrcCoeff,
18 GrBlendCoeff optDstCoeff, 19 GrBlendCoeff optDstCoeff,
19 GrGpu* gpu, 20 GrGpu* gpu,
20 const GrDeviceCoordTexture* dstCopy, 21 const GrDeviceCoordTexture* dstCopy,
21 GrGpu::DrawType drawType) { 22 GrGpu::DrawType drawType) {
22 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); 23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType);
23 fColor = drawState.getColor(); 24 fColor = drawState.getColor();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 217 }
217 fVACount -= numToRemove; 218 fVACount -= numToRemove;
218 fVAPtr = fOptVA.get(); 219 fVAPtr = fOptVA.get();
219 } 220 }
220 221
221 void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds, 222 void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds,
222 GrProgramDesc::DescInfo* descIn fo, 223 GrProgramDesc::DescInfo* descIn fo,
223 int* firstColorStageIdx, 224 int* firstColorStageIdx,
224 uint8_t* fixedFunctionVAToRemov e) { 225 uint8_t* fixedFunctionVAToRemov e) {
225 // Set up color and flags for ConstantColorComponent checks 226 // Set up color and flags for ConstantColorComponent checks
226 GrProcessor::InvariantOutput inout; 227 GrColor color;
227 inout.fIsSingleComponent = false; 228 GrColorComponentFlags flags;
228 if (!descInfo->hasColorVertexAttribute()) { 229 if (!descInfo->hasColorVertexAttribute()) {
229 inout.fColor = ds.getColor(); 230 color = ds.getColor();
230 inout.fValidFlags = kRGBA_GrColorComponentFlags; 231 flags = kRGBA_GrColorComponentFlags;
231 } else { 232 } else {
232 if (ds.vertexColorsAreOpaque()) { 233 if (ds.vertexColorsAreOpaque()) {
233 inout.fColor = 0xFF << GrColor_SHIFT_A; 234 color = 0xFF << GrColor_SHIFT_A;
234 inout.fValidFlags = kA_GrColorComponentFlag; 235 flags = kA_GrColorComponentFlag;
235 } else { 236 } else {
236 inout.fValidFlags = 0; 237 flags = static_cast<GrColorComponentFlags>(0);
237 // not strictly necessary but we get false alarms from tools about u ninit. 238 // not strictly necessary but we get false alarms from tools about u ninit.
238 inout.fColor = 0; 239 color = 0;
239 } 240 }
240 } 241 }
242 GrInvariantOutput inout(color, flags, false);
241 243
242 for (int i = 0; i < ds.numColorStages(); ++i) { 244 for (int i = 0; i < ds.numColorStages(); ++i) {
243 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); 245 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor();
244 fp->computeInvariantOutput(&inout); 246 fp->computeInvariantOutput(&inout);
245 if (!inout.fWillUseInputColor) { 247 if (!inout.willUseInputColor()) {
246 *firstColorStageIdx = i; 248 *firstColorStageIdx = i;
247 descInfo->fInputColorIsUsed = false; 249 descInfo->fInputColorIsUsed = false;
248 } 250 }
249 if (kRGBA_GrColorComponentFlags == inout.fValidFlags) { 251 if (kRGBA_GrColorComponentFlags == inout.validFlags()) {
250 *firstColorStageIdx = i + 1; 252 *firstColorStageIdx = i + 1;
251 fColor = inout.fColor; 253 fColor = inout.color();
252 descInfo->fInputColorIsUsed = true; 254 descInfo->fInputColorIsUsed = true;
253 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; 255 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
254 // Since we are clearing all previous color stages we are in a state where we have found 256 // Since we are clearing all previous color stages we are in a state where we have found
255 // zero stages that don't multiply the inputColor. 257 // zero stages that don't multiply the inputColor.
256 inout.fNonMulStageFound = false; 258 inout.resetNonMulStageFound();
257 } 259 }
258 } 260 }
259 } 261 }
260 262
261 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, 263 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds,
262 GrProgramDesc::DescInfo* des cInfo, 264 GrProgramDesc::DescInfo* des cInfo,
263 int* firstCoverageStageIdx) { 265 int* firstCoverageStageIdx) {
264 // We do not try to optimize out constantColor coverage effects here. It is extremely rare 266 // We do not try to optimize out constantColor coverage effects here. It is extremely rare
265 // to have a coverage effect that returns a constant value for all four chan nels. Thus we 267 // to have a coverage effect that returns a constant value for all four chan nels. Thus we
266 // save having to make extra virtual calls by not checking for it. 268 // save having to make extra virtual calls by not checking for it.
267 269
268 // Don't do any optimizations on coverage stages. It should not be the case where we do not use 270 // Don't do any optimizations on coverage stages. It should not be the case where we do not use
269 // input coverage in an effect 271 // input coverage in an effect
270 #ifdef OptCoverageStages 272 #ifdef OptCoverageStages
271 GrProcessor::InvariantOutput inout; 273 GrInvariantOutput inout;
272 for (int i = 0; i < ds.numCoverageStages(); ++i) { 274 for (int i = 0; i < ds.numCoverageStages(); ++i) {
273 const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor(); 275 const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor();
274 fp->computeInvariantOutput(&inout); 276 fp->computeInvariantOutput(&inout);
275 if (!inout.fWillUseInputColor) { 277 if (!inout.fWillUseInputColor) {
276 *firstCoverageStageIdx = i; 278 *firstCoverageStageIdx = i;
277 descInfo->fInputCoverageIsUsed = false; 279 descInfo->fInputCoverageIsUsed = false;
278 } 280 }
279 } 281 }
280 #endif 282 #endif
281 } 283 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; 362 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1;
361 for (int i = 0; i < this->numFragmentStages(); i++) { 363 for (int i = 0; i < this->numFragmentStages(); i++) {
362 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), 364 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i),
363 explicitLocalCoords)) { 365 explicitLocalCoords)) {
364 return false; 366 return false;
365 } 367 }
366 } 368 }
367 return true; 369 return true;
368 } 370 }
369 371
OLDNEW
« no previous file with comments | « src/gpu/GrInvariantOutput.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698