Index: src/gpu/gl/GrGpuGL.cpp |
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
index 4f4bb0f93f51c40af99e37a361f822e2267892cf..8f4d1be0ebbdcc5c366d75ecd997535eee63aedb 100644 |
--- a/src/gpu/gl/GrGpuGL.cpp |
+++ b/src/gpu/gl/GrGpuGL.cpp |
@@ -1680,20 +1680,29 @@ const GrStencilSettings& even_odd_nv_path_stencil_settings() { |
kOnes16, kOnes16, kOnes16); |
return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
} |
-} |
-void GrGpuGL::setStencilPathSettings(const GrPath&, |
- SkPath::FillType fill, |
- GrStencilSettings* settings) { |
+GrGLenum sk_path_fill_type_to_gl_fill_mode(SkPath::FillType fill) { |
switch (fill) { |
- case SkPath::kEvenOdd_FillType: |
- *settings = even_odd_nv_path_stencil_settings(); |
- return; |
+ default: |
+ GrCrash("Unexpected path fill."); |
+ /* fallthrough */; |
case SkPath::kWinding_FillType: |
- *settings = winding_nv_path_stencil_settings(); |
- return; |
+ return GR_GL_COUNT_UP; |
+ case SkPath::kEvenOdd_FillType: |
+ return GR_GL_INVERT; |
+ } |
+} |
+} |
+ |
+const GrStencilSettings& GrGpuGL::getStencilPathSettings(const GrPath&, SkPath::FillType fill) { |
+ switch (fill) { |
default: |
GrCrash("Unexpected path fill."); |
+ /* fallthrough */; |
+ case SkPath::kWinding_FillType: |
+ return winding_nv_path_stencil_settings(); |
+ case SkPath::kEvenOdd_FillType: |
+ return even_odd_nv_path_stencil_settings(); |
} |
} |
@@ -1708,32 +1717,48 @@ void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) { |
} |
// Decide how to manipulate the stencil buffer based on the fill rule. |
- // Also, assert that the stencil settings we set in setStencilPathSettings |
- // are present. |
SkASSERT(!fStencilSettings.isTwoSided()); |
- GrGLenum fillMode; |
- switch (fill) { |
- case SkPath::kWinding_FillType: |
- fillMode = GR_GL_COUNT_UP; |
- SkASSERT(kIncClamp_StencilOp == |
- fStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
- SkASSERT(kIncClamp_StencilOp == |
- fStencilSettings.failOp(GrStencilSettings::kFront_Face)); |
- break; |
- case SkPath::kEvenOdd_FillType: |
- fillMode = GR_GL_INVERT; |
- SkASSERT(kInvert_StencilOp == |
- fStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
- SkASSERT(kInvert_StencilOp == |
- fStencilSettings.failOp(GrStencilSettings::kFront_Face)); |
- break; |
- default: |
- // Only the above two fill rules are allowed. |
- GrCrash("Unexpected path fill."); |
- return; // suppress unused var warning. |
+ GrGLenum fillMode = sk_path_fill_type_to_gl_fill_mode(fill); |
+ GrGLint writeMask = fStencilPathSettings.writeMask(GrStencilSettings::kFront_Face); |
+ GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
+} |
+ |
+void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { |
+ SkASSERT(this->caps()->pathStencilingSupport()); |
+ |
+ GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); |
+ GrDrawState* drawState = this->drawState(); |
+ SkASSERT(NULL != drawState->getRenderTarget()); |
+ if (NULL == drawState->getRenderTarget()->getStencilBuffer()) { |
Mark Kilgard
2013/09/13 15:42:24
Do we really expect to get here without a stencil
bsalomon
2013/09/13 20:25:28
It's not illegal for a caller to give us an FBO wi
Kimmo Kinnunen
2013/09/18 07:52:38
Done.
|
+ return; |
} |
- GrGLint writeMask = fStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
+ |
+ SkASSERT(!fStencilSettings.isTwoSided()); |
+ GrGLenum fillMode = sk_path_fill_type_to_gl_fill_mode(fill); |
+ GrGLint writeMask = fStencilPathSettings.writeMask(GrStencilSettings::kFront_Face); |
GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
+ if (!fCurrentProgram->hasVertexShader()) { |
+ GL_CALL(CoverFillPath(id, GR_GL_CONVEX_HULL)); |
Chris Dalton
2013/09/13 19:49:58
I'd suggest using BOUNDING_BOX here.
Mark, though
Kimmo Kinnunen
2013/09/18 07:52:38
Done.
|
+ } else { |
Mark Kilgard
2013/09/13 15:42:24
Is there a reason we would ever want to get into t
Chris Dalton
2013/09/13 19:49:58
Yes, the contract is that every time we draw a pat
bsalomon
2013/09/13 20:25:28
agreed
Kimmo Kinnunen
2013/09/18 07:52:38
I'm not sure I follow. I thought an effect can for
bsalomon
2013/09/18 14:24:22
Effects that require vertex shaders are only insta
|
+ GrDrawState::AutoViewMatrixRestore avmr; |
+ SkMatrix vmi; |
+ SkRect bounds = SkRect::MakeLTRB(0, 0, |
+ SkIntToScalar(drawState->getRenderTarget()->width()), |
+ SkIntToScalar(drawState->getRenderTarget()->height())); |
+ |
+ // mapRect through persp matrix may not be correct |
+ if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewInverse(&vmi)) { |
+ vmi.mapRect(&bounds); |
+ // theoretically could set bloat = 0, instead leave it because of matrix inversion |
+ // precision. |
+ SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_ScalarHalf; |
+ bounds.outset(bloat, bloat); |
+ } else { |
+ avmr.setIdentity(drawState); |
+ } |
+ |
+ this->drawSimpleRect(bounds, NULL); |
+ } |
} |
void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { |
@@ -1857,16 +1882,20 @@ void set_gl_stencil(const GrGLInterface* gl, |
} |
void GrGpuGL::flushStencil(DrawType type) { |
- if (kStencilPath_DrawType == type) { |
- SkASSERT(!fStencilSettings.isTwoSided()); |
+ if ((kStencilPath_DrawType == type || kDrawPath_DrawType == type) && |
+ fHWStencilPathSettings != fStencilPathSettings) { |
+ SkASSERT(!fStencilPathSettings.isTwoSided()); |
// Just the func, ref, and mask is set here. The op and write mask are params to the call |
// that draws the path to the SB (glStencilFillPath) |
GrGLenum func = |
- gr_to_gl_stencil_func(fStencilSettings.func(GrStencilSettings::kFront_Face)); |
+ gr_to_gl_stencil_func(fStencilPathSettings.func(GrStencilSettings::kFront_Face)); |
GL_CALL(PathStencilFunc(func, |
- fStencilSettings.funcRef(GrStencilSettings::kFront_Face), |
- fStencilSettings.funcMask(GrStencilSettings::kFront_Face))); |
- } else if (fHWStencilSettings != fStencilSettings) { |
+ fStencilPathSettings.funcRef(GrStencilSettings::kFront_Face), |
+ fStencilPathSettings.funcMask(GrStencilSettings::kFront_Face))); |
+ fHWStencilPathSettings = fStencilPathSettings; |
+ } |
+ |
+ if (kStencilPath_DrawType != type && fHWStencilSettings != fStencilSettings) { |
if (fStencilSettings.isDisabled()) { |
if (kNo_TriState != fHWStencilTestEnabled) { |
GL_CALL(Disable(GR_GL_STENCIL_TEST)); |