Break up GrGpuGL::flushGLCommonState

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



git-svn-id: http://skia.googlecode.com/svn/trunk@4144 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 42043f9..379d40d 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2182,16 +2182,11 @@
                                     this->getResetTimestamp());
 }
 
-bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) {
+void GrGpuGL::flushMiscFixedFunctionState() {
 
-    GrDrawState* drawState = this->drawState();
-    // GrGpu::setupClipAndFlushState should have already checked this
-    // and bailed if not true.
-    GrAssert(NULL != drawState->getRenderTarget());
+    const GrDrawState& drawState = this->getDrawState();
 
-    this->flushAAState(type);
-
-    if (drawState->isDitherState()) {
+    if (drawState.isDitherState()) {
         if (kYes_TriState != fHWDitherEnabled) {
             GL_CALL(Enable(GR_GL_DITHER));
             fHWDitherEnabled = kYes_TriState;
@@ -2203,7 +2198,7 @@
         }
     }
 
-    if (drawState->isColorWriteDisabled()) {
+    if (drawState.isColorWriteDisabled()) {
         if (kNo_TriState != fHWWriteToColor) {
             GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE,
                               GR_GL_FALSE, GR_GL_FALSE));
@@ -2216,7 +2211,7 @@
         }
     }
 
-    if (fHWDrawFace != drawState->getDrawFace()) {
+    if (fHWDrawFace != drawState.getDrawFace()) {
         switch (this->getDrawState().getDrawFace()) {
             case GrDrawState::kCCW_DrawFace:
                 GL_CALL(Enable(GR_GL_CULL_FACE));
@@ -2232,23 +2227,8 @@
             default:
                 GrCrash("Unknown draw face.");
         }
-        fHWDrawFace = drawState->getDrawFace();
+        fHWDrawFace = drawState.getDrawFace();
     }
-
-#if GR_DEBUG
-    // check for circular rendering
-    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
-        GrAssert(!this->isStageEnabled(s) ||
-                 NULL == drawState->getRenderTarget() ||
-                 NULL == drawState->getTexture(s) ||
-                 drawState->getTexture(s)->asRenderTarget() !=
-                    drawState->getRenderTarget());
-    }
-#endif
-
-    this->flushStencil();
-
-    return true;
 }
 
 void GrGpuGL::notifyVertexBufferBind(const GrGLVertexBuffer* buffer) {
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index b5dd09a..3fab9ee 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -156,15 +156,6 @@
                     int* extraVertexOffset,
                     int* extraIndexOffset);
 
-    // flushes state that is common to fixed and programmable GL
-    // dither
-    // line smoothing
-    // texture binding
-    // sampler state (filtering, tiling)
-    // FBO binding
-    // line width
-    bool flushGLStateCommon(GrPrimitiveType type);
-
     // Subclasses should call this to flush the blend state.
     // The params should be the final coeffecients to apply
     // (after any blending optimizations or dual source blending considerations
@@ -265,6 +256,9 @@
     // flushes the color matrix
     void flushColorMatrix();
 
+    // flushes dithering, color-mask, and face culling stat
+    void flushMiscFixedFunctionState();
+
     static void DeleteProgram(const GrGLInterface* gl,
                               CachedData* programData);
 
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 1f3216f..c230d40 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -389,12 +389,15 @@
 }
 
 bool GrGpuGL::flushGraphicsState(GrPrimitiveType type) {
-    if (!flushGLStateCommon(type)) {
-        return false;
-    }
-
     const GrDrawState& drawState = this->getDrawState();
 
+    // GrGpu::setupClipAndFlushState should have already checked this
+    // and bailed if not true.
+    GrAssert(NULL != drawState.getRenderTarget());
+
+    this->flushStencil();
+    this->flushAAState(type);
+
     GrBlendCoeff srcCoeff;
     GrBlendCoeff dstCoeff;
     BlendOptFlags blendOpts = this->getBlendOpts(false, &srcCoeff, &dstCoeff);
@@ -438,6 +441,15 @@
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (this->isStageEnabled(s)) {
 
+
+#if GR_DEBUG
+        // check for circular rendering
+        GrAssert(NULL == drawState.getRenderTarget() ||
+                 NULL == drawState.getTexture(s) ||
+                 drawState.getTexture(s)->asRenderTarget() !=
+                    drawState.getRenderTarget());
+#endif
+
             this->flushBoundTextureAndParams(s);
 
             this->flushTextureMatrixAndDomain(s);