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

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

Issue 719203002: Add GrProcOptInfo class to track various output information for color and coverage stages. (Closed) Base URL: https://skia.googlesource.com/skia.git@moveIO
Patch Set: initialize values 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/GrPaint.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 #include "GrProcOptInfo.h"
15 15
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
17 BlendOptFlags blendOptFlags, 17 BlendOptFlags blendOptFlags,
18 GrBlendCoeff optSrcCoeff, 18 GrBlendCoeff optSrcCoeff,
19 GrBlendCoeff optDstCoeff, 19 GrBlendCoeff optDstCoeff,
20 GrGpu* gpu, 20 GrGpu* gpu,
21 const GrDeviceCoordTexture* dstCopy, 21 const GrDeviceCoordTexture* dstCopy,
22 GrGpu::DrawType drawType) { 22 GrGpu::DrawType drawType) {
23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); 23 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType);
24 fColor = drawState.getColor(); 24 fColor = drawState.getColor();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } else { 232 } else {
233 if (ds.vertexColorsAreOpaque()) { 233 if (ds.vertexColorsAreOpaque()) {
234 color = 0xFF << GrColor_SHIFT_A; 234 color = 0xFF << GrColor_SHIFT_A;
235 flags = kA_GrColorComponentFlag; 235 flags = kA_GrColorComponentFlag;
236 } else { 236 } else {
237 flags = static_cast<GrColorComponentFlags>(0); 237 flags = static_cast<GrColorComponentFlags>(0);
238 // 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.
239 color = 0; 239 color = 0;
240 } 240 }
241 } 241 }
242 GrInvariantOutput inout(color, flags, false); 242 GrProcOptInfo poi;
243 243 if (ds.numColorStages() > 0) {
244 for (int i = 0; i < ds.numColorStages(); ++i) { 244 poi.calcWithInitialValues(&ds.getColorStage(0), ds.numColorStages(), col or, flags, false);
245 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); 245 *firstColorStageIdx = poi.firstEffectiveStageIndex();
246 fp->computeInvariantOutput(&inout); 246 descInfo->fInputColorIsUsed = poi.inputColorIsUsed();
247 if (!inout.willUseInputColor()) { 247 fColor = poi.inputColorToEffectiveStage();
248 *firstColorStageIdx = i; 248 if (poi.removeVertexAttrib()) {
249 descInfo->fInputColorIsUsed = false;
250 }
251 if (kRGBA_GrColorComponentFlags == inout.validFlags()) {
252 *firstColorStageIdx = i + 1;
253 fColor = inout.color();
254 descInfo->fInputColorIsUsed = true;
255 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; 249 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
256 // Since we are clearing all previous color stages we are in a state where we have found
257 // zero stages that don't multiply the inputColor.
258 inout.resetNonMulStageFound();
259 } 250 }
260 } 251 }
261 } 252 }
262 253
263 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, 254 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds,
264 GrProgramDesc::DescInfo* des cInfo, 255 GrProgramDesc::DescInfo* des cInfo,
265 int* firstCoverageStageIdx) { 256 int* firstCoverageStageIdx) {
266 // We do not try to optimize out constantColor coverage effects here. It is extremely rare 257 // We do not try to optimize out constantColor coverage effects here. It is extremely rare
267 // to have a coverage effect that returns a constant value for all four chan nels. Thus we 258 // to have a coverage effect that returns a constant value for all four chan nels. Thus we
268 // save having to make extra virtual calls by not checking for it. 259 // save having to make extra virtual calls by not checking for it.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; 353 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1;
363 for (int i = 0; i < this->numFragmentStages(); i++) { 354 for (int i = 0; i < this->numFragmentStages(); i++) {
364 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), 355 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i),
365 explicitLocalCoords)) { 356 explicitLocalCoords)) {
366 return false; 357 return false;
367 } 358 }
368 } 359 }
369 return true; 360 return true;
370 } 361 }
371 362
OLDNEW
« no previous file with comments | « src/gpu/GrInvariantOutput.cpp ('k') | src/gpu/GrPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698