OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrTessellatingPathRenderer.h" | 8 #include "GrTessellatingPathRenderer.h" |
9 | 9 |
10 #include "GrAuditTrail.h" | 10 #include "GrAuditTrail.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { | 104 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { |
105 } | 105 } |
106 | 106 |
107 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
t { | 107 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
t { |
108 // This path renderer can draw all fill styles, all stroke styles except hai
rlines, but does | 108 // This path renderer can draw all fill styles, all stroke styles except hai
rlines, but does |
109 // not do antialiasing. It can do convex and concave paths, but we'll leave
the convex ones to | 109 // not do antialiasing. It can do convex and concave paths, but we'll leave
the convex ones to |
110 // simpler algorithms. Similary, we skip the non-hairlines that can be treat
ed as hairline. | 110 // simpler algorithms. Similary, we skip the non-hairlines that can be treat
ed as hairline. |
111 // An arbitrary path effect could produce a hairline result so we pass on th
ose. | 111 // An arbitrary path effect could produce a hairline result so we pass on th
ose. |
112 return !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullpt
r) && | 112 return !IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix
, nullptr) && |
113 !args.fStyle->strokeRec().isHairlineStyle() && | 113 !args.fShape->style().strokeRec().isHairlineStyle() && |
114 !args.fStyle->hasNonDashPathEffect() && !args.fAntiAlias && !args.fPa
th->isConvex(); | 114 !args.fShape->style().hasNonDashPathEffect() && !args.fAntiAlias && |
| 115 !args.fShape->knownToBeConvex(); |
115 } | 116 } |
116 | 117 |
117 class TessellatingPathBatch : public GrVertexBatch { | 118 class TessellatingPathBatch : public GrVertexBatch { |
118 public: | 119 public: |
119 DEFINE_BATCH_CLASS_ID | 120 DEFINE_BATCH_CLASS_ID |
120 | 121 |
121 static GrDrawBatch* Create(const GrColor& color, | 122 static GrDrawBatch* Create(const GrColor& color, |
122 const SkPath& path, | 123 const SkPath& path, |
123 const GrStyle& style, | 124 const GrStyle& style, |
124 const SkMatrix& viewMatrix, | 125 const SkMatrix& viewMatrix, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 286 |
286 SkIRect clipBoundsI; | 287 SkIRect clipBoundsI; |
287 args.fClip->getConservativeBounds(args.fDrawContext->width(), args.fDrawCont
ext->height(), | 288 args.fClip->getConservativeBounds(args.fDrawContext->width(), args.fDrawCont
ext->height(), |
288 &clipBoundsI); | 289 &clipBoundsI); |
289 SkRect clipBounds = SkRect::Make(clipBoundsI); | 290 SkRect clipBounds = SkRect::Make(clipBoundsI); |
290 SkMatrix vmi; | 291 SkMatrix vmi; |
291 if (!args.fViewMatrix->invert(&vmi)) { | 292 if (!args.fViewMatrix->invert(&vmi)) { |
292 return false; | 293 return false; |
293 } | 294 } |
294 vmi.mapRect(&clipBounds); | 295 vmi.mapRect(&clipBounds); |
295 SkAutoTUnref<GrDrawBatch> batch(TessellatingPathBatch::Create(args.fColor, *
args.fPath, | 296 SkPath path; |
296 *args.fStyle,
*args.fViewMatrix, | 297 args.fShape->asPath(&path); |
| 298 SkAutoTUnref<GrDrawBatch> batch(TessellatingPathBatch::Create(args.fColor, p
ath, |
| 299 args.fShape->s
tyle(), |
| 300 *args.fViewMat
rix, |
297 clipBounds)); | 301 clipBounds)); |
298 | 302 |
299 GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHW
AA(*args.fPaint)); | 303 GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHW
AA(*args.fPaint)); |
300 pipelineBuilder.setUserStencil(args.fUserStencilSettings); | 304 pipelineBuilder.setUserStencil(args.fUserStencilSettings); |
301 | 305 |
302 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); | 306 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); |
303 | 307 |
304 return true; | 308 return true; |
305 } | 309 } |
306 | 310 |
(...skipping 13 matching lines...) Expand all Loading... |
320 } | 324 } |
321 vmi.mapRect(&clipBounds); | 325 vmi.mapRect(&clipBounds); |
322 GrStyle style; | 326 GrStyle style; |
323 do { | 327 do { |
324 GrTest::TestStyle(random, &style); | 328 GrTest::TestStyle(random, &style); |
325 } while (style.strokeRec().isHairlineStyle()); | 329 } while (style.strokeRec().isHairlineStyle()); |
326 return TessellatingPathBatch::Create(color, path, style, viewMatrix, clipBou
nds); | 330 return TessellatingPathBatch::Create(color, path, style, viewMatrix, clipBou
nds); |
327 } | 331 } |
328 | 332 |
329 #endif | 333 #endif |
OLD | NEW |