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; |
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 if (this->hasGeometryProcessor()) { | 750 if (this->hasGeometryProcessor()) { |
751 fGeometryProcessor->computeInvariantOutput(&inoutCoverage); | 751 fGeometryProcessor->computeInvariantOutput(&inoutCoverage); |
752 } | 752 } |
753 | 753 |
754 // Run through the coverage stages | 754 // Run through the coverage stages |
755 for (int s = 0; s < this->numCoverageStages(); ++s) { | 755 for (int s = 0; s < this->numCoverageStages(); ++s) { |
756 const GrProcessor* processor = this->getCoverageStage(s).getProcesso
r(); | 756 const GrProcessor* processor = this->getCoverageStage(s).getProcesso
r(); |
757 processor->computeInvariantOutput(&inoutCoverage); | 757 processor->computeInvariantOutput(&inoutCoverage); |
758 } | 758 } |
759 | 759 |
760 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 760 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
761 // coverage and color both have A==1. | 761 // coverage and color both have A==1. |
762 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 762 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
763 } | 763 } |
764 | 764 |
765 return inoutColor.isOpaque(); | 765 return inoutColor.isOpaque(); |
766 } | 766 } |
767 | 767 |
OLD | NEW |