roll more changes from r2830 back in



git-svn-id: http://skia.googlecode.com/svn/trunk@2842 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f455984..de36307 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -217,20 +217,15 @@
 // 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_target_state(GrDrawTarget* target){
-        GrDrawState* drawState = target->drawState();
+void reset_draw_state(GrDrawState* drawState){
 
         drawState->setViewMatrix(GrMatrix::I());
         drawState->setColorFilter(0, SkXfermode::kDst_Mode);
-        drawState->disableState(GrDrawState::kDither_StateBit |
-                                GrDrawState::kHWAntialias_StateBit |
-                                GrDrawState::kClip_StateBit |
-                                GrDrawState::kNoColorWrites_StateBit |
-                                GrDrawState::kEdgeAAConcave_StateBit);
+        drawState->resetStateFlags();
         drawState->setEdgeAAData(NULL, 0);
         drawState->disableStencil();
         drawState->setAlpha(0xFF);
-        target->setBlendFunc(kOne_BlendCoeff,
+        drawState->setBlendFunc(kOne_BlendCoeff,
                            kZero_BlendCoeff);
         drawState->setFirstCoverageStage(GrDrawState::kNumStages);
         drawState->setDrawFace(GrDrawState::kBoth_DrawFace);
@@ -354,8 +349,8 @@
 
         if (NULL != texture) {
             GrDrawTarget::AutoStateRestore asr(fGpu);
-            reset_target_state(fGpu);
             GrDrawState* drawState = fGpu->drawState();
+            reset_draw_state(drawState);
             drawState->setRenderTarget(texture->asRenderTarget());
             drawState->setTexture(0, clampEntry.texture());
 
@@ -1779,8 +1774,8 @@
         GrAssert(NULL != target);
 
         GrDrawTarget::AutoStateRestore asr(fGpu);
-        reset_target_state(fGpu);
         GrDrawState* drawState = fGpu->drawState();
+        reset_draw_state(drawState);
         drawState->setRenderTarget(target);
 
         GrMatrix matrix;
@@ -1817,8 +1812,8 @@
     ASSERT_OWNED_RESOURCE(src);
 
     GrDrawTarget::AutoStateRestore asr(fGpu);
-    reset_target_state(fGpu);
     GrDrawState* drawState = fGpu->drawState();
+    reset_draw_state(drawState);
     drawState->setRenderTarget(dst);
     GrSamplerState sampler(GrSamplerState::kClamp_WrapMode,
                            GrSamplerState::kNearest_Filter);
@@ -1888,8 +1883,8 @@
                                      config, buffer, rowBytes, flags);
 
     GrDrawTarget::AutoStateRestore  asr(fGpu);
-    reset_target_state(fGpu);
     GrDrawState* drawState = fGpu->drawState();
+    reset_draw_state(drawState);
 
     GrMatrix matrix;
     matrix.setTranslate(GrIntToScalar(left), GrIntToScalar(top));
@@ -1949,7 +1944,7 @@
     } else {
         drawState->disableState(GrDrawState::kHWAntialias_StateBit);
     }
-    target->setBlendFunc(paint.fSrcBlendCoeff, paint.fDstBlendCoeff);
+    drawState->setBlendFunc(paint.fSrcBlendCoeff, paint.fDstBlendCoeff);
     drawState->setColorFilter(paint.fColorFilterColor, paint.fColorFilterXfermode);
 
     if (paint.getActiveMaskStageMask() && !target->canApplyCoverage()) {
@@ -2155,7 +2150,7 @@
     drawState->setViewMatrix(GrMatrix::I());
     drawState->setTexture(0, texture);
     drawState->setAlpha(0xFF);
-    fGpu->setBlendFunc(kOne_BlendCoeff, kZero_BlendCoeff);
+    drawState->setBlendFunc(kOne_BlendCoeff, kZero_BlendCoeff);
     fGpu->drawSimpleRect(rect, NULL, 1 << 0);
 }