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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
t { | 1378 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
t { |
1379 // This path renderer can draw all fill styles, all stroke styles except hai
rlines, but does | 1379 // This path renderer can draw all fill styles, all stroke styles except hai
rlines, but does |
1380 // not do antialiasing. It can do convex and concave paths, but we'll leave
the convex ones to | 1380 // not do antialiasing. It can do convex and concave paths, but we'll leave
the convex ones to |
1381 // simpler algorithms. | 1381 // simpler algorithms. |
1382 return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, nullp
tr) && | 1382 return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, nullp
tr) && |
1383 !args.fAntiAlias && !args.fPath->isConvex(); | 1383 !args.fAntiAlias && !args.fPath->isConvex(); |
1384 } | 1384 } |
1385 | 1385 |
1386 class TessellatingPathBatch : public GrVertexBatch { | 1386 class TessellatingPathBatch : public GrVertexBatch { |
1387 public: | 1387 public: |
1388 DEFINE_BATCH_CLASS_ID | |
1389 | 1388 |
1390 static GrDrawBatch* Create(const GrColor& color, | 1389 static GrDrawBatch* Create(const GrColor& color, |
1391 const SkPath& path, | 1390 const SkPath& path, |
1392 const GrStrokeInfo& stroke, | 1391 const GrStrokeInfo& stroke, |
1393 const SkMatrix& viewMatrix, | 1392 const SkMatrix& viewMatrix, |
1394 SkRect clipBounds) { | 1393 SkRect clipBounds) { |
1395 return new TessellatingPathBatch(color, path, stroke, viewMatrix, clipBo
unds); | 1394 return new TessellatingPathBatch(color, path, stroke, viewMatrix, clipBo
unds); |
1396 } | 1395 } |
1397 | 1396 |
1398 const char* name() const override { return "TessellatingPathBatch"; } | 1397 const char* name() const override { return "TessellatingPathBatch"; } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 target->draw(vertices); | 1580 target->draw(vertices); |
1582 } | 1581 } |
1583 | 1582 |
1584 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; } | 1583 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; } |
1585 | 1584 |
1586 TessellatingPathBatch(const GrColor& color, | 1585 TessellatingPathBatch(const GrColor& color, |
1587 const SkPath& path, | 1586 const SkPath& path, |
1588 const GrStrokeInfo& stroke, | 1587 const GrStrokeInfo& stroke, |
1589 const SkMatrix& viewMatrix, | 1588 const SkMatrix& viewMatrix, |
1590 const SkRect& clipBounds) | 1589 const SkRect& clipBounds) |
1591 : INHERITED(ClassID()) | 1590 : fColor(color) |
1592 , fColor(color) | |
1593 , fPath(path) | 1591 , fPath(path) |
1594 , fStroke(stroke) | 1592 , fStroke(stroke) |
1595 , fViewMatrix(viewMatrix) | 1593 , fViewMatrix(viewMatrix) |
1596 , fClipBounds(clipBounds) { | 1594 , fClipBounds(clipBounds) { |
| 1595 this->initClassID<TessellatingPathBatch>(); |
| 1596 |
1597 fBounds = path.getBounds(); | 1597 fBounds = path.getBounds(); |
1598 if (!stroke.isFillStyle()) { | 1598 if (!stroke.isFillStyle()) { |
1599 SkScalar radius = SkScalarHalf(stroke.getWidth()); | 1599 SkScalar radius = SkScalarHalf(stroke.getWidth()); |
1600 if (stroke.getJoin() == SkPaint::kMiter_Join) { | 1600 if (stroke.getJoin() == SkPaint::kMiter_Join) { |
1601 SkScalar scale = stroke.getMiter(); | 1601 SkScalar scale = stroke.getMiter(); |
1602 if (scale > SK_Scalar1) { | 1602 if (scale > SK_Scalar1) { |
1603 radius = SkScalarMul(radius, scale); | 1603 radius = SkScalarMul(radius, scale); |
1604 } | 1604 } |
1605 } | 1605 } |
1606 fBounds.outset(radius, radius); | 1606 fBounds.outset(radius, radius); |
1607 } | 1607 } |
1608 viewMatrix.mapRect(&fBounds); | 1608 viewMatrix.mapRect(&fBounds); |
1609 } | 1609 } |
1610 | 1610 |
1611 GrColor fColor; | 1611 GrColor fColor; |
1612 SkPath fPath; | 1612 SkPath fPath; |
1613 GrStrokeInfo fStroke; | 1613 GrStrokeInfo fStroke; |
1614 SkMatrix fViewMatrix; | 1614 SkMatrix fViewMatrix; |
1615 SkRect fClipBounds; // in source space | 1615 SkRect fClipBounds; // in source space |
1616 GrPipelineOptimizations fPipelineInfo; | 1616 GrPipelineOptimizations fPipelineInfo; |
1617 | |
1618 typedef GrVertexBatch INHERITED; | |
1619 }; | 1617 }; |
1620 | 1618 |
1621 bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { | 1619 bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { |
1622 SkASSERT(!args.fAntiAlias); | 1620 SkASSERT(!args.fAntiAlias); |
1623 const GrRenderTarget* rt = args.fPipelineBuilder->getRenderTarget(); | 1621 const GrRenderTarget* rt = args.fPipelineBuilder->getRenderTarget(); |
1624 if (nullptr == rt) { | 1622 if (nullptr == rt) { |
1625 return false; | 1623 return false; |
1626 } | 1624 } |
1627 | 1625 |
1628 SkIRect clipBoundsI; | 1626 SkIRect clipBoundsI; |
(...skipping 25 matching lines...) Expand all Loading... |
1654 bool result = viewMatrix.invert(&vmi); | 1652 bool result = viewMatrix.invert(&vmi); |
1655 if (!result) { | 1653 if (!result) { |
1656 SkFAIL("Cannot invert matrix\n"); | 1654 SkFAIL("Cannot invert matrix\n"); |
1657 } | 1655 } |
1658 vmi.mapRect(&clipBounds); | 1656 vmi.mapRect(&clipBounds); |
1659 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); | 1657 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); |
1660 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl
ipBounds); | 1658 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl
ipBounds); |
1661 } | 1659 } |
1662 | 1660 |
1663 #endif | 1661 #endif |
OLD | NEW |