aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTessellator.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-03-10 08:38:45 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-10 08:38:45 -0800
commit6599efffeef3168dfc68dca99c30454c5c23b859 (patch)
treea605fb7f6ecb9a8c13da21e416ee339685012a5f /src/gpu/GrTessellator.cpp
parente7bbe0378233d16aa0921965f4a4ccc66b2eeec3 (diff)
GrTessellator: abstract vertex allocation into caller.
This abstracts all vertex allocation out of GrTessellator via a VertexBuffer interface. This removes all GPU-related calls from GrTessellator. It also factors vertex drawing into GrTessellatingPathRenderer::drawVertices(), and makes tessellate() (now draw() also responsible for drawing. This means the cache hit case is clearer as an early-out, and storing into cache is done in draw() as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1776003002 Review URL: https://codereview.chromium.org/1776003002
Diffstat (limited to 'src/gpu/GrTessellator.cpp')
-rw-r--r--src/gpu/GrTessellator.cpp37
1 files changed, 7 insertions, 30 deletions
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index a8fa79e560..f4195dfb03 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;
}