Index: src/gpu/GrOptDrawState.cpp |
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp |
index 77a9fc8dc454a25672d849f9ec8d5fb1f10c2081..95512517613eeb377edb01c0226af6a62548b6e6 100644 |
--- a/src/gpu/GrOptDrawState.cpp |
+++ b/src/gpu/GrOptDrawState.cpp |
@@ -9,12 +9,15 @@ |
#include "GrDrawState.h" |
#include "GrDrawTargetCaps.h" |
+#include "gl/GrGpuGL.h" |
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
BlendOptFlags blendOptFlags, |
GrBlendCoeff optSrcCoeff, |
GrBlendCoeff optDstCoeff, |
- const GrDrawTargetCaps& caps) { |
+ GrGpu* gpu, |
+ const GrDeviceCoordTexture* dstCopy, |
+ GrGpu::DrawType drawType) { |
fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); |
fColor = drawState.getColor(); |
fCoverage = drawState.getCoverage(); |
@@ -52,7 +55,8 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove); |
} |
this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx); |
- this->setOutputStateInfo(drawState, caps, firstCoverageStageIdx, &separateCoverageFromColor); |
+ this->setOutputStateInfo(drawState, *gpu->caps(), firstCoverageStageIdx, |
+ &separateCoverageFromColor); |
// Copy GeometryProcesssor from DS or ODS |
if (drawState.hasGeometryProcessor()) { |
@@ -79,10 +83,16 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
fNumColorStages = fFragmentStages.count(); |
} |
} |
+ |
+ // now create a key |
+ gpu->buildKey(this, drawType, dstCopy, &fDesc); |
}; |
-GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDrawTargetCaps& caps, |
+GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, |
+ GrGpu* gpu, |
+ const GrDeviceCoordTexture* dstCopy, |
GrGpu::DrawType drawType) { |
+ const GrDrawTargetCaps& caps = *gpu->caps(); |
if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCachedCapsID) { |
GrBlendCoeff srcCoeff; |
GrBlendCoeff dstCoeff; |
@@ -100,7 +110,7 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra |
} |
drawState.fCachedOptState = SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, |
- dstCoeff, caps)); |
+ dstCoeff, gpu, dstCopy, drawType)); |
drawState.fCachedCapsID = caps.getUniqueID(); |
} else { |
#ifdef SK_DEBUG |
@@ -109,8 +119,8 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra |
BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
&srcCoeff, |
&dstCoeff); |
- SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, caps) == |
- *drawState.fCachedOptState); |
+ SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, gpu, dstCopy, |
+ drawType) == *drawState.fCachedOptState); |
#endif |
} |
drawState.fCachedOptState->ref(); |
@@ -122,8 +132,8 @@ void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
int firstCoverageStageIdx, |
bool* separateCoverageFromColor) { |
// Set this default and then possibly change our mind if there is coverage. |
- fPrimaryOutputType = kModulate_PrimaryOutputType; |
- fSecondaryOutputType = kNone_SecondaryOutputType; |
+ fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
+ fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
// If we do have coverage determine whether it matters. |
*separateCoverageFromColor = this->hasGeometryProcessor(); |
@@ -135,24 +145,24 @@ void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
if (caps.dualSourceBlendingSupport()) { |
if (kZero_GrBlendCoeff == fDstBlend) { |
// write the coverage value to second color |
- fSecondaryOutputType = kCoverage_SecondaryOutputType; |
+ fSecondaryOutputType = GrProgramDesc:: kCoverage_SecondaryOutputType; |
*separateCoverageFromColor = true; |
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
} else if (kSA_GrBlendCoeff == fDstBlend) { |
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
- fSecondaryOutputType = kCoverageISA_SecondaryOutputType; |
+ fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType; |
*separateCoverageFromColor = true; |
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
} else if (kSC_GrBlendCoeff == fDstBlend) { |
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
- fSecondaryOutputType = kCoverageISC_SecondaryOutputType; |
+ fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType; |
*separateCoverageFromColor = true; |
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
} |
} else if (fReadsDst && |
kOne_GrBlendCoeff == fSrcBlend && |
kZero_GrBlendCoeff == fDstBlend) { |
- fPrimaryOutputType = kCombineWithDst_PrimaryOutputType; |
+ fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType; |
*separateCoverageFromColor = true; |
} |
} |