aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGpu.cpp
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-05-10 14:23:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-10 14:23:01 -0700
commit12dbb3947e1aaf205b4fcf13b40e54e50650eb37 (patch)
treeb5f94e96f154882abce1ba1793e2ad45b8fef8d9 /src/gpu/gl/GrGLGpu.cpp
parent554784cd85029c05d9ed04b1aeb71520d196153a (diff)
Separate user and raw stencil settings
Adds a new GrUserStencilSettings class that describes in abstract terms how a draw will use the stencil (e.g. kAlwaysIfInClip, kSetClipBit, etc.). GrPipelineBuilder now only defines the GrUserStencilSettings. When the GrPipeline is finalized, the user stencil settings are then translated into concrete GrStencilSettings. At this point, GrClipMaskManager only needs to tell the GrAppliedClip whether or not there is a stencil clip. It does not need to modify stencil settings and GrPipelineBuilder does not need AutoRestoreStencil. This is one step of the stencil overhaul. In the future it will also allow us to clean up the special case handling for nvpr and the stateful fClipMode member of GrClipMaskManager. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1962243002 Review-Url: https://codereview.chromium.org/1962243002
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp74
1 files changed, 35 insertions, 39 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 40d0e488d5..8c5951dbdc 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2869,40 +2869,38 @@ namespace {
GrGLenum gr_to_gl_stencil_op(GrStencilOp op) {
- static const GrGLenum gTable[] = {
- GR_GL_KEEP, // kKeep_StencilOp
- GR_GL_REPLACE, // kReplace_StencilOp
- GR_GL_INCR_WRAP, // kIncWrap_StencilOp
- GR_GL_INCR, // kIncClamp_StencilOp
- GR_GL_DECR_WRAP, // kDecWrap_StencilOp
- GR_GL_DECR, // kDecClamp_StencilOp
- GR_GL_ZERO, // kZero_StencilOp
- GR_GL_INVERT, // kInvert_StencilOp
+ static const GrGLenum gTable[kGrStencilOpCount] = {
+ GR_GL_KEEP, // kKeep
+ GR_GL_ZERO, // kZero
+ GR_GL_REPLACE, // kReplace
+ GR_GL_INVERT, // kInvert
+ GR_GL_INCR_WRAP, // kIncWrap
+ GR_GL_DECR_WRAP, // kDecWrap
+ GR_GL_INCR, // kIncClamp
+ GR_GL_DECR, // kDecClamp
};
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCnt);
- GR_STATIC_ASSERT(0 == kKeep_StencilOp);
- GR_STATIC_ASSERT(1 == kReplace_StencilOp);
- GR_STATIC_ASSERT(2 == kIncWrap_StencilOp);
- GR_STATIC_ASSERT(3 == kIncClamp_StencilOp);
- GR_STATIC_ASSERT(4 == kDecWrap_StencilOp);
- GR_STATIC_ASSERT(5 == kDecClamp_StencilOp);
- GR_STATIC_ASSERT(6 == kZero_StencilOp);
- GR_STATIC_ASSERT(7 == kInvert_StencilOp);
- SkASSERT((unsigned) op < kStencilOpCnt);
- return gTable[op];
+ GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep);
+ GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero);
+ GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace);
+ GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert);
+ GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap);
+ GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap);
+ GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp);
+ GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp);
+ SkASSERT(op < (GrStencilOp)kGrStencilOpCount);
+ return gTable[(int)op];
}
void set_gl_stencil(const GrGLInterface* gl,
- const GrStencilSettings& settings,
- GrGLenum glFace,
- GrStencilSettings::Face grFace) {
- GrGLenum glFunc = GrToGLStencilFunc(settings.func(grFace));
- GrGLenum glFailOp = gr_to_gl_stencil_op(settings.failOp(grFace));
- GrGLenum glPassOp = gr_to_gl_stencil_op(settings.passOp(grFace));
+ const GrStencilSettings::Face& face,
+ GrGLenum glFace) {
+ GrGLenum glFunc = GrToGLStencilFunc(face.fTest);
+ GrGLenum glFailOp = gr_to_gl_stencil_op(face.fFailOp);
+ GrGLenum glPassOp = gr_to_gl_stencil_op(face.fPassOp);
- GrGLint ref = settings.funcRef(grFace);
- GrGLint mask = settings.funcMask(grFace);
- GrGLint writeMask = settings.writeMask(grFace);
+ GrGLint ref = face.fRef;
+ GrGLint mask = face.fTestMask;
+ GrGLint writeMask = face.fWriteMask;
if (GR_GL_FRONT_AND_BACK == glFace) {
// we call the combined func just in case separate stencil is not
@@ -2932,20 +2930,18 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
}
}
if (!stencilSettings.isDisabled()) {
- if (this->caps()->twoSidedStencilSupport()) {
+ if (stencilSettings.isTwoSided()) {
+ SkASSERT(this->caps()->twoSidedStencilSupport());
set_gl_stencil(this->glInterface(),
- stencilSettings,
- GR_GL_FRONT,
- GrStencilSettings::kFront_Face);
+ stencilSettings.front(),
+ GR_GL_FRONT);
set_gl_stencil(this->glInterface(),
- stencilSettings,
- GR_GL_BACK,
- GrStencilSettings::kBack_Face);
+ stencilSettings.back(),
+ GR_GL_BACK);
} else {
set_gl_stencil(this->glInterface(),
- stencilSettings,
- GR_GL_FRONT_AND_BACK,
- GrStencilSettings::kFront_Face);
+ stencilSettings.front(),
+ GR_GL_FRONT_AND_BACK);
}
}
fHWStencilSettings = stencilSettings;