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

Unified Diff: src/gpu/GrContext.cpp

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/GrCommandBuilder.h ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c9342a5e6a75aa564c2ef4bfe53eac573bce8bd0..58e8508e370528f68493c0e8488e3fad8cc59873 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();
}
« no previous file with comments | « src/gpu/GrCommandBuilder.h ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698