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

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

Issue 791143002: Fix to set correct output type when blending when we've read dst (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merging follow up fix cls 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/GrOptDrawState.h ('k') | src/gpu/GrProcessor.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 "GrDrawState.h" 10 #include "GrDrawState.h"
(...skipping 26 matching lines...) Expand all
37 GrXferProcessor::OptFlags optFlags; 37 GrXferProcessor::OptFlags optFlags;
38 if (xferProcessor) { 38 if (xferProcessor) {
39 fXferProcessor.reset(xferProcessor.get()); 39 fXferProcessor.reset(xferProcessor.get());
40 40
41 optFlags = xferProcessor->getOptimizations(colorPOI, 41 optFlags = xferProcessor->getOptimizations(colorPOI,
42 coveragePOI, 42 coveragePOI,
43 drawState.isCoverageDrawing() , 43 drawState.isCoverageDrawing() ,
44 drawState.isColorWriteDisable d(), 44 drawState.isColorWriteDisable d(),
45 drawState.getStencil().doesWr ite(), 45 drawState.getStencil().doesWr ite(),
46 &fColor, 46 &fColor,
47 &fCoverage); 47 &fCoverage,
48 caps);
48 } 49 }
49 50
50 // When path rendering the stencil settings are not always set on the draw s tate 51 // When path rendering the stencil settings are not always set on the draw s tate
51 // so we must check the draw type. In cases where we will skip drawing we si mply return a 52 // so we must check the draw type. In cases where we will skip drawing we si mply return a
52 // null GrOptDrawState. 53 // null GrOptDrawState.
53 if (!xferProcessor || ((GrXferProcessor::kSkipDraw_OptFlag & optFlags) && 54 if (!xferProcessor || ((GrXferProcessor::kSkipDraw_OptFlag & optFlags) &&
54 GrGpu::kStencilPath_DrawType != drawType)) { 55 GrGpu::kStencilPath_DrawType != drawType)) {
55 // Set the fields that don't default init and return. The lack of a rend er target will 56 // Set the fields that don't default init and return. The lack of a rend er target will
56 // indicate that this can be skipped. 57 // indicate that this can be skipped.
57 fFlags = 0; 58 fFlags = 0;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 140
140 // let the GP init the batch tracker 141 // let the GP init the batch tracker
141 if (drawState.hasGeometryProcessor()) { 142 if (drawState.hasGeometryProcessor()) {
142 GrGeometryProcessor::InitBT init; 143 GrGeometryProcessor::InitBT init;
143 init.fOutputColor = fDescInfo.fInputColorIsUsed; 144 init.fOutputColor = fDescInfo.fInputColorIsUsed;
144 init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed; 145 init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed;
145 init.fColor = this->getColor(); 146 init.fColor = this->getColor();
146 init.fCoverage = this->getCoverage(); 147 init.fCoverage = this->getCoverage();
147 fGeometryProcessor->initBatchTracker(&fBatchTracker, init); 148 fGeometryProcessor->initBatchTracker(&fBatchTracker, init);
148 } 149 }
149
150 this->setOutputStateInfo(drawState, coverageColor, optFlags, caps);
151 }
152
153 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
154 GrColor coverage,
155 GrXferProcessor::OptFlags optFlags,
156 const GrDrawTargetCaps& caps) {
157 // Set this default and then possibly change our mind if there is coverage.
158 fDescInfo.fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
159 fDescInfo.fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
160
161 // Determine whether we should use dual source blending or shader code to ke ep coverage
162 // separate from color.
163 bool keepCoverageSeparate = !(optFlags & GrXferProcessor::kSetCoverageDrawin g_OptFlag);
164 if (keepCoverageSeparate && !ds.hasSolidCoverage(coverage)) {
165 if (caps.dualSourceBlendingSupport()) {
166 if (kZero_GrBlendCoeff == fDstBlend) {
167 // write the coverage value to second color
168 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverage_Second aryOutputType;
169 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
170 } else if (kSA_GrBlendCoeff == fDstBlend) {
171 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
172 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISA_Sec ondaryOutputType;
173 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
174 } else if (kSC_GrBlendCoeff == fDstBlend) {
175 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
176 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISC_Sec ondaryOutputType;
177 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
178 }
179 } else if (fDescInfo.fReadsDst &&
180 kOne_GrBlendCoeff == fSrcBlend &&
181 kZero_GrBlendCoeff == fDstBlend) {
182 fDescInfo.fPrimaryOutputType = GrProgramDesc::kCombineWithDst_Primar yOutputType;
183 }
184 }
185 } 150 }
186 151
187 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, 152 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
188 GrXferProcessor::OptFlags fl ags, 153 GrXferProcessor::OptFlags fl ags,
189 const GrProcOptInfo& colorPO I, 154 const GrProcOptInfo& colorPO I,
190 const GrProcOptInfo& coverag ePOI, 155 const GrProcOptInfo& coverag ePOI,
191 int* firstColorStageIdx, 156 int* firstColorStageIdx,
192 int* firstCoverageStageIdx) { 157 int* firstCoverageStageIdx) {
193 fDescInfo.fReadsDst = false; 158 fDescInfo.fReadsDst = false;
194 fDescInfo.fReadsFragPosition = false; 159 fDescInfo.fReadsFragPosition = false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (this->hasGeometryProcessor()) { 220 if (this->hasGeometryProcessor()) {
256 if (!that.hasGeometryProcessor()) { 221 if (!that.hasGeometryProcessor()) {
257 return false; 222 return false;
258 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) { 223 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) {
259 return false; 224 return false;
260 } 225 }
261 } else if (that.hasGeometryProcessor()) { 226 } else if (that.hasGeometryProcessor()) {
262 return false; 227 return false;
263 } 228 }
264 229
230 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) {
231 return false;
232 }
233
265 // The program desc comparison should have already assured that the stage co unts match. 234 // The program desc comparison should have already assured that the stage co unts match.
266 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); 235 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
267 for (int i = 0; i < this->numFragmentStages(); i++) { 236 for (int i = 0; i < this->numFragmentStages(); i++) {
268 237
269 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { 238 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
270 return false; 239 return false;
271 } 240 }
272 } 241 }
273 return true; 242 return true;
274 } 243 }
275 244
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698