OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrPathStencilSettings_DEFINED |
| 9 #define GrPathStencilSettings_DEFINED |
| 10 |
| 11 //////////////////////////////////////////////////////////////////////////////// |
| 12 // Stencil rules for paths |
| 13 |
| 14 ////// Even/Odd |
| 15 |
| 16 static constexpr GrStencilSettings gEOStencilPass( |
| 17 kInvert_StencilOp, |
| 18 kKeep_StencilOp, |
| 19 kAlwaysIfInClip_StencilFunc, |
| 20 0xffff, |
| 21 0xffff, |
| 22 0xffff); |
| 23 |
| 24 // ok not to check clip b/c stencil pass only wrote inside clip |
| 25 static constexpr GrStencilSettings gEOColorPass( |
| 26 kZero_StencilOp, |
| 27 kZero_StencilOp, |
| 28 kNotEqual_StencilFunc, |
| 29 0xffff, |
| 30 0x0000, |
| 31 0xffff); |
| 32 |
| 33 // have to check clip b/c outside clip will always be zero. |
| 34 static constexpr GrStencilSettings gInvEOColorPass( |
| 35 kZero_StencilOp, |
| 36 kZero_StencilOp, |
| 37 kEqualIfInClip_StencilFunc, |
| 38 0xffff, |
| 39 0x0000, |
| 40 0xffff); |
| 41 |
| 42 ////// Winding |
| 43 |
| 44 // 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 |
| 46 // them. |
| 47 |
| 48 static constexpr GrStencilSettings gWindStencilSeparateWithWrap( |
| 49 kIncWrap_StencilOp, kDecWrap_StencilOp, |
| 50 kKeep_StencilOp, kKeep_StencilOp, |
| 51 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, |
| 52 0xffff, 0xffff, |
| 53 0xffff, 0xffff, |
| 54 0xffff, 0xffff); |
| 55 |
| 56 // if inc'ing the max value, invert to make 0 |
| 57 // if dec'ing zero invert to make all ones. |
| 58 // we can't avoid touching the stencil on both passing and |
| 59 // failing, so we can't resctrict ourselves to the clip. |
| 60 static constexpr GrStencilSettings gWindStencilSeparateNoWrap( |
| 61 kInvert_StencilOp, kInvert_StencilOp, |
| 62 kIncClamp_StencilOp, kDecClamp_StencilOp, |
| 63 kEqual_StencilFunc, kEqual_StencilFunc, |
| 64 0xffff, 0xffff, |
| 65 0xffff, 0x0000, |
| 66 0xffff, 0xffff); |
| 67 |
| 68 // 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 |
| 70 // and dec. These are same as the above two split into the incrementing and |
| 71 // decrementing passes. |
| 72 static constexpr GrStencilSettings gWindSingleStencilWithWrapInc( |
| 73 kIncWrap_StencilOp, |
| 74 kKeep_StencilOp, |
| 75 kAlwaysIfInClip_StencilFunc, |
| 76 0xffff, |
| 77 0xffff, |
| 78 0xffff); |
| 79 |
| 80 static constexpr GrStencilSettings gWindSingleStencilWithWrapDec( |
| 81 kDecWrap_StencilOp, |
| 82 kKeep_StencilOp, |
| 83 kAlwaysIfInClip_StencilFunc, |
| 84 0xffff, |
| 85 0xffff, |
| 86 0xffff); |
| 87 |
| 88 static constexpr GrStencilSettings gWindSingleStencilNoWrapInc( |
| 89 kInvert_StencilOp, |
| 90 kIncClamp_StencilOp, |
| 91 kEqual_StencilFunc, |
| 92 0xffff, |
| 93 0xffff, |
| 94 0xffff); |
| 95 |
| 96 static constexpr GrStencilSettings gWindSingleStencilNoWrapDec( |
| 97 kInvert_StencilOp, |
| 98 kDecClamp_StencilOp, |
| 99 kEqual_StencilFunc, |
| 100 0xffff, |
| 101 0x0000, |
| 102 0xffff); |
| 103 |
| 104 // Color passes are the same whether we use the two-sided stencil or two passes |
| 105 |
| 106 static constexpr GrStencilSettings gWindColorPass( |
| 107 kZero_StencilOp, |
| 108 kZero_StencilOp, |
| 109 kNonZeroIfInClip_StencilFunc, |
| 110 0xffff, |
| 111 0x0000, |
| 112 0xffff); |
| 113 |
| 114 static constexpr GrStencilSettings gInvWindColorPass( |
| 115 kZero_StencilOp, |
| 116 kZero_StencilOp, |
| 117 kEqualIfInClip_StencilFunc, |
| 118 0xffff, |
| 119 0x0000, |
| 120 0xffff); |
| 121 |
| 122 ////// Normal render to stencil |
| 123 |
| 124 // Sometimes the default path renderer can draw a path directly to the stencil |
| 125 // buffer without having to first resolve the interior / exterior. |
| 126 static constexpr GrStencilSettings gDirectToStencil( |
| 127 kZero_StencilOp, |
| 128 kIncClamp_StencilOp, |
| 129 kAlwaysIfInClip_StencilFunc, |
| 130 0xffff, |
| 131 0x0000, |
| 132 0xffff); |
| 133 |
| 134 #endif |
OLD | NEW |