Reland r7342 with fixes.



git-svn-id: http://skia.googlecode.com/svn/trunk@7346 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index e327413..87ecc85 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -570,8 +570,11 @@
 
     GrDrawTarget::AutoClipRestore acr(target);
     AutoGeometryPush agp(target);
+
+    GrDrawState playbackState;
     GrDrawState* prevDrawState = target->drawState();
     prevDrawState->ref();
+    target->setDrawState(&playbackState);
 
     GrClipData clipData;
 
@@ -581,6 +584,7 @@
     int currDraw        = 0;
     int currStencilPath = 0;
 
+
     for (int c = 0; c < numCmds; ++c) {
         switch (fCmds[c]) {
             case kDraw_Cmd: {
@@ -611,7 +615,7 @@
                 break;
             }
             case kSetState_Cmd:
-                target->setDrawState(&fStates[currState]);
+                fStates[currState].restoreTo(&playbackState);
                 ++currState;
                 break;
             case kSetClip_Cmd:
@@ -860,7 +864,7 @@
 }
 
 bool GrInOrderDrawBuffer::needsNewState() const {
-    return fStates.empty() || fStates.back() != this->getDrawState();
+    return fStates.empty() || !fStates.back().isEqual(this->getDrawState());
 }
 
 bool GrInOrderDrawBuffer::needsNewClip() const {
@@ -883,19 +887,8 @@
     fCmds.push_back(kSetClip_Cmd);
 }
 
-void GrInOrderDrawBuffer::recordDefaultClip() {
-    fClips.push_back() = SkClipStack();
-    fClipOrigins.push_back() = SkIPoint::Make(0, 0);
-    fCmds.push_back(kSetClip_Cmd);
-}
-
 void GrInOrderDrawBuffer::recordState() {
-    fStates.push_back(this->getDrawState());
-    fCmds.push_back(kSetState_Cmd);
-}
-
-void GrInOrderDrawBuffer::recordDefaultState() {
-    fStates.push_back(GrDrawState());
+    fStates.push_back().saveFrom(this->getDrawState());
     fCmds.push_back(kSetState_Cmd);
 }