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 GR_STATIC_CONST_SAME_STENCIL(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 GR_STATIC_CONST_SAME_STENCIL(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 GR_STATIC_CONST_SAME_STENCIL(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 GR_STATIC_CONST_STENCIL(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 GR_STATIC_CONST_STENCIL(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 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapInc, |
| 95 kIncWrap_StencilOp, |
| 96 kKeep_StencilOp, |
| 97 kAlwaysIfInClip_StencilFunc, |
| 98 0xffff, |
| 99 0xffff, |
| 100 0xffff); |
| 101 |
| 102 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapDec, |
| 103 kDecWrap_StencilOp, |
| 104 kKeep_StencilOp, |
| 105 kAlwaysIfInClip_StencilFunc, |
| 106 0xffff, |
| 107 0xffff, |
| 108 0xffff); |
| 109 |
| 110 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilNoWrapInc, |
| 111 kInvert_StencilOp, |
| 112 kIncClamp_StencilOp, |
| 113 kEqual_StencilFunc, |
| 114 0xffff, |
| 115 0xffff, |
| 116 0xffff); |
| 117 |
| 118 GR_STATIC_CONST_SAME_STENCIL(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 GR_STATIC_CONST_SAME_STENCIL(gWindColorPass, |
| 129 kZero_StencilOp, |
| 130 kZero_StencilOp, |
| 131 kNonZeroIfInClip_StencilFunc, |
| 132 0xffff, |
| 133 0x0000, |
| 134 0xffff); |
| 135 |
| 136 GR_STATIC_CONST_SAME_STENCIL(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 GR_STATIC_CONST_SAME_STENCIL(gDirectToStencil, |
| 149 kZero_StencilOp, |
| 150 kIncClamp_StencilOp, |
| 151 kAlwaysIfInClip_StencilFunc, |
| 152 0xffff, |
| 153 0x0000, |
| 154 0xffff); |
| 155 |
32 //////////////////////////////////////////////////////////////////////////////// | 156 //////////////////////////////////////////////////////////////////////////////// |
33 // Helpers for drawPath | 157 // Helpers for drawPath |
34 | 158 |
35 #define STENCIL_OFF 0 // Always disable stencil (even when needed) | 159 #define STENCIL_OFF 0 // Always disable stencil (even when needed) |
36 | 160 |
37 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
e) { | 161 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
e) { |
38 #if STENCIL_OFF | 162 #if STENCIL_OFF |
39 return true; | 163 return true; |
40 #else | 164 #else |
41 if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { | 165 if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 geometry.fColor = color; | 767 geometry.fColor = color; |
644 geometry.fPath = path; | 768 geometry.fPath = path; |
645 geometry.fTolerance = srcSpaceTol; | 769 geometry.fTolerance = srcSpaceTol; |
646 | 770 |
647 viewMatrix.mapRect(&bounds); | 771 viewMatrix.mapRect(&bounds); |
648 uint8_t coverage = GrRandomCoverage(random); | 772 uint8_t coverage = GrRandomCoverage(random); |
649 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 773 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
650 } | 774 } |
651 | 775 |
652 #endif | 776 #endif |
OLD | NEW |