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

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

Issue 699943003: Move GrInvariantOutput out of GrProcessor and into its own class. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 "GrInvariantOutput.h"
10 #include "GrOptDrawState.h" 11 #include "GrOptDrawState.h"
11 #include "GrPaint.h" 12 #include "GrPaint.h"
12 13
13 //////////////////////////////////////////////////////////////////////////////s 14 //////////////////////////////////////////////////////////////////////////////s
14 15
15 bool GrDrawState::isEqual(const GrDrawState& that) const { 16 bool GrDrawState::isEqual(const GrDrawState& that) const {
16 bool usingVertexColors = this->hasColorVertexAttribute(); 17 bool usingVertexColors = this->hasColorVertexAttribute();
17 if (!usingVertexColors && this->fColor != that.fColor) { 18 if (!usingVertexColors && this->fColor != that.fColor) {
18 return false; 19 return false;
19 } 20 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 (this->willEffectReadDstColor() && 382 (this->willEffectReadDstColor() &&
382 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); 383 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
383 } 384 }
384 385
385 bool GrDrawState::hasSolidCoverage() const { 386 bool GrDrawState::hasSolidCoverage() const {
386 // If we're drawing coverage directly then coverage is effectively treated a s color. 387 // If we're drawing coverage directly then coverage is effectively treated a s color.
387 if (this->isCoverageDrawing()) { 388 if (this->isCoverageDrawing()) {
388 return true; 389 return true;
389 } 390 }
390 391
391 GrProcessor::InvariantOutput inout; 392 GrInvariantOutput inout;
392 inout.fIsSingleComponent = true; 393 inout.fIsSingleComponent = true;
393 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. 394 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified.
394 if (this->hasCoverageVertexAttribute()) { 395 if (this->hasCoverageVertexAttribute()) {
395 inout.fValidFlags = 0; 396 inout.fValidFlags = 0;
396 } else { 397 } else {
397 inout.fColor = this->getCoverageColor(); 398 inout.fColor = this->getCoverageColor();
398 inout.fValidFlags = kRGBA_GrColorComponentFlags; 399 inout.fValidFlags = kRGBA_GrColorComponentFlags;
399 } 400 }
400 401
401 // Run through the coverage stages and see if the coverage will be all ones at the end. 402 // Run through the coverage stages and see if the coverage will be all ones at the end.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 *dstCoeff = kOne_GrBlendCoeff; 704 *dstCoeff = kOne_GrBlendCoeff;
704 return kCoverageAsAlpha_BlendOptFlag; 705 return kCoverageAsAlpha_BlendOptFlag;
705 } 706 }
706 } 707 }
707 708
708 return kNone_BlendOpt; 709 return kNone_BlendOpt;
709 } 710 }
710 711
711 712
712 bool GrDrawState::srcAlphaWillBeOne() const { 713 bool GrDrawState::srcAlphaWillBeOne() const {
713 GrProcessor::InvariantOutput inoutColor; 714 GrInvariantOutput inoutColor;
714 inoutColor.fIsSingleComponent = false; 715 inoutColor.fIsSingleComponent = false;
715 // Check if per-vertex or constant color may have partial alpha 716 // Check if per-vertex or constant color may have partial alpha
716 if (this->hasColorVertexAttribute()) { 717 if (this->hasColorVertexAttribute()) {
717 if (fHints & kVertexColorsAreOpaque_Hint) { 718 if (fHints & kVertexColorsAreOpaque_Hint) {
718 inoutColor.fValidFlags = kA_GrColorComponentFlag; 719 inoutColor.fValidFlags = kA_GrColorComponentFlag;
719 inoutColor.fColor = 0xFF << GrColor_SHIFT_A; 720 inoutColor.fColor = 0xFF << GrColor_SHIFT_A;
720 } else { 721 } else {
721 inoutColor.fValidFlags = 0; 722 inoutColor.fValidFlags = 0;
722 // not strictly necessary but we get false alarms from tools about u ninit. 723 // not strictly necessary but we get false alarms from tools about u ninit.
723 inoutColor.fColor = 0; 724 inoutColor.fColor = 0;
724 } 725 }
725 } else { 726 } else {
726 inoutColor.fValidFlags = kRGBA_GrColorComponentFlags; 727 inoutColor.fValidFlags = kRGBA_GrColorComponentFlags;
727 inoutColor.fColor = this->getColor(); 728 inoutColor.fColor = this->getColor();
728 } 729 }
729 730
730 // Run through the color stages 731 // Run through the color stages
731 for (int s = 0; s < this->numColorStages(); ++s) { 732 for (int s = 0; s < this->numColorStages(); ++s) {
732 const GrProcessor* processor = this->getColorStage(s).getProcessor(); 733 const GrProcessor* processor = this->getColorStage(s).getProcessor();
733 processor->computeInvariantOutput(&inoutColor); 734 processor->computeInvariantOutput(&inoutColor);
734 } 735 }
735 736
736 // Check whether coverage is treated as color. If so we run through the cove rage computation. 737 // Check whether coverage is treated as color. If so we run through the cove rage computation.
737 if (this->isCoverageDrawing()) { 738 if (this->isCoverageDrawing()) {
738 // The shader generated for coverage drawing runs the full coverage comp utation and then 739 // 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. 740 // makes the shader output be the multiplication of color and coverage. We mirror that here.
740 GrProcessor::InvariantOutput inoutCoverage; 741 GrInvariantOutput inoutCoverage;
741 inoutCoverage.fIsSingleComponent = true; 742 inoutCoverage.fIsSingleComponent = true;
742 if (this->hasCoverageVertexAttribute()) { 743 if (this->hasCoverageVertexAttribute()) {
743 inoutCoverage.fValidFlags = 0; 744 inoutCoverage.fValidFlags = 0;
744 inoutCoverage.fColor = 0; // suppresses any warnings. 745 inoutCoverage.fColor = 0; // suppresses any warnings.
745 } else { 746 } else {
746 inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags; 747 inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags;
747 inoutCoverage.fColor = this->getCoverageColor(); 748 inoutCoverage.fColor = this->getCoverageColor();
748 } 749 }
749 750
750 if (this->hasGeometryProcessor()) { 751 if (this->hasGeometryProcessor()) {
751 fGeometryProcessor->computeInvariantOutput(&inoutCoverage); 752 fGeometryProcessor->computeInvariantOutput(&inoutCoverage);
752 } 753 }
753 754
754 // Run through the coverage stages 755 // Run through the coverage stages
755 for (int s = 0; s < this->numCoverageStages(); ++s) { 756 for (int s = 0; s < this->numCoverageStages(); ++s) {
756 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r(); 757 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r();
757 processor->computeInvariantOutput(&inoutCoverage); 758 processor->computeInvariantOutput(&inoutCoverage);
758 } 759 }
759 760
760 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 761 // 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. 762 // coverage and color both have A==1.
762 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); 763 return (inoutColor.isOpaque() && inoutCoverage.isOpaque());
763 } 764 }
764 765
765 return inoutColor.isOpaque(); 766 return inoutColor.isOpaque();
766 } 767 }
767 768
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698