aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-05-11 13:58:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-11 13:58:09 -0700
commit93a379bd4d6b30d86c270b879cf172d80172a72b (patch)
treeccf26fcf4d1fcba61a816f6c8fcdc8c57ddbda3b /src/gpu/gl
parentf8237781d28bad38522b3b351688a2f7ee5e0caa (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 Committed: https://skia.googlesource.com/skia/+/12dbb3947e1aaf205b4fcf13b40e54e50650eb37 Review-Url: https://codereview.chromium.org/1962243002
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp74
-rw-r--r--src/gpu/gl/GrGLPathRendering.cpp37
-rw-r--r--src/gpu/gl/GrGLPathRendering.h2
-rw-r--r--src/gpu/gl/GrGLUtil.cpp43
-rw-r--r--src/gpu/gl/GrGLUtil.h4
5 files changed, 76 insertions, 84 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 004a4a90a5..6b03df3e10 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2874,40 +2874,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
@@ -2937,20 +2935,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;
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index 5616f9d58a..66648d8479 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -70,9 +70,9 @@ static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) {
default:
SkFAIL("Unexpected path fill.");
/* fallthrough */;
- case kIncClamp_StencilOp:
+ case GrStencilOp::kIncClamp:
return GR_GL_COUNT_UP;
- case kInvert_StencilOp:
+ case GrStencilOp::kInvert:
return GR_GL_INVERT;
}
}
@@ -133,9 +133,9 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath*
this->flushPathStencilSettings(*args.fStencil);
SkASSERT(!fHWPathStencilSettings.isTwoSided());
- GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
- fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
- GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
+ GrGLenum fillMode =
+ gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp);
+ GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask;
if (glPath->shouldFill()) {
GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask));
@@ -157,9 +157,9 @@ void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline,
this->flushPathStencilSettings(stencil);
SkASSERT(!fHWPathStencilSettings.isTwoSided());
- GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
- fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
- GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
+ GrGLenum fillMode =
+ gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp);
+ GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask;
if (glPath->shouldStroke()) {
if (glPath->shouldFill()) {
@@ -191,10 +191,8 @@ void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline,
const GrGLPathRange* glPathRange = static_cast<const GrGLPathRange*>(pathRange);
GrGLenum fillMode =
- gr_stencil_op_to_gl_path_rendering_fill_mode(
- fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
- GrGLint writeMask =
- fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
+ gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp);
+ GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask;
if (glPathRange->shouldStroke()) {
if (glPathRange->shouldFill()) {
@@ -322,16 +320,15 @@ void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci
SkASSERT(stencilSettings.isValid());
// 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)
- const GrStencilSettings::Face kFront_Face = GrStencilSettings::kFront_Face;
- GrStencilFunc func = stencilSettings.func(kFront_Face);
- uint16_t funcRef = stencilSettings.funcRef(kFront_Face);
- uint16_t funcMask = stencilSettings.funcMask(kFront_Face);
+ uint16_t ref = stencilSettings.front().fRef;
+ GrStencilTest test = stencilSettings.front().fTest;
+ uint16_t testMask = stencilSettings.front().fTestMask;
if (!fHWPathStencilSettings.isValid() ||
- func != fHWPathStencilSettings.func(kFront_Face) ||
- funcRef != fHWPathStencilSettings.funcRef(kFront_Face) ||
- funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) {
- GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask));
+ ref != fHWPathStencilSettings.front().fRef ||
+ test != fHWPathStencilSettings.front().fTest ||
+ testMask != fHWPathStencilSettings.front().fTestMask) {
+ GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask));
}
fHWPathStencilSettings = stencilSettings;
}
diff --git a/src/gpu/gl/GrGLPathRendering.h b/src/gpu/gl/GrGLPathRendering.h
index 8fb699deb3..40f72ccd7b 100644
--- a/src/gpu/gl/GrGLPathRendering.h
+++ b/src/gpu/gl/GrGLPathRendering.h
@@ -10,12 +10,12 @@
#include "SkRefCnt.h"
#include "GrPathRendering.h"
-#include "GrStencil.h"
#include "gl/GrGLTypes.h"
#include "glsl/GrGLSLUtil.h"
class GrGLNameAllocator;
class GrGLGpu;
+class GrStencilSettings;
class GrStyle;
/**
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 46b58f1d76..ecc587b714 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -334,27 +334,26 @@ GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) {
return GrGLGetRendererFromString((const char*) v);
}
-GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc) {
- static const GrGLenum gTable[] = {
- GR_GL_ALWAYS, // kAlways_StencilFunc
- GR_GL_NEVER, // kNever_StencilFunc
- GR_GL_GREATER, // kGreater_StencilFunc
- GR_GL_GEQUAL, // kGEqual_StencilFunc
- GR_GL_LESS, // kLess_StencilFunc
- GR_GL_LEQUAL, // kLEqual_StencilFunc,
- GR_GL_EQUAL, // kEqual_StencilFunc,
- GR_GL_NOTEQUAL, // kNotEqual_StencilFunc,
+GrGLenum GrToGLStencilFunc(GrStencilTest test) {
+ static const GrGLenum gTable[kGrStencilTestCount] = {
+ GR_GL_ALWAYS, // kAlways
+ GR_GL_NEVER, // kNever
+ GR_GL_GREATER, // kGreater
+ GR_GL_GEQUAL, // kGEqual
+ GR_GL_LESS, // kLess
+ GR_GL_LEQUAL, // kLEqual
+ GR_GL_EQUAL, // kEqual
+ GR_GL_NOTEQUAL, // kNotEqual
};
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kBasicStencilFuncCnt);
- GR_STATIC_ASSERT(0 == kAlways_StencilFunc);
- GR_STATIC_ASSERT(1 == kNever_StencilFunc);
- GR_STATIC_ASSERT(2 == kGreater_StencilFunc);
- GR_STATIC_ASSERT(3 == kGEqual_StencilFunc);
- GR_STATIC_ASSERT(4 == kLess_StencilFunc);
- GR_STATIC_ASSERT(5 == kLEqual_StencilFunc);
- GR_STATIC_ASSERT(6 == kEqual_StencilFunc);
- GR_STATIC_ASSERT(7 == kNotEqual_StencilFunc);
- SkASSERT((unsigned) basicFunc < kBasicStencilFuncCnt);
-
- return gTable[basicFunc];
+ GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways);
+ GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever);
+ GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater);
+ GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual);
+ GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess);
+ GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual);
+ GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual);
+ GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual);
+ SkASSERT(test < (GrStencilTest)kGrStencilTestCount);
+
+ return gTable[(int)test];
}
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index c30ee93689..98f738b091 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -10,7 +10,7 @@
#include "gl/GrGLInterface.h"
#include "GrGLDefines.h"
-#include "GrStencil.h"
+#include "GrStencilSettings.h"
class SkMatrix;
@@ -205,7 +205,7 @@ void GrGLClearErr(const GrGLInterface* gl);
// call glGetError without doing a redundant error check or logging.
#define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError()
-GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc);
+GrGLenum GrToGLStencilFunc(GrStencilTest test);
#endif