fix for msan
authorjoshualitt <joshualitt@chromium.org>
Tue, 24 Feb 2015 21:20:59 +0000 (13:20 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 24 Feb 2015 21:20:59 +0000 (13:20 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/958433004

src/gpu/GrBatchTarget.cpp
src/gpu/GrBatchTarget.h
src/gpu/GrDefaultPathRenderer.cpp

index 7a2d14e..21658d2 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "GrBatchTarget.h"
 
-#include "GrBufferAllocPool.h"
 #include "GrPipeline.h"
 
 /*
index 51dd8ca..ae046c1 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef GrBatchBuffer_DEFINED
 #define GrBatchBuffer_DEFINED
 
+#include "GrBufferAllocPool.h"
 #include "GrPendingProgramElement.h"
 #include "GrPipeline.h"
 #include "GrGpu.h"
@@ -82,6 +83,13 @@ public:
 
     const GrIndexBuffer* quadIndexBuffer() const { return fGpu->getQuadIndexBuffer(); }
 
+    // A helper for draws which overallocate and then return data to the pool
+    void putBackIndices(size_t indices) { fIndexPool->putBack(indices * sizeof(uint16_t)); }
+
+    void putBackVertices(size_t vertices, size_t vertexStride) {
+        fVertexPool->putBack(vertices * vertexStride);
+    }
+
 private:
     GrGpu* fGpu;
     GrVertexBufferAllocPool* fVertexPool;
index 131b518..302aad7 100644 (file)
@@ -372,6 +372,10 @@ public:
             drawInfo.setIndexCount(0);
         }
         batchTarget->draw(drawInfo);
+
+        // put back reserves
+        batchTarget->putBackIndices((size_t)(maxIndices - indexOffset));
+        batchTarget->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)vertexStride);
     }
 
     SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }