| 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 "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1330 |
| 1331 }; | 1331 }; |
| 1332 | 1332 |
| 1333 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { | 1333 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport( | 1336 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport( |
| 1337 const GrDrawTarget*, | 1337 const GrDrawTarget*, |
| 1338 const GrPipelineBuil
der*, | 1338 const GrPipelineBuil
der*, |
| 1339 const SkPath&, | 1339 const SkPath&, |
| 1340 const SkStrokeRec&)
const { | 1340 const GrStrokeInfo&)
const { |
| 1341 return GrPathRenderer::kNoSupport_StencilSupport; | 1341 return GrPathRenderer::kNoSupport_StencilSupport; |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 bool GrTessellatingPathRenderer::canDrawPath(const GrDrawTarget* target, | 1344 bool GrTessellatingPathRenderer::canDrawPath(const GrDrawTarget* target, |
| 1345 const GrPipelineBuilder* pipelineBu
ilder, | 1345 const GrPipelineBuilder* pipelineBu
ilder, |
| 1346 const SkMatrix& viewMatrix, | 1346 const SkMatrix& viewMatrix, |
| 1347 const SkPath& path, | 1347 const SkPath& path, |
| 1348 const SkStrokeRec& stroke, | 1348 const GrStrokeInfo& stroke, |
| 1349 bool antiAlias) const { | 1349 bool antiAlias) const { |
| 1350 // This path renderer can draw all fill styles, but does not do antialiasing
. It can do convex | 1350 // This path renderer can draw all fill styles, but does not do antialiasing
. It can do convex |
| 1351 // and concave paths, but we'll leave the convex ones to simpler algorithms. | 1351 // and concave paths, but we'll leave the convex ones to simpler algorithms. |
| 1352 return stroke.isFillStyle() && !antiAlias && !path.isConvex(); | 1352 return stroke.isFillStyle() && !antiAlias && !path.isConvex(); |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 class TessellatingPathBatch : public GrBatch { | 1355 class TessellatingPathBatch : public GrBatch { |
| 1356 public: | 1356 public: |
| 1357 | 1357 |
| 1358 static GrBatch* Create(const GrColor& color, | 1358 static GrBatch* Create(const GrColor& color, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 SkMatrix fViewMatrix; | 1491 SkMatrix fViewMatrix; |
| 1492 SkRect fClipBounds; // in source space | 1492 SkRect fClipBounds; // in source space |
| 1493 GrPipelineInfo fPipelineInfo; | 1493 GrPipelineInfo fPipelineInfo; |
| 1494 }; | 1494 }; |
| 1495 | 1495 |
| 1496 bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, | 1496 bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, |
| 1497 GrPipelineBuilder* pipelineBuilder, | 1497 GrPipelineBuilder* pipelineBuilder, |
| 1498 GrColor color, | 1498 GrColor color, |
| 1499 const SkMatrix& viewM, | 1499 const SkMatrix& viewM, |
| 1500 const SkPath& path, | 1500 const SkPath& path, |
| 1501 const SkStrokeRec& stroke, | 1501 const GrStrokeInfo&, |
| 1502 bool antiAlias) { | 1502 bool antiAlias) { |
| 1503 SkASSERT(!antiAlias); | 1503 SkASSERT(!antiAlias); |
| 1504 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 1504 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
| 1505 if (NULL == rt) { | 1505 if (NULL == rt) { |
| 1506 return false; | 1506 return false; |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 SkIRect clipBoundsI; | 1509 SkIRect clipBoundsI; |
| 1510 pipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); | 1510 pipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); |
| 1511 SkRect clipBounds = SkRect::Make(clipBoundsI); | 1511 SkRect clipBounds = SkRect::Make(clipBoundsI); |
| 1512 SkMatrix vmi; | 1512 SkMatrix vmi; |
| 1513 if (!viewM.invert(&vmi)) { | 1513 if (!viewM.invert(&vmi)) { |
| 1514 return false; | 1514 return false; |
| 1515 } | 1515 } |
| 1516 vmi.mapRect(&clipBounds); | 1516 vmi.mapRect(&clipBounds); |
| 1517 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); | 1517 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); |
| 1518 target->drawBatch(pipelineBuilder, batch); | 1518 target->drawBatch(pipelineBuilder, batch); |
| 1519 | 1519 |
| 1520 return true; | 1520 return true; |
| 1521 } | 1521 } |
| OLD | NEW |