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 | #include "GrMSAAPathRenderer.h" |
| 9 | |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 10 | #include "GrAuditTrail.h" |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 11 | #include "GrBatchFlushState.h" |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 12 | #include "GrClip.h" |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 13 | #include "GrDefaultGeoProcFactory.h" |
| 14 | #include "GrPathStencilSettings.h" |
| 15 | #include "GrPathUtils.h" |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 16 | #include "GrPipelineBuilder.h" |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 17 | #include "GrMesh.h" |
| 18 | #include "SkGeometry.h" |
| 19 | #include "SkTraceEvent.h" |
| 20 | #include "glsl/GrGLSLGeometryProcessor.h" |
| 21 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 22 | #include "glsl/GrGLSLVertexShaderBuilder.h" |
| 23 | #include "glsl/GrGLSLProgramDataManager.h" |
| 24 | #include "glsl/GrGLSLUtil.h" |
| 25 | #include "gl/GrGLVaryingHandler.h" |
| 26 | #include "batches/GrRectBatchFactory.h" |
| 27 | #include "batches/GrVertexBatch.h" |
| 28 | |
| 29 | static const float kTolerance = 0.5f; |
| 30 | |
| 31 | //////////////////////////////////////////////////////////////////////////////// |
| 32 | // Helpers for drawPath |
| 33 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 34 | static inline bool single_pass_shape(const GrShape& shape) { |
| 35 | if (!shape.inverseFilled()) { |
| 36 | return shape.knownToBeConvex(); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 37 | } |
| 38 | return false; |
| 39 | } |
| 40 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 41 | GrPathRenderer::StencilSupport GrMSAAPathRenderer::onGetStencilSupport(const GrShape& shape) const { |
| 42 | if (single_pass_shape(shape)) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 43 | return GrPathRenderer::kNoRestriction_StencilSupport; |
| 44 | } else { |
| 45 | return GrPathRenderer::kStencilOnly_StencilSupport; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | struct MSAALineVertices { |
| 50 | struct Vertex { |
| 51 | SkPoint fPosition; |
| 52 | SkColor fColor; |
| 53 | }; |
| 54 | Vertex* vertices; |
| 55 | Vertex* nextVertex; |
| 56 | #ifdef SK_DEBUG |
| 57 | Vertex* verticesEnd; |
| 58 | #endif |
| 59 | uint16_t* indices; |
| 60 | uint16_t* nextIndex; |
| 61 | }; |
| 62 | |
| 63 | struct MSAAQuadVertices { |
| 64 | struct Vertex { |
| 65 | SkPoint fPosition; |
| 66 | SkPoint fUV; |
| 67 | SkColor fColor; |
| 68 | }; |
| 69 | Vertex* vertices; |
| 70 | Vertex* nextVertex; |
| 71 | #ifdef SK_DEBUG |
| 72 | Vertex* verticesEnd; |
| 73 | #endif |
| 74 | uint16_t* indices; |
| 75 | uint16_t* nextIndex; |
| 76 | }; |
| 77 | |
| 78 | static inline void append_contour_edge_indices(uint16_t fanCenterIdx, |
| 79 | uint16_t edgeV0Idx, |
| 80 | MSAALineVertices& lines) { |
| 81 | *(lines.nextIndex++) = fanCenterIdx; |
| 82 | *(lines.nextIndex++) = edgeV0Idx; |
| 83 | *(lines.nextIndex++) = edgeV0Idx + 1; |
| 84 | } |
| 85 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 86 | static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, const SkPoint pts[], |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 87 | SkColor color, bool indexed, uint16_t subpathLineIdxStart) { |
| 88 | SkASSERT(lines.nextVertex < lines.verticesEnd); |
| 89 | *lines.nextVertex = { pts[2], color }; |
| 90 | if (indexed) { |
| 91 | int prevIdx = (uint16_t) (lines.nextVertex - lines.vertices - 1); |
| 92 | if (prevIdx > subpathLineIdxStart) { |
| 93 | append_contour_edge_indices(subpathLineIdxStart, prevIdx, lines); |
| 94 | } |
| 95 | } |
| 96 | lines.nextVertex++; |
| 97 | |
| 98 | SkASSERT(quads.nextVertex + 2 < quads.verticesEnd); |
| 99 | // the texture coordinates are drawn from the Loop-Blinn rendering algorithm |
| 100 | *(quads.nextVertex++) = { pts[0], SkPoint::Make(0.0, 0.0), color }; |
| 101 | *(quads.nextVertex++) = { pts[1], SkPoint::Make(0.5, 0.0), color }; |
| 102 | *(quads.nextVertex++) = { pts[2], SkPoint::Make(1.0, 1.0), color }; |
| 103 | if (indexed) { |
| 104 | uint16_t offset = (uint16_t) (quads.nextVertex - quads.vertices) - 3; |
| 105 | *(quads.nextIndex++) = offset++; |
| 106 | *(quads.nextIndex++) = offset++; |
| 107 | *(quads.nextIndex++) = offset++; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | class MSAAQuadProcessor : public GrGeometryProcessor { |
| 112 | public: |
| 113 | static GrGeometryProcessor* Create(const SkMatrix& viewMatrix) { |
| 114 | return new MSAAQuadProcessor(viewMatrix); |
| 115 | } |
| 116 | |
| 117 | virtual ~MSAAQuadProcessor() {} |
| 118 | |
| 119 | const char* name() const override { return "MSAAQuadProcessor"; } |
| 120 | |
| 121 | const Attribute* inPosition() const { return fInPosition; } |
| 122 | const Attribute* inUV() const { return fInUV; } |
| 123 | const Attribute* inColor() const { return fInColor; } |
| 124 | const SkMatrix& viewMatrix() const { return fViewMatrix; } |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 125 | |
| 126 | class GLSLProcessor : public GrGLSLGeometryProcessor { |
| 127 | public: |
| 128 | GLSLProcessor(const GrGeometryProcessor& qpr) {} |
| 129 | |
| 130 | void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
| 131 | const MSAAQuadProcessor& qp = args.fGP.cast<MSAAQuadProcessor>(); |
| 132 | GrGLSLVertexBuilder* vsBuilder = args.fVertBuilder; |
| 133 | GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; |
| 134 | GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 135 | |
| 136 | // emit attributes |
| 137 | varyingHandler->emitAttributes(qp); |
| 138 | varyingHandler->addPassThroughAttribute(qp.inColor(), args.fOutputColor); |
| 139 | |
| 140 | GrGLSLVertToFrag uv(kVec2f_GrSLType); |
| 141 | varyingHandler->addVarying("uv", &uv, kHigh_GrSLPrecision); |
| 142 | vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName); |
| 143 | |
| 144 | // Setup position |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 145 | this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 146 | qp.viewMatrix(), &fViewMatrixUniform); |
| 147 | |
| 148 | // emit transforms |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 149 | this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar, |
| 150 | qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 151 | args.fTransformsOut); |
| 152 | |
| 153 | GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 154 | fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(), |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 155 | uv.fsIn()); |
| 156 | fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage); |
| 157 | } |
| 158 | |
| 159 | static inline void GenKey(const GrGeometryProcessor& gp, |
| 160 | const GrGLSLCaps&, |
| 161 | GrProcessorKeyBuilder* b) { |
| 162 | const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>(); |
| 163 | uint32_t key = 0; |
| 164 | key |= qp.viewMatrix().hasPerspective() ? 0x1 : 0x0; |
| 165 | key |= qp.viewMatrix().isIdentity() ? 0x2: 0x0; |
| 166 | b->add32(key); |
| 167 | } |
| 168 | |
| 169 | virtual void setData(const GrGLSLProgramDataManager& pdman, |
| 170 | const GrPrimitiveProcessor& gp) override { |
| 171 | const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>(); |
| 172 | if (!qp.viewMatrix().isIdentity()) { |
| 173 | float viewMatrix[3 * 3]; |
| 174 | GrGLSLGetMatrix<3>(viewMatrix, qp.viewMatrix()); |
| 175 | pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 176 | } |
| 177 | } |
| 178 | |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 179 | private: |
| 180 | typedef GrGLSLGeometryProcessor INHERITED; |
| 181 | |
| 182 | UniformHandle fViewMatrixUniform; |
| 183 | }; |
| 184 | |
| 185 | virtual void getGLSLProcessorKey(const GrGLSLCaps& caps, |
| 186 | GrProcessorKeyBuilder* b) const override { |
| 187 | GLSLProcessor::GenKey(*this, caps, b); |
| 188 | } |
| 189 | |
| 190 | virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override { |
| 191 | return new GLSLProcessor(*this); |
| 192 | } |
| 193 | |
| 194 | private: |
| 195 | MSAAQuadProcessor(const SkMatrix& viewMatrix) |
| 196 | : fViewMatrix(viewMatrix) { |
| 197 | this->initClassID<MSAAQuadProcessor>(); |
bsalomon | 6cb807b | 2016-08-17 11:33:39 -0700 | [diff] [blame^] | 198 | fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, |
| 199 | kHigh_GrSLPrecision); |
| 200 | fInUV = &this->addVertexAttrib("inUV", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); |
| 201 | fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 202 | this->setSampleShading(1.0f); |
| 203 | } |
| 204 | |
| 205 | const Attribute* fInPosition; |
| 206 | const Attribute* fInUV; |
| 207 | const Attribute* fInColor; |
| 208 | SkMatrix fViewMatrix; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 209 | |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 210 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 211 | |
| 212 | typedef GrGeometryProcessor INHERITED; |
| 213 | }; |
| 214 | |
| 215 | class MSAAPathBatch : public GrVertexBatch { |
| 216 | public: |
| 217 | DEFINE_BATCH_CLASS_ID |
| 218 | |
bsalomon | 8e9e45a | 2016-07-08 09:14:07 -0700 | [diff] [blame] | 219 | MSAAPathBatch(GrColor color, const SkPath& path, const SkMatrix& viewMatrix, |
| 220 | const SkRect& devBounds) |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 221 | : INHERITED(ClassID()) |
| 222 | , fViewMatrix(viewMatrix) { |
| 223 | fPaths.emplace_back(PathInfo{color, path}); |
bsalomon | 8e9e45a | 2016-07-08 09:14:07 -0700 | [diff] [blame] | 224 | this->setBounds(devBounds, HasAABloat::kNo, IsZeroArea::kNo); |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 225 | int contourCount; |
| 226 | this->computeWorstCasePointCount(path, &contourCount, &fMaxLineVertices, &fMaxQuadVertices); |
| 227 | fMaxLineIndices = fMaxLineVertices * 3; |
| 228 | fMaxQuadIndices = fMaxQuadVertices * 3; |
| 229 | fIsIndexed = contourCount > 1; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | const char* name() const override { return "MSAAPathBatch"; } |
| 233 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 234 | void computePipelineOptimizations(GrInitInvariantOutput* color, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 235 | GrInitInvariantOutput* coverage, |
| 236 | GrBatchToXPOverrides* overrides) const override { |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 237 | // When this is called on a batch, there is only one path |
| 238 | color->setKnownFourComponents(fPaths[0].fColor); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 239 | coverage->setKnownSingleComponent(0xff); |
| 240 | } |
| 241 | |
| 242 | bool isValid() const { |
| 243 | return !fIsIndexed || fMaxLineIndices <= SK_MaxU16; |
| 244 | } |
| 245 | |
| 246 | private: |
| 247 | void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 248 | // Handle any color overrides |
| 249 | if (!overrides.readsColor()) { |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 250 | fPaths[0].fColor = GrColor_ILLEGAL; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 251 | } |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 252 | overrides.getOverrideColorIfSet(&fPaths[0].fColor); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 253 | } |
| 254 | |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 255 | void computeWorstCasePointCount(const SkPath& path, int* subpaths, int* outLinePointCount, |
| 256 | int* outQuadPointCount) const { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 257 | int linePointCount = 0; |
| 258 | int quadPointCount = 0; |
| 259 | *subpaths = 1; |
| 260 | |
| 261 | bool first = true; |
| 262 | |
| 263 | SkPath::Iter iter(path, false); |
| 264 | SkPath::Verb verb; |
| 265 | |
| 266 | SkPoint pts[4]; |
| 267 | while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { |
| 268 | switch (verb) { |
| 269 | case SkPath::kLine_Verb: |
| 270 | linePointCount += 1; |
| 271 | break; |
| 272 | case SkPath::kConic_Verb: { |
| 273 | SkScalar weight = iter.conicWeight(); |
| 274 | SkAutoConicToQuads converter; |
| 275 | converter.computeQuads(pts, weight, kTolerance); |
| 276 | int quadPts = converter.countQuads(); |
| 277 | linePointCount += quadPts; |
| 278 | quadPointCount += 3 * quadPts; |
| 279 | } |
| 280 | case SkPath::kQuad_Verb: |
| 281 | linePointCount += 1; |
| 282 | quadPointCount += 3; |
| 283 | break; |
| 284 | case SkPath::kCubic_Verb: { |
| 285 | SkSTArray<15, SkPoint, true> quadPts; |
| 286 | GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadPts); |
| 287 | int count = quadPts.count(); |
| 288 | linePointCount += count / 3; |
| 289 | quadPointCount += count; |
| 290 | break; |
| 291 | } |
| 292 | case SkPath::kMove_Verb: |
| 293 | linePointCount += 1; |
| 294 | if (!first) { |
| 295 | ++(*subpaths); |
| 296 | } |
| 297 | break; |
| 298 | default: |
| 299 | break; |
| 300 | } |
| 301 | first = false; |
| 302 | } |
| 303 | *outLinePointCount = linePointCount; |
| 304 | *outQuadPointCount = quadPointCount; |
| 305 | } |
| 306 | |
| 307 | void onPrepareDraws(Target* target) const override { |
| 308 | SkASSERT(this->isValid()); |
| 309 | if (fMaxLineVertices == 0) { |
| 310 | SkASSERT(fMaxQuadVertices == 0); |
| 311 | return; |
| 312 | } |
| 313 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 314 | GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 315 | : kTriangleFan_GrPrimitiveType; |
| 316 | |
| 317 | // allocate vertex / index buffers |
| 318 | const GrBuffer* lineVertexBuffer; |
| 319 | int firstLineVertex; |
| 320 | MSAALineVertices lines; |
| 321 | size_t lineVertexStride = sizeof(MSAALineVertices::Vertex); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 322 | lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 323 | fMaxLineVertices, |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 324 | &lineVertexBuffer, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 325 | &firstLineVertex); |
| 326 | if (!lines.vertices) { |
| 327 | SkDebugf("Could not allocate vertices\n"); |
| 328 | return; |
| 329 | } |
| 330 | lines.nextVertex = lines.vertices; |
| 331 | SkDEBUGCODE(lines.verticesEnd = lines.vertices + fMaxLineVertices;) |
| 332 | |
| 333 | MSAAQuadVertices quads; |
| 334 | size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex); |
| 335 | SkAutoFree quadVertexPtr(sk_malloc_throw(fMaxQuadVertices * quadVertexStride)); |
| 336 | quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get(); |
| 337 | quads.nextVertex = quads.vertices; |
| 338 | SkDEBUGCODE(quads.verticesEnd = quads.vertices + fMaxQuadVertices;) |
| 339 | |
| 340 | const GrBuffer* lineIndexBuffer = nullptr; |
| 341 | int firstLineIndex; |
| 342 | if (fIsIndexed) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 343 | lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBuffer, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 344 | &firstLineIndex); |
| 345 | if (!lines.indices) { |
| 346 | SkDebugf("Could not allocate indices\n"); |
| 347 | return; |
| 348 | } |
| 349 | lines.nextIndex = lines.indices; |
| 350 | } else { |
| 351 | lines.indices = nullptr; |
| 352 | lines.nextIndex = nullptr; |
| 353 | } |
| 354 | |
| 355 | SkAutoFree quadIndexPtr; |
| 356 | if (fIsIndexed) { |
| 357 | quads.indices = (uint16_t*) sk_malloc_throw(fMaxQuadIndices * sizeof(uint16_t)); |
| 358 | quadIndexPtr.set(quads.indices); |
| 359 | quads.nextIndex = quads.indices; |
| 360 | } else { |
| 361 | quads.indices = nullptr; |
| 362 | quads.nextIndex = nullptr; |
| 363 | } |
| 364 | |
| 365 | // fill buffers |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 366 | for (int i = 0; i < fPaths.count(); i++) { |
| 367 | const PathInfo& pathInfo = fPaths[i]; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 368 | |
| 369 | if (!this->createGeom(lines, |
| 370 | quads, |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 371 | pathInfo.fPath, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 372 | fViewMatrix, |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 373 | pathInfo.fColor, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 374 | fIsIndexed)) { |
| 375 | return; |
| 376 | } |
| 377 | } |
| 378 | int lineVertexOffset = (int) (lines.nextVertex - lines.vertices); |
| 379 | int lineIndexOffset = (int) (lines.nextIndex - lines.indices); |
| 380 | SkASSERT(lineVertexOffset <= fMaxLineVertices && lineIndexOffset <= fMaxLineIndices); |
| 381 | int quadVertexOffset = (int) (quads.nextVertex - quads.vertices); |
| 382 | int quadIndexOffset = (int) (quads.nextIndex - quads.indices); |
| 383 | SkASSERT(quadVertexOffset <= fMaxQuadVertices && quadIndexOffset <= fMaxQuadIndices); |
| 384 | |
| 385 | if (lineVertexOffset) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 386 | sk_sp<GrGeometryProcessor> lineGP; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 387 | { |
| 388 | using namespace GrDefaultGeoProcFactory; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 389 | lineGP = GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_Type), |
| 390 | Coverage(255), |
| 391 | LocalCoords(LocalCoords::kUnused_Type), |
| 392 | fViewMatrix); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 393 | } |
| 394 | SkASSERT(lineVertexStride == lineGP->getVertexStride()); |
| 395 | |
| 396 | GrMesh lineMeshes; |
| 397 | if (fIsIndexed) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 398 | lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineIndexBuffer, |
| 399 | firstLineVertex, firstLineIndex, lineVertexOffset, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 400 | lineIndexOffset); |
| 401 | } else { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 402 | lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 403 | lineVertexOffset); |
| 404 | } |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 405 | target->draw(lineGP.get(), lineMeshes); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | if (quadVertexOffset) { |
| 409 | SkAutoTUnref<const GrGeometryProcessor> quadGP(MSAAQuadProcessor::Create(fViewMatrix)); |
| 410 | SkASSERT(quadVertexStride == quadGP->getVertexStride()); |
| 411 | |
| 412 | const GrBuffer* quadVertexBuffer; |
| 413 | int firstQuadVertex; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 414 | MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*) |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 415 | target->makeVertexSpace(quadVertexStride, quadVertexOffset, &quadVertexBuffer, |
| 416 | &firstQuadVertex); |
| 417 | memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOffset); |
| 418 | GrMesh quadMeshes; |
| 419 | if (fIsIndexed) { |
| 420 | const GrBuffer* quadIndexBuffer; |
| 421 | int firstQuadIndex; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 422 | uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadIndexOffset, |
| 423 | &quadIndexBuffer, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 424 | &firstQuadIndex); |
| 425 | memcpy(quadIndices, quads.indices, sizeof(uint16_t) * quadIndexOffset); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 426 | quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuffer, |
| 427 | quadIndexBuffer, firstQuadVertex, firstQuadIndex, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 428 | quadVertexOffset, quadIndexOffset); |
| 429 | } else { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 430 | quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 431 | quadVertexOffset); |
| 432 | } |
| 433 | target->draw(quadGP, quadMeshes); |
| 434 | } |
| 435 | } |
| 436 | |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 437 | bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 438 | MSAAPathBatch* that = t->cast<MSAAPathBatch>(); |
| 439 | if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(), |
| 440 | that->bounds(), caps)) { |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) { |
| 445 | return false; |
| 446 | } |
| 447 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 448 | if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) || |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 449 | (fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) { |
| 450 | return false; |
| 451 | } |
| 452 | |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 453 | fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin()); |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 454 | this->joinBounds(*that); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 455 | fIsIndexed = true; |
| 456 | fMaxLineVertices += that->fMaxLineVertices; |
| 457 | fMaxQuadVertices += that->fMaxQuadVertices; |
| 458 | fMaxLineIndices += that->fMaxLineIndices; |
| 459 | fMaxQuadIndices += that->fMaxQuadIndices; |
| 460 | return true; |
| 461 | } |
| 462 | |
| 463 | bool createGeom(MSAALineVertices& lines, |
| 464 | MSAAQuadVertices& quads, |
| 465 | const SkPath& path, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 466 | const SkMatrix& m, |
| 467 | SkColor color, |
| 468 | bool isIndexed) const { |
| 469 | { |
| 470 | uint16_t subpathIdxStart = (uint16_t) (lines.nextVertex - lines.vertices); |
| 471 | |
| 472 | SkPoint pts[4]; |
| 473 | |
| 474 | bool first = true; |
| 475 | SkPath::Iter iter(path, false); |
| 476 | |
| 477 | bool done = false; |
| 478 | while (!done) { |
| 479 | SkPath::Verb verb = iter.next(pts); |
| 480 | switch (verb) { |
| 481 | case SkPath::kMove_Verb: |
| 482 | if (!first) { |
| 483 | uint16_t currIdx = (uint16_t) (lines.nextVertex - lines.vertices); |
| 484 | subpathIdxStart = currIdx; |
| 485 | } |
| 486 | SkASSERT(lines.nextVertex < lines.verticesEnd); |
| 487 | *(lines.nextVertex++) = { pts[0], color }; |
| 488 | break; |
| 489 | case SkPath::kLine_Verb: |
| 490 | if (isIndexed) { |
| 491 | uint16_t prevIdx = (uint16_t) (lines.nextVertex - lines.vertices - 1); |
| 492 | if (prevIdx > subpathIdxStart) { |
| 493 | append_contour_edge_indices(subpathIdxStart, prevIdx, lines); |
| 494 | } |
| 495 | } |
| 496 | SkASSERT(lines.nextVertex < lines.verticesEnd); |
| 497 | *(lines.nextVertex++) = { pts[1], color }; |
| 498 | break; |
| 499 | case SkPath::kConic_Verb: { |
| 500 | SkScalar weight = iter.conicWeight(); |
| 501 | SkAutoConicToQuads converter; |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 502 | const SkPoint* quadPts = converter.computeQuads(pts, weight, kTolerance); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 503 | for (int i = 0; i < converter.countQuads(); ++i) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 504 | add_quad(lines, quads, quadPts + i * 2, color, isIndexed, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 505 | subpathIdxStart); |
| 506 | } |
| 507 | break; |
| 508 | } |
| 509 | case SkPath::kQuad_Verb: { |
| 510 | add_quad(lines, quads, pts, color, isIndexed, subpathIdxStart); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 511 | break; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 512 | } |
| 513 | case SkPath::kCubic_Verb: { |
| 514 | SkSTArray<15, SkPoint, true> quadPts; |
| 515 | GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadPts); |
| 516 | int count = quadPts.count(); |
| 517 | for (int i = 0; i < count; i += 3) { |
| 518 | add_quad(lines, quads, &quadPts[i], color, isIndexed, subpathIdxStart); |
| 519 | } |
| 520 | break; |
| 521 | } |
| 522 | case SkPath::kClose_Verb: |
| 523 | break; |
| 524 | case SkPath::kDone_Verb: |
| 525 | done = true; |
| 526 | } |
| 527 | first = false; |
| 528 | } |
| 529 | } |
| 530 | return true; |
| 531 | } |
| 532 | |
bsalomon | 50c56a3 | 2016-06-30 12:05:32 -0700 | [diff] [blame] | 533 | struct PathInfo { |
| 534 | GrColor fColor; |
| 535 | SkPath fPath; |
| 536 | }; |
| 537 | |
| 538 | SkSTArray<1, PathInfo, true> fPaths; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 539 | |
| 540 | SkMatrix fViewMatrix; |
| 541 | int fMaxLineVertices; |
| 542 | int fMaxQuadVertices; |
| 543 | int fMaxLineIndices; |
| 544 | int fMaxQuadIndices; |
| 545 | bool fIsIndexed; |
| 546 | |
| 547 | typedef GrVertexBatch INHERITED; |
| 548 | }; |
| 549 | |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 550 | bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, |
| 551 | const GrPaint& paint, |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 552 | const GrUserStencilSettings& userStencilSettings, |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 553 | const GrClip& clip, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 554 | const SkMatrix& viewMatrix, |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 555 | const GrShape& shape, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 556 | bool stencilOnly) { |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 557 | SkASSERT(shape.style().isSimpleFill()); |
| 558 | SkPath path; |
| 559 | shape.asPath(&path); |
| 560 | |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 561 | static const int kMaxNumPasses = 2; |
| 562 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 563 | int passCount = 0; |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 564 | const GrUserStencilSettings* passes[kMaxNumPasses]; |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 565 | bool reverse = false; |
| 566 | bool lastPassIsBounds; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 567 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 568 | if (single_pass_shape(shape)) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 569 | passCount = 1; |
| 570 | if (stencilOnly) { |
| 571 | passes[0] = &gDirectToStencil; |
| 572 | } else { |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 573 | passes[0] = &userStencilSettings; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 574 | } |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 575 | lastPassIsBounds = false; |
| 576 | } else { |
| 577 | switch (path.getFillType()) { |
| 578 | case SkPath::kInverseEvenOdd_FillType: |
| 579 | reverse = true; |
| 580 | // fallthrough |
| 581 | case SkPath::kEvenOdd_FillType: |
| 582 | passes[0] = &gEOStencilPass; |
| 583 | if (stencilOnly) { |
| 584 | passCount = 1; |
| 585 | lastPassIsBounds = false; |
| 586 | } else { |
| 587 | passCount = 2; |
| 588 | lastPassIsBounds = true; |
| 589 | if (reverse) { |
| 590 | passes[1] = &gInvEOColorPass; |
| 591 | } else { |
| 592 | passes[1] = &gEOColorPass; |
| 593 | } |
| 594 | } |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 595 | break; |
| 596 | |
| 597 | case SkPath::kInverseWinding_FillType: |
| 598 | reverse = true; |
| 599 | // fallthrough |
| 600 | case SkPath::kWinding_FillType: |
| 601 | passes[0] = &gWindStencilSeparateWithWrap; |
| 602 | passCount = 2; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 603 | if (stencilOnly) { |
| 604 | lastPassIsBounds = false; |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 605 | passCount = 1; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 606 | } else { |
| 607 | lastPassIsBounds = true; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 608 | if (reverse) { |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 609 | passes[1] = &gInvWindColorPass; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 610 | } else { |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 611 | passes[1] = &gWindColorPass; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 612 | } |
| 613 | } |
| 614 | break; |
| 615 | default: |
| 616 | SkDEBUGFAIL("Unknown path fFill!"); |
| 617 | return false; |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | SkRect devBounds; |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 622 | GetPathDevBounds(path, drawContext->width(), drawContext->height(), viewMatrix, &devBounds); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 623 | |
robertphillips | 8e37530 | 2016-07-11 10:43:58 -0700 | [diff] [blame] | 624 | SkASSERT(passCount <= kMaxNumPasses); |
| 625 | |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 626 | for (int p = 0; p < passCount; ++p) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 627 | if (lastPassIsBounds && (p == passCount-1)) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 628 | SkRect bounds; |
| 629 | SkMatrix localMatrix = SkMatrix::I(); |
| 630 | if (reverse) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 631 | // draw over the dev bounds (which will be the whole dst surface for inv fill). |
| 632 | bounds = devBounds; |
| 633 | SkMatrix vmi; |
| 634 | // mapRect through persp matrix may not be correct |
| 635 | if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { |
| 636 | vmi.mapRect(&bounds); |
| 637 | } else { |
| 638 | if (!viewMatrix.invert(&localMatrix)) { |
| 639 | return false; |
| 640 | } |
| 641 | } |
| 642 | } else { |
| 643 | bounds = path.getBounds(); |
| 644 | } |
| 645 | const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : |
| 646 | viewMatrix; |
| 647 | SkAutoTUnref<GrDrawBatch> batch( |
robertphillips | 3950f0d | 2016-07-07 07:33:13 -0700 | [diff] [blame] | 648 | GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 649 | &localMatrix)); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 650 | |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 651 | GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); |
| 652 | pipelineBuilder.setUserStencil(passes[p]); |
| 653 | |
| 654 | drawContext->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 655 | } else { |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 656 | SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor(), path, |
bsalomon | 8e9e45a | 2016-07-08 09:14:07 -0700 | [diff] [blame] | 657 | viewMatrix, devBounds)); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 658 | if (!batch->isValid()) { |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 659 | return false; |
| 660 | } |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 661 | |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 662 | GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); |
| 663 | pipelineBuilder.setUserStencil(passes[p]); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 664 | if (passCount > 1) { |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 665 | pipelineBuilder.setDisableColorXPFactory(); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 666 | } |
| 667 | |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 668 | drawContext->drawBatch(pipelineBuilder, clip, batch); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | return true; |
| 672 | } |
| 673 | |
| 674 | bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
bsalomon | ee43241 | 2016-06-27 07:18:18 -0700 | [diff] [blame] | 675 | // This path renderer only fills and relies on MSAA for antialiasing. Stroked shapes are |
| 676 | // handled by passing on the original shape and letting the caller compute the stroked shape |
| 677 | // which will have a fill style. |
| 678 | return args.fShape->style().isSimpleFill() && !args.fAntiAlias; |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) { |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 682 | GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 683 | "GrMSAAPathRenderer::onDrawPath"); |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 684 | SkTLazy<GrShape> tmpShape; |
| 685 | const GrShape* shape = args.fShape; |
| 686 | if (shape->style().applies()) { |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 687 | SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 688 | tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStrokeRec, styleScale)); |
| 689 | shape = tmpShape.get(); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 690 | } |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 691 | return this->internalDrawPath(args.fDrawContext, |
| 692 | *args.fPaint, |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 693 | *args.fUserStencilSettings, |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 694 | *args.fClip, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 695 | *args.fViewMatrix, |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 696 | *shape, |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 697 | false); |
| 698 | } |
| 699 | |
| 700 | void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 701 | GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 702 | "GrMSAAPathRenderer::onStencilPath"); |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 703 | SkASSERT(args.fShape->style().isSimpleFill()); |
| 704 | SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling()); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 705 | |
| 706 | GrPaint paint; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 707 | paint.setXPFactory(GrDisableColorXPFactory::Make()); |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 708 | paint.setAntiAlias(args.fIsAA); |
| 709 | |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 710 | this->internalDrawPath(args.fDrawContext, paint, GrUserStencilSettings::kUnused, *args.fClip, |
robertphillips | 3950f0d | 2016-07-07 07:33:13 -0700 | [diff] [blame] | 711 | *args.fViewMatrix, *args.fShape, true); |
ethannicholas | 6536ae5 | 2016-05-02 12:16:49 -0700 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | /////////////////////////////////////////////////////////////////////////////////////////////////// |