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

Unified Diff: src/gpu/GrBatchTarget.h

Issue 1131553002: Isolate GrBufferAllocPools inside GrBatchTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 5 years, 7 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/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBatchTarget.h
diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h
index 91726e5b9f7df20e942e64b688cc12052e0956b3..f317f3046e9c60786872d369863c4b4227439e5a 100644
--- a/src/gpu/GrBatchTarget.h
+++ b/src/gpu/GrBatchTarget.h
@@ -19,16 +19,10 @@
* GrBatch instances use this object to allocate space for their geometry and to issue the draws
* that render their batch.
*/
-
-class GrIndexBufferAllocPool;
-class GrVertexBufferAllocPool;
-
class GrBatchTarget : public SkNoncopyable {
public:
typedef GrBatchAtlas::BatchToken BatchToken;
- GrBatchTarget(GrGpu* gpu,
- GrVertexBufferAllocPool* vpool,
- GrIndexBufferAllocPool* ipool);
+ GrBatchTarget(GrGpu* gpu);
void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline) {
GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipeline));
@@ -94,6 +88,7 @@ public:
void resetNumberOfDraws() { fNumberOfDraws = 0; }
int numberOfDraws() const { return fNumberOfDraws; }
void preFlush() {
+ this->unmapVertexAndIndexBuffers();
int updateCount = fAsapUploads.count();
for (int i = 0; i < updateCount; i++) {
fAsapUploads[i]->upload(TextureUploader(fGpu));
@@ -117,11 +112,13 @@ public:
const GrDrawTargetCaps& caps() const { return *fGpu->caps(); }
- GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
- GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
-
GrResourceProvider* resourceProvider() const { return fGpu->getContext()->resourceProvider(); }
+ void* makeVertSpace(size_t vertexSize, int vertexCount,
+ const GrVertexBuffer** buffer, int* startVertex);
+ uint16_t* makeIndexSpace(int indexCount,
+ const GrIndexBuffer** buffer, int* startIndex);
+
// A helper for draws which overallocate and then return data to the pool
void putBackIndices(size_t indices) { fIndexPool->putBack(indices * sizeof(uint16_t)); }
@@ -129,10 +126,20 @@ public:
fVertexPool->putBack(vertices * vertexStride);
}
+ void reset() {
+ fVertexPool->reset();
+ fIndexPool->reset();
+ }
+
private:
+ void unmapVertexAndIndexBuffers() {
+ fVertexPool->unmap();
+ fIndexPool->unmap();
+ }
+
GrGpu* fGpu;
- GrVertexBufferAllocPool* fVertexPool;
- GrIndexBufferAllocPool* fIndexPool;
+ SkAutoTDelete<GrVertexBufferAllocPool> fVertexPool;
+ SkAutoTDelete<GrIndexBufferAllocPool> fIndexPool;
typedef void* TBufferAlign; // This wouldn't be enough align if a command used long double.
« no previous file with comments | « src/gpu/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698