diff options
30 files changed, 99 insertions, 206 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index 82853e6642..585c9b7e05 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -13,7 +13,6 @@ #if SK_SUPPORT_GPU #include "GrBatchTarget.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrPathUtils.h" #include "GrTest.h" diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index cd9b3d10e5..f8f5210ac2 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -13,7 +13,6 @@ #if SK_SUPPORT_GPU #include "GrBatchTarget.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrPathUtils.h" diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 16ebeed342..24b1d51471 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -25,7 +25,6 @@ class GrFragmentProcessor; class GrGpu; class GrGpuTraceMarker; class GrIndexBuffer; -class GrIndexBufferAllocPool; class GrLayerCache; class GrOvalRenderer; class GrPath; @@ -39,7 +38,6 @@ class GrTextBlobCache; class GrTextContext; class GrTextureParams; class GrVertexBuffer; -class GrVertexBufferAllocPool; class GrStrokeInfo; class GrSoftwarePathRenderer; class SkGpuDevice; @@ -596,8 +594,6 @@ private: GrPathRendererChain* fPathRendererChain; GrSoftwarePathRenderer* fSoftwarePathRenderer; - GrVertexBufferAllocPool* fDrawBufferVBAllocPool; - GrIndexBufferAllocPool* fDrawBufferIBAllocPool; GrDrawTarget* fDrawBuffer; // Set by OverbudgetCB() to request that GrContext flush before exiting a draw. @@ -626,8 +622,6 @@ private: void initMockContext(); void initCommon(); - void setupDrawBuffer(); - class AutoCheckFlush; // Sets the paint and returns the target to draw into. GrDrawTarget* prepareToDraw(GrPipelineBuilder*, diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 7e989946ac..046ef80dc9 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDrawTargetCaps.h" #include "GrGeometryProcessor.h" @@ -795,11 +794,8 @@ public: int firstVertex; size_t vertexStride = quadProcessor->getVertexStride(); - void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - vertexCount, - &vertexBuffer, - &firstVertex); - + void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount, + &vertexBuffer, &firstVertex); if (!vertices) { SkDebugf("Could not allocate vertices\n"); return; @@ -808,17 +804,13 @@ public: const GrIndexBuffer* indexBuffer; int firstIndex; - void *indices = batchTarget->indexPool()->makeSpace(indexCount, - &indexBuffer, - &firstIndex); - - if (!indices) { + uint16_t *idxs = batchTarget->makeIndexSpace(indexCount, &indexBuffer, &firstIndex); + if (!idxs) { SkDebugf("Could not allocate indices\n"); return; } QuadVertex* verts = reinterpret_cast<QuadVertex*>(vertices); - uint16_t* idxs = reinterpret_cast<uint16_t*>(indices); SkSTArray<kPreallocDrawCnt, Draw, true> draws; create_vertices(segments, fanPt, &draws, verts, idxs); diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp index 7c0468d933..fc4ab1647b 100755 --- a/src/gpu/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrPipelineBuilder.h" #include "GrResourceProvider.h" @@ -209,10 +208,10 @@ public: SkASSERT(vertexStride == 2 * sizeof(SkPoint)); const GrVertexBuffer* vertexBuffer; - void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - kVerticesPerQuad * instanceCount, - &vertexBuffer, - &flushInfo.fVertexOffset); + void* vertices = batchTarget->makeVertSpace(vertexStride, + kVerticesPerQuad * instanceCount, + &vertexBuffer, + &flushInfo.fVertexOffset); flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); flushInfo.fIndexBuffer.reset(batchTarget->resourceProvider()->refQuadIndexBuffer()); if (!vertices || !flushInfo.fIndexBuffer) { diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index f9b0c5a7ff..6101c9ba5b 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" #include "GrBatchTest.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrDrawTargetCaps.h" @@ -870,10 +869,8 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel size_t vertexStride = lineGP->getVertexStride(); int vertexCount = kLineSegNumVertices * lineCount; - void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - vertexCount, - &vertexBuffer, - &firstVertex); + void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount, + &vertexBuffer, &firstVertex); if (!vertices || !linesIndexBuffer) { SkDebugf("Could not allocate vertices\n"); @@ -908,10 +905,8 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel size_t vertexStride = sizeof(BezierVertex); int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * conicCount; - void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - vertexCount, - &vertexBuffer, - &firstVertex); + void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount, + &vertexBuffer, &firstVertex); if (!vertices || !quadsIndexBuffer) { SkDebugf("Could not allocate vertices\n"); diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 5848870ebf..7940e96b84 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -9,7 +9,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" #include "GrBatchTest.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrGeometryProcessor.h" diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index 7731f4d9be..9b90f8ac41 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -1526,10 +1526,10 @@ public: int instanceCount = fInstanceCount; const GrVertexBuffer* vertexBuffer; - void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - glyphCount * kVerticesPerGlyph, - &vertexBuffer, - &flushInfo.fVertexOffset); + void* vertices = batchTarget->makeVertSpace(vertexStride, + glyphCount * kVerticesPerGlyph, + &vertexBuffer, + &flushInfo.fVertexOffset); flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); flushInfo.fIndexBuffer.reset(batchTarget->resourceProvider()->refQuadIndexBuffer()); if (!vertices || !flushInfo.fVertexBuffer) { diff --git a/src/gpu/GrBatch.cpp b/src/gpu/GrBatch.cpp index 7d1c0ae25f..0655a4cd9d 100644 --- a/src/gpu/GrBatch.cpp +++ b/src/gpu/GrBatch.cpp @@ -58,8 +58,8 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType const GrVertexBuffer* vertexBuffer; int firstVertex; int vertexCount = verticesPerInstance * instancesToDraw; - void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, vertexCount, &vertexBuffer, - &firstVertex); + void* vertices = batchTarget->makeVertSpace(vertexStride, vertexCount, + &vertexBuffer, &firstVertex); if (!vertices) { SkDebugf("Vertices could not be allocated for instanced rendering."); return NULL; diff --git a/src/gpu/GrBatch.h b/src/gpu/GrBatch.h index dc01db4f20..1da964b7fc 100644 --- a/src/gpu/GrBatch.h +++ b/src/gpu/GrBatch.h @@ -17,9 +17,7 @@ #include "SkTypes.h" class GrGpu; -class GrIndexBufferAllocPool; class GrPipeline; -class GrVertexBufferAllocPool; struct GrInitInvariantOutput; diff --git a/src/gpu/GrBatchTarget.cpp b/src/gpu/GrBatchTarget.cpp index b5293d70c5..31b4cc9f47 100644 --- a/src/gpu/GrBatchTarget.cpp +++ b/src/gpu/GrBatchTarget.cpp @@ -10,18 +10,27 @@ #include "GrBatchAtlas.h" #include "GrPipeline.h" -GrBatchTarget::GrBatchTarget(GrGpu* gpu, - GrVertexBufferAllocPool* vpool, - GrIndexBufferAllocPool* ipool) +static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; +static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; + +static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; +static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; + +GrBatchTarget::GrBatchTarget(GrGpu* gpu) : fGpu(gpu) - , fVertexPool(vpool) - , fIndexPool(ipool) , fFlushBuffer(kFlushBufferInitialSizeInBytes) , fIter(fFlushBuffer) , fNumberOfDraws(0) , fCurrentToken(0) , fLastFlushedToken(0) , fInlineUpdatesIndex(0) { + + fVertexPool.reset(SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu, + DRAW_BUFFER_VBPOOL_BUFFER_SIZE, + DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS))); + fIndexPool.reset(SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, + DRAW_BUFFER_IBPOOL_BUFFER_SIZE, + DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS))); } void GrBatchTarget::flushNext(int n) { @@ -53,3 +62,14 @@ void GrBatchTarget::flushNext(int n) { } } } + +void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount, + const GrVertexBuffer** buffer, int* startVertex) { + return fVertexPool->makeSpace(vertexSize, vertexCount, buffer, startVertex); +} + +uint16_t* GrBatchTarget::makeIndexSpace(int indexCount, + const GrIndexBuffer** buffer, int* startIndex) { + return reinterpret_cast<uint16_t*>(fIndexPool->makeSpace(indexCount, buffer, startIndex)); +} + diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h index 91726e5b9f..f317f3046e 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. diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index 82ec432bd9..878d537d45 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -358,10 +358,10 @@ GrGeometryBuffer* GrBufferAllocPool::createBuffer(size_t size) { GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu, size_t bufferSize, int preallocBufferCnt) -: GrBufferAllocPool(gpu, - kVertex_BufferType, - bufferSize, - preallocBufferCnt) { + : GrBufferAllocPool(gpu, + kVertex_BufferType, + bufferSize, + preallocBufferCnt) { } void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, @@ -391,10 +391,10 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu, size_t bufferSize, int preallocBufferCnt) -: GrBufferAllocPool(gpu, - kIndex_BufferType, - bufferSize, - preallocBufferCnt) { + : GrBufferAllocPool(gpu, + kIndex_BufferType, + bufferSize, + preallocBufferCnt) { } void* GrIndexBufferAllocPool::makeSpace(int indexCount, diff --git a/src/gpu/GrCommandBuilder.h b/src/gpu/GrCommandBuilder.h index 05c29fb014..eb51b5b721 100644 --- a/src/gpu/GrCommandBuilder.h +++ b/src/gpu/GrCommandBuilder.h @@ -11,19 +11,13 @@ #include "GrTargetCommands.h" class GrInOrderDrawBuffer; -class GrVertexBufferAllocPool; -class GrIndexBufferAllocPool; class GrCommandBuilder : ::SkNoncopyable { public: typedef GrTargetCommands::Cmd Cmd; typedef GrTargetCommands::State State; - GrCommandBuilder(GrGpu* gpu, - GrVertexBufferAllocPool* vertexPool, - GrIndexBufferAllocPool* indexPool) - : fCommands(gpu, vertexPool, indexPool) { - } + GrCommandBuilder(GrGpu* gpu) : fCommands(gpu) { } virtual ~GrCommandBuilder() {} diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index c9342a5e6a..58e8508e37 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -13,7 +13,6 @@ #include "GrBatch.h" #include "GrBatchFontCache.h" #include "GrBatchTarget.h" -#include "GrBufferAllocPool.h" #include "GrDefaultGeoProcFactory.h" #include "GrGpuResource.h" #include "GrGpuResourcePriv.h" @@ -50,12 +49,6 @@ #include "effects/GrDashingEffect.h" #include "effects/GrSingleTextureEffect.h" -static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; -static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; - -static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; -static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; - #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) #define RETURN_IF_ABANDONED if (!fDrawBuffer) { return; } #define RETURN_FALSE_IF_ABANDONED if (!fDrawBuffer) { return false; } @@ -109,8 +102,6 @@ GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id()) fSoftwarePathRenderer = NULL; fBatchFontCache = NULL; fDrawBuffer = NULL; - fDrawBufferVBAllocPool = NULL; - fDrawBufferIBAllocPool = NULL; fFlushToReduceCacheSize = false; fAARectRenderer = NULL; fOvalRenderer = NULL; @@ -140,7 +131,7 @@ void GrContext::initCommon() { fDidTestPMConversions = false; - this->setupDrawBuffer(); + fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (this)); // GrBatchFontCache will eventually replace GrFontCache fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); @@ -163,8 +154,6 @@ GrContext::~GrContext() { SkDELETE(fResourceCache); SkDELETE(fBatchFontCache); SkDELETE(fDrawBuffer); - SkDELETE(fDrawBufferVBAllocPool); - SkDELETE(fDrawBufferIBAllocPool); fAARectRenderer->unref(); fOvalRenderer->unref(); @@ -187,15 +176,9 @@ void GrContext::abandonContext() { SkSafeSetNull(fPathRendererChain); SkSafeSetNull(fSoftwarePathRenderer); - delete fDrawBuffer; + SkDELETE(fDrawBuffer); fDrawBuffer = NULL; - delete fDrawBufferVBAllocPool; - fDrawBufferVBAllocPool = NULL; - - delete fDrawBufferIBAllocPool; - fDrawBufferIBAllocPool = NULL; - fBatchFontCache->freeAll(); fLayerCache->freeAll(); fTextBlobCache->freeAll(); @@ -483,10 +466,8 @@ public: const GrVertexBuffer* vertexBuffer; int firstVertex; - void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, - vertexCount, - &vertexBuffer, - &firstVertex); + void* verts = batchTarget->makeVertSpace(vertexStride, vertexCount, + &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); @@ -821,10 +802,8 @@ public: const GrVertexBuffer* vertexBuffer; int firstVertex; - void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, - this->vertexCount(), - &vertexBuffer, - &firstVertex); + void* verts = batchTarget->makeVertSpace(vertexStride, this->vertexCount(), + &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); @@ -834,11 +813,9 @@ public: const GrIndexBuffer* indexBuffer = NULL; int firstIndex = 0; - void* indices = NULL; + uint16_t* indices = NULL; if (this->hasIndices()) { - indices = batchTarget->indexPool()->makeSpace(this->indexCount(), - &indexBuffer, - &firstIndex); + indices = batchTarget->makeIndexSpace(this->indexCount(), &indexBuffer, &firstIndex); if (!indices) { SkDebugf("Could not allocate indices\n"); @@ -854,7 +831,7 @@ public: // TODO we can actually cache this interleaved and then just memcopy if (this->hasIndices()) { for (int j = 0; j < args.fIndices.count(); ++j, ++indexOffset) { - *((uint16_t*)indices + indexOffset) = args.fIndices[j] + vertexOffset; + *(indices + indexOffset) = args.fIndices[j] + vertexOffset; } } @@ -1813,25 +1790,6 @@ int GrContext::getRecommendedSampleCount(GrPixelConfig config, chosenSampleCount : 0; } -void GrContext::setupDrawBuffer() { - SkASSERT(NULL == fDrawBuffer); - SkASSERT(NULL == fDrawBufferVBAllocPool); - SkASSERT(NULL == fDrawBufferIBAllocPool); - - fDrawBufferVBAllocPool = - SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu, - DRAW_BUFFER_VBPOOL_BUFFER_SIZE, - DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS)); - fDrawBufferIBAllocPool = - SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, - DRAW_BUFFER_IBPOOL_BUFFER_SIZE, - DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS)); - - fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (this, - fDrawBufferVBAllocPool, - fDrawBufferIBAllocPool)); -} - GrDrawTarget* GrContext::getTextTarget() { return this->prepareToDraw(); } diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index 41e4d390c3..1cc50dc6c1 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" #include "GrBatchTest.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrPathUtils.h" @@ -320,10 +319,8 @@ public: const GrVertexBuffer* vertexBuffer; int firstVertex; - void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, - maxVertices, - &vertexBuffer, - &firstVertex); + void* verts = batchTarget->makeVertSpace(vertexStride, maxVertices, + &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); @@ -335,9 +332,7 @@ public: void* indices = NULL; if (isIndexed) { - indices = batchTarget->indexPool()->makeSpace(maxIndices, - &indexBuffer, - &firstIndex); + indices = batchTarget->makeIndexSpace(maxIndices, &indexBuffer, &firstIndex); if (!indices) { SkDebugf("Could not allocate indices\n"); diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index d3c661ffcd..a1489c6a42 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -9,7 +9,6 @@ #include "GrDrawTarget.h" #include "GrBatch.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDrawTargetCaps.h" #include "GrPath.h" @@ -30,14 +29,10 @@ #define DEBUG_INVAL_BUFFER 0xdeadcafe #define DEBUG_INVAL_START_IDX -1 -GrDrawTarget::GrDrawTarget(GrContext* context, - GrVertexBufferAllocPool* vpool, - GrIndexBufferAllocPool* ipool) +GrDrawTarget::GrDrawTarget(GrContext* context) : fContext(context) , fCaps(SkRef(context->getGpu()->caps())) , fGpuTraceMarkerCount(0) - , fVertexPool(vpool) - , fIndexPool(ipool) , fFlushing(false) { SkASSERT(context); } @@ -113,13 +108,6 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil } } -void GrDrawTarget::reset() { - fVertexPool->reset(); - fIndexPool->reset(); - - this->onReset(); -} - void GrDrawTarget::flush() { if (fFlushing) { return; diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index cadf3e3423..1b88153c28 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -30,11 +30,9 @@ class GrClip; class GrDrawTargetCaps; -class GrIndexBufferAllocPool; class GrPath; class GrPathRange; class GrPipeline; -class GrVertexBufferAllocPool; class GrDrawTarget : public SkRefCnt { public: @@ -47,14 +45,14 @@ public: // The context may not be fully constructed and should not be used during GrDrawTarget // construction. - GrDrawTarget(GrContext* context, GrVertexBufferAllocPool*, GrIndexBufferAllocPool*); + GrDrawTarget(GrContext* context); virtual ~GrDrawTarget() {} /** * Empties the draw buffer of any queued up draws. */ - void reset(); + void reset() { this->onReset(); } /** * This plays any queued up draws to its GrGpu target. It also resets this object (i.e. flushing @@ -240,9 +238,6 @@ protected: return fContext->getGpu(); } - GrVertexBufferAllocPool* getVertexAllocPool() { return fVertexPool; } - GrIndexBufferAllocPool* getIndexAllocPool() { return fIndexPool; } - const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; } // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required @@ -334,8 +329,6 @@ private: int fGpuTraceMarkerCount; GrTraceMarkerSet fActiveTraceMarkers; GrTraceMarkerSet fStoredTraceMarkers; - GrVertexBufferAllocPool* fVertexPool; - GrIndexBufferAllocPool* fIndexPool; bool fFlushing; typedef SkRefCnt INHERITED; @@ -346,10 +339,8 @@ private: */ class GrClipTarget : public GrDrawTarget { public: - GrClipTarget(GrContext* context, - GrVertexBufferAllocPool* vpool, - GrIndexBufferAllocPool* ipool) - : INHERITED(context, vpool, ipool) { + GrClipTarget(GrContext* context) + : INHERITED(context) { fClipMaskManager.setClipTarget(this); } diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index d98b3ced25..8222504b0e 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -9,7 +9,6 @@ #include "GrGpu.h" -#include "GrBufferAllocPool.h" #include "GrContext.h" #include "GrDrawTargetCaps.h" #include "GrGpuResourcePriv.h" diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index d89d371288..b580f483ae 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -14,7 +14,6 @@ #include "SkPath.h" class GrContext; -class GrIndexBufferAllocPool; class GrPath; class GrPathRange; class GrPathRenderer; @@ -22,7 +21,6 @@ class GrPathRendererChain; class GrPipeline; class GrPrimitiveProcessor; class GrStencilAttachment; -class GrVertexBufferAllocPool; class GrVertices; class GrGpu : public SkRefCnt { diff --git a/src/gpu/GrInOrderCommandBuilder.h b/src/gpu/GrInOrderCommandBuilder.h index 4fc7cc74dd..164db92811 100644 --- a/src/gpu/GrInOrderCommandBuilder.h +++ b/src/gpu/GrInOrderCommandBuilder.h @@ -15,11 +15,7 @@ public: typedef GrCommandBuilder::Cmd Cmd; typedef GrCommandBuilder::State State; - GrInOrderCommandBuilder(GrGpu* gpu, - GrVertexBufferAllocPool* vertexPool, - GrIndexBufferAllocPool* indexPool) - : INHERITED(gpu, vertexPool, indexPool) { - } + GrInOrderCommandBuilder(GrGpu* gpu) : INHERITED(gpu) { } Cmd* recordDrawBatch(State*, GrBatch*) override; Cmd* recordStencilPath(const GrPipelineBuilder&, diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 35e71a910c..f28a83f2b5 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -7,18 +7,13 @@ #include "GrInOrderDrawBuffer.h" -GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context, - GrVertexBufferAllocPool* vertexPool, - GrIndexBufferAllocPool* indexPool) - : INHERITED(context, vertexPool, indexPool) - , fCommands(SkNEW_ARGS(GrInOrderCommandBuilder, (context->getGpu(), vertexPool, indexPool))) +GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context) + : INHERITED(context) + , fCommands(SkNEW_ARGS(GrInOrderCommandBuilder, (context->getGpu()))) , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) , fPipelineBuffer(kPipelineBufferMinReserve) , fDrawID(0) { - - SkASSERT(vertexPool); - SkASSERT(indexPool); } GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 37d89735c0..182ba80511 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -29,14 +29,8 @@ public: * Creates a GrInOrderDrawBuffer * * @param context the context object that owns this draw buffer. - * @param vertexPool pool where vertices for queued draws will be saved when - * the vertex source is either reserved or array. - * @param indexPool pool where indices for queued draws will be saved when - * the index source is either reserved or array. */ - GrInOrderDrawBuffer(GrContext* context, - GrVertexBufferAllocPool* vertexPool, - GrIndexBufferAllocPool* indexPool); + GrInOrderDrawBuffer(GrContext* context); ~GrInOrderDrawBuffer() override; diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index eb22ca9cb4..966a9498a9 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" #include "GrBatchTest.h" -#include "GrBufferAllocPool.h" #include "GrDrawTarget.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index d66aed1ddc..afdbf5c30f 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -66,10 +66,8 @@ private: SkAlignedSStorage<kMaxSize> fData; }; -class GrIndexBufferAllocPool; class GrGLSLCaps; class GrGLPrimitiveProcessor; -class GrVertexBufferAllocPool; struct GrInitInvariantOutput; diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index bf1a7af281..7e57c03291 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -11,6 +11,7 @@ void GrTargetCommands::reset() { fCmdBuffer.reset(); + fBatchTarget.reset(); } void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { @@ -31,8 +32,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } } - iodb->getVertexAllocPool()->unmap(); - iodb->getIndexAllocPool()->unmap(); fBatchTarget.preFlush(); CmdBuffer::Iter iter(fCmdBuffer); diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index aaecac6989..71ce4706b5 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -20,16 +20,13 @@ #include "SkTypes.h" class GrInOrderDrawBuffer; -class GrVertexBufferAllocPool; -class GrIndexBufferAllocPool; + class GrTargetCommands : ::SkNoncopyable { public: - GrTargetCommands(GrGpu* gpu, - GrVertexBufferAllocPool* vertexPool, - GrIndexBufferAllocPool* indexPool) + GrTargetCommands(GrGpu* gpu) : fCmdBuffer(kCmdBufferInitialSizeInBytes) - , fBatchTarget(gpu, vertexPool, indexPool) { + , fBatchTarget(gpu) { } class Cmd : ::SkNoncopyable { diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp index 262cce3e3d..24d4068cdb 100644 --- a/src/gpu/GrTessellatingPathRenderer.cpp +++ b/src/gpu/GrTessellatingPathRenderer.cpp @@ -1439,11 +1439,7 @@ public: size_t stride = gp->getVertexStride(); const GrVertexBuffer* vertexBuffer; int firstVertex; - void* verts = batchTarget->vertexPool()->makeSpace(stride, - count, - &vertexBuffer, - &firstVertex); - + void* verts = batchTarget->makeVertSpace(stride, count, &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); return; diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index dfec04864c..727fbbc662 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -131,7 +131,6 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT // Code for the mock context. It's built on a mock GrGpu class that does nothing. //// -#include "GrBufferAllocPool.h" #include "GrInOrderDrawBuffer.h" #include "GrGpu.h" @@ -266,10 +265,6 @@ void GrContext::initMockContext() { // these objects are required for any of tests that use this context. TODO: make stop allocating // resources in the buffer pools. SkDELETE(fDrawBuffer); - SkDELETE(fDrawBufferVBAllocPool); - SkDELETE(fDrawBufferIBAllocPool); - fDrawBuffer = NULL; - fDrawBufferVBAllocPool = NULL; - fDrawBufferIBAllocPool = NULL; + } diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 869454049a..e5fb218d7b 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -10,7 +10,6 @@ #include "GrBatch.h" #include "GrBatchTarget.h" #include "GrBatchTest.h" -#include "GrBufferAllocPool.h" #include "GrGeometryProcessor.h" #include "GrContext.h" #include "GrCoordTransform.h" |