bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 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 | #include "GrDefaultPathRenderer.h" |
| 9 | |
| 10 | #include "GrContext.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 11 | #include "GrDefaultGeoProcFactory.h" |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 12 | #include "GrDrawState.h" |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 13 | #include "GrPathUtils.h" |
egdaniel | af18a09 | 2015-01-05 10:22:28 -0800 | [diff] [blame] | 14 | #include "SkGeometry.h" |
tomhudson@google.com | dd5f744 | 2011-08-30 15:13:55 +0000 | [diff] [blame] | 15 | #include "SkString.h" |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 16 | #include "SkStrokeRec.h" |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 17 | #include "SkTLazy.h" |
commit-bot@chromium.org | 933e65d | 2014-03-20 20:00:24 +0000 | [diff] [blame] | 18 | #include "SkTraceEvent.h" |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 19 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 20 | GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
| 21 | bool stencilWrapOpsSupport) |
| 22 | : fSeparateStencil(separateStencilSupport) |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 23 | , fStencilWrapOps(stencilWrapOpsSupport) { |
bsalomon@google.com | 289533a | 2011-10-27 12:34:25 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 27 | //////////////////////////////////////////////////////////////////////////////// |
| 28 | // Stencil rules for paths |
| 29 | |
| 30 | ////// Even/Odd |
| 31 | |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 32 | GR_STATIC_CONST_SAME_STENCIL(gEOStencilPass, |
| 33 | kInvert_StencilOp, |
| 34 | kKeep_StencilOp, |
| 35 | kAlwaysIfInClip_StencilFunc, |
| 36 | 0xffff, |
| 37 | 0xffff, |
| 38 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 39 | |
| 40 | // ok not to check clip b/c stencil pass only wrote inside clip |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 41 | GR_STATIC_CONST_SAME_STENCIL(gEOColorPass, |
| 42 | kZero_StencilOp, |
| 43 | kZero_StencilOp, |
| 44 | kNotEqual_StencilFunc, |
| 45 | 0xffff, |
| 46 | 0x0000, |
| 47 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 48 | |
| 49 | // have to check clip b/c outside clip will always be zero. |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 50 | GR_STATIC_CONST_SAME_STENCIL(gInvEOColorPass, |
| 51 | kZero_StencilOp, |
| 52 | kZero_StencilOp, |
| 53 | kEqualIfInClip_StencilFunc, |
| 54 | 0xffff, |
| 55 | 0x0000, |
| 56 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 57 | |
| 58 | ////// Winding |
| 59 | |
| 60 | // when we have separate stencil we increment front faces / decrement back faces |
| 61 | // when we don't have wrap incr and decr we use the stencil test to simulate |
| 62 | // them. |
| 63 | |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 64 | GR_STATIC_CONST_STENCIL(gWindStencilSeparateWithWrap, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 65 | kIncWrap_StencilOp, kDecWrap_StencilOp, |
| 66 | kKeep_StencilOp, kKeep_StencilOp, |
| 67 | kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, |
tomhudson@google.com | 62b0968 | 2011-11-09 16:39:17 +0000 | [diff] [blame] | 68 | 0xffff, 0xffff, |
| 69 | 0xffff, 0xffff, |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 70 | 0xffff, 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 71 | |
| 72 | // if inc'ing the max value, invert to make 0 |
| 73 | // if dec'ing zero invert to make all ones. |
| 74 | // we can't avoid touching the stencil on both passing and |
| 75 | // failing, so we can't resctrict ourselves to the clip. |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 76 | GR_STATIC_CONST_STENCIL(gWindStencilSeparateNoWrap, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 77 | kInvert_StencilOp, kInvert_StencilOp, |
| 78 | kIncClamp_StencilOp, kDecClamp_StencilOp, |
| 79 | kEqual_StencilFunc, kEqual_StencilFunc, |
tomhudson@google.com | 62b0968 | 2011-11-09 16:39:17 +0000 | [diff] [blame] | 80 | 0xffff, 0xffff, |
| 81 | 0xffff, 0x0000, |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 82 | 0xffff, 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 83 | |
| 84 | // When there are no separate faces we do two passes to setup the winding rule |
| 85 | // stencil. First we draw the front faces and inc, then we draw the back faces |
| 86 | // and dec. These are same as the above two split into the incrementing and |
| 87 | // decrementing passes. |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 88 | GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapInc, |
| 89 | kIncWrap_StencilOp, |
| 90 | kKeep_StencilOp, |
| 91 | kAlwaysIfInClip_StencilFunc, |
| 92 | 0xffff, |
| 93 | 0xffff, |
| 94 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 95 | |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 96 | GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapDec, |
| 97 | kDecWrap_StencilOp, |
| 98 | kKeep_StencilOp, |
| 99 | kAlwaysIfInClip_StencilFunc, |
| 100 | 0xffff, |
| 101 | 0xffff, |
| 102 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 103 | |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 104 | GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilNoWrapInc, |
| 105 | kInvert_StencilOp, |
| 106 | kIncClamp_StencilOp, |
| 107 | kEqual_StencilFunc, |
| 108 | 0xffff, |
| 109 | 0xffff, |
| 110 | 0xffff); |
| 111 | |
| 112 | GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilNoWrapDec, |
| 113 | kInvert_StencilOp, |
| 114 | kDecClamp_StencilOp, |
| 115 | kEqual_StencilFunc, |
| 116 | 0xffff, |
| 117 | 0x0000, |
| 118 | 0xffff); |
| 119 | |
| 120 | // Color passes are the same whether we use the two-sided stencil or two passes |
| 121 | |
| 122 | GR_STATIC_CONST_SAME_STENCIL(gWindColorPass, |
| 123 | kZero_StencilOp, |
| 124 | kZero_StencilOp, |
| 125 | kNonZeroIfInClip_StencilFunc, |
| 126 | 0xffff, |
| 127 | 0x0000, |
| 128 | 0xffff); |
| 129 | |
| 130 | GR_STATIC_CONST_SAME_STENCIL(gInvWindColorPass, |
| 131 | kZero_StencilOp, |
| 132 | kZero_StencilOp, |
| 133 | kEqualIfInClip_StencilFunc, |
| 134 | 0xffff, |
| 135 | 0x0000, |
| 136 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 137 | |
| 138 | ////// Normal render to stencil |
| 139 | |
| 140 | // Sometimes the default path renderer can draw a path directly to the stencil |
| 141 | // buffer without having to first resolve the interior / exterior. |
bsalomon@google.com | 6b2445e | 2011-12-15 19:47:46 +0000 | [diff] [blame] | 142 | GR_STATIC_CONST_SAME_STENCIL(gDirectToStencil, |
| 143 | kZero_StencilOp, |
| 144 | kIncClamp_StencilOp, |
| 145 | kAlwaysIfInClip_StencilFunc, |
| 146 | 0xffff, |
| 147 | 0x0000, |
| 148 | 0xffff); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 149 | |
| 150 | //////////////////////////////////////////////////////////////////////////////// |
| 151 | // Helpers for drawPath |
| 152 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 153 | #define STENCIL_OFF 0 // Always disable stencil (even when needed) |
| 154 | |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 155 | static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& stroke) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 156 | #if STENCIL_OFF |
| 157 | return true; |
| 158 | #else |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 159 | if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { |
bsalomon@google.com | 7d72c45 | 2012-01-30 14:02:44 +0000 | [diff] [blame] | 160 | return path.isConvex(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 161 | } |
| 162 | return false; |
| 163 | #endif |
| 164 | } |
| 165 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 166 | GrPathRenderer::StencilSupport |
| 167 | GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
| 168 | const GrDrawState*, |
| 169 | const SkPath& path, |
| 170 | const SkStrokeRec& stroke) const { |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 171 | if (single_pass_path(path, stroke)) { |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 172 | return GrPathRenderer::kNoRestriction_StencilSupport; |
| 173 | } else { |
| 174 | return GrPathRenderer::kStencilOnly_StencilSupport; |
| 175 | } |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 176 | } |
| 177 | |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 178 | static inline void append_countour_edge_indices(bool hairLine, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 179 | uint16_t fanCenterIdx, |
| 180 | uint16_t edgeV0Idx, |
| 181 | uint16_t** indices) { |
| 182 | // when drawing lines we're appending line segments along |
| 183 | // the contour. When applying the other fill rules we're |
| 184 | // drawing triangle fans around fanCenterIdx. |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 185 | if (!hairLine) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 186 | *((*indices)++) = fanCenterIdx; |
| 187 | } |
| 188 | *((*indices)++) = edgeV0Idx; |
| 189 | *((*indices)++) = edgeV0Idx + 1; |
| 190 | } |
| 191 | |
egdaniel | af18a09 | 2015-01-05 10:22:28 -0800 | [diff] [blame] | 192 | static inline void add_quad(SkPoint** vert, const SkPoint* base, const SkPoint pts[], |
| 193 | SkScalar srcSpaceTolSqd, SkScalar srcSpaceTol, bool indexed, |
| 194 | bool isHairline, uint16_t subpathIdxStart, uint16_t** idx) { |
| 195 | // first pt of quad is the pt we ended on in previous step |
| 196 | uint16_t firstQPtIdx = (uint16_t)(*vert - base) - 1; |
| 197 | uint16_t numPts = (uint16_t) |
| 198 | GrPathUtils::generateQuadraticPoints( |
| 199 | pts[0], pts[1], pts[2], |
| 200 | srcSpaceTolSqd, vert, |
| 201 | GrPathUtils::quadraticPointCount(pts, srcSpaceTol)); |
| 202 | if (indexed) { |
| 203 | for (uint16_t i = 0; i < numPts; ++i) { |
| 204 | append_countour_edge_indices(isHairline, subpathIdxStart, |
| 205 | firstQPtIdx + i, idx); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 210 | bool GrDefaultPathRenderer::createGeom(GrDrawTarget* target, |
| 211 | GrDrawState* drawState, |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 212 | GrPrimitiveType* primType, |
| 213 | int* vertexCnt, |
bsalomon@google.com | b372942 | 2012-03-07 19:13:28 +0000 | [diff] [blame] | 214 | int* indexCnt, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 215 | GrDrawTarget::AutoReleaseGeometry* arg, |
| 216 | const SkPath& path, |
| 217 | const SkStrokeRec& stroke, |
| 218 | SkScalar srcSpaceTol) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 219 | { |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 220 | SkScalar srcSpaceTolSqd = SkScalarMul(srcSpaceTol, srcSpaceTol); |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 221 | int contourCnt; |
| 222 | int maxPts = GrPathUtils::worstCasePointCount(path, &contourCnt, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 223 | srcSpaceTol); |
| 224 | |
| 225 | if (maxPts <= 0) { |
| 226 | return false; |
| 227 | } |
| 228 | if (maxPts > ((int)SK_MaxU16 + 1)) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 229 | SkDebugf("Path not rendered, too many verts (%d)\n", maxPts); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 230 | return false; |
| 231 | } |
| 232 | |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 233 | bool indexed = contourCnt > 1; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 234 | |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 235 | const bool isHairline = stroke.isHairlineStyle(); |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 236 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 237 | int maxIdxs = 0; |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 238 | if (isHairline) { |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 239 | if (indexed) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 240 | maxIdxs = 2 * maxPts; |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 241 | *primType = kLines_GrPrimitiveType; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 242 | } else { |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 243 | *primType = kLineStrip_GrPrimitiveType; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 244 | } |
| 245 | } else { |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 246 | if (indexed) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 247 | maxIdxs = 3 * maxPts; |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 248 | *primType = kTriangles_GrPrimitiveType; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 249 | } else { |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 250 | *primType = kTriangleFan_GrPrimitiveType; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 254 | if (!arg->set(target, maxPts, GrDefaultGeoProcFactory::DefaultVertexStride(), maxIdxs)) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 255 | return false; |
| 256 | } |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 257 | SkASSERT(GrDefaultGeoProcFactory::DefaultVertexStride() == sizeof(SkPoint)); |
bsalomon@google.com | b372942 | 2012-03-07 19:13:28 +0000 | [diff] [blame] | 258 | |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 259 | uint16_t* idxBase = reinterpret_cast<uint16_t*>(arg->indices()); |
bsalomon@google.com | b372942 | 2012-03-07 19:13:28 +0000 | [diff] [blame] | 260 | uint16_t* idx = idxBase; |
| 261 | uint16_t subpathIdxStart = 0; |
| 262 | |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 263 | SkPoint* base = reinterpret_cast<SkPoint*>(arg->vertices()); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 264 | SkASSERT(base); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 265 | SkPoint* vert = base; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 266 | |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 267 | SkPoint pts[4]; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 268 | |
| 269 | bool first = true; |
| 270 | int subpath = 0; |
| 271 | |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 272 | SkPath::Iter iter(path, false); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 273 | |
| 274 | for (;;) { |
bsalomon@google.com | 94b284d | 2013-05-10 17:14:06 +0000 | [diff] [blame] | 275 | SkPath::Verb verb = iter.next(pts); |
| 276 | switch (verb) { |
| 277 | case SkPath::kMove_Verb: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 278 | if (!first) { |
| 279 | uint16_t currIdx = (uint16_t) (vert - base); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 280 | subpathIdxStart = currIdx; |
| 281 | ++subpath; |
| 282 | } |
| 283 | *vert = pts[0]; |
| 284 | vert++; |
| 285 | break; |
bsalomon@google.com | 94b284d | 2013-05-10 17:14:06 +0000 | [diff] [blame] | 286 | case SkPath::kLine_Verb: |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 287 | if (indexed) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 288 | uint16_t prevIdx = (uint16_t)(vert - base) - 1; |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 289 | append_countour_edge_indices(isHairline, subpathIdxStart, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 290 | prevIdx, &idx); |
| 291 | } |
| 292 | *(vert++) = pts[1]; |
| 293 | break; |
egdaniel | af18a09 | 2015-01-05 10:22:28 -0800 | [diff] [blame] | 294 | case SkPath::kConic_Verb: { |
| 295 | SkScalar weight = iter.conicWeight(); |
| 296 | SkAutoConicToQuads converter; |
| 297 | // Converting in src-space, hance the finer tolerance (0.25) |
| 298 | // TODO: find a way to do this in dev-space so the tolerance means something |
| 299 | const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.25f); |
| 300 | for (int i = 0; i < converter.countQuads(); ++i) { |
| 301 | add_quad(&vert, base, quadPts + i*2, srcSpaceTolSqd, srcSpaceTol, indexed, |
| 302 | isHairline, subpathIdxStart, &idx); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 303 | } |
| 304 | break; |
| 305 | } |
egdaniel | af18a09 | 2015-01-05 10:22:28 -0800 | [diff] [blame] | 306 | case SkPath::kQuad_Verb: |
| 307 | add_quad(&vert, base, pts, srcSpaceTolSqd, srcSpaceTol, indexed, |
| 308 | isHairline, subpathIdxStart, &idx); |
| 309 | break; |
bsalomon@google.com | 94b284d | 2013-05-10 17:14:06 +0000 | [diff] [blame] | 310 | case SkPath::kCubic_Verb: { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 311 | // first pt of cubic is the pt we ended on in previous step |
| 312 | uint16_t firstCPtIdx = (uint16_t)(vert - base) - 1; |
| 313 | uint16_t numPts = (uint16_t) GrPathUtils::generateCubicPoints( |
| 314 | pts[0], pts[1], pts[2], pts[3], |
| 315 | srcSpaceTolSqd, &vert, |
| 316 | GrPathUtils::cubicPointCount(pts, srcSpaceTol)); |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 317 | if (indexed) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 318 | for (uint16_t i = 0; i < numPts; ++i) { |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 319 | append_countour_edge_indices(isHairline, subpathIdxStart, |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 320 | firstCPtIdx + i, &idx); |
| 321 | } |
| 322 | } |
| 323 | break; |
| 324 | } |
bsalomon@google.com | 94b284d | 2013-05-10 17:14:06 +0000 | [diff] [blame] | 325 | case SkPath::kClose_Verb: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 326 | break; |
bsalomon@google.com | 94b284d | 2013-05-10 17:14:06 +0000 | [diff] [blame] | 327 | case SkPath::kDone_Verb: |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 328 | // uint16_t currIdx = (uint16_t) (vert - base); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 329 | goto FINISHED; |
| 330 | } |
| 331 | first = false; |
| 332 | } |
| 333 | FINISHED: |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 334 | SkASSERT((vert - base) <= maxPts); |
| 335 | SkASSERT((idx - idxBase) <= maxIdxs); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 336 | |
robertphillips@google.com | adacc70 | 2013-10-14 21:53:24 +0000 | [diff] [blame] | 337 | *vertexCnt = static_cast<int>(vert - base); |
| 338 | *indexCnt = static_cast<int>(idx - idxBase); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 339 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 340 | } |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 341 | return true; |
| 342 | } |
| 343 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 344 | bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, |
| 345 | GrDrawState* drawState, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 346 | GrColor color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 347 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 348 | const SkPath& path, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 349 | const SkStrokeRec& origStroke, |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 350 | bool stencilOnly) { |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 351 | SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); |
| 352 | |
| 353 | SkScalar hairlineCoverage; |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 354 | uint8_t newCoverage = 0xff; |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 355 | if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 356 | newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 357 | |
| 358 | if (!stroke->isHairlineStyle()) { |
| 359 | stroke.writable()->setHairlineStyle(); |
| 360 | } |
| 361 | } |
| 362 | |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 363 | SkScalar tol = SK_Scalar1; |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 364 | tol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, path.getBounds()); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 365 | |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 366 | int vertexCnt; |
| 367 | int indexCnt; |
| 368 | GrPrimitiveType primType; |
bsalomon@google.com | b372942 | 2012-03-07 19:13:28 +0000 | [diff] [blame] | 369 | GrDrawTarget::AutoReleaseGeometry arg; |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 370 | if (!this->createGeom(target, |
| 371 | drawState, |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 372 | &primType, |
| 373 | &vertexCnt, |
bsalomon@google.com | b372942 | 2012-03-07 19:13:28 +0000 | [diff] [blame] | 374 | &indexCnt, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 375 | &arg, |
| 376 | path, |
| 377 | *stroke, |
| 378 | tol)) { |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 379 | return false; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 380 | } |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 381 | // Save the current xp on the draw state so we can reset it if needed |
| 382 | SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(drawState->getXPFactory())); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 383 | // face culling doesn't make sense here |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 384 | SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace()); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 385 | |
| 386 | int passCount = 0; |
| 387 | const GrStencilSettings* passes[3]; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 388 | GrDrawState::DrawFace drawFace[3]; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 389 | bool reverse = false; |
| 390 | bool lastPassIsBounds; |
| 391 | |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 392 | if (stroke->isHairlineStyle()) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 393 | passCount = 1; |
| 394 | if (stencilOnly) { |
| 395 | passes[0] = &gDirectToStencil; |
| 396 | } else { |
| 397 | passes[0] = NULL; |
| 398 | } |
| 399 | lastPassIsBounds = false; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 400 | drawFace[0] = GrDrawState::kBoth_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 401 | } else { |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 402 | if (single_pass_path(path, *stroke)) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 403 | passCount = 1; |
| 404 | if (stencilOnly) { |
| 405 | passes[0] = &gDirectToStencil; |
| 406 | } else { |
| 407 | passes[0] = NULL; |
| 408 | } |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 409 | drawFace[0] = GrDrawState::kBoth_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 410 | lastPassIsBounds = false; |
| 411 | } else { |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 412 | switch (path.getFillType()) { |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 413 | case SkPath::kInverseEvenOdd_FillType: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 414 | reverse = true; |
| 415 | // fallthrough |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 416 | case SkPath::kEvenOdd_FillType: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 417 | passes[0] = &gEOStencilPass; |
| 418 | if (stencilOnly) { |
| 419 | passCount = 1; |
| 420 | lastPassIsBounds = false; |
| 421 | } else { |
| 422 | passCount = 2; |
| 423 | lastPassIsBounds = true; |
| 424 | if (reverse) { |
| 425 | passes[1] = &gInvEOColorPass; |
| 426 | } else { |
| 427 | passes[1] = &gEOColorPass; |
| 428 | } |
| 429 | } |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 430 | drawFace[0] = drawFace[1] = GrDrawState::kBoth_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 431 | break; |
| 432 | |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 433 | case SkPath::kInverseWinding_FillType: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 434 | reverse = true; |
| 435 | // fallthrough |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 436 | case SkPath::kWinding_FillType: |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 437 | if (fSeparateStencil) { |
| 438 | if (fStencilWrapOps) { |
| 439 | passes[0] = &gWindStencilSeparateWithWrap; |
| 440 | } else { |
| 441 | passes[0] = &gWindStencilSeparateNoWrap; |
| 442 | } |
| 443 | passCount = 2; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 444 | drawFace[0] = GrDrawState::kBoth_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 445 | } else { |
| 446 | if (fStencilWrapOps) { |
| 447 | passes[0] = &gWindSingleStencilWithWrapInc; |
| 448 | passes[1] = &gWindSingleStencilWithWrapDec; |
| 449 | } else { |
| 450 | passes[0] = &gWindSingleStencilNoWrapInc; |
| 451 | passes[1] = &gWindSingleStencilNoWrapDec; |
| 452 | } |
| 453 | // which is cw and which is ccw is arbitrary. |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 454 | drawFace[0] = GrDrawState::kCW_DrawFace; |
| 455 | drawFace[1] = GrDrawState::kCCW_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 456 | passCount = 3; |
| 457 | } |
| 458 | if (stencilOnly) { |
| 459 | lastPassIsBounds = false; |
| 460 | --passCount; |
| 461 | } else { |
| 462 | lastPassIsBounds = true; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 463 | drawFace[passCount-1] = GrDrawState::kBoth_DrawFace; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 464 | if (reverse) { |
| 465 | passes[passCount-1] = &gInvWindColorPass; |
| 466 | } else { |
| 467 | passes[passCount-1] = &gWindColorPass; |
| 468 | } |
| 469 | } |
| 470 | break; |
| 471 | default: |
mtklein@google.com | 330313a | 2013-08-22 15:37:26 +0000 | [diff] [blame] | 472 | SkDEBUGFAIL("Unknown path fFill!"); |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 473 | return false; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
bsalomon@google.com | 1dd9baa | 2013-05-20 16:49:06 +0000 | [diff] [blame] | 478 | SkRect devBounds; |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 479 | GetPathDevBounds(path, drawState->getRenderTarget(), viewMatrix, &devBounds); |
bsalomon@google.com | 1dd9baa | 2013-05-20 16:49:06 +0000 | [diff] [blame] | 480 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 481 | for (int p = 0; p < passCount; ++p) { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 482 | drawState->setDrawFace(drawFace[p]); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 483 | if (passes[p]) { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 484 | *drawState->stencil() = *passes[p]; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | if (lastPassIsBounds && (p == passCount-1)) { |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 488 | // Reset the XP Factory on drawState |
| 489 | drawState->setXPFactory(backupXPFactory); |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 490 | SkRect bounds; |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 491 | SkMatrix localMatrix = SkMatrix::I(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 492 | if (reverse) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 493 | SkASSERT(drawState->getRenderTarget()); |
bsalomon@google.com | 1dd9baa | 2013-05-20 16:49:06 +0000 | [diff] [blame] | 494 | // draw over the dev bounds (which will be the whole dst surface for inv fill). |
| 495 | bounds = devBounds; |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 496 | SkMatrix vmi; |
bsalomon@google.com | 8c2fe99 | 2011-09-13 15:27:18 +0000 | [diff] [blame] | 497 | // mapRect through persp matrix may not be correct |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 498 | if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 499 | vmi.mapRect(&bounds); |
bsalomon@google.com | 8c2fe99 | 2011-09-13 15:27:18 +0000 | [diff] [blame] | 500 | } else { |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 501 | if (!viewMatrix.invert(&localMatrix)) { |
| 502 | return false; |
| 503 | } |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 504 | } |
| 505 | } else { |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 506 | bounds = path.getBounds(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 507 | } |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 508 | GrDrawTarget::AutoGeometryPush agp(target); |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 509 | const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : |
| 510 | viewMatrix; |
| 511 | target->drawRect(drawState, color, viewM, bounds, NULL, &localMatrix); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 512 | } else { |
| 513 | if (passCount > 1) { |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 514 | drawState->setDisableColorXPFactory(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 515 | } |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 516 | GrDrawState::AutoRestoreEffects are(drawState); |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 517 | SkAutoTUnref<const GrGeometryProcessor> gp( |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 518 | GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, |
| 519 | color, |
| 520 | viewMatrix, |
| 521 | SkMatrix::I(), |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 522 | false, |
| 523 | newCoverage)); |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 524 | if (indexCnt) { |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 525 | target->drawIndexed(drawState, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 526 | gp, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 527 | primType, |
| 528 | 0, |
| 529 | 0, |
| 530 | vertexCnt, |
| 531 | indexCnt, |
| 532 | &devBounds); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 533 | } else { |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 534 | target->drawNonIndexed(drawState, gp, primType, 0, vertexCnt, &devBounds); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | } |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 538 | return true; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 539 | } |
| 540 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 541 | bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, |
| 542 | const GrDrawState* drawState, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 543 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 544 | const SkPath& path, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 545 | const SkStrokeRec& stroke, |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 546 | bool antiAlias) const { |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 547 | // this class can draw any path with any fill but doesn't do any anti-aliasing. |
egdaniel | af18a09 | 2015-01-05 10:22:28 -0800 | [diff] [blame] | 548 | return !antiAlias && (stroke.isFillStyle() || IsStrokeHairlineOrEquivalent(stroke, |
| 549 | viewMatrix, |
| 550 | NULL)); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 551 | } |
| 552 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 553 | bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target, |
| 554 | GrDrawState* drawState, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 555 | GrColor color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 556 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 557 | const SkPath& path, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 558 | const SkStrokeRec& stroke, |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 559 | bool antiAlias) { |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 560 | return this->internalDrawPath(target, |
| 561 | drawState, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 562 | color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 563 | viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 564 | path, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 565 | stroke, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 566 | false); |
bsalomon@google.com | c2099d2 | 2012-03-02 21:26:50 +0000 | [diff] [blame] | 567 | } |
| 568 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 569 | void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
| 570 | GrDrawState* drawState, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 571 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 572 | const SkPath& path, |
| 573 | const SkStrokeRec& stroke) { |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 574 | SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
| 575 | SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 576 | this->internalDrawPath(target, drawState, GrColor_WHITE, viewMatrix, path, stroke, true); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 577 | } |