ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 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 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 11 | #include "GrUserStencilSettings.h" |
| 12 | |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 13 | //////////////////////////////////////////////////////////////////////////////// |
| 14 | // Stencil rules for paths |
| 15 | |
| 16 | ////// Even/Odd |
| 17 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 18 | static constexpr GrUserStencilSettings gEOStencilPass( |
| 19 | GrUserStencilSettings::StaticInit< |
| 20 | 0xffff, |
| 21 | GrUserStencilTest::kAlwaysIfInClip, |
| 22 | 0xffff, |
| 23 | GrUserStencilOp::kInvert, |
| 24 | GrUserStencilOp::kKeep, |
| 25 | 0xffff>() |
| 26 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 27 | |
| 28 | // ok not to check clip b/c stencil pass only wrote inside clip |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 29 | static constexpr GrUserStencilSettings gEOColorPass( |
| 30 | GrUserStencilSettings::StaticInit< |
| 31 | 0x0000, |
| 32 | GrUserStencilTest::kNotEqual, |
| 33 | 0xffff, |
| 34 | GrUserStencilOp::kZero, |
| 35 | GrUserStencilOp::kZero, |
| 36 | 0xffff>() |
| 37 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 38 | |
| 39 | // have to check clip b/c outside clip will always be zero. |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 40 | static constexpr GrUserStencilSettings gInvEOColorPass( |
| 41 | GrUserStencilSettings::StaticInit< |
| 42 | 0x0000, |
| 43 | GrUserStencilTest::kEqualIfInClip, |
| 44 | 0xffff, |
| 45 | GrUserStencilOp::kZero, |
| 46 | GrUserStencilOp::kZero, |
| 47 | 0xffff>() |
| 48 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 49 | |
| 50 | ////// Winding |
| 51 | |
Brian Salomon | 15b2509 | 2017-05-08 11:10:53 -0400 | [diff] [blame] | 52 | static constexpr GrUserStencilSettings gWindStencilPass ( |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 53 | GrUserStencilSettings::StaticInitSeparate< |
| 54 | 0xffff, 0xffff, |
| 55 | GrUserStencilTest::kAlwaysIfInClip, GrUserStencilTest::kAlwaysIfInClip, |
| 56 | 0xffff, 0xffff, |
| 57 | GrUserStencilOp::kIncWrap, GrUserStencilOp::kDecWrap, |
| 58 | GrUserStencilOp::kKeep, GrUserStencilOp::kKeep, |
| 59 | 0xffff, 0xffff>() |
| 60 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 61 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 62 | static constexpr GrUserStencilSettings gWindColorPass( |
| 63 | GrUserStencilSettings::StaticInit< |
| 64 | 0x0000, |
| 65 | GrUserStencilTest::kLessIfInClip, // "0 < stencil" is equivalent to "0 != stencil". |
| 66 | 0xffff, |
| 67 | GrUserStencilOp::kZero, |
| 68 | GrUserStencilOp::kZero, |
| 69 | 0xffff>() |
| 70 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 71 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 72 | static constexpr GrUserStencilSettings gInvWindColorPass( |
| 73 | GrUserStencilSettings::StaticInit< |
| 74 | 0x0000, |
| 75 | GrUserStencilTest::kEqualIfInClip, |
| 76 | 0xffff, |
| 77 | GrUserStencilOp::kZero, |
| 78 | GrUserStencilOp::kZero, |
| 79 | 0xffff>() |
| 80 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 81 | |
| 82 | ////// Normal render to stencil |
| 83 | |
| 84 | // Sometimes the default path renderer can draw a path directly to the stencil |
| 85 | // buffer without having to first resolve the interior / exterior. |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 86 | static constexpr GrUserStencilSettings gDirectToStencil( |
| 87 | GrUserStencilSettings::StaticInit< |
| 88 | 0x0000, |
| 89 | GrUserStencilTest::kAlwaysIfInClip, |
| 90 | 0xffff, |
| 91 | GrUserStencilOp::kZero, |
| 92 | GrUserStencilOp::kIncMaybeClamp, |
| 93 | 0xffff>() |
| 94 | ); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 95 | |
| 96 | #endif |