Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: src/gpu/GrTessellatingPathRenderer.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTargetCommands.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrBatchTarget.h" 10 #include "GrBatchFlushState.h"
11 #include "GrBatchTest.h" 11 #include "GrBatchTest.h"
12 #include "GrDefaultGeoProcFactory.h" 12 #include "GrDefaultGeoProcFactory.h"
13 #include "GrPathUtils.h" 13 #include "GrPathUtils.h"
14 #include "GrVertices.h" 14 #include "GrVertices.h"
15 #include "GrResourceCache.h" 15 #include "GrResourceCache.h"
16 #include "GrResourceProvider.h" 16 #include "GrResourceProvider.h"
17 #include "SkChunkAlloc.h" 17 #include "SkChunkAlloc.h"
18 #include "SkGeometry.h" 18 #include "SkGeometry.h"
19 19
20 #include "batches/GrVertexBatch.h" 20 #include "batches/GrVertexBatch.h"
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 info.fTolerance = isLinear ? 0 : tol; 1502 info.fTolerance = isLinear ? 0 : tol;
1503 info.fCount = actualCount; 1503 info.fCount = actualCount;
1504 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info))); 1504 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
1505 key->setCustomData(data.get()); 1505 key->setCustomData(data.get());
1506 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get() ); 1506 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get() );
1507 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key ))); 1507 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key )));
1508 } 1508 }
1509 return actualCount; 1509 return actualCount;
1510 } 1510 }
1511 1511
1512 void generateGeometry(GrBatchTarget* batchTarget) override { 1512 void onPrepareDraws(Target* target) override {
1513 // construct a cache key from the path's genID and the view matrix 1513 // construct a cache key from the path's genID and the view matrix
1514 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain() ; 1514 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain() ;
1515 GrUniqueKey key; 1515 GrUniqueKey key;
1516 int clipBoundsSize32 = 1516 int clipBoundsSize32 =
1517 fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) : 0; 1517 fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) : 0;
1518 int strokeDataSize32 = fStroke.computeUniqueKeyFragmentData32Cnt(); 1518 int strokeDataSize32 = fStroke.computeUniqueKeyFragmentData32Cnt();
1519 GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32 + strok eDataSize32); 1519 GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32 + strok eDataSize32);
1520 builder[0] = fPath.getGenerationID(); 1520 builder[0] = fPath.getGenerationID();
1521 builder[1] = fPath.getFillType(); 1521 builder[1] = fPath.getFillType();
1522 // For inverse fills, the tessellation is dependent on clip bounds. 1522 // For inverse fills, the tessellation is dependent on clip bounds.
1523 if (fPath.isInverseFillType()) { 1523 if (fPath.isInverseFillType()) {
1524 memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds)); 1524 memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds));
1525 } 1525 }
1526 fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]); 1526 fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]);
1527 builder.finish(); 1527 builder.finish();
1528 GrResourceProvider* rp = batchTarget->resourceProvider(); 1528 GrResourceProvider* rp = target->resourceProvider();
1529 SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrV ertexBuffer>(key)); 1529 SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrV ertexBuffer>(key));
1530 int actualCount; 1530 int actualCount;
1531 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance; 1531 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance;
1532 SkScalar tol = GrPathUtils::scaleToleranceToSrc( 1532 SkScalar tol = GrPathUtils::scaleToleranceToSrc(
1533 screenSpaceTol, fViewMatrix, fPath.getBounds()); 1533 screenSpaceTol, fViewMatrix, fPath.getBounds());
1534 if (!cache_match(vertexBuffer.get(), tol, &actualCount)) { 1534 if (!cache_match(vertexBuffer.get(), tol, &actualCount)) {
1535 actualCount = tessellate(&key, rp, vertexBuffer); 1535 actualCount = tessellate(&key, rp, vertexBuffer);
1536 } 1536 }
1537 1537
1538 if (actualCount == 0) { 1538 if (actualCount == 0) {
(...skipping 12 matching lines...) Expand all
1551 if (fPipelineInfo.readsCoverage()) { 1551 if (fPipelineInfo.readsCoverage()) {
1552 coverageType = Coverage::kSolid_Type; 1552 coverageType = Coverage::kSolid_Type;
1553 } else { 1553 } else {
1554 coverageType = Coverage::kNone_Type; 1554 coverageType = Coverage::kNone_Type;
1555 } 1555 }
1556 Coverage coverage(coverageType); 1556 Coverage coverage(coverageType);
1557 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s, 1557 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s,
1558 fViewMatrix)); 1558 fViewMatrix));
1559 } 1559 }
1560 1560
1561 batchTarget->initDraw(gp, this->pipeline()); 1561 target->initDraw(gp, this->pipeline());
1562 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 1562 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
1563 1563
1564 GrPrimitiveType primitiveType = WIREFRAME ? kLines_GrPrimitiveType 1564 GrPrimitiveType primitiveType = WIREFRAME ? kLines_GrPrimitiveType
1565 : kTriangles_GrPrimitiveType; 1565 : kTriangles_GrPrimitiveType;
1566 GrVertices vertices; 1566 GrVertices vertices;
1567 vertices.init(primitiveType, vertexBuffer.get(), 0, actualCount); 1567 vertices.init(primitiveType, vertexBuffer.get(), 0, actualCount);
1568 batchTarget->draw(vertices); 1568 target->draw(vertices);
1569 } 1569 }
1570 1570
1571 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; } 1571 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; }
1572 1572
1573 private: 1573 private:
1574 TessellatingPathBatch(const GrColor& color, 1574 TessellatingPathBatch(const GrColor& color,
1575 const SkPath& path, 1575 const SkPath& path,
1576 const GrStrokeInfo& stroke, 1576 const GrStrokeInfo& stroke,
1577 const SkMatrix& viewMatrix, 1577 const SkMatrix& viewMatrix,
1578 const SkRect& clipBounds) 1578 const SkRect& clipBounds)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 bool result = viewMatrix.invert(&vmi); 1641 bool result = viewMatrix.invert(&vmi);
1642 if (!result) { 1642 if (!result) {
1643 SkFAIL("Cannot invert matrix\n"); 1643 SkFAIL("Cannot invert matrix\n");
1644 } 1644 }
1645 vmi.mapRect(&clipBounds); 1645 vmi.mapRect(&clipBounds);
1646 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); 1646 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random);
1647 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds); 1647 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds);
1648 } 1648 }
1649 1649
1650 #endif 1650 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698