Cleanup of r2830.



git-svn-id: http://skia.googlecode.com/svn/trunk@2841 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 340cff1..cbe153c 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -9,6 +9,7 @@
 
 
 #include "GrInOrderDrawBuffer.h"
+#include "GrRenderTarget.h"
 #include "GrTexture.h"
 #include "GrBufferAllocPool.h"
 #include "GrIndexBuffer.h"
@@ -78,6 +79,8 @@
     GrAssert(!(fDraws.empty() && fCurrQuad));
     GrAssert(!(0 != fMaxQuads && NULL == fQuadIndexBuffer));
 
+    GrDrawState* drawState = this->drawState();
+
     // if we have a quad IB then either append to the previous run of
     // rects or start a new run
     if (fMaxQuads) {
@@ -89,9 +92,8 @@
             GrPrintf("Failed to get space for vertices!\n");
             return;
         }
-        AutoViewMatrixRestore avmr(this);
-        GrMatrix combinedMatrix = this->getViewMatrix();
-        this->setViewMatrix(GrMatrix::I());
+        GrMatrix combinedMatrix = drawState->getViewMatrix();
+        GrDrawState::AutoViewMatrixRestore avmr(drawState, GrMatrix::I());
         if (NULL != matrix) {
             combinedMatrix.preConcat(*matrix);
         }
@@ -102,14 +104,14 @@
         // simply because the clip has changed if the clip doesn't affect
         // the rect.
         bool disabledClip = false;
-        if (this->isClipState() && fClip.isRect()) {
+        if (drawState->isClipState() && fClip.isRect()) {
 
             GrRect clipRect = fClip.getRect(0);
             // If the clip rect touches the edge of the viewport, extended it
             // out (close) to infinity to avoid bogus intersections.
             // We might consider a more exact clip to viewport if this
             // conservative test fails.
-            const GrRenderTarget* target = this->getRenderTarget();
+            const GrRenderTarget* target = drawState->getRenderTarget();
             if (0 >= clipRect.fLeft) {
                 clipRect.fLeft = GR_ScalarMin;
             }
@@ -132,7 +134,7 @@
                 }
             }
             if (insideClip) {
-                this->disableState(kClip_StateBit);
+                drawState->disableState(GrDrawState::kClip_StateBit);
                 disabledClip = true;
             }
         }
@@ -176,7 +178,7 @@
             fLastRectVertexLayout = layout;
         }
         if (disabledClip) {
-            this->enableState(kClip_StateBit);
+            drawState->enableState(GrDrawState::kClip_StateBit);
         }
     } else {
         INHERITED::drawRect(rect, matrix, stageMask, srcRects, srcMatrices);
@@ -310,8 +312,8 @@
         // the current render target. If we get that smart we have to make sure
         // those draws aren't read before this clear (render-to-texture).
         r.setLTRB(0, 0, 
-                  this->getRenderTarget()->width(), 
-                  this->getRenderTarget()->height());
+                  this->getDrawState().getRenderTarget()->width(), 
+                  this->getDrawState().getRenderTarget()->height());
         rect = &r;
     }
     Clear& clr = fClears.push_back();
@@ -328,9 +330,9 @@
     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.fTextures[s]);
+            GrSafeUnref(dstate.getTexture(s));
         }
-        GrSafeUnref(dstate.fRenderTarget);
+        GrSafeUnref(dstate.getRenderTarget());
     }
     int numDraws = fDraws.count();
     for (int d = 0; d < numDraws; ++d) {
@@ -593,15 +595,16 @@
 }
 
 void GrInOrderDrawBuffer::pushState() {
+    const GrDrawState& drawState = this->getDrawState();
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
-        GrSafeRef(fCurrDrawState.fTextures[s]);
+        GrSafeRef(drawState.getTexture(s));
     }
-    GrSafeRef(fCurrDrawState.fRenderTarget);
+    GrSafeRef(drawState.getRenderTarget());
     this->saveCurrentDrawState(&fStates.push_back());
  }
 
 bool GrInOrderDrawBuffer::needsNewClip() const {
-   if (fCurrDrawState.fFlagBits & kClip_StateBit) {
+   if (this->getDrawState().isClipState()) {
        if (fClips.empty() || (fClipSet && fClips.back() != fClip)) {
            return true;
        }