diff options
Diffstat (limited to 'src/gpu/GrDrawState.cpp')
-rw-r--r-- | src/gpu/GrDrawState.cpp | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index 872d20a1ab..b4cf9c8b41 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -421,26 +421,26 @@ bool GrDrawState::hasSolidCoverage() const { return true; } - GrColor coverage; - uint32_t validComponentFlags; + GrProcessor::InvariantOutput inout; + inout.fIsSingleComponent = false; // Initialize to an unknown starting coverage if per-vertex coverage is specified. if (this->hasCoverageVertexAttribute()) { - validComponentFlags = 0; + inout.fValidFlags = 0; } else { - coverage = fCoverage; - validComponentFlags = kRGBA_GrColorComponentFlags; + inout.fColor = fCoverage; + inout.fValidFlags = kRGBA_GrColorComponentFlags; } // Run through the coverage stages and see if the coverage will be all ones at the end. if (this->hasGeometryProcessor()) { const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor(); - gp->getConstantColorComponents(&coverage, &validComponentFlags); + gp->computeInvariantOutput(&inout); } for (int s = 0; s < this->numCoverageStages(); ++s) { const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); - processor->getConstantColorComponents(&coverage, &validComponentFlags); + processor->computeInvariantOutput(&inout); } - return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff == coverage); + return inout.isSolidWhite(); } ////////////////////////////////////////////////////////////////////////////// @@ -755,55 +755,54 @@ GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, bool GrDrawState::srcAlphaWillBeOne() const { - uint32_t validComponentFlags; - GrColor color; + GrProcessor::InvariantOutput inoutColor; + inoutColor.fIsSingleComponent = false; // Check if per-vertex or constant color may have partial alpha if (this->hasColorVertexAttribute()) { if (fHints & kVertexColorsAreOpaque_Hint) { - validComponentFlags = kA_GrColorComponentFlag; - color = 0xFF << GrColor_SHIFT_A; + inoutColor.fValidFlags = kA_GrColorComponentFlag; + inoutColor.fColor = 0xFF << GrColor_SHIFT_A; } else { - validComponentFlags = 0; - color = 0; // not strictly necessary but we get false alarms from tools about uninit. + inoutColor.fValidFlags = 0; + // not strictly necessary but we get false alarms from tools about uninit. + inoutColor.fColor = 0; } } else { - validComponentFlags = kRGBA_GrColorComponentFlags; - color = this->getColor(); + inoutColor.fValidFlags = kRGBA_GrColorComponentFlags; + inoutColor.fColor = this->getColor(); } // Run through the color stages for (int s = 0; s < this->numColorStages(); ++s) { const GrProcessor* processor = this->getColorStage(s).getProcessor(); - processor->getConstantColorComponents(&color, &validComponentFlags); + processor->computeInvariantOutput(&inoutColor); } // Check whether coverage is treated as color. If so we run through the coverage computation. if (this->isCoverageDrawing()) { // The shader generated for coverage drawing runs the full coverage computation and then // makes the shader output be the multiplication of color and coverage. We mirror that here. - GrColor coverage; - uint32_t coverageComponentFlags; + GrProcessor::InvariantOutput inoutCoverage; + inoutCoverage.fIsSingleComponent = false; if (this->hasCoverageVertexAttribute()) { - coverageComponentFlags = 0; - coverage = 0; // suppresses any warnings. + inoutCoverage.fValidFlags = 0; + inoutCoverage.fColor = 0; // suppresses any warnings. } else { - coverageComponentFlags = kRGBA_GrColorComponentFlags; - coverage = this->getCoverageColor(); + inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags; + inoutCoverage.fColor = this->getCoverageColor(); } // Run through the coverage stages for (int s = 0; s < this->numCoverageStages(); ++s) { const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); - processor->getConstantColorComponents(&coverage, &coverageComponentFlags); + processor->computeInvariantOutput(&inoutCoverage); } // Since the shader will multiply coverage and color, the only way the final A==1 is if // coverage and color both have A==1. - return (kA_GrColorComponentFlag & validComponentFlags & coverageComponentFlags) && - 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage); - + return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); } - return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnpackA(color); + return inoutColor.isOpaque(); } |