aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrClipMaskManager.cpp15
-rw-r--r--src/gpu/GrStencil.h46
-rw-r--r--src/gpu/gl/GrGpuGL.cpp84
3 files changed, 106 insertions, 39 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 53221a3aa2..6b8074329d 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -911,18 +911,9 @@ void GrClipMaskManager::setGpuStencil() {
stencilBits = stencilBuffer->bits();
}
-#if GR_DEBUG
- if (!fGpu->getCaps().fStencilWrapOpsSupport) {
- GrAssert(settings.frontPassOp() != kIncWrap_StencilOp);
- GrAssert(settings.frontPassOp() != kDecWrap_StencilOp);
- GrAssert(settings.frontFailOp() != kIncWrap_StencilOp);
- GrAssert(settings.backFailOp() != kDecWrap_StencilOp);
- GrAssert(settings.backPassOp() != kIncWrap_StencilOp);
- GrAssert(settings.backPassOp() != kDecWrap_StencilOp);
- GrAssert(settings.backFailOp() != kIncWrap_StencilOp);
- GrAssert(settings.frontFailOp() != kDecWrap_StencilOp);
- }
-#endif
+ GrAssert(fGpu->getCaps().fStencilWrapOpsSupport ||
+ !settings.usesWrapOp());
+ GrAssert(fGpu->getCaps().fTwoSidedStencilSupport || !settings.isTwoSided());
this->adjustStencilParams(&settings, clipMode, stencilBits);
fGpu->setStencilSettings(settings);
}
diff --git a/src/gpu/GrStencil.h b/src/gpu/GrStencil.h
index 3a7595a796..b4aa70e554 100644
--- a/src/gpu/GrStencil.h
+++ b/src/gpu/GrStencil.h
@@ -178,19 +178,6 @@ public:
fPad0 = fPad1 = 0;
this->setDisabled();
}
-
- GrStencilOp frontPassOp() const { return static_cast<GrStencilOp>(fPassOps[kFront_Face]); }
- GrStencilOp backPassOp() const { return static_cast<GrStencilOp>(fPassOps[kBack_Face]); }
- GrStencilOp frontFailOp() const { return static_cast<GrStencilOp>(fFailOps[kFront_Face]); }
- GrStencilOp backFailOp() const { return static_cast<GrStencilOp>(fFailOps[kBack_Face]); }
- GrStencilFunc frontFunc() const { return static_cast<GrStencilFunc>(fFuncs[kFront_Face]); }
- GrStencilFunc backFunc() const { return static_cast<GrStencilFunc>(fFuncs[kBack_Face]); }
- uint16_t frontFuncMask() const { return fFuncMasks[kFront_Face]; }
- uint16_t backFuncMask() const { return fFuncMasks[kBack_Face]; }
- uint16_t frontFuncRef() const { return fFuncRefs[kFront_Face]; }
- uint16_t backFuncRef() const { return fFuncRefs[kBack_Face]; }
- uint16_t frontWriteMask() const { return fWriteMasks[kFront_Face]; }
- uint16_t backWriteMask() const { return fWriteMasks[kFront_Face]; }
GrStencilOp passOp(Face f) const { return static_cast<GrStencilOp>(fPassOps[f]); }
GrStencilOp failOp(Face f) const { return static_cast<GrStencilOp>(fFailOps[f]); }
@@ -199,19 +186,6 @@ public:
uint16_t funcRef(Face f) const { return fFuncRefs[f]; }
uint16_t writeMask(Face f) const { return fWriteMasks[f]; }
- void setFrontPassOp(GrStencilOp op) { fPassOps[kFront_Face] = op; fFlags = 0;}
- void setBackPassOp(GrStencilOp op) { fPassOps[kBack_Face] = op; fFlags = 0;}
- void setFrontFailOp(GrStencilOp op) { fFailOps[kFront_Face] = op; fFlags = 0;}
- void setBackFailOp(GrStencilOp op) { fFailOps[kBack_Face] = op; fFlags = 0;}
- void setFrontFunc(GrStencilFunc func) { fFuncs[kFront_Face] = func; fFlags = 0;}
- void setBackFunc(GrStencilFunc func) { fFuncs[kBack_Face] = func; fFlags = 0;}
- void setFrontFuncMask(unsigned short mask) { fFuncMasks[kFront_Face] = mask; }
- void setBackFuncMask(unsigned short mask) { fFuncMasks[kBack_Face] = mask; }
- void setFrontFuncRef(unsigned short ref) { fFuncRefs[kFront_Face] = ref; }
- void setBackFuncRef(unsigned short ref) { fFuncRefs[kBack_Face] = ref; }
- void setFrontWriteMask(unsigned short writeMask) { fWriteMasks[kFront_Face] = writeMask; }
- void setBackWriteMask(unsigned short writeMask) { fWriteMasks[kBack_Face] = writeMask; }
-
void setPassOp(Face f, GrStencilOp op) { fPassOps[f] = op; fFlags = 0;}
void setFailOp(Face f, GrStencilOp op) { fFailOps[f] = op; fFlags = 0;}
void setFunc(Face f, GrStencilFunc func) { fFuncs[f] = func; fFlags = 0;}
@@ -251,6 +225,26 @@ public:
fFlags = kIsDisabled_StencilFlag | kDoesNotWrite_StencilFlag;
}
+ bool isTwoSided() const {
+ return fPassOps[kFront_Face] != fPassOps[kBack_Face] ||
+ fFailOps[kFront_Face] != fFailOps[kBack_Face] ||
+ fFuncs[kFront_Face] != fFuncs[kBack_Face] ||
+ fFuncMasks[kFront_Face] != fFuncMasks[kBack_Face] ||
+ fFuncRefs[kFront_Face] != fFuncRefs[kBack_Face] ||
+ fWriteMasks[kFront_Face] != fWriteMasks[kBack_Face];
+ }
+
+ bool usesWrapOp() const {
+ return kIncWrap_StencilOp == fPassOps[kFront_Face] ||
+ kDecWrap_StencilOp == fPassOps[kFront_Face] ||
+ kIncWrap_StencilOp == fPassOps[kBack_Face] ||
+ kDecWrap_StencilOp == fPassOps[kBack_Face] ||
+ kIncWrap_StencilOp == fFailOps[kFront_Face] ||
+ kDecWrap_StencilOp == fFailOps[kFront_Face] ||
+ kIncWrap_StencilOp == fFailOps[kBack_Face] ||
+ kDecWrap_StencilOp == fFailOps[kBack_Face];
+ }
+
bool isDisabled() const {
if (fFlags & kIsDisabled_StencilFlag) {
return true;
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) {