Make fewer copies when using GrDrawTarget::AutoStateRestore
Review URL: http://codereview.appspot.com/5938043/
git-svn-id: http://skia.googlecode.com/svn/trunk@3557 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index ab46a47..e6b3ca8 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -462,11 +462,10 @@
this->resetIndexSource();
uint32_t numStates = fStates.count();
for (uint32_t i = 0; i < numStates; ++i) {
- const GrDrawState& dstate = this->accessSavedDrawState(fStates[i]);
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
- GrSafeUnref(dstate.getTexture(s));
+ GrSafeUnref(fStates[i].getTexture(s));
}
- GrSafeUnref(dstate.getRenderTarget());
+ GrSafeUnref(fStates[i].getRenderTarget());
}
int numDraws = fDraws.count();
for (int d = 0; d < numDraws; ++d) {
@@ -522,8 +521,7 @@
const Draw& draw = fDraws[i];
if (draw.fStateChanged) {
++currState;
- GrDrawState* ds = &GrDrawTarget::accessSavedDrawState(fStates[currState]);
- target->setDrawState(ds);
+ target->setDrawState(&fStates[currState]);
}
if (draw.fClipChanged) {
++currClip;
@@ -773,8 +771,7 @@
if (fStates.empty()) {
return true;
} else {
- const GrDrawState& old = this->accessSavedDrawState(fStates.back());
- return old != this->getDrawState();
+ return fStates.back() != this->getDrawState();
}
}
@@ -784,7 +781,7 @@
GrSafeRef(drawState.getTexture(s));
}
GrSafeRef(drawState.getRenderTarget());
- this->saveCurrentDrawState(&fStates.push_back());
+ fStates.push_back(this->getDrawState());
}
bool GrInOrderDrawBuffer::needsNewClip() const {