Add GrDrawState reset

Review URL: http://codereview.appspot.com/5543059/




git-svn-id: http://skia.googlecode.com/svn/trunk@3043 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d9b9f08..0a3ab42 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -215,23 +215,6 @@
                            sb->numSamples(), v);
 }
 
-// This should be subsumed by a future version of GrDrawState
-// It does not reset stage textures/samplers or per-vertex-edge-aa state since
-// they aren't used unless the vertex layout references them.
-// It also doesn't set the render target.
-void reset_draw_state(GrDrawState* drawState){
-
-        drawState->setViewMatrix(GrMatrix::I());
-        drawState->setColorFilter(0, SkXfermode::kDst_Mode);
-        drawState->resetStateFlags();
-        drawState->setEdgeAAData(NULL, 0);
-        drawState->disableStencil();
-        drawState->setAlpha(0xFF);
-        drawState->setBlendFunc(kOne_BlendCoeff,
-                           kZero_BlendCoeff);
-        drawState->setFirstCoverageStage(GrDrawState::kNumStages);
-        drawState->setDrawFace(GrDrawState::kBoth_DrawFace);
-}
 }
 
 GrContext::TextureCacheEntry GrContext::findAndLockTexture(
@@ -356,7 +339,7 @@
         if (NULL != texture) {
             GrDrawTarget::AutoStateRestore asr(fGpu);
             GrDrawState* drawState = fGpu->drawState();
-            reset_draw_state(drawState);
+            drawState->reset();
             drawState->setRenderTarget(texture->asRenderTarget());
             drawState->setTexture(0, clampEntry.texture());
 
@@ -786,11 +769,13 @@
     GrRenderTarget* offRT = record->fOffscreen.texture()->asRenderTarget();
     GrAssert(NULL != offRT);
 
-    GrPaint tempPaint;
-    tempPaint.reset();
-    this->setPaint(tempPaint, target);
+    
     GrDrawState* drawState = target->drawState();
+    GrMatrix vm = drawState->getViewMatrix();
+    drawState->reset();
+    *drawState->viewMatrix() = vm;
     drawState->setRenderTarget(offRT);
+    
 #if PREFER_MSAA_OFFSCREEN_AA
     drawState->enableState(GrDrawState::kHWAntialias_StateBit);
 #endif
@@ -1900,7 +1885,7 @@
 
         GrDrawTarget::AutoStateRestore asr(fGpu);
         GrDrawState* drawState = fGpu->drawState();
-        reset_draw_state(drawState);
+        drawState->reset();
         drawState->setRenderTarget(target);
 
         GrMatrix matrix;
@@ -1934,7 +1919,7 @@
 
     GrDrawTarget::AutoStateRestore asr(fGpu);
     GrDrawState* drawState = fGpu->drawState();
-    reset_draw_state(drawState);
+    drawState->reset();
     drawState->setRenderTarget(dst);
     GrMatrix sampleM;
     sampleM.setIDiv(src->width(), src->height());
@@ -2004,7 +1989,7 @@
 
     GrDrawTarget::AutoStateRestore  asr(fGpu);
     GrDrawState* drawState = fGpu->drawState();
-    reset_draw_state(drawState);
+    drawState->reset();
 
     GrMatrix matrix;
     matrix.setTranslate(GrIntToScalar(left), GrIntToScalar(top));