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
diff --git a/src/gpu/GrTessellator.h b/src/gpu/GrTessellator.h
index 4304920..9e7d5f0 100644
--- a/src/gpu/GrTessellator.h
+++ b/src/gpu/GrTessellator.h
@@ -8,8 +8,10 @@
#ifndef GrTessellator_DEFINED
#define GrTessellator_DEFINED
-#include "SkPath.h"
-#include "GrResourceProvider.h"
+#include "SkPoint.h"
+
+class SkPath;
+struct SkRect;
/**
* Provides utility functions for converting paths to a collection of triangles.
@@ -19,6 +21,13 @@
namespace GrTessellator {
+class VertexAllocator {
+public:
+ virtual ~VertexAllocator() {}
+ virtual SkPoint* lock(int vertexCount) = 0;
+ virtual void unlock(int actualCount) = 0;
+};
+
struct WindingVertex {
SkPoint fPos;
int fWinding;
@@ -32,9 +41,7 @@
WindingVertex** verts);
int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
- GrResourceProvider* resourceProvider,
- SkAutoTUnref<GrVertexBuffer>& vertexBuffer, bool canMapVB, bool* isLinear);
-
+ VertexAllocator*, bool *isLinear);
}
#endif