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

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

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: nvpr bug fixed 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
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"
11 #include "GrOptDrawState.h" 11 #include "GrOptDrawState.h"
12 #include "GrPaint.h" 12 #include "GrPaint.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrXferProcessor.h" 14 #include "GrXferProcessor.h"
15 #include "effects/GrPorterDuffXferProcessor.h" 15 #include "effects/GrPorterDuffXferProcessor.h"
16 16
17 /////////////////////////////////////////////////////////////////////////////// 17 ///////////////////////////////////////////////////////////////////////////////
18 18
19 bool GrDrawState::isEqual(const GrDrawState& that) const { 19 bool GrDrawState::isEqual(const GrDrawState& that) const {
20 bool usingVertexColors = this->hasColorVertexAttribute();
21 if (!usingVertexColors && this->fColor != that.fColor) {
22 return false;
23 }
24
25 if (this->getRenderTarget() != that.getRenderTarget() || 20 if (this->getRenderTarget() != that.getRenderTarget() ||
26 this->fColorStages.count() != that.fColorStages.count() || 21 this->fColorStages.count() != that.fColorStages.count() ||
27 this->fCoverageStages.count() != that.fCoverageStages.count() || 22 this->fCoverageStages.count() != that.fCoverageStages.count() ||
28 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || 23 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
29 this->fSrcBlend != that.fSrcBlend || 24 this->fSrcBlend != that.fSrcBlend ||
30 this->fDstBlend != that.fDstBlend || 25 this->fDstBlend != that.fDstBlend ||
31 this->fBlendConstant != that.fBlendConstant || 26 this->fBlendConstant != that.fBlendConstant ||
32 this->fFlagBits != that.fFlagBits || 27 this->fFlagBits != that.fFlagBits ||
33 this->fStencilSettings != that.fStencilSettings || 28 this->fStencilSettings != that.fStencilSettings ||
34 this->fDrawFace != that.fDrawFace) { 29 this->fDrawFace != that.fDrawFace) {
35 return false; 30 return false;
36 } 31 }
37 32
38 bool usingVertexCoverage = this->hasCoverageVertexAttribute();
39 if (!usingVertexCoverage && this->fCoverage != that.fCoverage) {
40 return false;
41 }
42
43 bool explicitLocalCoords = this->hasLocalCoordAttribute(); 33 bool explicitLocalCoords = this->hasLocalCoordAttribute();
44 if (this->hasGeometryProcessor()) { 34 if (this->hasGeometryProcessor()) {
45 if (!that.hasGeometryProcessor()) { 35 if (!that.hasGeometryProcessor()) {
46 return false; 36 return false;
47 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) { 37 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce ssor())) {
48 return false; 38 return false;
49 } 39 }
50 } else if (that.hasGeometryProcessor()) { 40 } else if (that.hasGeometryProcessor()) {
51 return false; 41 return false;
52 } 42 }
(...skipping 24 matching lines...) Expand all
77 fColorStages[i].localCoordChange(preConcatMatrix); 67 fColorStages[i].localCoordChange(preConcatMatrix);
78 } 68 }
79 for (int i = 0; i < this->numCoverageStages(); ++i) { 69 for (int i = 0; i < this->numCoverageStages(); ++i) {
80 fCoverageStages[i].localCoordChange(preConcatMatrix); 70 fCoverageStages[i].localCoordChange(preConcatMatrix);
81 } 71 }
82 } 72 }
83 } 73 }
84 74
85 GrDrawState& GrDrawState::operator=(const GrDrawState& that) { 75 GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
86 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); 76 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
87 fColor = that.fColor;
88 fViewMatrix = that.fViewMatrix; 77 fViewMatrix = that.fViewMatrix;
89 fSrcBlend = that.fSrcBlend; 78 fSrcBlend = that.fSrcBlend;
90 fDstBlend = that.fDstBlend; 79 fDstBlend = that.fDstBlend;
91 fBlendConstant = that.fBlendConstant; 80 fBlendConstant = that.fBlendConstant;
92 fFlagBits = that.fFlagBits; 81 fFlagBits = that.fFlagBits;
93 fStencilSettings = that.fStencilSettings; 82 fStencilSettings = that.fStencilSettings;
94 fCoverage = that.fCoverage;
95 fDrawFace = that.fDrawFace; 83 fDrawFace = that.fDrawFace;
96 fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get())); 84 fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get()));
97 fXPFactory.reset(SkRef(that.getXPFactory())); 85 fXPFactory.reset(SkRef(that.getXPFactory()));
98 fColorStages = that.fColorStages; 86 fColorStages = that.fColorStages;
99 fCoverageStages = that.fCoverageStages; 87 fCoverageStages = that.fCoverageStages;
100 88
101 fHints = that.fHints; 89 fHints = that.fHints;
102 90
103 fColorProcInfoValid = that.fColorProcInfoValid; 91 fColorProcInfoValid = that.fColorProcInfoValid;
104 fCoverageProcInfoValid = that.fCoverageProcInfoValid; 92 fCoverageProcInfoValid = that.fCoverageProcInfoValid;
105 if (fColorProcInfoValid) { 93 if (fColorProcInfoValid) {
106 fColorProcInfo = that.fColorProcInfo; 94 fColorProcInfo = that.fColorProcInfo;
107 } 95 }
108 if (fCoverageProcInfoValid) { 96 if (fCoverageProcInfoValid) {
109 fCoverageProcInfo = that.fCoverageProcInfo; 97 fCoverageProcInfo = that.fCoverageProcInfo;
110 } 98 }
111 return *this; 99 return *this;
112 } 100 }
113 101
114 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { 102 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
115 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); 103 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
116 fRenderTarget.reset(NULL); 104 fRenderTarget.reset(NULL);
117 105
118 fGeometryProcessor.reset(NULL); 106 fGeometryProcessor.reset(NULL);
119 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); 107 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
120 fColorStages.reset(); 108 fColorStages.reset();
121 fCoverageStages.reset(); 109 fCoverageStages.reset();
122 110
123 fColor = 0xffffffff;
124 if (NULL == initialViewMatrix) { 111 if (NULL == initialViewMatrix) {
125 fViewMatrix.reset(); 112 fViewMatrix.reset();
126 } else { 113 } else {
127 fViewMatrix = *initialViewMatrix; 114 fViewMatrix = *initialViewMatrix;
128 } 115 }
129 fSrcBlend = kOne_GrBlendCoeff; 116 fSrcBlend = kOne_GrBlendCoeff;
130 fDstBlend = kZero_GrBlendCoeff; 117 fDstBlend = kZero_GrBlendCoeff;
131 fBlendConstant = 0x0; 118 fBlendConstant = 0x0;
132 fFlagBits = 0x0; 119 fFlagBits = 0x0;
133 fStencilSettings.setDisabled(); 120 fStencilSettings.setDisabled();
134 fCoverage = 0xff;
135 fDrawFace = kBoth_DrawFace; 121 fDrawFace = kBoth_DrawFace;
136 122
137 fHints = 0; 123 fHints = 0;
138 124
139 fColorProcInfoValid = false; 125 fColorProcInfoValid = false;
140 fCoverageProcInfoValid = false; 126 fCoverageProcInfoValid = false;
141 } 127 }
142 128
143 bool GrDrawState::setIdentityViewMatrix() { 129 bool GrDrawState::setIdentityViewMatrix() {
144 if (this->numFragmentStages()) { 130 if (this->numFragmentStages()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // These have no equivalent in GrPaint, set them to defaults 169 // These have no equivalent in GrPaint, set them to defaults
184 fBlendConstant = 0x0; 170 fBlendConstant = 0x0;
185 fDrawFace = kBoth_DrawFace; 171 fDrawFace = kBoth_DrawFace;
186 fStencilSettings.setDisabled(); 172 fStencilSettings.setDisabled();
187 fFlagBits = 0; 173 fFlagBits = 0;
188 fHints = 0; 174 fHints = 0;
189 175
190 // Enable the clip bit 176 // Enable the clip bit
191 this->enableState(GrDrawState::kClip_StateBit); 177 this->enableState(GrDrawState::kClip_StateBit);
192 178
193 this->setColor(paint.getColor());
194 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); 179 this->setState(GrDrawState::kDither_StateBit, paint.isDither());
195 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); 180 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias());
196 181
197 this->setCoverage(0xFF);
198 fColorProcInfoValid = false; 182 fColorProcInfoValid = false;
199 fCoverageProcInfoValid = false; 183 fCoverageProcInfoValid = false;
200 } 184 }
201 185
202 //////////////////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////////////////
203 187
204 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { 188 bool GrDrawState::couldApplyCoverage(GrColor color, GrColor coverage,
189 const GrDrawTargetCaps& caps) const {
205 if (caps.dualSourceBlendingSupport()) { 190 if (caps.dualSourceBlendingSupport()) {
206 return true; 191 return true;
207 } 192 }
208 // we can correctly apply coverage if a) we have dual source blending 193 // we can correctly apply coverage if a) we have dual source blending
209 // or b) one of our blend optimizations applies 194 // or b) one of our blend optimizations applies
210 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color 195 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color
211 GrBlendCoeff srcCoeff; 196 GrBlendCoeff srcCoeff;
212 GrBlendCoeff dstCoeff; 197 GrBlendCoeff dstCoeff;
213 BlendOpt opt = this->getBlendOpt(true, &srcCoeff, &dstCoeff); 198 BlendOpt opt = this->getBlendOpt(color, coverage, true, &srcCoeff, &dstCoeff );
214 return GrDrawState::kNone_BlendOpt != opt || 199 return GrDrawState::kNone_BlendOpt != opt ||
215 (this->willEffectReadDstColor() && 200 (this->willEffectReadDstColor(color, coverage) &&
216 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); 201 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
217 } 202 }
218 203
219 bool GrDrawState::hasSolidCoverage() const { 204 bool GrDrawState::hasSolidCoverage(GrColor coverage) const {
220 // If we're drawing coverage directly then coverage is effectively treated a s color. 205 // If we're drawing coverage directly then coverage is effectively treated a s color.
221 if (this->isCoverageDrawing()) { 206 if (this->isCoverageDrawing()) {
222 return true; 207 return true;
223 } 208 }
224 209
225 if (this->numCoverageStages() > 0) { 210 if (this->numCoverageStages() > 0) {
226 return false; 211 return false;
227 } 212 }
228 213
229 this->calcCoverageInvariantOutput(); 214 this->calcCoverageInvariantOutput(coverage);
230 return fCoverageProcInfo.isSolidWhite(); 215 return fCoverageProcInfo.isSolidWhite();
231 } 216 }
232 217
233 //////////////////////////////////////////////////////////////////////////////s 218 //////////////////////////////////////////////////////////////////////////////s
234 219
235 bool GrDrawState::willEffectReadDstColor() const { 220 bool GrDrawState::willEffectReadDstColor(GrColor color, GrColor coverage) const {
236 if (!this->isColorWriteDisabled()) { 221 if (!this->isColorWriteDisabled()) {
237 this->calcColorInvariantOutput(); 222 this->calcColorInvariantOutput(color);
238 if (fColorProcInfo.readsDst()) { 223 if (fColorProcInfo.readsDst()) {
239 return true; 224 return true;
240 } 225 }
241 } 226 }
242 this->calcCoverageInvariantOutput(); 227 this->calcCoverageInvariantOutput(coverage);
243 return fCoverageProcInfo.readsDst(); 228 return fCoverageProcInfo.readsDst();
244 } 229 }
245 230
246 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { 231 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
247 if (fDrawState) { 232 if (fDrawState) {
248 // See the big comment on the class definition about GPs. 233 // See the big comment on the class definition about GPs.
249 if (SK_InvalidUniqueID == fOriginalGPID) { 234 if (SK_InvalidUniqueID == fOriginalGPID) {
250 fDrawState->fGeometryProcessor.reset(NULL); 235 fDrawState->fGeometryProcessor.reset(NULL);
251 } else { 236 } else {
252 SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() == 237 SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() ==
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 374 }
390 375
391 //////////////////////////////////////////////////////////////////////////////// 376 ////////////////////////////////////////////////////////////////////////////////
392 377
393 GrDrawState::~GrDrawState() { 378 GrDrawState::~GrDrawState() {
394 SkASSERT(0 == fBlockEffectRemovalCnt); 379 SkASSERT(0 == fBlockEffectRemovalCnt);
395 } 380 }
396 381
397 //////////////////////////////////////////////////////////////////////////////// 382 ////////////////////////////////////////////////////////////////////////////////
398 383
399 GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage, 384 GrDrawState::BlendOpt GrDrawState::getBlendOpt(GrColor color,
385 GrColor coverage,
386 bool forceCoverage,
400 GrBlendCoeff* srcCoeff, 387 GrBlendCoeff* srcCoeff,
401 GrBlendCoeff* dstCoeff) const { 388 GrBlendCoeff* dstCoeff) const {
402 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; 389 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff;
403 if (NULL == srcCoeff) { 390 if (NULL == srcCoeff) {
404 srcCoeff = &bogusSrcCoeff; 391 srcCoeff = &bogusSrcCoeff;
405 } 392 }
406 if (NULL == dstCoeff) { 393 if (NULL == dstCoeff) {
407 dstCoeff = &bogusDstCoeff; 394 dstCoeff = &bogusDstCoeff;
408 } 395 }
409 396
410 *srcCoeff = this->getSrcBlendCoeff(); 397 *srcCoeff = this->getSrcBlendCoeff();
411 *dstCoeff = this->getDstBlendCoeff(); 398 *dstCoeff = this->getDstBlendCoeff();
412 399
413 if (this->isColorWriteDisabled()) { 400 if (this->isColorWriteDisabled()) {
414 *srcCoeff = kZero_GrBlendCoeff; 401 *srcCoeff = kZero_GrBlendCoeff;
415 *dstCoeff = kOne_GrBlendCoeff; 402 *dstCoeff = kOne_GrBlendCoeff;
416 } 403 }
417 404
418 bool srcAIsOne = this->srcAlphaWillBeOne(); 405 bool srcAIsOne = this->srcAlphaWillBeOne(color, coverage);
419 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff || 406 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff ||
420 (kSA_GrBlendCoeff == *dstCoeff && srcAIsOne); 407 (kSA_GrBlendCoeff == *dstCoeff && srcAIsOne);
421 bool dstCoeffIsZero = kZero_GrBlendCoeff == *dstCoeff || 408 bool dstCoeffIsZero = kZero_GrBlendCoeff == *dstCoeff ||
422 (kISA_GrBlendCoeff == *dstCoeff && srcAIsOne); 409 (kISA_GrBlendCoeff == *dstCoeff && srcAIsOne);
423 410
424 // When coeffs are (0,1) there is no reason to draw at all, unless 411 // When coeffs are (0,1) there is no reason to draw at all, unless
425 // stenciling is enabled. Having color writes disabled is effectively 412 // stenciling is enabled. Having color writes disabled is effectively
426 // (0,1). 413 // (0,1).
427 if ((kZero_GrBlendCoeff == *srcCoeff && dstCoeffIsOne)) { 414 if ((kZero_GrBlendCoeff == *srcCoeff && dstCoeffIsOne)) {
428 if (this->getStencil().doesWrite()) { 415 if (this->getStencil().doesWrite()) {
429 return kEmitCoverage_BlendOpt; 416 return kEmitCoverage_BlendOpt;
430 } else { 417 } else {
431 *dstCoeff = kOne_GrBlendCoeff; 418 *dstCoeff = kOne_GrBlendCoeff;
432 return kSkipDraw_BlendOpt; 419 return kSkipDraw_BlendOpt;
433 } 420 }
434 } 421 }
435 422
436 bool hasCoverage = forceCoverage || !this->hasSolidCoverage(); 423 bool hasCoverage = forceCoverage || !this->hasSolidCoverage(coverage);
437 424
438 // if we don't have coverage we can check whether the dst 425 // if we don't have coverage we can check whether the dst
439 // has to read at all. If not, we'll disable blending. 426 // has to read at all. If not, we'll disable blending.
440 if (!hasCoverage) { 427 if (!hasCoverage) {
441 if (dstCoeffIsZero) { 428 if (dstCoeffIsZero) {
442 if (kOne_GrBlendCoeff == *srcCoeff) { 429 if (kOne_GrBlendCoeff == *srcCoeff) {
443 // if there is no coverage and coeffs are (1,0) then we 430 // if there is no coverage and coeffs are (1,0) then we
444 // won't need to read the dst at all, it gets replaced by src 431 // won't need to read the dst at all, it gets replaced by src
445 *dstCoeff = kZero_GrBlendCoeff; 432 *dstCoeff = kZero_GrBlendCoeff;
446 return kNone_BlendOpt; 433 return kNone_BlendOpt;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // the dst coeff is effectively one so blend works out to: 467 // the dst coeff is effectively one so blend works out to:
481 // cS + (c)(1)D + (1-c)D = cS + D. 468 // cS + (c)(1)D + (1-c)D = cS + D.
482 *dstCoeff = kOne_GrBlendCoeff; 469 *dstCoeff = kOne_GrBlendCoeff;
483 return kCoverageAsAlpha_BlendOpt; 470 return kCoverageAsAlpha_BlendOpt;
484 } 471 }
485 } 472 }
486 473
487 return kNone_BlendOpt; 474 return kNone_BlendOpt;
488 } 475 }
489 476
490 bool GrDrawState::srcAlphaWillBeOne() const { 477 bool GrDrawState::srcAlphaWillBeOne(GrColor color, GrColor coverage) const {
491 this->calcColorInvariantOutput(); 478 this->calcColorInvariantOutput(color);
492 if (this->isCoverageDrawing()) { 479 if (this->isCoverageDrawing()) {
493 this->calcCoverageInvariantOutput(); 480 this->calcCoverageInvariantOutput(coverage);
494 return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque()); 481 return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque());
495 } 482 }
496 return fColorProcInfo.isOpaque(); 483 return fColorProcInfo.isOpaque();
497 } 484 }
498 485
499 bool GrDrawState::willBlendWithDst() const { 486 bool GrDrawState::willBlendWithDst(GrColor color, GrColor coverage) const {
500 if (!this->hasSolidCoverage()) { 487 if (!this->hasSolidCoverage(coverage)) {
501 return true; 488 return true;
502 } 489 }
503 490
504 if (this->willEffectReadDstColor()) { 491 if (this->willEffectReadDstColor(color, coverage)) {
505 return true; 492 return true;
506 } 493 }
507 494
508 if (GrBlendCoeffRefsDst(this->getSrcBlendCoeff())) { 495 if (GrBlendCoeffRefsDst(this->getSrcBlendCoeff())) {
509 return true; 496 return true;
510 } 497 }
511 498
512 GrBlendCoeff dstCoeff = this->getDstBlendCoeff(); 499 GrBlendCoeff dstCoeff = this->getDstBlendCoeff();
513 if (!(kZero_GrBlendCoeff == dstCoeff || 500 if (!(kZero_GrBlendCoeff == dstCoeff ||
514 (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne()))) { 501 (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne(color, covera ge)))) {
515 return true; 502 return true;
516 } 503 }
517 504
518 return false; 505 return false;
519 } 506 }
520 507
521 void GrDrawState::calcColorInvariantOutput() const { 508 void GrDrawState::calcColorInvariantOutput(GrColor color) const {
522 if (!fColorProcInfoValid) { 509 if (!fColorProcInfoValid || color != fColorCache) {
523 GrColor color;
524 GrColorComponentFlags flags; 510 GrColorComponentFlags flags;
525 if (this->hasColorVertexAttribute()) { 511 if (this->hasColorVertexAttribute()) {
526 if (fHints & kVertexColorsAreOpaque_Hint) { 512 if (fHints & kVertexColorsAreOpaque_Hint) {
527 flags = kA_GrColorComponentFlag; 513 flags = kA_GrColorComponentFlag;
528 color = 0xFF << GrColor_SHIFT_A; 514 color = 0xFF << GrColor_SHIFT_A;
529 } else { 515 } else {
530 flags = static_cast<GrColorComponentFlags>(0); 516 flags = static_cast<GrColorComponentFlags>(0);
531 color = 0; 517 color = 0;
532 } 518 }
533 } else { 519 } else {
534 flags = kRGBA_GrColorComponentFlags; 520 flags = kRGBA_GrColorComponentFlags;
535 color = this->getColor();
536 } 521 }
537 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo rStages(), 522 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo rStages(),
538 color, flags, false); 523 color, flags, false);
539 fColorProcInfoValid = true; 524 fColorProcInfoValid = true;
525 fColorCache = color;
540 } 526 }
541 } 527 }
542 528
543 void GrDrawState::calcCoverageInvariantOutput() const { 529 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
544 if (!fCoverageProcInfoValid) { 530 if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
545 GrColor color;
546 GrColorComponentFlags flags; 531 GrColorComponentFlags flags;
547 // Check if per-vertex or constant color may have partial alpha 532 // Check if per-vertex or constant color may have partial alpha
548 if (this->hasCoverageVertexAttribute()) { 533 if (this->hasCoverageVertexAttribute()) {
549 flags = static_cast<GrColorComponentFlags>(0); 534 flags = static_cast<GrColorComponentFlags>(0);
550 color = 0; 535 coverage = 0;
551 } else { 536 } else {
552 flags = kRGBA_GrColorComponentFlags; 537 flags = kRGBA_GrColorComponentFlags;
553 color = this->getCoverageColor();
554 } 538 }
555 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->n umCoverageStages(), 539 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->n umCoverageStages(),
556 color, flags, true, fGeometryPro cessor.get()); 540 coverage, flags, true, fGeometry Processor.get());
557 fCoverageProcInfoValid = true; 541 fCoverageProcInfoValid = true;
542 fCoverageCache = coverage;
558 } 543 }
559 } 544 }
560 545
OLDNEW
« src/gpu/GrDrawState.h ('K') | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698