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 "GrOptDrawState.h" | 10 #include "GrOptDrawState.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); | 382 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); |
383 } | 383 } |
384 | 384 |
385 bool GrDrawState::hasSolidCoverage() const { | 385 bool GrDrawState::hasSolidCoverage() const { |
386 // If we're drawing coverage directly then coverage is effectively treated a s color. | 386 // If we're drawing coverage directly then coverage is effectively treated a s color. |
387 if (this->isCoverageDrawing()) { | 387 if (this->isCoverageDrawing()) { |
388 return true; | 388 return true; |
389 } | 389 } |
390 | 390 |
391 GrProcessor::InvariantOutput inout; | 391 GrProcessor::InvariantOutput inout; |
392 inout.fIsSingleComponent = false; | 392 inout.fIsSingleComponent = true; |
bsalomon
2014/10/24 15:13:59
I think it is time to enforce that the coverage at
| |
393 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. | 393 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. |
394 if (this->hasCoverageVertexAttribute()) { | 394 if (this->hasCoverageVertexAttribute()) { |
395 inout.fValidFlags = 0; | 395 inout.fValidFlags = 0; |
396 } else { | 396 } else { |
397 inout.fColor = this->getCoverageColor(); | 397 inout.fColor = this->getCoverageColor(); |
398 inout.fValidFlags = kRGBA_GrColorComponentFlags; | 398 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
399 } | 399 } |
400 | 400 |
401 // Run through the coverage stages and see if the coverage will be all ones at the end. | 401 // Run through the coverage stages and see if the coverage will be all ones at the end. |
402 if (this->hasGeometryProcessor()) { | 402 if (this->hasGeometryProcessor()) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 for (int s = 0; s < this->numColorStages(); ++s) { | 731 for (int s = 0; s < this->numColorStages(); ++s) { |
732 const GrProcessor* processor = this->getColorStage(s).getProcessor(); | 732 const GrProcessor* processor = this->getColorStage(s).getProcessor(); |
733 processor->computeInvariantOutput(&inoutColor); | 733 processor->computeInvariantOutput(&inoutColor); |
734 } | 734 } |
735 | 735 |
736 // Check whether coverage is treated as color. If so we run through the cove rage computation. | 736 // Check whether coverage is treated as color. If so we run through the cove rage computation. |
737 if (this->isCoverageDrawing()) { | 737 if (this->isCoverageDrawing()) { |
738 // The shader generated for coverage drawing runs the full coverage comp utation and then | 738 // The shader generated for coverage drawing runs the full coverage comp utation and then |
739 // makes the shader output be the multiplication of color and coverage. We mirror that here. | 739 // makes the shader output be the multiplication of color and coverage. We mirror that here. |
740 GrProcessor::InvariantOutput inoutCoverage; | 740 GrProcessor::InvariantOutput inoutCoverage; |
741 inoutCoverage.fIsSingleComponent = false; | 741 inoutCoverage.fIsSingleComponent = true; |
742 if (this->hasCoverageVertexAttribute()) { | 742 if (this->hasCoverageVertexAttribute()) { |
743 inoutCoverage.fValidFlags = 0; | 743 inoutCoverage.fValidFlags = 0; |
744 inoutCoverage.fColor = 0; // suppresses any warnings. | 744 inoutCoverage.fColor = 0; // suppresses any warnings. |
745 } else { | 745 } else { |
746 inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags; | 746 inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags; |
747 inoutCoverage.fColor = this->getCoverageColor(); | 747 inoutCoverage.fColor = this->getCoverageColor(); |
748 } | 748 } |
749 | 749 |
750 // Run through the coverage stages | 750 // Run through the coverage stages |
751 for (int s = 0; s < this->numCoverageStages(); ++s) { | 751 for (int s = 0; s < this->numCoverageStages(); ++s) { |
752 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r(); | 752 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r(); |
753 processor->computeInvariantOutput(&inoutCoverage); | 753 processor->computeInvariantOutput(&inoutCoverage); |
754 } | 754 } |
755 | 755 |
756 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if | 756 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if |
757 // coverage and color both have A==1. | 757 // coverage and color both have A==1. |
758 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 758 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
759 } | 759 } |
760 | 760 |
761 return inoutColor.isOpaque(); | 761 return inoutColor.isOpaque(); |
762 } | 762 } |
763 | 763 |
OLD | NEW |