OLD | NEW |
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 "GrInvariantOutput.h" | |
12 #include "GrOptDrawState.h" | 11 #include "GrOptDrawState.h" |
13 #include "GrPaint.h" | 12 #include "GrPaint.h" |
| 13 #include "GrProcOptInfo.h" |
14 | 14 |
15 //////////////////////////////////////////////////////////////////////////////s | 15 //////////////////////////////////////////////////////////////////////////////s |
16 | 16 |
17 bool GrDrawState::isEqual(const GrDrawState& that) const { | 17 bool GrDrawState::isEqual(const GrDrawState& that) const { |
18 bool usingVertexColors = this->hasColorVertexAttribute(); | 18 bool usingVertexColors = this->hasColorVertexAttribute(); |
19 if (!usingVertexColors && this->fColor != that.fColor) { | 19 if (!usingVertexColors && this->fColor != that.fColor) { |
20 return false; | 20 return false; |
21 } | 21 } |
22 | 22 |
23 if (this->getRenderTarget() != that.getRenderTarget() || | 23 if (this->getRenderTarget() != that.getRenderTarget() || |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (that.hasGeometryProcessor()) { | 144 if (that.hasGeometryProcessor()) { |
145 fGeometryProcessor.initAndRef(that.fGeometryProcessor); | 145 fGeometryProcessor.initAndRef(that.fGeometryProcessor); |
146 } else { | 146 } else { |
147 fGeometryProcessor.reset(NULL); | 147 fGeometryProcessor.reset(NULL); |
148 } | 148 } |
149 fColorStages = that.fColorStages; | 149 fColorStages = that.fColorStages; |
150 fCoverageStages = that.fCoverageStages; | 150 fCoverageStages = that.fCoverageStages; |
151 | 151 |
152 fHints = that.fHints; | 152 fHints = that.fHints; |
153 | 153 |
| 154 fColorProcInfoValid = that.fColorProcInfoValid; |
| 155 fCoverageProcInfoValid = that.fCoverageProcInfoValid; |
| 156 if (fColorProcInfoValid) { |
| 157 fColorProcInfo = that.fColorProcInfo; |
| 158 } |
| 159 if (fCoverageProcInfoValid) { |
| 160 fCoverageProcInfo = that.fCoverageProcInfo; |
| 161 } |
| 162 |
154 memcpy(fFixedFunctionVertexAttribIndices, | 163 memcpy(fFixedFunctionVertexAttribIndices, |
155 that.fFixedFunctionVertexAttribIndices, | 164 that.fFixedFunctionVertexAttribIndices, |
156 sizeof(fFixedFunctionVertexAttribIndices)); | 165 sizeof(fFixedFunctionVertexAttribIndices)); |
157 return *this; | 166 return *this; |
158 } | 167 } |
159 | 168 |
160 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { | 169 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
161 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); | 170 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
162 SkASSERT(!fRenderTarget.ownsPendingIO()); | 171 SkASSERT(!fRenderTarget.ownsPendingIO()); |
163 | 172 |
(...skipping 13 matching lines...) Expand all Loading... |
177 } | 186 } |
178 fSrcBlend = kOne_GrBlendCoeff; | 187 fSrcBlend = kOne_GrBlendCoeff; |
179 fDstBlend = kZero_GrBlendCoeff; | 188 fDstBlend = kZero_GrBlendCoeff; |
180 fBlendConstant = 0x0; | 189 fBlendConstant = 0x0; |
181 fFlagBits = 0x0; | 190 fFlagBits = 0x0; |
182 fStencilSettings.setDisabled(); | 191 fStencilSettings.setDisabled(); |
183 fCoverage = 0xff; | 192 fCoverage = 0xff; |
184 fDrawFace = kBoth_DrawFace; | 193 fDrawFace = kBoth_DrawFace; |
185 | 194 |
186 fHints = 0; | 195 fHints = 0; |
| 196 |
| 197 fColorProcInfoValid = false; |
| 198 fCoverageProcInfoValid = false; |
187 } | 199 } |
188 | 200 |
189 bool GrDrawState::setIdentityViewMatrix() { | 201 bool GrDrawState::setIdentityViewMatrix() { |
190 if (this->numFragmentStages()) { | 202 if (this->numFragmentStages()) { |
191 SkMatrix invVM; | 203 SkMatrix invVM; |
192 if (!fViewMatrix.invert(&invVM)) { | 204 if (!fViewMatrix.invert(&invVM)) { |
193 // sad trombone sound | 205 // sad trombone sound |
194 return false; | 206 return false; |
195 } | 207 } |
196 for (int s = 0; s < this->numColorStages(); ++s) { | 208 for (int s = 0; s < this->numColorStages(); ++s) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 244 |
233 // Enable the clip bit | 245 // Enable the clip bit |
234 this->enableState(GrDrawState::kClip_StateBit); | 246 this->enableState(GrDrawState::kClip_StateBit); |
235 | 247 |
236 this->setColor(paint.getColor()); | 248 this->setColor(paint.getColor()); |
237 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); | 249 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); |
238 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); | 250 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); |
239 | 251 |
240 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); | 252 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); |
241 this->setCoverage(0xFF); | 253 this->setCoverage(0xFF); |
| 254 fColorProcInfoValid = false; |
| 255 fCoverageProcInfoValid = false; |
242 } | 256 } |
243 | 257 |
244 //////////////////////////////////////////////////////////////////////////////// | 258 //////////////////////////////////////////////////////////////////////////////// |
245 | 259 |
246 bool GrDrawState::validateVertexAttribs() const { | 260 bool GrDrawState::validateVertexAttribs() const { |
247 // check consistency of effects and attributes | 261 // check consistency of effects and attributes |
248 GrSLType slTypes[kMaxVertexAttribCnt]; | 262 GrSLType slTypes[kMaxVertexAttribCnt]; |
249 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { | 263 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { |
250 slTypes[i] = static_cast<GrSLType>(-1); | 264 slTypes[i] = static_cast<GrSLType>(-1); |
251 } | 265 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 fFixedFunctionVertexAttribIndices[attribs[i].fBinding] = i; | 343 fFixedFunctionVertexAttribIndices[attribs[i].fBinding] = i; |
330 } | 344 } |
331 #ifdef SK_DEBUG | 345 #ifdef SK_DEBUG |
332 size_t dwordCount = GrVertexAttribTypeSize(attribs[i].fType) >> 2; | 346 size_t dwordCount = GrVertexAttribTypeSize(attribs[i].fType) >> 2; |
333 uint32_t mask = (1 << dwordCount)-1; | 347 uint32_t mask = (1 << dwordCount)-1; |
334 size_t offsetShift = attribs[i].fOffset >> 2; | 348 size_t offsetShift = attribs[i].fOffset >> 2; |
335 SkASSERT(!(overlapCheck & (mask << offsetShift))); | 349 SkASSERT(!(overlapCheck & (mask << offsetShift))); |
336 overlapCheck |= (mask << offsetShift); | 350 overlapCheck |= (mask << offsetShift); |
337 #endif | 351 #endif |
338 } | 352 } |
| 353 fColorProcInfoValid = false; |
| 354 fCoverageProcInfoValid = false; |
339 // Positions must be specified. | 355 // Positions must be specified. |
340 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBin
ding]); | 356 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBin
ding]); |
341 } | 357 } |
342 | 358 |
343 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
344 | 360 |
345 void GrDrawState::setDefaultVertexAttribs() { | 361 void GrDrawState::setDefaultVertexAttribs() { |
346 static const GrVertexAttrib kPositionAttrib = | 362 static const GrVertexAttrib kPositionAttrib = |
347 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}; | 363 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}; |
348 | 364 |
349 fVAPtr = &kPositionAttrib; | 365 fVAPtr = &kPositionAttrib; |
350 fVACount = 1; | 366 fVACount = 1; |
351 fVAStride = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType); | 367 fVAStride = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType); |
352 | 368 |
353 // set all the fixed function indices to -1 except position. | 369 // set all the fixed function indices to -1 except position. |
354 memset(fFixedFunctionVertexAttribIndices, | 370 memset(fFixedFunctionVertexAttribIndices, |
355 0xff, | 371 0xff, |
356 sizeof(fFixedFunctionVertexAttribIndices)); | 372 sizeof(fFixedFunctionVertexAttribIndices)); |
357 fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding] = 0; | 373 fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding] = 0; |
| 374 fColorProcInfoValid = false; |
| 375 fCoverageProcInfoValid = false; |
358 } | 376 } |
359 | 377 |
360 //////////////////////////////////////////////////////////////////////////////// | 378 //////////////////////////////////////////////////////////////////////////////// |
361 | 379 |
362 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { | 380 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { |
363 if (caps.dualSourceBlendingSupport()) { | 381 if (caps.dualSourceBlendingSupport()) { |
364 return true; | 382 return true; |
365 } | 383 } |
366 // we can correctly apply coverage if a) we have dual source blending | 384 // we can correctly apply coverage if a) we have dual source blending |
367 // or b) one of our blend optimizations applies | 385 // or b) one of our blend optimizations applies |
368 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color | 386 // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color |
369 GrBlendCoeff srcCoeff; | 387 GrBlendCoeff srcCoeff; |
370 GrBlendCoeff dstCoeff; | 388 GrBlendCoeff dstCoeff; |
371 BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff); | 389 BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff); |
372 return GrDrawState::kNone_BlendOpt != flag || | 390 return GrDrawState::kNone_BlendOpt != flag || |
373 (this->willEffectReadDstColor() && | 391 (this->willEffectReadDstColor() && |
374 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); | 392 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); |
375 } | 393 } |
376 | 394 |
377 bool GrDrawState::hasSolidCoverage() const { | 395 bool GrDrawState::hasSolidCoverage() const { |
378 // If we're drawing coverage directly then coverage is effectively treated a
s color. | 396 // If we're drawing coverage directly then coverage is effectively treated a
s color. |
379 if (this->isCoverageDrawing()) { | 397 if (this->isCoverageDrawing()) { |
380 return true; | 398 return true; |
381 } | 399 } |
382 | 400 |
383 if (this->numCoverageStages() > 0) { | 401 if (this->numCoverageStages() > 0) { |
384 return false; | 402 return false; |
385 } | 403 } |
386 | 404 |
387 GrColor color; | 405 this->calcCoverageInvariantOutput(); |
388 GrColorComponentFlags flags; | 406 return fCoverageProcInfo.isSolidWhite(); |
389 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. | |
390 if (this->hasCoverageVertexAttribute()) { | |
391 color = 0; | |
392 flags = static_cast<GrColorComponentFlags>(0); | |
393 } else { | |
394 color = this->getCoverageColor(); | |
395 flags = kRGBA_GrColorComponentFlags; | |
396 } | |
397 GrInvariantOutput inout(color, flags, true); | |
398 | |
399 // check the coverage output from the GP | |
400 if (this->hasGeometryProcessor()) { | |
401 fGeometryProcessor->computeInvariantOutput(&inout); | |
402 } | |
403 | |
404 return inout.isSolidWhite(); | |
405 } | 407 } |
406 | 408 |
407 ////////////////////////////////////////////////////////////////////////////// | 409 ////////////////////////////////////////////////////////////////////////////// |
408 | 410 |
409 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { | 411 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { |
410 SkASSERT(drawState); | 412 SkASSERT(drawState); |
411 fDrawState = drawState; | 413 fDrawState = drawState; |
412 fVAPtr = drawState->fVAPtr; | 414 fVAPtr = drawState->fVAPtr; |
413 fVACount = drawState->fVACount; | 415 fVACount = drawState->fVACount; |
414 fVAStride = drawState->fVAStride; | 416 fVAStride = drawState->fVAStride; |
415 fDrawState->setDefaultVertexAttribs(); | 417 fDrawState->setDefaultVertexAttribs(); |
416 } | 418 } |
417 | 419 |
418 //////////////////////////////////////////////////////////////////////////////s | 420 //////////////////////////////////////////////////////////////////////////////s |
419 | 421 |
420 bool GrDrawState::willEffectReadDstColor() const { | 422 bool GrDrawState::willEffectReadDstColor() const { |
421 if (!this->isColorWriteDisabled()) { | 423 if (!this->isColorWriteDisabled()) { |
422 for (int s = 0; s < this->numColorStages(); ++s) { | 424 this->calcColorInvariantOutput(); |
423 if (this->getColorStage(s).getProcessor()->willReadDstColor()) { | 425 if (fColorProcInfo.readsDst()) { |
424 return true; | |
425 } | |
426 } | |
427 } | |
428 for (int s = 0; s < this->numCoverageStages(); ++s) { | |
429 if (this->getCoverageStage(s).getProcessor()->willReadDstColor()) { | |
430 return true; | 426 return true; |
431 } | 427 } |
432 } | 428 } |
433 return false; | 429 this->calcCoverageInvariantOutput(); |
| 430 return fCoverageProcInfo.readsDst(); |
434 } | 431 } |
435 | 432 |
436 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { | 433 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
437 if (fDrawState) { | 434 if (fDrawState) { |
438 // See the big comment on the class definition about GPs. | 435 // See the big comment on the class definition about GPs. |
439 if (SK_InvalidUniqueID == fOriginalGPID) { | 436 if (SK_InvalidUniqueID == fOriginalGPID) { |
440 fDrawState->fGeometryProcessor.reset(NULL); | 437 fDrawState->fGeometryProcessor.reset(NULL); |
441 } else { | 438 } else { |
442 SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() == | 439 SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() == |
443 fOriginalGPID); | 440 fOriginalGPID); |
444 fOriginalGPID = SK_InvalidUniqueID; | 441 fOriginalGPID = SK_InvalidUniqueID; |
445 } | 442 } |
446 | 443 |
447 int m = fDrawState->numColorStages() - fColorEffectCnt; | 444 int m = fDrawState->numColorStages() - fColorEffectCnt; |
448 SkASSERT(m >= 0); | 445 SkASSERT(m >= 0); |
449 fDrawState->fColorStages.pop_back_n(m); | 446 fDrawState->fColorStages.pop_back_n(m); |
450 | 447 |
451 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; | 448 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; |
452 SkASSERT(n >= 0); | 449 SkASSERT(n >= 0); |
453 fDrawState->fCoverageStages.pop_back_n(n); | 450 fDrawState->fCoverageStages.pop_back_n(n); |
| 451 if (m + n > 0) { |
| 452 fDrawState->fColorProcInfoValid = false; |
| 453 fDrawState->fCoverageProcInfoValid = false; |
| 454 } |
454 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 455 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
455 } | 456 } |
456 fDrawState = ds; | 457 fDrawState = ds; |
457 if (NULL != ds) { | 458 if (NULL != ds) { |
458 SkASSERT(SK_InvalidUniqueID == fOriginalGPID); | 459 SkASSERT(SK_InvalidUniqueID == fOriginalGPID); |
459 if (NULL != ds->getGeometryProcessor()) { | 460 if (NULL != ds->getGeometryProcessor()) { |
460 fOriginalGPID = ds->getGeometryProcessor()->getUniqueID(); | 461 fOriginalGPID = ds->getGeometryProcessor()->getUniqueID(); |
461 } | 462 } |
462 fColorEffectCnt = ds->numColorStages(); | 463 fColorEffectCnt = ds->numColorStages(); |
463 fCoverageEffectCnt = ds->numCoverageStages(); | 464 fCoverageEffectCnt = ds->numCoverageStages(); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // the dst coeff is effectively one so blend works out to: | 683 // the dst coeff is effectively one so blend works out to: |
683 // cS + (c)(1)D + (1-c)D = cS + D. | 684 // cS + (c)(1)D + (1-c)D = cS + D. |
684 *dstCoeff = kOne_GrBlendCoeff; | 685 *dstCoeff = kOne_GrBlendCoeff; |
685 return kCoverageAsAlpha_BlendOptFlag; | 686 return kCoverageAsAlpha_BlendOptFlag; |
686 } | 687 } |
687 } | 688 } |
688 | 689 |
689 return kNone_BlendOpt; | 690 return kNone_BlendOpt; |
690 } | 691 } |
691 | 692 |
692 | |
693 bool GrDrawState::srcAlphaWillBeOne() const { | 693 bool GrDrawState::srcAlphaWillBeOne() const { |
694 GrColor color; | 694 this->calcColorInvariantOutput(); |
695 GrColorComponentFlags flags; | 695 if (this->isCoverageDrawing()) { |
696 // Check if per-vertex or constant color may have partial alpha | 696 this->calcCoverageInvariantOutput(); |
697 if (this->hasColorVertexAttribute()) { | 697 return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque()); |
698 if (fHints & kVertexColorsAreOpaque_Hint) { | |
699 flags = kA_GrColorComponentFlag; | |
700 color = 0xFF << GrColor_SHIFT_A; | |
701 } else { | |
702 flags = static_cast<GrColorComponentFlags>(0); | |
703 color = 0; | |
704 } | |
705 } else { | |
706 flags = kRGBA_GrColorComponentFlags; | |
707 color = this->getColor(); | |
708 } | 698 } |
709 GrInvariantOutput inoutColor(color, flags, false); | 699 return fColorProcInfo.isOpaque(); |
710 | |
711 // Run through the color stages | |
712 for (int s = 0; s < this->numColorStages(); ++s) { | |
713 const GrProcessor* processor = this->getColorStage(s).getProcessor(); | |
714 processor->computeInvariantOutput(&inoutColor); | |
715 } | |
716 | |
717 // Check whether coverage is treated as color. If so we run through the cove
rage computation. | |
718 if (this->isCoverageDrawing()) { | |
719 // The shader generated for coverage drawing runs the full coverage comp
utation and then | |
720 // makes the shader output be the multiplication of color and coverage.
We mirror that here. | |
721 if (this->hasCoverageVertexAttribute()) { | |
722 flags = static_cast<GrColorComponentFlags>(0); | |
723 color = 0; | |
724 } else { | |
725 flags = kRGBA_GrColorComponentFlags; | |
726 color = this->getCoverageColor(); | |
727 } | |
728 GrInvariantOutput inoutCoverage(color, flags, true); | |
729 | |
730 if (this->hasGeometryProcessor()) { | |
731 fGeometryProcessor->computeInvariantOutput(&inoutCoverage); | |
732 } | |
733 | |
734 // Run through the coverage stages | |
735 for (int s = 0; s < this->numCoverageStages(); ++s) { | |
736 const GrProcessor* processor = this->getCoverageStage(s).getProcesso
r(); | |
737 processor->computeInvariantOutput(&inoutCoverage); | |
738 } | |
739 | |
740 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | |
741 // coverage and color both have A==1. | |
742 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | |
743 } | |
744 | |
745 return inoutColor.isOpaque(); | |
746 } | 700 } |
747 | 701 |
748 bool GrDrawState::willBlendWithDst() const { | 702 bool GrDrawState::willBlendWithDst() const { |
749 if (!this->hasSolidCoverage()) { | 703 if (!this->hasSolidCoverage()) { |
750 return true; | 704 return true; |
751 } | 705 } |
752 | 706 |
753 if (this->willEffectReadDstColor()) { | 707 if (this->willEffectReadDstColor()) { |
754 return true; | 708 return true; |
755 } | 709 } |
756 | 710 |
757 if (GrBlendCoeffRefsDst(this->getSrcBlendCoeff())) { | 711 if (GrBlendCoeffRefsDst(this->getSrcBlendCoeff())) { |
758 return true; | 712 return true; |
759 } | 713 } |
760 | 714 |
761 GrBlendCoeff dstCoeff = this->getDstBlendCoeff(); | 715 GrBlendCoeff dstCoeff = this->getDstBlendCoeff(); |
762 if (!(kZero_GrBlendCoeff == dstCoeff || | 716 if (!(kZero_GrBlendCoeff == dstCoeff || |
763 (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne()))) { | 717 (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne()))) { |
764 return true; | 718 return true; |
765 } | 719 } |
766 | 720 |
767 return false; | 721 return false; |
768 } | 722 } |
769 | 723 |
| 724 void GrDrawState::calcColorInvariantOutput() const { |
| 725 if (!fColorProcInfoValid) { |
| 726 GrColor color; |
| 727 GrColorComponentFlags flags; |
| 728 if (this->hasColorVertexAttribute()) { |
| 729 if (fHints & kVertexColorsAreOpaque_Hint) { |
| 730 flags = kA_GrColorComponentFlag; |
| 731 color = 0xFF << GrColor_SHIFT_A; |
| 732 } else { |
| 733 flags = static_cast<GrColorComponentFlags>(0); |
| 734 color = 0; |
| 735 } |
| 736 } else { |
| 737 flags = kRGBA_GrColorComponentFlags; |
| 738 color = this->getColor(); |
| 739 } |
| 740 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo
rStages(), |
| 741 color, flags, false); |
| 742 fColorProcInfoValid = true; |
| 743 } |
| 744 } |
| 745 |
| 746 void GrDrawState::calcCoverageInvariantOutput() const { |
| 747 if (!fCoverageProcInfoValid) { |
| 748 GrColor color; |
| 749 GrColorComponentFlags flags; |
| 750 // Check if per-vertex or constant color may have partial alpha |
| 751 if (this->hasCoverageVertexAttribute()) { |
| 752 flags = static_cast<GrColorComponentFlags>(0); |
| 753 color = 0; |
| 754 } else { |
| 755 flags = kRGBA_GrColorComponentFlags; |
| 756 color = this->getCoverageColor(); |
| 757 } |
| 758 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->n
umCoverageStages(), |
| 759 color, flags, true, fGeometryPro
cessor.get()); |
| 760 fCoverageProcInfoValid = true; |
| 761 } |
| 762 } |
| 763 |
OLD | NEW |