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