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" |
11 #include "GrBatchTarget.h" | 11 #include "GrBatchTarget.h" |
12 #include "GrDefaultGeoProcFactory.h" | 12 #include "GrDefaultGeoProcFactory.h" |
13 #include "GrPathUtils.h" | 13 #include "GrPathUtils.h" |
| 14 #include "GrStrokeInfo.h" |
14 #include "SkChunkAlloc.h" | 15 #include "SkChunkAlloc.h" |
15 #include "SkGeometry.h" | 16 #include "SkGeometry.h" |
16 | 17 |
17 #include <stdio.h> | 18 #include <stdio.h> |
18 | 19 |
19 /* | 20 /* |
20 * This path renderer tessellates the path into triangles, uploads the triangles
to a | 21 * This path renderer tessellates the path into triangles, uploads the triangles
to a |
21 * vertex buffer, and renders them with a single draw call. It does not currentl
y do | 22 * vertex buffer, and renders them with a single draw call. It does not currentl
y do |
22 * antialiasing, so it must be used in conjunction with multisampling. | 23 * antialiasing, so it must be used in conjunction with multisampling. |
23 * | 24 * |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 | 1325 |
1325 }; | 1326 }; |
1326 | 1327 |
1327 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { | 1328 GrTessellatingPathRenderer::GrTessellatingPathRenderer() { |
1328 } | 1329 } |
1329 | 1330 |
1330 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport( | 1331 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport( |
1331 const GrDrawTarget*, | 1332 const GrDrawTarget*, |
1332 const GrPipelineBuil
der*, | 1333 const GrPipelineBuil
der*, |
1333 const SkPath&, | 1334 const SkPath&, |
1334 const SkStrokeRec&)
const { | 1335 const GrStrokeInfo&)
const { |
1335 return GrPathRenderer::kNoSupport_StencilSupport; | 1336 return GrPathRenderer::kNoSupport_StencilSupport; |
1336 } | 1337 } |
1337 | 1338 |
1338 bool GrTessellatingPathRenderer::canDrawPath(const GrDrawTarget* target, | 1339 bool GrTessellatingPathRenderer::canDrawPath(const GrDrawTarget* target, |
1339 const GrPipelineBuilder* pipelineBu
ilder, | 1340 const GrPipelineBuilder* pipelineBu
ilder, |
1340 const SkMatrix& viewMatrix, | 1341 const SkMatrix& viewMatrix, |
1341 const SkPath& path, | 1342 const SkPath& path, |
1342 const SkStrokeRec& stroke, | 1343 const GrStrokeInfo& stroke, |
1343 bool antiAlias) const { | 1344 bool antiAlias) const { |
1344 // This path renderer can draw all fill styles, but does not do antialiasing
. It can do convex | 1345 // This path renderer can draw all fill styles, but does not do antialiasing
. It can do convex |
1345 // and concave paths, but we'll leave the convex ones to simpler algorithms. | 1346 // and concave paths, but we'll leave the convex ones to simpler algorithms. |
1346 return stroke.isFillStyle() && !antiAlias && !path.isConvex(); | 1347 return stroke.getStrokeRec().isFillStyle() && !antiAlias && !path.isConvex()
; |
1347 } | 1348 } |
1348 | 1349 |
1349 class TessellatingPathBatch : public GrBatch { | 1350 class TessellatingPathBatch : public GrBatch { |
1350 public: | 1351 public: |
1351 | 1352 |
1352 static GrBatch* Create(const GrColor& color, | 1353 static GrBatch* Create(const GrColor& color, |
1353 const SkPath& path, | 1354 const SkPath& path, |
1354 const SkMatrix& viewMatrix, | 1355 const SkMatrix& viewMatrix, |
1355 SkRect clipBounds) { | 1356 SkRect clipBounds) { |
1356 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB
ounds)); | 1357 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB
ounds)); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 SkMatrix fViewMatrix; | 1485 SkMatrix fViewMatrix; |
1485 SkRect fClipBounds; // in source space | 1486 SkRect fClipBounds; // in source space |
1486 GrPipelineInfo fPipelineInfo; | 1487 GrPipelineInfo fPipelineInfo; |
1487 }; | 1488 }; |
1488 | 1489 |
1489 bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, | 1490 bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, |
1490 GrPipelineBuilder* pipelineBuilder, | 1491 GrPipelineBuilder* pipelineBuilder, |
1491 GrColor color, | 1492 GrColor color, |
1492 const SkMatrix& viewM, | 1493 const SkMatrix& viewM, |
1493 const SkPath& path, | 1494 const SkPath& path, |
1494 const SkStrokeRec& stroke, | 1495 const GrStrokeInfo& stroke, |
1495 bool antiAlias) { | 1496 bool antiAlias) { |
1496 SkASSERT(!antiAlias); | 1497 SkASSERT(!antiAlias); |
1497 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 1498 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
1498 if (NULL == rt) { | 1499 if (NULL == rt) { |
1499 return false; | 1500 return false; |
1500 } | 1501 } |
1501 | 1502 |
1502 SkIRect clipBoundsI; | 1503 SkIRect clipBoundsI; |
1503 pipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); | 1504 pipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); |
1504 SkRect clipBounds = SkRect::Make(clipBoundsI); | 1505 SkRect clipBounds = SkRect::Make(clipBoundsI); |
1505 SkMatrix vmi; | 1506 SkMatrix vmi; |
1506 if (!viewM.invert(&vmi)) { | 1507 if (!viewM.invert(&vmi)) { |
1507 return false; | 1508 return false; |
1508 } | 1509 } |
1509 vmi.mapRect(&clipBounds); | 1510 vmi.mapRect(&clipBounds); |
1510 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); | 1511 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); |
1511 target->drawBatch(pipelineBuilder, batch); | 1512 target->drawBatch(pipelineBuilder, batch); |
1512 | 1513 |
1513 return true; | 1514 return true; |
1514 } | 1515 } |
OLD | NEW |