Fixed texture ref/unref bug in GrInOrderDrawBuffer/GrDrawState
http://codereview.appspot.com/6186043/
git-svn-id: http://skia.googlecode.com/svn/trunk@3832 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index e6b3ca8..de49e8c 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -466,6 +466,10 @@
GrSafeUnref(fStates[i].getTexture(s));
}
GrSafeUnref(fStates[i].getRenderTarget());
+
+ // GrInOrderDrawBuffer is no longer managing the refs/unrefs
+ // for the stored GrDrawStates
+ fStates[i].disableState(GrDrawState::kTexturesNeedRef_StateBit);
}
int numDraws = fDraws.count();
for (int d = 0; d < numDraws; ++d) {
@@ -782,6 +786,10 @@
}
GrSafeRef(drawState.getRenderTarget());
fStates.push_back(this->getDrawState());
+
+ // Any textures that are added to the stored state need to be
+ // reffed so the unref in reset doesn't inappropriately free them
+ fStates.back().enableState(GrDrawState::kTexturesNeedRef_StateBit);
}
bool GrInOrderDrawBuffer::needsNewClip() const {