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

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

Issue 808813002: Add Coverage Drawing XP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits 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/GrDrawState.h ('k') | src/gpu/GrOptDrawState.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 2012 Google Inc. 2 * Copyright 2012 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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 9
10 #include "GrBlend.h" 10 #include "GrBlend.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return true; 178 return true;
179 } 179 }
180 180
181 this->calcColorInvariantOutput(color); 181 this->calcColorInvariantOutput(color);
182 182
183 // The coverage isn't actually white, its unknown, but this will produce the same effect 183 // The coverage isn't actually white, its unknown, but this will produce the same effect
184 // TODO we want to cache the result of this call, but we can probably clean up the interface 184 // TODO we want to cache the result of this call, but we can probably clean up the interface
185 // so we don't have to pass in a seemingly known coverage 185 // so we don't have to pass in a seemingly known coverage
186 this->calcCoverageInvariantOutput(GrColor_WHITE); 186 this->calcCoverageInvariantOutput(GrColor_WHITE);
187 return fXPFactory->canApplyCoverage(fColorProcInfo, fCoverageProcInfo, 187 return fXPFactory->canApplyCoverage(fColorProcInfo, fCoverageProcInfo,
188 this->isCoverageDrawing(), this->isColor WriteDisabled()); 188 this->isColorWriteDisabled());
189 }
190
191 bool GrDrawState::hasSolidCoverage(const GrPrimitiveProcessor* pp) const {
192 // If we're drawing coverage directly then coverage is effectively treated a s color.
193 if (this->isCoverageDrawing()) {
194 return true;
195 }
196
197 if (this->numCoverageStages() > 0) {
198 return false;
199 }
200
201 this->calcCoverageInvariantOutput(pp);
202 return fCoverageProcInfo.isSolidWhite();
203 } 189 }
204 190
205 //////////////////////////////////////////////////////////////////////////////s 191 //////////////////////////////////////////////////////////////////////////////s
206 192
207 bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const { 193 bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const {
208 this->calcColorInvariantOutput(pp); 194 this->calcColorInvariantOutput(pp);
209 this->calcCoverageInvariantOutput(pp); 195 this->calcCoverageInvariantOutput(pp);
210 // TODO: Remove need to create the XP here. 196 // TODO: Remove need to create the XP here.
211 // Also once all custom blends are turned into XPs we can remove the n eed 197 // Also once all custom blends are turned into XPs we can remove the n eed
212 // to check other stages since only xp's will be able to read dst 198 // to check other stages since only xp's will be able to read dst
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 fCoverageEffectCnt = ds->numCoverageStages(); 231 fCoverageEffectCnt = ds->numCoverageStages();
246 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) 232 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
247 } 233 }
248 } 234 }
249 235
250 //////////////////////////////////////////////////////////////////////////////// 236 ////////////////////////////////////////////////////////////////////////////////
251 237
252 // Some blend modes allow folding a fractional coverage value into the color's a lpha channel, while 238 // Some blend modes allow folding a fractional coverage value into the color's a lpha channel, while
253 // others will blend incorrectly. 239 // others will blend incorrectly.
254 bool GrDrawState::canTweakAlphaForCoverage() const { 240 bool GrDrawState::canTweakAlphaForCoverage() const {
255 return fXPFactory->canTweakAlphaForCoverage(this->isCoverageDrawing()); 241 return fXPFactory->canTweakAlphaForCoverage();
256 } 242 }
257 243
258 //////////////////////////////////////////////////////////////////////////////// 244 ////////////////////////////////////////////////////////////////////////////////
259 245
260 void GrDrawState::AutoViewMatrixRestore::restore() { 246 void GrDrawState::AutoViewMatrixRestore::restore() {
261 if (fDrawState) { 247 if (fDrawState) {
262 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) 248 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;)
263 fDrawState->fViewMatrix = fViewMatrix; 249 fDrawState->fViewMatrix = fViewMatrix;
264 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); 250 SkASSERT(fDrawState->numColorStages() >= fNumColorStages);
265 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; 251 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 GrDrawState::~GrDrawState() { 333 GrDrawState::~GrDrawState() {
348 SkASSERT(0 == fBlockEffectRemovalCnt); 334 SkASSERT(0 == fBlockEffectRemovalCnt);
349 } 335 }
350 336
351 //////////////////////////////////////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////////////
352 338
353 bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const { 339 bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
354 this->calcColorInvariantOutput(pp); 340 this->calcColorInvariantOutput(pp);
355 this->calcCoverageInvariantOutput(pp); 341 this->calcCoverageInvariantOutput(pp);
356 return fXPFactory->willBlendWithDst(fColorProcInfo, fCoverageProcInfo, 342 return fXPFactory->willBlendWithDst(fColorProcInfo, fCoverageProcInfo,
357 this->isCoverageDrawing(), this->isColor WriteDisabled()); 343 this->isColorWriteDisabled());
358 } 344 }
359 345
360 void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const { 346 void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
361 if (!fColorProcInfoValid || fColorPrimProc != pp) { 347 if (!fColorProcInfoValid || fColorPrimProc != pp) {
362 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->num ColorStages()); 348 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->num ColorStages());
363 fColorProcInfoValid = true; 349 fColorProcInfoValid = true;
364 fColorPrimProc = pp; 350 fColorPrimProc = pp;
365 } 351 }
366 } 352 }
367 353
(...skipping 19 matching lines...) Expand all
387 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const { 373 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
388 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { 374 if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
389 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; 375 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
390 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), 376 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(),
391 this->numCoverageStages(), cover age, flags, 377 this->numCoverageStages(), cover age, flags,
392 true); 378 true);
393 fCoverageProcInfoValid = true; 379 fCoverageProcInfoValid = true;
394 fCoverageCache = coverage; 380 fCoverageCache = coverage;
395 } 381 }
396 } 382 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698