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

Unified Diff: src/gpu/GrTessellator.cpp

Issue 1776003002: GrTessellator: abstract vertex allocation into caller (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: VertexBuffer -> VertexAllocator Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTessellator.h ('k') | src/gpu/batches/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTessellator.cpp
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index a8fa79e56059ec9606f8a99ac231c5a9e9bf15ff..f4195dfb03696d9384fa9a26a38f389069145f86 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -7,17 +7,11 @@
#include "GrTessellator.h"
-#include "GrBatchFlushState.h"
-#include "GrBatchTest.h"
-#include "GrDefaultGeoProcFactory.h"
#include "GrPathUtils.h"
-#include "GrVertices.h"
-#include "GrResourceCache.h"
-#include "GrResourceProvider.h"
-#include "SkGeometry.h"
-#include "SkChunkAlloc.h"
-#include "batches/GrVertexBatch.h"
+#include "SkChunkAlloc.h"
+#include "SkGeometry.h"
+#include "SkPath.h"
#include <stdio.h>
@@ -1370,8 +1364,7 @@ namespace GrTessellator {
// Stage 6: Triangulate the monotone polygons into a vertex buffer.
int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
- GrResourceProvider* resourceProvider,
- SkAutoTUnref<GrVertexBuffer>& vertexBuffer, bool canMapVB, bool* isLinear) {
+ VertexAllocator* vertexAllocator, bool* isLinear) {
int contourCnt;
int sizeEstimate;
get_contour_count_and_size_estimate(path, tolerance, &contourCnt, &sizeEstimate);
@@ -1387,21 +1380,11 @@ int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
return 0;
}
- size_t size = count * sizeof(SkPoint);
- if (!vertexBuffer.get() || vertexBuffer->gpuMemorySize() < size) {
- vertexBuffer.reset(resourceProvider->createVertexBuffer(
- size, GrResourceProvider::kStatic_BufferUsage, 0));
- }
- if (!vertexBuffer.get()) {
+ SkPoint* verts = vertexAllocator->lock(count);
+ if (!verts) {
SkDebugf("Could not allocate vertices\n");
return 0;
}
- SkPoint* verts;
- if (canMapVB) {
- verts = static_cast<SkPoint*>(vertexBuffer->map());
- } else {
- verts = new SkPoint[count];
- }
SkPoint* end = verts;
for (Poly* poly = polys; poly; poly = poly->fNext) {
if (apply_fill_type(fillType, poly->fWinding)) {
@@ -1411,13 +1394,7 @@ int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
int actualCount = static_cast<int>(end - verts);
LOG("actual count: %d\n", actualCount);
SkASSERT(actualCount <= count);
- if (canMapVB) {
- vertexBuffer->unmap();
- } else {
- vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint));
- delete[] verts;
- }
-
+ vertexAllocator->unlock(actualCount);
return actualCount;
}
« no previous file with comments | « src/gpu/GrTessellator.h ('k') | src/gpu/batches/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698