| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "batches/GrRectBatchFactory.h" | 23 #include "batches/GrRectBatchFactory.h" |
| 24 #include "batches/GrVertexBatch.h" | 24 #include "batches/GrVertexBatch.h" |
| 25 | 25 |
| 26 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, | 26 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
| 27 bool stencilWrapOpsSupport) | 27 bool stencilWrapOpsSupport) |
| 28 : fSeparateStencil(separateStencilSupport) | 28 : fSeparateStencil(separateStencilSupport) |
| 29 , fStencilWrapOps(stencilWrapOpsSupport) { | 29 , fStencilWrapOps(stencilWrapOpsSupport) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 | |
| 33 //////////////////////////////////////////////////////////////////////////////// | |
| 34 // Stencil rules for paths | |
| 35 | |
| 36 ////// Even/Odd | |
| 37 | |
| 38 static constexpr GrStencilSettings gEOStencilPass( | |
| 39 kInvert_StencilOp, | |
| 40 kKeep_StencilOp, | |
| 41 kAlwaysIfInClip_StencilFunc, | |
| 42 0xffff, | |
| 43 0xffff, | |
| 44 0xffff); | |
| 45 | |
| 46 // ok not to check clip b/c stencil pass only wrote inside clip | |
| 47 static constexpr GrStencilSettings gEOColorPass( | |
| 48 kZero_StencilOp, | |
| 49 kZero_StencilOp, | |
| 50 kNotEqual_StencilFunc, | |
| 51 0xffff, | |
| 52 0x0000, | |
| 53 0xffff); | |
| 54 | |
| 55 // have to check clip b/c outside clip will always be zero. | |
| 56 static constexpr GrStencilSettings gInvEOColorPass( | |
| 57 kZero_StencilOp, | |
| 58 kZero_StencilOp, | |
| 59 kEqualIfInClip_StencilFunc, | |
| 60 0xffff, | |
| 61 0x0000, | |
| 62 0xffff); | |
| 63 | |
| 64 ////// Winding | |
| 65 | |
| 66 // when we have separate stencil we increment front faces / decrement back faces | |
| 67 // when we don't have wrap incr and decr we use the stencil test to simulate | |
| 68 // them. | |
| 69 | |
| 70 static constexpr GrStencilSettings gWindStencilSeparateWithWrap( | |
| 71 kIncWrap_StencilOp, kDecWrap_StencilOp, | |
| 72 kKeep_StencilOp, kKeep_StencilOp, | |
| 73 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, | |
| 74 0xffff, 0xffff, | |
| 75 0xffff, 0xffff, | |
| 76 0xffff, 0xffff); | |
| 77 | |
| 78 // if inc'ing the max value, invert to make 0 | |
| 79 // if dec'ing zero invert to make all ones. | |
| 80 // we can't avoid touching the stencil on both passing and | |
| 81 // failing, so we can't resctrict ourselves to the clip. | |
| 82 static constexpr GrStencilSettings gWindStencilSeparateNoWrap( | |
| 83 kInvert_StencilOp, kInvert_StencilOp, | |
| 84 kIncClamp_StencilOp, kDecClamp_StencilOp, | |
| 85 kEqual_StencilFunc, kEqual_StencilFunc, | |
| 86 0xffff, 0xffff, | |
| 87 0xffff, 0x0000, | |
| 88 0xffff, 0xffff); | |
| 89 | |
| 90 // When there are no separate faces we do two passes to setup the winding rule | |
| 91 // stencil. First we draw the front faces and inc, then we draw the back faces | |
| 92 // and dec. These are same as the above two split into the incrementing and | |
| 93 // decrementing passes. | |
| 94 static constexpr GrStencilSettings gWindSingleStencilWithWrapInc( | |
| 95 kIncWrap_StencilOp, | |
| 96 kKeep_StencilOp, | |
| 97 kAlwaysIfInClip_StencilFunc, | |
| 98 0xffff, | |
| 99 0xffff, | |
| 100 0xffff); | |
| 101 | |
| 102 static constexpr GrStencilSettings gWindSingleStencilWithWrapDec( | |
| 103 kDecWrap_StencilOp, | |
| 104 kKeep_StencilOp, | |
| 105 kAlwaysIfInClip_StencilFunc, | |
| 106 0xffff, | |
| 107 0xffff, | |
| 108 0xffff); | |
| 109 | |
| 110 static constexpr GrStencilSettings gWindSingleStencilNoWrapInc( | |
| 111 kInvert_StencilOp, | |
| 112 kIncClamp_StencilOp, | |
| 113 kEqual_StencilFunc, | |
| 114 0xffff, | |
| 115 0xffff, | |
| 116 0xffff); | |
| 117 | |
| 118 static constexpr GrStencilSettings gWindSingleStencilNoWrapDec( | |
| 119 kInvert_StencilOp, | |
| 120 kDecClamp_StencilOp, | |
| 121 kEqual_StencilFunc, | |
| 122 0xffff, | |
| 123 0x0000, | |
| 124 0xffff); | |
| 125 | |
| 126 // Color passes are the same whether we use the two-sided stencil or two passes | |
| 127 | |
| 128 static constexpr GrStencilSettings gWindColorPass( | |
| 129 kZero_StencilOp, | |
| 130 kZero_StencilOp, | |
| 131 kNonZeroIfInClip_StencilFunc, | |
| 132 0xffff, | |
| 133 0x0000, | |
| 134 0xffff); | |
| 135 | |
| 136 static constexpr GrStencilSettings gInvWindColorPass( | |
| 137 kZero_StencilOp, | |
| 138 kZero_StencilOp, | |
| 139 kEqualIfInClip_StencilFunc, | |
| 140 0xffff, | |
| 141 0x0000, | |
| 142 0xffff); | |
| 143 | |
| 144 ////// Normal render to stencil | |
| 145 | |
| 146 // Sometimes the default path renderer can draw a path directly to the stencil | |
| 147 // buffer without having to first resolve the interior / exterior. | |
| 148 static constexpr GrStencilSettings gDirectToStencil( | |
| 149 kZero_StencilOp, | |
| 150 kIncClamp_StencilOp, | |
| 151 kAlwaysIfInClip_StencilFunc, | |
| 152 0xffff, | |
| 153 0x0000, | |
| 154 0xffff); | |
| 155 | |
| 156 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
| 157 // Helpers for drawPath | 33 // Helpers for drawPath |
| 158 | 34 |
| 159 #define STENCIL_OFF 0 // Always disable stencil (even when needed) | 35 #define STENCIL_OFF 0 // Always disable stencil (even when needed) |
| 160 | 36 |
| 161 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
e) { | 37 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
e) { |
| 162 #if STENCIL_OFF | 38 #if STENCIL_OFF |
| 163 return true; | 39 return true; |
| 164 #else | 40 #else |
| 165 if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { | 41 if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 geometry.fColor = color; | 643 geometry.fColor = color; |
| 768 geometry.fPath = path; | 644 geometry.fPath = path; |
| 769 geometry.fTolerance = srcSpaceTol; | 645 geometry.fTolerance = srcSpaceTol; |
| 770 | 646 |
| 771 viewMatrix.mapRect(&bounds); | 647 viewMatrix.mapRect(&bounds); |
| 772 uint8_t coverage = GrRandomCoverage(random); | 648 uint8_t coverage = GrRandomCoverage(random); |
| 773 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 649 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
| 774 } | 650 } |
| 775 | 651 |
| 776 #endif | 652 #endif |
| OLD | NEW |