Index: src/gpu/GrDrawState.cpp |
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp |
index 236d48f229ef2b478a7e1e77c5f13bca4e190326..6acc202065b78a4872c2f52846709ab5c0b6e076 100644 |
--- a/src/gpu/GrDrawState.cpp |
+++ b/src/gpu/GrDrawState.cpp |
@@ -299,7 +299,14 @@ GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore( |
void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
if (NULL != fDrawState) { |
- fDrawState->fGeometryProcessor.reset(fGeometryProcessor.detach()); |
+ // See the big comment on the class definition about GPs. |
+ if (NULL != fOriginalGP) { |
+ SkASSERT(fDrawState->getGeometryProcessor()->getEffect() == fOriginalGP); |
+ fOriginalGP->unref(); |
+ fOriginalGP = NULL; |
+ } else { |
+ fDrawState->fGeometryProcessor.reset(NULL); |
+ } |
int m = fDrawState->numColorStages() - fColorEffectCnt; |
SkASSERT(m >= 0); |
@@ -315,10 +322,9 @@ 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); |
+ SkASSERT(NULL == fOriginalGP); |
+ if (NULL != ds->getGeometryProcessor()) { |
+ fOriginalGP = SkRef(ds->getGeometryProcessor()->getEffect()); |
} |
fColorEffectCnt = ds->numColorStages(); |
fCoverageEffectCnt = ds->numCoverageStages(); |