aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStencil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrStencil.cpp')
-rw-r--r--src/gpu/GrStencil.cpp352
1 files changed, 165 insertions, 187 deletions
diff --git a/src/gpu/GrStencil.cpp b/src/gpu/GrStencil.cpp
index 81b3b8d144..66249429d2 100644
--- a/src/gpu/GrStencil.cpp
+++ b/src/gpu/GrStencil.cpp
@@ -9,17 +9,6 @@
#include "GrStencil.h"
-const GrStencilSettings GrStencilSettings::gDisabled = {
- kKeep_StencilOp, kKeep_StencilOp,
- kKeep_StencilOp, kKeep_StencilOp,
- kAlways_StencilFunc, kAlways_StencilFunc,
- 0x0000, 0x0000,
- 0x0000, 0x0000,
- 0x0000, 0x0000
-};
-GR_STATIC_ASSERT(0 == kKeep_StencilOp);
-GR_STATIC_ASSERT(0 == kAlways_StencilFunc);
-
////////////////////////////////////////////////////////////////////////////////
// Stencil Rules for Merging user stencil space into clip
@@ -32,171 +21,160 @@ GR_STATIC_ASSERT(0 == kAlways_StencilFunc);
// Replace
// set the ref to be the clip bit, but mask it out for the test
-static const GrStencilSettings gUserToClipReplace = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-static const GrStencilSettings gInvUserToClipReplace = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipReplace,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff, // unset clip bit
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipReplace,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff, // unset clip bit
+ 0x0000, // set clip bit
+ 0xffff);
///////
// Intersect
-static const GrStencilSettings gUserToClipIsect = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-static const GrStencilSettings gInvUserToClipIsect = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipIsect,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipIsect,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
///////
// Difference
-static const GrStencilSettings gUserToClipDiff = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-static const GrStencilSettings gInvUserToClipDiff = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipDiff,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipDiff,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
///////
// Union
// first pass makes all the passing cases >= just clip bit set.
-static const GrStencilSettings gUserToClipUnionPass0 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kKeep_StencilOp, kKeep_StencilOp,
- kLEqual_StencilFunc, kLEqual_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0001, 0x0001, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipUnionPass0,
+ kReplace_StencilOp,
+ kKeep_StencilOp,
+ kLEqual_StencilFunc,
+ 0xffff,
+ 0x0001, // set clip bit
+ 0xffff);
// second pass allows anything greater than just clip bit set to pass
-static const GrStencilSettings gUserToClipUnionPass1 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLEqual_StencilFunc, kLEqual_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipUnionPass1,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kLEqual_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
// first pass finds zeros in the user bits and if found sets
// the clip bit to 1
-static const GrStencilSettings gInvUserToClipUnionPass0 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kKeep_StencilOp, kKeep_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000, // set clip bit
- 0x0000, 0x0000 // set clip bit
-};
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipUnionPass0,
+ kReplace_StencilOp,
+ kKeep_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0x0000 // set clip bit
+);
// second pass zeros the user bits
-static const GrStencilSettings gInvUserToClipUnionPass1 = {
- kZero_StencilOp, kZero_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000,
- 0xffff, 0xffff // unset clip bit
-};
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipUnionPass1,
+ kZero_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff,
+ 0x0000,
+ 0xffff // unset clip bit
+);
///////
// Xor
-static const GrStencilSettings gUserToClipXorPass0 = {
- kInvert_StencilOp, kInvert_StencilOp,
- kKeep_StencilOp, kKeep_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000,
- 0xffff, 0xffff
-};
-
-static const GrStencilSettings gUserToClipXorPass1 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kGreater_StencilFunc, kGreater_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-
-static const GrStencilSettings gInvUserToClipXorPass0 = {
- kInvert_StencilOp, kInvert_StencilOp,
- kKeep_StencilOp, kKeep_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000,
- 0xffff, 0xffff
-};
-
-static const GrStencilSettings gInvUserToClipXorPass1 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipXorPass0,
+ kInvert_StencilOp,
+ kKeep_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff, // unset clip bit
+ 0x0000,
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipXorPass1,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kGreater_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipXorPass0,
+ kInvert_StencilOp,
+ kKeep_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff, // unset clip bit
+ 0x0000,
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipXorPass1,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0xffff);
///////
// Reverse Diff
-static const GrStencilSettings gUserToClipRDiffPass0 = {
- kInvert_StencilOp, kInvert_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kLess_StencilFunc, kLess_StencilFunc,
- 0xffff, 0xffff, // unset clip bit
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-
-static const GrStencilSettings gUserToClipRDiffPass1 = {
- kReplace_StencilOp, kReplace_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0x0000, 0x0000, // set clip bit
- 0x0000, 0x0000, // set clip bit
- 0xffff, 0xffff
-};
-
-static const GrStencilSettings gInvUserToClipRDiff = {
- kInvert_StencilOp, kInvert_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kEqual_StencilFunc, kEqual_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000,
- 0x0000, 0x0000 // set clip bit
-};
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipRDiffPass0,
+ kInvert_StencilOp,
+ kZero_StencilOp,
+ kLess_StencilFunc,
+ 0xffff, // unset clip bit
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gUserToClipRDiffPass1,
+ kReplace_StencilOp,
+ kZero_StencilOp,
+ kEqual_StencilFunc,
+ 0x0000, // set clip bit
+ 0x0000, // set clip bit
+ 0xffff);
+
+GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiff,
+ kInvert_StencilOp,
+ kZero_StencilOp,
+ kEqual_StencilFunc,
+ 0xffff,
+ 0x0000,
+ 0x0000 // set clip bit
+);
///////
// Direct to Stencil
@@ -206,41 +184,41 @@ static const GrStencilSettings gInvUserToClipRDiff = {
// this one only works if used right after stencil clip was cleared.
// Our GrClip doesn't allow midstream replace ops.
-static const GrStencilSettings gReplaceClip = {
- kReplace_StencilOp, kReplace_StencilOp,
- kReplace_StencilOp, kReplace_StencilOp,
- kAlways_StencilFunc, kAlways_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0x0000, 0x0000 // set clipBit
-};
-
-static const GrStencilSettings gUnionClip = {
- kReplace_StencilOp, kReplace_StencilOp,
- kReplace_StencilOp, kReplace_StencilOp,
- kAlways_StencilFunc, kAlways_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000, // set clip bit
- 0x0000, 0x0000 // set clip bit
-};
-
-static const GrStencilSettings gXorClip = {
- kInvert_StencilOp, kInvert_StencilOp,
- kInvert_StencilOp, kInvert_StencilOp,
- kAlways_StencilFunc, kAlways_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000,
- 0x0000, 0x0000 // set clip bit
-};
-
-static const GrStencilSettings gDiffClip = {
- kZero_StencilOp, kZero_StencilOp,
- kZero_StencilOp, kZero_StencilOp,
- kAlways_StencilFunc, kAlways_StencilFunc,
- 0xffff, 0xffff,
- 0x0000, 0x0000,
- 0x0000, 0x0000 // set clip bit
-};
+GR_STATIC_CONST_SAME_STENCIL(gReplaceClip,
+ kReplace_StencilOp,
+ kReplace_StencilOp,
+ kAlways_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0x0000 // set clipBit
+);
+
+GR_STATIC_CONST_SAME_STENCIL(gUnionClip,
+ kReplace_StencilOp,
+ kReplace_StencilOp,
+ kAlways_StencilFunc,
+ 0xffff,
+ 0x0000, // set clip bit
+ 0x0000 // set clip bit
+);
+
+GR_STATIC_CONST_SAME_STENCIL(gXorClip,
+ kInvert_StencilOp,
+ kInvert_StencilOp,
+ kAlways_StencilFunc,
+ 0xffff,
+ 0x0000,
+ 0x0000 // set clip bit
+);
+
+GR_STATIC_CONST_SAME_STENCIL(gDiffClip,
+ kZero_StencilOp,
+ kZero_StencilOp,
+ kAlways_StencilFunc,
+ 0xffff,
+ 0x0000,
+ 0x0000 // set clip bit
+);
bool GrStencilSettings::GetClipPasses(GrSetOp op,
bool canBeDirect,