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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 info.fTolerance = isLinear ? 0 : tol; | 1490 info.fTolerance = isLinear ? 0 : tol; |
1491 info.fCount = actualCount; | 1491 info.fCount = actualCount; |
1492 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info))); | 1492 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info))); |
1493 key->setCustomData(data.get()); | 1493 key->setCustomData(data.get()); |
1494 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get()
); | 1494 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get()
); |
1495 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key
))); | 1495 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key
))); |
1496 } | 1496 } |
1497 return actualCount; | 1497 return actualCount; |
1498 } | 1498 } |
1499 | 1499 |
1500 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1500 void generateGeometry(GrBatchTarget* batchTarget) override { |
1501 // construct a cache key from the path's genID and the view matrix | 1501 // construct a cache key from the path's genID and the view matrix |
1502 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain()
; | 1502 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain()
; |
1503 GrUniqueKey key; | 1503 GrUniqueKey key; |
1504 int clipBoundsSize32 = | 1504 int clipBoundsSize32 = |
1505 fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) :
0; | 1505 fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) :
0; |
1506 GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32); | 1506 GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32); |
1507 builder[0] = fPath.getGenerationID(); | 1507 builder[0] = fPath.getGenerationID(); |
1508 builder[1] = fPath.getFillType(); | 1508 builder[1] = fPath.getFillType(); |
1509 // For inverse fills, the tessellation is dependent on clip bounds. | 1509 // For inverse fills, the tessellation is dependent on clip bounds. |
1510 if (fPath.isInverseFillType()) { | 1510 if (fPath.isInverseFillType()) { |
(...skipping 26 matching lines...) Expand all Loading... |
1537 if (fPipelineInfo.readsCoverage()) { | 1537 if (fPipelineInfo.readsCoverage()) { |
1538 coverageType = Coverage::kSolid_Type; | 1538 coverageType = Coverage::kSolid_Type; |
1539 } else { | 1539 } else { |
1540 coverageType = Coverage::kNone_Type; | 1540 coverageType = Coverage::kNone_Type; |
1541 } | 1541 } |
1542 Coverage coverage(coverageType); | 1542 Coverage coverage(coverageType); |
1543 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, | 1543 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, |
1544 fViewMatrix)); | 1544 fViewMatrix)); |
1545 } | 1545 } |
1546 | 1546 |
1547 batchTarget->initDraw(gp, pipeline); | 1547 batchTarget->initDraw(gp, this->pipeline()); |
1548 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); | 1548 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); |
1549 | 1549 |
1550 GrPrimitiveType primitiveType = WIREFRAME ? kLines_GrPrimitiveType | 1550 GrPrimitiveType primitiveType = WIREFRAME ? kLines_GrPrimitiveType |
1551 : kTriangles_GrPrimitiveType; | 1551 : kTriangles_GrPrimitiveType; |
1552 GrVertices vertices; | 1552 GrVertices vertices; |
1553 vertices.init(primitiveType, vertexBuffer.get(), 0, actualCount); | 1553 vertices.init(primitiveType, vertexBuffer.get(), 0, actualCount); |
1554 batchTarget->draw(vertices); | 1554 batchTarget->draw(vertices); |
1555 } | 1555 } |
1556 | 1556 |
1557 bool onCombineIfPossible(GrBatch*) override { | 1557 bool onCombineIfPossible(GrBatch*) override { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 SkMatrix vmi; | 1614 SkMatrix vmi; |
1615 bool result = viewMatrix.invert(&vmi); | 1615 bool result = viewMatrix.invert(&vmi); |
1616 if (!result) { | 1616 if (!result) { |
1617 SkFAIL("Cannot invert matrix\n"); | 1617 SkFAIL("Cannot invert matrix\n"); |
1618 } | 1618 } |
1619 vmi.mapRect(&clipBounds); | 1619 vmi.mapRect(&clipBounds); |
1620 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds); | 1620 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds); |
1621 } | 1621 } |
1622 | 1622 |
1623 #endif | 1623 #endif |
OLD | NEW |