Index: src/gpu/GrDrawState.cpp |
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp |
index 0c2b1c3684e295d3bb321669375a9f3d414cb4ed..236d48f229ef2b478a7e1e77c5f13bca4e190326 100644 |
--- a/src/gpu/GrDrawState.cpp |
+++ b/src/gpu/GrDrawState.cpp |
@@ -54,6 +54,9 @@ GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatr |
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
*this = state; |
if (!preConcatMatrix.isIdentity()) { |
+ if (this->hasGeometryProcessor()) { |
+ fGeometryProcessor->localCoordChange(preConcatMatrix); |
+ } |
for (int i = 0; i < this->numColorStages(); ++i) { |
fColorStages[i].localCoordChange(preConcatMatrix); |
} |
@@ -79,6 +82,11 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
fStencilSettings = that.fStencilSettings; |
fCoverage = that.fCoverage; |
fDrawFace = that.fDrawFace; |
+ if (that.hasGeometryProcessor()) { |
+ fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*that.fGeometryProcessor.get()))); |
+ } else { |
+ fGeometryProcessor.reset(NULL); |
+ } |
fColorStages = that.fColorStages; |
fCoverageStages = that.fCoverageStages; |
fOptSrcBlend = that.fOptSrcBlend; |
@@ -95,6 +103,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
+ fGeometryProcessor.reset(NULL); |
fColorStages.reset(); |
fCoverageStages.reset(); |
@@ -128,6 +137,9 @@ bool GrDrawState::setIdentityViewMatrix() { |
// sad trombone sound |
return false; |
} |
+ if (this->hasGeometryProcessor()) { |
+ fGeometryProcessor->localCoordChange(invVM); |
+ } |
for (int s = 0; s < this->numColorStages(); ++s) { |
fColorStages[s].localCoordChange(invVM); |
} |
@@ -142,6 +154,7 @@ bool GrDrawState::setIdentityViewMatrix() { |
void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) { |
SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
+ fGeometryProcessor.reset(NULL); |
fColorStages.reset(); |
fCoverageStages.reset(); |
@@ -286,6 +299,8 @@ GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore( |
void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
if (NULL != fDrawState) { |
+ fDrawState->fGeometryProcessor.reset(fGeometryProcessor.detach()); |
+ |
int m = fDrawState->numColorStages() - fColorEffectCnt; |
SkASSERT(m >= 0); |
fDrawState->fColorStages.pop_back_n(m); |
@@ -300,6 +315,11 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
} |
fDrawState = ds; |
if (NULL != ds) { |
+ if (ds->hasGeometryProcessor()) { |
+ fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*ds->getGeometryProcessor()))); |
+ } else { |
+ fGeometryProcessor.reset(NULL); |
+ } |
fColorEffectCnt = ds->numColorStages(); |
fCoverageEffectCnt = ds->numCoverageStages(); |
SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) |
@@ -429,6 +449,10 @@ void GrDrawState::AutoViewMatrixRestore::restore() { |
SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); |
int i = 0; |
+ if (fHasGeometryProcessor) { |
+ SkASSERT(fDrawState->hasGeometryProcessor()); |
+ fDrawState->fGeometryProcessor->restoreCoordChange(fSavedCoordChanges[i++]); |
+ } |
for (int s = 0; s < fNumColorStages; ++s, ++i) { |
fDrawState->fColorStages[s].restoreCoordChange(fSavedCoordChanges[i]); |
} |
@@ -471,6 +495,7 @@ bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) { |
if (0 == drawState->numTotalStages()) { |
drawState->fViewMatrix.reset(); |
fDrawState = drawState; |
+ fHasGeometryProcessor = false; |
fNumColorStages = 0; |
fSavedCoordChanges.reset(0); |
SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
@@ -492,6 +517,13 @@ void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co |
fSavedCoordChanges.reset(fDrawState->numTotalStages()); |
int i = 0; |
+ fHasGeometryProcessor = false; |
+ if (fDrawState->hasGeometryProcessor()) { |
+ fDrawState->fGeometryProcessor->saveCoordChange(&fSavedCoordChanges[i++]); |
+ fDrawState->fGeometryProcessor->localCoordChange(coordChangeMatrix); |
+ fHasGeometryProcessor = true; |
+ } |
+ |
fNumColorStages = fDrawState->numColorStages(); |
for (int s = 0; s < fNumColorStages; ++s, ++i) { |
fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); |
@@ -543,6 +575,10 @@ bool GrDrawState::srcAlphaWillBeOne() const { |
} |
// Run through the coverage stages |
+ if (this->hasGeometryProcessor()) { |
+ const GrEffect* effect = fGeometryProcessor->getEffect(); |
+ effect->getConstantColorComponents(&coverage, &coverageComponentFlags); |
+ } |
for (int s = 0; s < this->numCoverageStages(); ++s) { |
const GrEffect* effect = this->getCoverageStage(s).getEffect(); |
effect->getConstantColorComponents(&coverage, &coverageComponentFlags); |