Index: src/gpu/GrOptDrawState.cpp |
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
index 9ebe551d6bc5d5fa141f94854ca75e17ebf17daf..409305ce33fae912d79acbd2f3964ed589d4464a 100644 |
--- a/src/gpu/GrOptDrawState.cpp |
+++ b/src/gpu/GrOptDrawState.cpp |
@@ -44,8 +44,7 @@ |
drawState.isColorWriteDisabled(), |
drawState.getStencil().doesWrite(), |
&fColor, |
- &fCoverage, |
- caps); |
+ &fCoverage); |
} |
// When path rendering the stencil settings are not always set on the draw state |
@@ -147,6 +146,42 @@ |
init.fCoverage = this->getCoverage(); |
fGeometryProcessor->initBatchTracker(&fBatchTracker, init); |
} |
+ |
+ this->setOutputStateInfo(drawState, coverageColor, optFlags, caps); |
+} |
+ |
+void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
+ GrColor coverage, |
+ GrXferProcessor::OptFlags optFlags, |
+ const GrDrawTargetCaps& caps) { |
+ // Set this default and then possibly change our mind if there is coverage. |
+ fDescInfo.fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
+ |
+ // Determine whether we should use dual source blending or shader code to keep coverage |
+ // separate from color. |
+ bool keepCoverageSeparate = !(optFlags & GrXferProcessor::kSetCoverageDrawing_OptFlag); |
+ if (keepCoverageSeparate && !ds.hasSolidCoverage(coverage)) { |
+ if (caps.dualSourceBlendingSupport()) { |
+ if (kZero_GrBlendCoeff == fDstBlend) { |
+ // write the coverage value to second color |
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType; |
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
+ } else if (kSA_GrBlendCoeff == fDstBlend) { |
+ // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType; |
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
+ } else if (kSC_GrBlendCoeff == fDstBlend) { |
+ // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType; |
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
+ } |
+ } else if (fDescInfo.fReadsDst && |
+ kOne_GrBlendCoeff == fSrcBlend && |
+ kZero_GrBlendCoeff == fDstBlend) { |
+ fDescInfo.fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType; |
+ } |
+ } |
} |
void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, |
@@ -227,10 +262,6 @@ |
return false; |
} |
- if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { |
- return false; |
- } |
- |
// The program desc comparison should have already assured that the stage counts match. |
SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
for (int i = 0; i < this->numFragmentStages(); i++) { |