Index: src/gpu/GrOptDrawState.cpp |
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
index 60360d21c6168d3dd8134c6e3b8eb483bb25a60e..8fa64f56ddf95e9b687ec82f072d78bc011d3908 100644 |
--- a/src/gpu/GrOptDrawState.cpp |
+++ b/src/gpu/GrOptDrawState.cpp |
@@ -32,23 +32,24 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
fPrimitiveProcessor.reset(gp); |
} else { |
SkASSERT(!gp && pathProc && (GrGpu::IsPathRenderingDrawType(drawType) || |
- GrGpu::kStencilPath_DrawType == drawType)); |
+ GrGpu::kStencilPath_DrawType == drawType)); |
fPrimitiveProcessor.reset(pathProc); |
} |
const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor); |
const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProcessor); |
- |
- fColor = colorPOI.inputColorToEffectiveStage(); |
- // TODO fix this when coverage stages work correctly |
- // fCoverage = coveragePOI.inputColorToEffectiveStage(); |
- fCoverage = fPrimitiveProcessor->coverage(); |
// Create XferProcessor from DS's XPFactory |
SkAutoTUnref<GrXferProcessor> xferProcessor( |
drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); |
+ GrColor color = GrColor_ILLEGAL; |
+ if (colorPOI.firstEffectiveStageIndex() != 0) { |
+ color = colorPOI.inputColorToEffectiveStage(); |
+ } |
+ |
+ uint8_t coverage; |
GrXferProcessor::OptFlags optFlags; |
if (xferProcessor) { |
fXferProcessor.reset(xferProcessor.get()); |
@@ -58,11 +59,20 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
drawState.isCoverageDrawing(), |
drawState.isColorWriteDisabled(), |
drawState.getStencil().doesWrite(), |
- &fColor, |
- &fCoverage, |
+ &color, |
+ &coverage, |
caps); |
} |
+ // We might get an updated color from the XP, so we need to make sure the NVPR color is correct |
+ // TODO once pathProc is installed here as well, we don't need color on optstate |
+ if (GrColor_ILLEGAL == color) { |
+ fColor = colorPOI.inputColorToEffectiveStage(); |
+ } else { |
+ fColor = color; |
+ } |
+ |
+ |
// When path rendering the stencil settings are not always set on the draw state |
// so we must check the draw type. In cases where we will skip drawing we simply return a |
// null GrOptDrawState. |
@@ -98,22 +108,14 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
fFlags |= kDither_Flag; |
} |
- fDescInfo.fHasVertexColor = gp && gp->hasVertexColor(); |
- |
- fDescInfo.fHasVertexCoverage = gp && gp->hasVertexCoverage(); |
- |
+ // TODO move local coords completely into GP |
bool hasLocalCoords = gp && gp->hasLocalCoords(); |
int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); |
- fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed(); |
- if (colorPOI.removeVertexAttrib()) { |
- fDescInfo.fHasVertexColor = false; |
- } |
// TODO: Once we can handle single or four channel input into coverage stages then we can use |
// drawState's coverageProcInfo (like color above) to set this initial information. |
int firstCoverageStageIdx = 0; |
- fDescInfo.fInputCoverageIsUsed = true; |
GrXferProcessor::BlendInfo blendInfo; |
fXferProcessor->getBlendInfo(&blendInfo); |
@@ -140,10 +142,9 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
// let the GP init the batch tracker |
if (gp) { |
GrGeometryProcessor::InitBT init; |
- init.fOutputColor = fDescInfo.fInputColorIsUsed; |
- init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed; |
- init.fColor = this->getColor(); |
- init.fCoverage = this->getCoverage(); |
+ init.fColorIgnored = optFlags & GrXferProcessor::kClearColorStages_OptFlag; |
+ init.fOverrideColor = color; |
+ init.fCoverageIgnored = optFlags & GrXferProcessor::kClearCoverageStages_OptFlag; |
fGeometryProcessor->initBatchTracker(&fBatchTracker, init); |
} |
} |
@@ -158,18 +159,14 @@ void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, |
fDescInfo.fReadsFragPosition = false; |
if (flags & GrXferProcessor::kClearColorStages_OptFlag) { |
- fDescInfo.fInputColorIsUsed = true; |
*firstColorStageIdx = ds.numColorStages(); |
- fDescInfo.fHasVertexColor = false; |
} else { |
fDescInfo.fReadsDst = colorPOI.readsDst(); |
fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition(); |
} |
if (flags & GrXferProcessor::kClearCoverageStages_OptFlag) { |
- fDescInfo.fInputCoverageIsUsed = true; |
*firstCoverageStageIdx = ds.numCoverageStages(); |
- fDescInfo.fHasVertexCoverage = false; |
} else { |
if (coveragePOI.readsDst()) { |
fDescInfo.fReadsDst = true; |
@@ -192,10 +189,6 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
return false; |
} |
- if (!fDescInfo.fHasVertexColor && this->fColor != that.fColor) { |
- return false; |
- } |
- |
if (this->getRenderTarget() != that.getRenderTarget() || |
this->fFragmentStages.count() != that.fFragmentStages.count() || |
this->fNumColorStages != that.fNumColorStages || |
@@ -209,17 +202,9 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
return false; |
} |
- if (!fDescInfo.fHasVertexCoverage && this->fCoverage != that.fCoverage) { |
- return false; |
- } |
- |
- if (this->hasGeometryProcessor()) { |
- if (!that.hasGeometryProcessor()) { |
- return false; |
- } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProcessor())) { |
- return false; |
- } |
- } else if (that.hasGeometryProcessor()) { |
+ if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker, |
+ *that.getPrimitiveProcessor(), |
+ that.getBatchTracker())) { |
return false; |
} |
@@ -235,6 +220,9 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
return false; |
} |
} |
+ |
+ // Now update the GrPrimitiveProcessor's batch tracker |
+ fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); |
return true; |
} |