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

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

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update comment and nits Created 6 years, 2 months 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 "GrOptDrawState.h" 10 #include "GrOptDrawState.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 (this->willEffectReadDstColor() && 414 (this->willEffectReadDstColor() &&
415 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); 415 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
416 } 416 }
417 417
418 bool GrDrawState::hasSolidCoverage() const { 418 bool GrDrawState::hasSolidCoverage() const {
419 // If we're drawing coverage directly then coverage is effectively treated a s color. 419 // If we're drawing coverage directly then coverage is effectively treated a s color.
420 if (this->isCoverageDrawing()) { 420 if (this->isCoverageDrawing()) {
421 return true; 421 return true;
422 } 422 }
423 423
424 GrColor coverage; 424 GrProcessor::InvarientOutput invarientOutput;
425 uint32_t validComponentFlags; 425 invarientOutput.isSingleComponent = false;
426 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. 426 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified.
427 if (this->hasCoverageVertexAttribute()) { 427 if (this->hasCoverageVertexAttribute()) {
428 validComponentFlags = 0; 428 invarientOutput.validFlags = 0;
429 } else { 429 } else {
430 coverage = fCoverage; 430 invarientOutput.color = fCoverage;
431 validComponentFlags = kRGBA_GrColorComponentFlags; 431 invarientOutput.validFlags = kRGBA_GrColorComponentFlags;
432 } 432 }
433 433
434 // Run through the coverage stages and see if the coverage will be all ones at the end. 434 // Run through the coverage stages and see if the coverage will be all ones at the end.
435 if (this->hasGeometryProcessor()) { 435 if (this->hasGeometryProcessor()) {
436 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor (); 436 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor ();
437 gp->getConstantColorComponents(&coverage, &validComponentFlags); 437 gp->computeInvarientOutput(&invarientOutput);
438 } 438 }
439 for (int s = 0; s < this->numCoverageStages(); ++s) { 439 for (int s = 0; s < this->numCoverageStages(); ++s) {
440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); 440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
441 processor->getConstantColorComponents(&coverage, &validComponentFlags); 441 processor->computeInvarientOutput(&invarientOutput);
442 } 442 }
443 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff = = coverage); 443 return invarientOutput.hasOpaqueColor();
444 } 444 }
445 445
446 ////////////////////////////////////////////////////////////////////////////// 446 //////////////////////////////////////////////////////////////////////////////
447 447
448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) { 448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) {
449 SkASSERT(drawState); 449 SkASSERT(drawState);
450 fDrawState = drawState; 450 fDrawState = drawState;
451 fVAPtr = drawState->fVAPtr; 451 fVAPtr = drawState->fVAPtr;
452 fVACount = drawState->fVACount; 452 fVACount = drawState->fVACount;
453 fVAStride = drawState->fVAStride; 453 fVAStride = drawState->fVAStride;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 *dstCoeff = kOne_GrBlendCoeff; 748 *dstCoeff = kOne_GrBlendCoeff;
749 return kCoverageAsAlpha_BlendOptFlag; 749 return kCoverageAsAlpha_BlendOptFlag;
750 } 750 }
751 } 751 }
752 752
753 return kNone_BlendOpt; 753 return kNone_BlendOpt;
754 } 754 }
755 755
756 756
757 bool GrDrawState::srcAlphaWillBeOne() const { 757 bool GrDrawState::srcAlphaWillBeOne() const {
758 uint32_t validComponentFlags; 758 GrProcessor::InvarientOutput invarientOutputColor;
759 GrColor color; 759 invarientOutputColor.isSingleComponent = false;
760 // Check if per-vertex or constant color may have partial alpha 760 // Check if per-vertex or constant color may have partial alpha
761 if (this->hasColorVertexAttribute()) { 761 if (this->hasColorVertexAttribute()) {
762 if (fHints & kVertexColorsAreOpaque_Hint) { 762 if (fHints & kVertexColorsAreOpaque_Hint) {
763 validComponentFlags = kA_GrColorComponentFlag; 763 invarientOutputColor.validFlags = kA_GrColorComponentFlag;
764 color = 0xFF << GrColor_SHIFT_A; 764 invarientOutputColor.color = 0xFF << GrColor_SHIFT_A;
765 } else { 765 } else {
766 validComponentFlags = 0; 766 invarientOutputColor.validFlags = 0;
767 color = 0; // not strictly necessary but we get false alarms from to ols about uninit. 767 // not strictly necessary but we get false alarms from tools about u ninit.
768 invarientOutputColor.color = 0;
768 } 769 }
769 } else { 770 } else {
770 validComponentFlags = kRGBA_GrColorComponentFlags; 771 invarientOutputColor.validFlags = kRGBA_GrColorComponentFlags;
771 color = this->getColor(); 772 invarientOutputColor.color = this->getColor();
772 } 773 }
773 774
774 // Run through the color stages 775 // Run through the color stages
775 for (int s = 0; s < this->numColorStages(); ++s) { 776 for (int s = 0; s < this->numColorStages(); ++s) {
776 const GrProcessor* processor = this->getColorStage(s).getProcessor(); 777 const GrProcessor* processor = this->getColorStage(s).getProcessor();
777 processor->getConstantColorComponents(&color, &validComponentFlags); 778 processor->computeInvarientOutput(&invarientOutputColor);
778 } 779 }
779 780
780 // Check whether coverage is treated as color. If so we run through the cove rage computation. 781 // Check whether coverage is treated as color. If so we run through the cove rage computation.
781 if (this->isCoverageDrawing()) { 782 if (this->isCoverageDrawing()) {
782 // The shader generated for coverage drawing runs the full coverage comp utation and then 783 // The shader generated for coverage drawing runs the full coverage comp utation and then
783 // makes the shader output be the multiplication of color and coverage. We mirror that here. 784 // makes the shader output be the multiplication of color and coverage. We mirror that here.
784 GrColor coverage; 785 GrProcessor::InvarientOutput invarientOutputCoverage;
785 uint32_t coverageComponentFlags; 786 invarientOutputCoverage.isSingleComponent = false;
786 if (this->hasCoverageVertexAttribute()) { 787 if (this->hasCoverageVertexAttribute()) {
787 coverageComponentFlags = 0; 788 invarientOutputCoverage.validFlags = 0;
788 coverage = 0; // suppresses any warnings. 789 invarientOutputCoverage.color = 0; // suppresses any warnings.
789 } else { 790 } else {
790 coverageComponentFlags = kRGBA_GrColorComponentFlags; 791 invarientOutputCoverage.validFlags = kRGBA_GrColorComponentFlags;
791 coverage = this->getCoverageColor(); 792 invarientOutputCoverage.color = this->getCoverageColor();
792 } 793 }
793 794
794 // Run through the coverage stages 795 // Run through the coverage stages
795 for (int s = 0; s < this->numCoverageStages(); ++s) { 796 for (int s = 0; s < this->numCoverageStages(); ++s) {
796 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r(); 797 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r();
797 processor->getConstantColorComponents(&coverage, &coverageComponentF lags); 798 processor->computeInvarientOutput(&invarientOutputCoverage);
798 } 799 }
799 800
800 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 801 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
801 // coverage and color both have A==1. 802 // coverage and color both have A==1.
802 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) && 803 return (invarientOutputColor.hasOpaqueAlpha() && invarientOutputCoverage .hasOpaqueAlpha());
803 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage );
804
805 } 804 }
806 805
807 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color); 806 return invarientOutputColor.hasOpaqueAlpha();
808 } 807 }
809 808
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698