aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGpuGL.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-22 12:23:29 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-22 12:23:29 +0000
commit9e553c6e7cff5fd699ed4dee1d52317362ea30d0 (patch)
tree3b0a7cd23ac331881de26c74621f24e7286c0101 /src/gpu/gl/GrGpuGL.cpp
parent9ec075366ed94802a142fc5e948d19a774f85b43 (diff)
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
Diffstat (limited to 'src/gpu/gl/GrGpuGL.cpp')
-rw-r--r--src/gpu/gl/GrGpuGL.cpp84
1 files changed, 83 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 5b03500fc3..6c0d4b278e 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1734,8 +1734,90 @@ void GrGpuGL::onGpuDrawNonIndexed(GrPrimitiveType type,
#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) {