Minor GrStencilSettings cleanup

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



git-svn-id: http://skia.googlecode.com/svn/trunk@4299 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 5b03500..6c0d4b2 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1734,8 +1734,90 @@
 #endif
 }
 
-void GrGpuGL::onGpuStencilPath(const GrPath&, GrPathFill) {
+void GrGpuGL::onGpuStencilPath(const GrPath& path, GrPathFill fill) {
     GrCrash("Not implemented yet. Should not get here.");
+#if 0
+    GrGLuint id = static_cast<const GrGLPath*>(&path)->pathID();
+    GrDrawState* drawState = this->drawState();
+    GrAssert(NULL != drawState->getRenderTarget());
+    if (NULL == drawState->getRenderTarget()->getStencilBuffer()) {
+        return;
+    }
+    GrRenderTarget* rt = drawState->getRenderTarget();
+
+    GrGLint stencilBits = rt->getStencilBuffer()->bits();
+    GrGLuint clipStencilMask = 1 << (stencilBits -1);
+    GrGLuint userStencilMask = clipStencilMask - 1;
+    unsigned ref = 0;
+    unsigned mask = 0;
+    GrStencilFunc func = ConvertStencilFuncAndMask(kAlwaysIfInClip_StencilFunc,
+                                      fClipMaskManager.isClipInStencil() && drawState->isClipState(),
+                                      clipStencilMask,
+                                      userStencilMask,
+                                      &ref,
+                                      &mask);
+    const GrMatrix& m = drawState->getViewMatrix();
+    // We use the GL model view matrix to hold the draw state's view matrix
+    // and the GL projection matrix to convert to normalized y-up coords.
+    GrGLfloat mv[]  = {
+        // col 0
+        GrScalarToFloat(m[GrMatrix::kMScaleX]),
+        GrScalarToFloat(m[GrMatrix::kMSkewY]),
+        0,
+        GrScalarToFloat(m[GrMatrix::kMPersp0]),
+
+        // col 1
+        GrScalarToFloat(m[GrMatrix::kMSkewX]),
+        GrScalarToFloat(m[GrMatrix::kMScaleY]),
+        0,
+        GrScalarToFloat(m[GrMatrix::kMPersp1]),
+
+        // col 2
+        0, 0, 0, 0,
+
+        // col3
+        GrScalarToFloat(m[GrMatrix::kMTransX]),
+        GrScalarToFloat(m[GrMatrix::kMTransY]),
+        0.5f,
+        GrScalarToFloat(m[GrMatrix::kMPersp2])
+    };
+    GrGLfloat p[] = {
+        // col 0
+        2.f / rt->width(), 0, 0, 0,
+
+        // col 1
+        0, -2.f / rt->height(), 0, 0,
+
+        // col 2
+        0, 0, 1.f, 0,
+
+        // col 3
+        -1.f, 1.f, 0, 1.f,
+    };
+    GL_CALL(MatrixMode(GR_GL_MODELVIEW));
+    GL_CALL(LoadMatrixf(mv));
+    GL_CALL(MatrixMode(GR_GL_PROJECTION));
+    GL_CALL(LoadMatrixf(p));
+
+    GL_CALL(Enable(GR_GL_STENCIL_TEST));
+    GL_CALL(PathStencilFunc(grToGLStencilFunc[func], ref, mask));
+    fHWStencilSettings.invalidate();
+
+    // Decide how to manipulate the stencil buffer based on the fill rule.
+    GrGLenum fillMode;
+    switch (fill) {
+        case kWinding_PathFill:
+            fillMode = GR_GL_COUNT_UP;
+            break;
+        case kEvenOdd_PathFill:
+            fillMode = GR_GL_INVERT;
+            break;
+        default:
+            // Only the above two fill rules are allowed.
+            GrCrash("Invalid fill rule.");
+    }
+    GL_CALL(StencilFillPath(id, fillMode, mask));
+#endif
 }
 
 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) {