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

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

Issue 1288683004: Add support for non-mappable vert buffers to tessellating path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT 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 | « no previous file | no next file » | 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 "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 // Handle any color overrides 1410 // Handle any color overrides
1411 if (!opt.readsColor()) { 1411 if (!opt.readsColor()) {
1412 fColor = GrColor_ILLEGAL; 1412 fColor = GrColor_ILLEGAL;
1413 } 1413 }
1414 opt.getOverrideColorIfSet(&fColor); 1414 opt.getOverrideColorIfSet(&fColor);
1415 fPipelineInfo = opt; 1415 fPipelineInfo = opt;
1416 } 1416 }
1417 1417
1418 int tessellate(GrUniqueKey* key, 1418 int tessellate(GrUniqueKey* key,
1419 GrResourceProvider* resourceProvider, 1419 GrResourceProvider* resourceProvider,
1420 SkAutoTUnref<GrVertexBuffer>& vertexBuffer) { 1420 SkAutoTUnref<GrVertexBuffer>& vertexBuffer,
1421 bool canMapVB) {
1421 SkPath path; 1422 SkPath path;
1422 GrStrokeInfo stroke(fStroke); 1423 GrStrokeInfo stroke(fStroke);
1423 if (stroke.isDashed()) { 1424 if (stroke.isDashed()) {
1424 if (!stroke.applyDashToPath(&path, &stroke, fPath)) { 1425 if (!stroke.applyDashToPath(&path, &stroke, fPath)) {
1425 return 0; 1426 return 0;
1426 } 1427 }
1427 } else { 1428 } else {
1428 path = fPath; 1429 path = fPath;
1429 } 1430 }
1430 if (!stroke.isFillStyle()) { 1431 if (!stroke.isFillStyle()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1484
1484 size_t size = count * sizeof(SkPoint); 1485 size_t size = count * sizeof(SkPoint);
1485 if (!vertexBuffer.get() || vertexBuffer->gpuMemorySize() < size) { 1486 if (!vertexBuffer.get() || vertexBuffer->gpuMemorySize() < size) {
1486 vertexBuffer.reset(resourceProvider->createVertexBuffer( 1487 vertexBuffer.reset(resourceProvider->createVertexBuffer(
1487 size, GrResourceProvider::kStatic_BufferUsage, 0)); 1488 size, GrResourceProvider::kStatic_BufferUsage, 0));
1488 } 1489 }
1489 if (!vertexBuffer.get()) { 1490 if (!vertexBuffer.get()) {
1490 SkDebugf("Could not allocate vertices\n"); 1491 SkDebugf("Could not allocate vertices\n");
1491 return 0; 1492 return 0;
1492 } 1493 }
1493 SkPoint* verts = static_cast<SkPoint*>(vertexBuffer->map()); 1494 SkPoint* verts;
1494 LOG("emitting %d verts\n", count); 1495 if (canMapVB) {
1496 verts = static_cast<SkPoint*>(vertexBuffer->map());
1497 } else {
1498 verts = SkNEW_ARRAY(SkPoint, count);
1499 }
1495 SkPoint* end = polys_to_triangles(polys, fillType, verts); 1500 SkPoint* end = polys_to_triangles(polys, fillType, verts);
1496 vertexBuffer->unmap();
1497 int actualCount = static_cast<int>(end - verts); 1501 int actualCount = static_cast<int>(end - verts);
1498 LOG("actual count: %d\n", actualCount); 1502 LOG("actual count: %d\n", actualCount);
1499 SkASSERT(actualCount <= count); 1503 SkASSERT(actualCount <= count);
1504 if (canMapVB) {
1505 vertexBuffer->unmap();
1506 } else {
1507 vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint));
1508 SkDELETE_ARRAY(verts);
1509 }
1510
1500 1511
1501 if (!fPath.isVolatile()) { 1512 if (!fPath.isVolatile()) {
1502 TessInfo info; 1513 TessInfo info;
1503 info.fTolerance = isLinear ? 0 : tol; 1514 info.fTolerance = isLinear ? 0 : tol;
1504 info.fCount = actualCount; 1515 info.fCount = actualCount;
1505 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info))); 1516 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
1506 key->setCustomData(data.get()); 1517 key->setCustomData(data.get());
1507 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get() ); 1518 resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get() );
1508 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key ))); 1519 SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key )));
1509 } 1520 }
(...skipping 16 matching lines...) Expand all
1526 } 1537 }
1527 fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]); 1538 fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]);
1528 builder.finish(); 1539 builder.finish();
1529 GrResourceProvider* rp = target->resourceProvider(); 1540 GrResourceProvider* rp = target->resourceProvider();
1530 SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrV ertexBuffer>(key)); 1541 SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrV ertexBuffer>(key));
1531 int actualCount; 1542 int actualCount;
1532 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance; 1543 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance;
1533 SkScalar tol = GrPathUtils::scaleToleranceToSrc( 1544 SkScalar tol = GrPathUtils::scaleToleranceToSrc(
1534 screenSpaceTol, fViewMatrix, fPath.getBounds()); 1545 screenSpaceTol, fViewMatrix, fPath.getBounds());
1535 if (!cache_match(vertexBuffer.get(), tol, &actualCount)) { 1546 if (!cache_match(vertexBuffer.get(), tol, &actualCount)) {
1536 actualCount = tessellate(&key, rp, vertexBuffer); 1547 bool canMapVB = GrCaps::kNone_MapFlags != target->caps().mapBufferFl ags();
1548 actualCount = tessellate(&key, rp, vertexBuffer, canMapVB);
1537 } 1549 }
1538 1550
1539 if (actualCount == 0) { 1551 if (actualCount == 0) {
1540 return; 1552 return;
1541 } 1553 }
1542 1554
1543 SkAutoTUnref<const GrGeometryProcessor> gp; 1555 SkAutoTUnref<const GrGeometryProcessor> gp;
1544 { 1556 {
1545 using namespace GrDefaultGeoProcFactory; 1557 using namespace GrDefaultGeoProcFactory;
1546 1558
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 bool result = viewMatrix.invert(&vmi); 1653 bool result = viewMatrix.invert(&vmi);
1642 if (!result) { 1654 if (!result) {
1643 SkFAIL("Cannot invert matrix\n"); 1655 SkFAIL("Cannot invert matrix\n");
1644 } 1656 }
1645 vmi.mapRect(&clipBounds); 1657 vmi.mapRect(&clipBounds);
1646 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); 1658 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random);
1647 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds); 1659 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds);
1648 } 1660 }
1649 1661
1650 #endif 1662 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698