Handle too many (or too large) paths in GrDefaultPathRenderer
PathGeoBuilder constructs the geometry with the same basic
technique as before, but allows interrupting the process
to emit multiple draws.
Original test case was 2000 non-AA stroked circles, which
created ~66000 vertices. That now renders, as do various
tests with a single large path (as well as filled paths).
Added a new set of 'AtLeast' allocators for vertex and index
data. These take a minimum size and a fallback size. If the
minimum size can be satisfied by an existing block, then
the caller gets *all* memory in that block, otherwise they
get a new block sized for the fallback amount. The previous
allocation scheme wasn't a good fit for the new use-case,
and because we don't usually need many verts, the flexible
approach seems appropriate.
TODO: I think that this could be extracted and re-used for
MSAA path renderer without too much work? I need to read
that code more carefully to make sure it lines up.
Re-land of: https://skia-review.googlesource.com/18360
Re-land of: https://skia-review.googlesource.com/18983
Bug: skia:6695
Change-Id: I09ac1273e5af67ed0e3e886de90e2970c3d0b239
Reviewed-on: https://skia-review.googlesource.com/19480
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h
index 071b00b..1b58ef4 100644
--- a/src/gpu/GrBufferAllocPool.h
+++ b/src/gpu/GrBufferAllocPool.h
@@ -86,6 +86,38 @@
const GrBuffer** buffer,
size_t* offset);
+ /**
+ * Returns a block of memory to hold data. A buffer designated to hold the
+ * data is given to the caller. The buffer may or may not be locked. The
+ * returned ptr remains valid until any of the following:
+ * *makeSpace is called again.
+ * *unmap is called.
+ * *reset is called.
+ * *this object is destroyed.
+ *
+ * Once unmap on the pool is called the data is guaranteed to be in the
+ * buffer at the offset indicated by offset. Until that time it may be
+ * in temporary storage and/or the buffer may be locked.
+ *
+ * The caller requests a minimum number of bytes, but the block may be (much)
+ * larger. Assuming that a new block must be allocated, it will be fallbackSize bytes.
+ * The actual block size is returned in actualSize.
+ *
+ * @param minSize the minimum amount of data to make space for
+ * @param fallbackSize the amount of data to make space for if a new block is needed
+ * @param alignment alignment constraint from start of buffer
+ * @param buffer returns the buffer that will hold the data.
+ * @param offset returns the offset into buffer of the data.
+ * @param actualSize returns the capacity of the block
+ * @return pointer to where the client should write the data.
+ */
+ void* makeSpaceAtLeast(size_t minSize,
+ size_t fallbackSize,
+ size_t alignment,
+ const GrBuffer** buffer,
+ size_t* offset,
+ size_t* actualSize);
+
GrBuffer* getBuffer(size_t size);
private:
@@ -152,6 +184,40 @@
const GrBuffer** buffer,
int* startVertex);
+ /**
+ * Returns a block of memory to hold vertices. A buffer designated to hold
+ * the vertices given to the caller. The buffer may or may not be locked.
+ * The returned ptr remains valid until any of the following:
+ * *makeSpace is called again.
+ * *unmap is called.
+ * *reset is called.
+ * *this object is destroyed.
+ *
+ * Once unmap on the pool is called the vertices are guaranteed to be in
+ * the buffer at the offset indicated by startVertex. Until that time they
+ * may be in temporary storage and/or the buffer may be locked.
+ *
+ * The caller requests a minimum number of vertices, but the block may be (much)
+ * larger. Assuming that a new block must be allocated, it will be sized to hold
+ * fallbackVertexCount vertices. The actual block size (in vertices) is returned in
+ * actualVertexCount.
+ *
+ * @param vertexSize specifies size of a vertex to allocate space for
+ * @param minVertexCount minimum number of vertices to allocate space for
+ * @param fallbackVertexCount number of vertices to allocate space for if a new block is needed
+ * @param buffer returns the vertex buffer that will hold the vertices.
+ * @param startVertex returns the offset into buffer of the first vertex.
+ * In units of the size of a vertex from layout param.
+ * @param actualVertexCount returns the capacity of the block (in vertices)
+ * @return pointer to first vertex.
+ */
+ void* makeSpaceAtLeast(size_t vertexSize,
+ int minVertexCount,
+ int fallbackVertexCount,
+ const GrBuffer** buffer,
+ int* startVertex,
+ int* actualVertexCount);
+
private:
typedef GrBufferAllocPool INHERITED;
};
@@ -190,6 +256,37 @@
const GrBuffer** buffer,
int* startIndex);
+ /**
+ * Returns a block of memory to hold indices. A buffer designated to hold
+ * the indices is given to the caller. The buffer may or may not be locked.
+ * The returned ptr remains valid until any of the following:
+ * *makeSpace is called again.
+ * *unmap is called.
+ * *reset is called.
+ * *this object is destroyed.
+ *
+ * Once unmap on the pool is called the indices are guaranteed to be in the
+ * buffer at the offset indicated by startIndex. Until that time they may be
+ * in temporary storage and/or the buffer may be locked.
+ *
+ * The caller requests a minimum number of indices, but the block may be (much)
+ * larger. Assuming that a new block must be allocated, it will be sized to hold
+ * fallbackIndexCount indices. The actual block size (in indices) is returned in
+ * actualIndexCount.
+ *
+ * @param minIndexCount minimum number of indices to allocate space for
+ * @param fallbackIndexCount number of indices to allocate space for if a new block is needed
+ * @param buffer returns the index buffer that will hold the indices.
+ * @param startIndex returns the offset into buffer of the first index.
+ * @param actualIndexCount returns the capacity of the block (in indices)
+ * @return pointer to first index.
+ */
+ void* makeSpaceAtLeast(int minIndexCount,
+ int fallbackIndexCount,
+ const GrBuffer** buffer,
+ int* startIndex,
+ int* actualIndexCount);
+
private:
typedef GrBufferAllocPool INHERITED;
};