| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrPathStencilSettings_DEFINED | 8 #ifndef GrPathStencilSettings_DEFINED |
| 9 #define GrPathStencilSettings_DEFINED | 9 #define GrPathStencilSettings_DEFINED |
| 10 | 10 |
| 11 #include "GrUserStencilSettings.h" |
| 12 |
| 11 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
| 12 // Stencil rules for paths | 14 // Stencil rules for paths |
| 13 | 15 |
| 14 ////// Even/Odd | 16 ////// Even/Odd |
| 15 | 17 |
| 16 static constexpr GrStencilSettings gEOStencilPass( | 18 static constexpr GrUserStencilSettings gEOStencilPass( |
| 17 kInvert_StencilOp, | 19 GrUserStencilSettings::StaticInit< |
| 18 kKeep_StencilOp, | 20 0xffff, |
| 19 kAlwaysIfInClip_StencilFunc, | 21 GrUserStencilTest::kAlwaysIfInClip, |
| 20 0xffff, | 22 0xffff, |
| 21 0xffff, | 23 GrUserStencilOp::kInvert, |
| 22 0xffff); | 24 GrUserStencilOp::kKeep, |
| 25 0xffff>() |
| 26 ); |
| 23 | 27 |
| 24 // ok not to check clip b/c stencil pass only wrote inside clip | 28 // ok not to check clip b/c stencil pass only wrote inside clip |
| 25 static constexpr GrStencilSettings gEOColorPass( | 29 static constexpr GrUserStencilSettings gEOColorPass( |
| 26 kZero_StencilOp, | 30 GrUserStencilSettings::StaticInit< |
| 27 kZero_StencilOp, | 31 0x0000, |
| 28 kNotEqual_StencilFunc, | 32 GrUserStencilTest::kNotEqual, |
| 29 0xffff, | 33 0xffff, |
| 30 0x0000, | 34 GrUserStencilOp::kZero, |
| 31 0xffff); | 35 GrUserStencilOp::kZero, |
| 36 0xffff>() |
| 37 ); |
| 32 | 38 |
| 33 // have to check clip b/c outside clip will always be zero. | 39 // have to check clip b/c outside clip will always be zero. |
| 34 static constexpr GrStencilSettings gInvEOColorPass( | 40 static constexpr GrUserStencilSettings gInvEOColorPass( |
| 35 kZero_StencilOp, | 41 GrUserStencilSettings::StaticInit< |
| 36 kZero_StencilOp, | 42 0x0000, |
| 37 kEqualIfInClip_StencilFunc, | 43 GrUserStencilTest::kEqualIfInClip, |
| 38 0xffff, | 44 0xffff, |
| 39 0x0000, | 45 GrUserStencilOp::kZero, |
| 40 0xffff); | 46 GrUserStencilOp::kZero, |
| 47 0xffff>() |
| 48 ); |
| 41 | 49 |
| 42 ////// Winding | 50 ////// Winding |
| 43 | 51 |
| 44 // when we have separate stencil we increment front faces / decrement back faces | 52 // when we have separate stencil we increment front faces / decrement back faces |
| 45 // when we don't have wrap incr and decr we use the stencil test to simulate | 53 // when we don't have wrap incr and decr we use the stencil test to simulate |
| 46 // them. | 54 // them. |
| 47 | 55 |
| 48 static constexpr GrStencilSettings gWindStencilSeparateWithWrap( | 56 static constexpr GrUserStencilSettings gWindStencilSeparateWithWrap( |
| 49 kIncWrap_StencilOp, kDecWrap_StencilOp, | 57 GrUserStencilSettings::StaticInitSeparate< |
| 50 kKeep_StencilOp, kKeep_StencilOp, | 58 0xffff, 0xffff, |
| 51 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, | 59 GrUserStencilTest::kAlwaysIfInClip, GrUserStencilTest::kAlwaysIfInCli
p, |
| 52 0xffff, 0xffff, | 60 0xffff, 0xffff, |
| 53 0xffff, 0xffff, | 61 GrUserStencilOp::kIncWrap, GrUserStencilOp::kDecWrap, |
| 54 0xffff, 0xffff); | 62 GrUserStencilOp::kKeep, GrUserStencilOp::kKeep, |
| 63 0xffff, 0xffff>() |
| 64 ); |
| 55 | 65 |
| 56 // if inc'ing the max value, invert to make 0 | 66 // if inc'ing the max value, invert to make 0 |
| 57 // if dec'ing zero invert to make all ones. | 67 // if dec'ing zero invert to make all ones. |
| 58 // we can't avoid touching the stencil on both passing and | 68 // we can't avoid touching the stencil on both passing and |
| 59 // failing, so we can't resctrict ourselves to the clip. | 69 // failing, so we can't resctrict ourselves to the clip. |
| 60 static constexpr GrStencilSettings gWindStencilSeparateNoWrap( | 70 static constexpr GrUserStencilSettings gWindStencilSeparateNoWrap( |
| 61 kInvert_StencilOp, kInvert_StencilOp, | 71 GrUserStencilSettings::StaticInitSeparate< |
| 62 kIncClamp_StencilOp, kDecClamp_StencilOp, | 72 0xffff, 0x0000, |
| 63 kEqual_StencilFunc, kEqual_StencilFunc, | 73 GrUserStencilTest::kEqual, GrUserStencilTest::kEqual, |
| 64 0xffff, 0xffff, | 74 0xffff, 0xffff, |
| 65 0xffff, 0x0000, | 75 GrUserStencilOp::kInvert, GrUserStencilOp::kInvert, |
| 66 0xffff, 0xffff); | 76 GrUserStencilOp::kIncMaybeClamp, GrUserStencilOp::kDecMaybeClamp, |
| 77 0xffff, 0xffff>() |
| 78 ); |
| 67 | 79 |
| 68 // When there are no separate faces we do two passes to setup the winding rule | 80 // When there are no separate faces we do two passes to setup the winding rule |
| 69 // stencil. First we draw the front faces and inc, then we draw the back faces | 81 // stencil. First we draw the front faces and inc, then we draw the back faces |
| 70 // and dec. These are same as the above two split into the incrementing and | 82 // and dec. These are same as the above two split into the incrementing and |
| 71 // decrementing passes. | 83 // decrementing passes. |
| 72 static constexpr GrStencilSettings gWindSingleStencilWithWrapInc( | 84 static constexpr GrUserStencilSettings gWindSingleStencilWithWrapInc( |
| 73 kIncWrap_StencilOp, | 85 GrUserStencilSettings::StaticInit< |
| 74 kKeep_StencilOp, | 86 0xffff, |
| 75 kAlwaysIfInClip_StencilFunc, | 87 GrUserStencilTest::kAlwaysIfInClip, |
| 76 0xffff, | 88 0xffff, |
| 77 0xffff, | 89 GrUserStencilOp::kIncWrap, |
| 78 0xffff); | 90 GrUserStencilOp::kKeep, |
| 91 0xffff>() |
| 92 ); |
| 79 | 93 |
| 80 static constexpr GrStencilSettings gWindSingleStencilWithWrapDec( | 94 static constexpr GrUserStencilSettings gWindSingleStencilWithWrapDec( |
| 81 kDecWrap_StencilOp, | 95 GrUserStencilSettings::StaticInit< |
| 82 kKeep_StencilOp, | 96 0xffff, |
| 83 kAlwaysIfInClip_StencilFunc, | 97 GrUserStencilTest::kAlwaysIfInClip, |
| 84 0xffff, | 98 0xffff, |
| 85 0xffff, | 99 GrUserStencilOp::kDecWrap, |
| 86 0xffff); | 100 GrUserStencilOp::kKeep, |
| 101 0xffff>() |
| 102 ); |
| 87 | 103 |
| 88 static constexpr GrStencilSettings gWindSingleStencilNoWrapInc( | 104 static constexpr GrUserStencilSettings gWindSingleStencilNoWrapInc( |
| 89 kInvert_StencilOp, | 105 GrUserStencilSettings::StaticInit< |
| 90 kIncClamp_StencilOp, | 106 0xffff, |
| 91 kEqual_StencilFunc, | 107 GrUserStencilTest::kEqual, |
| 92 0xffff, | 108 0xffff, |
| 93 0xffff, | 109 GrUserStencilOp::kInvert, |
| 94 0xffff); | 110 GrUserStencilOp::kIncMaybeClamp, |
| 111 0xffff>() |
| 112 ); |
| 95 | 113 |
| 96 static constexpr GrStencilSettings gWindSingleStencilNoWrapDec( | 114 static constexpr GrUserStencilSettings gWindSingleStencilNoWrapDec( |
| 97 kInvert_StencilOp, | 115 GrUserStencilSettings::StaticInit< |
| 98 kDecClamp_StencilOp, | 116 0x0000, |
| 99 kEqual_StencilFunc, | 117 GrUserStencilTest::kEqual, |
| 100 0xffff, | 118 0xffff, |
| 101 0x0000, | 119 GrUserStencilOp::kInvert, |
| 102 0xffff); | 120 GrUserStencilOp::kDecMaybeClamp, |
| 121 0xffff>() |
| 122 ); |
| 103 | 123 |
| 104 // Color passes are the same whether we use the two-sided stencil or two passes | 124 // Color passes are the same whether we use the two-sided stencil or two passes |
| 105 | 125 |
| 106 static constexpr GrStencilSettings gWindColorPass( | 126 static constexpr GrUserStencilSettings gWindColorPass( |
| 107 kZero_StencilOp, | 127 GrUserStencilSettings::StaticInit< |
| 108 kZero_StencilOp, | 128 0x0000, |
| 109 kNonZeroIfInClip_StencilFunc, | 129 GrUserStencilTest::kLessIfInClip, // "0 < stencil" is equivalent to "0 !
= stencil". |
| 110 0xffff, | 130 0xffff, |
| 111 0x0000, | 131 GrUserStencilOp::kZero, |
| 112 0xffff); | 132 GrUserStencilOp::kZero, |
| 133 0xffff>() |
| 134 ); |
| 113 | 135 |
| 114 static constexpr GrStencilSettings gInvWindColorPass( | 136 static constexpr GrUserStencilSettings gInvWindColorPass( |
| 115 kZero_StencilOp, | 137 GrUserStencilSettings::StaticInit< |
| 116 kZero_StencilOp, | 138 0x0000, |
| 117 kEqualIfInClip_StencilFunc, | 139 GrUserStencilTest::kEqualIfInClip, |
| 118 0xffff, | 140 0xffff, |
| 119 0x0000, | 141 GrUserStencilOp::kZero, |
| 120 0xffff); | 142 GrUserStencilOp::kZero, |
| 143 0xffff>() |
| 144 ); |
| 121 | 145 |
| 122 ////// Normal render to stencil | 146 ////// Normal render to stencil |
| 123 | 147 |
| 124 // Sometimes the default path renderer can draw a path directly to the stencil | 148 // Sometimes the default path renderer can draw a path directly to the stencil |
| 125 // buffer without having to first resolve the interior / exterior. | 149 // buffer without having to first resolve the interior / exterior. |
| 126 static constexpr GrStencilSettings gDirectToStencil( | 150 static constexpr GrUserStencilSettings gDirectToStencil( |
| 127 kZero_StencilOp, | 151 GrUserStencilSettings::StaticInit< |
| 128 kIncClamp_StencilOp, | 152 0x0000, |
| 129 kAlwaysIfInClip_StencilFunc, | 153 GrUserStencilTest::kAlwaysIfInClip, |
| 130 0xffff, | 154 0xffff, |
| 131 0x0000, | 155 GrUserStencilOp::kZero, |
| 132 0xffff); | 156 GrUserStencilOp::kIncMaybeClamp, |
| 157 0xffff>() |
| 158 ); |
| 133 | 159 |
| 134 #endif | 160 #endif |
| OLD | NEW |