| Index: src/gpu/GrOptDrawState.cpp
|
| diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
|
| index 409305ce33fae912d79acbd2f3964ed589d4464a..51d486b244b18bcb48bdc5fd9c6ce7401fe06c04 100644
|
| --- a/src/gpu/GrOptDrawState.cpp
|
| +++ b/src/gpu/GrOptDrawState.cpp
|
| @@ -14,21 +14,36 @@
|
| #include "GrXferProcessor.h"
|
|
|
| GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| - GrColor color,
|
| - uint8_t coverage,
|
| + const GrGeometryProcessor* gp,
|
| + const GrPathProcessor* pp,
|
| const GrDrawTargetCaps& caps,
|
| const ScissorState& scissorState,
|
| const GrDeviceCoordTexture* dstCopy,
|
| GrGpu::DrawType drawType)
|
| : fFinalized(false) {
|
| - GrColor coverageColor = GrColorPackRGBA(coverage, coverage, coverage, coverage);
|
| fDrawType = drawType;
|
|
|
| - const GrProcOptInfo& colorPOI = drawState.colorProcInfo(color);
|
| - const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(coverageColor);
|
| + // Copy GeometryProcesssor from DS or ODS
|
| + if (gp) {
|
| + SkASSERT(!pp);
|
| + SkASSERT(!(GrGpu::IsPathRenderingDrawType(drawType) ||
|
| + GrGpu::kStencilPath_DrawType == drawType));
|
| + fGeometryProcessor.reset(gp);
|
| + fPrimitiveProcessor.reset(gp);
|
| + } else {
|
| + SkASSERT(!gp && pp && (GrGpu::IsPathRenderingDrawType(drawType) ||
|
| + GrGpu::kStencilPath_DrawType == drawType));
|
| + fPrimitiveProcessor.reset(pp);
|
| + }
|
| +
|
| +
|
| + const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor);
|
| + const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProcessor);
|
|
|
| fColor = colorPOI.inputColorToEffectiveStage();
|
| - fCoverage = coverage;
|
| + // TODO fix this when coverage stages work correctly
|
| + // fCoverage = coveragePOI.inputColorToEffectiveStage();
|
| + fCoverage = fPrimitiveProcessor->coverage();
|
|
|
| // Create XferProcessor from DS's XPFactory
|
| SkAutoTUnref<GrXferProcessor> xferProcessor(
|
| @@ -85,14 +100,11 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| fFlags |= kDither_Flag;
|
| }
|
|
|
| - fDescInfo.fHasVertexColor = drawState.hasGeometryProcessor() &&
|
| - drawState.getGeometryProcessor()->hasVertexColor();
|
| + fDescInfo.fHasVertexColor = gp && gp->hasVertexColor();
|
|
|
| - fDescInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() &&
|
| - drawState.getGeometryProcessor()->hasVertexCoverage();
|
| + fDescInfo.fHasVertexCoverage = gp && gp->hasVertexCoverage();
|
|
|
| - bool hasLocalCoords = drawState.hasGeometryProcessor() &&
|
| - drawState.getGeometryProcessor()->hasLocalCoords();
|
| + bool hasLocalCoords = gp && gp->hasLocalCoords();
|
|
|
| int firstColorStageIdx = colorPOI.firstEffectiveStageIndex();
|
| fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed();
|
| @@ -105,7 +117,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| int firstCoverageStageIdx = 0;
|
| fDescInfo.fInputCoverageIsUsed = true;
|
|
|
| -
|
| GrXferProcessor::BlendInfo blendInfo;
|
| fXferProcessor->getBlendInfo(&blendInfo);
|
| fSrcBlend = blendInfo.fSrcBlend;
|
| @@ -117,12 +128,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
|
|
| fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords;
|
|
|
| - // Copy GeometryProcesssor from DS or ODS
|
| - SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) ||
|
| - GrGpu::kStencilPath_DrawType ||
|
| - drawState.hasGeometryProcessor());
|
| - fGeometryProcessor.reset(drawState.getGeometryProcessor());
|
| -
|
| // Copy Stages from DS to ODS
|
| for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) {
|
| SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
|
| @@ -138,7 +143,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| }
|
|
|
| // let the GP init the batch tracker
|
| - if (drawState.hasGeometryProcessor()) {
|
| + if (gp) {
|
| GrGeometryProcessor::InitBT init;
|
| init.fOutputColor = fDescInfo.fInputColorIsUsed;
|
| init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed;
|
| @@ -147,11 +152,10 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| fGeometryProcessor->initBatchTracker(&fBatchTracker, init);
|
| }
|
|
|
| - this->setOutputStateInfo(drawState, coverageColor, optFlags, caps);
|
| + this->setOutputStateInfo(drawState, 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.
|
| @@ -161,7 +165,7 @@ void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
|
| // 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 (keepCoverageSeparate && !ds.hasSolidCoverage(fPrimitiveProcessor.get())) {
|
| if (caps.dualSourceBlendingSupport()) {
|
| if (kZero_GrBlendCoeff == fDstBlend) {
|
| // write the coverage value to second color
|
|
|