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