Index: src/gpu/GrResourceProvider.cpp |
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp |
index 79146d09113c37170a75bd9e025b0fc76b193970..a73bf752b046ad64419a249d53a565924a8063c8 100644 |
--- a/src/gpu/GrResourceProvider.cpp |
+++ b/src/gpu/GrResourceProvider.cpp |
@@ -7,15 +7,14 @@ |
#include "GrResourceProvider.h" |
+#include "GrBuffer.h" |
#include "GrGpu.h" |
-#include "GrIndexBuffer.h" |
#include "GrPathRendering.h" |
#include "GrRenderTarget.h" |
#include "GrRenderTargetPriv.h" |
#include "GrResourceCache.h" |
#include "GrResourceKey.h" |
#include "GrStencilAttachment.h" |
-#include "GrVertexBuffer.h" |
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey); |
@@ -25,16 +24,16 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin |
fQuadIndexBufferKey = gQuadIndexBufferKey; |
} |
-const GrIndexBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern, |
- int patternSize, |
- int reps, |
- int vertCount, |
- const GrUniqueKey& key) { |
+const GrBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern, |
+ int patternSize, |
+ int reps, |
+ int vertCount, |
+ const GrUniqueKey& key) { |
size_t bufferSize = patternSize * reps * sizeof(uint16_t); |
// This is typically used in GrBatchs, so we assume kNoPendingIO. |
- GrIndexBuffer* buffer = this->createIndexBuffer(bufferSize, kStatic_BufferUsage, |
- kNoPendingIO_Flag); |
+ GrBuffer* buffer = this->createBuffer(kIndex_GrBufferType, bufferSize, kStatic_GrAccessPattern, |
+ kNoPendingIO_Flag); |
if (!buffer) { |
return nullptr; |
} |
@@ -63,7 +62,7 @@ const GrIndexBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16 |
return buffer; |
} |
-const GrIndexBuffer* GrResourceProvider::createQuadIndexBuffer() { |
+const GrBuffer* GrResourceProvider::createQuadIndexBuffer() { |
static const int kMaxQuads = 1 << 12; // max possible: (1 << 14) - 1; |
GR_STATIC_ASSERT(4 * kMaxQuads <= 65535); |
static const uint16_t kPattern[] = { 0, 1, 2, 0, 2, 3 }; |
@@ -89,72 +88,31 @@ GrPathRange* GrResourceProvider::createGlyphs(const SkTypeface* tf, const SkDesc |
return this->gpu()->pathRendering()->createGlyphs(tf, desc, stroke); |
} |
-GrIndexBuffer* GrResourceProvider::createIndexBuffer(size_t size, BufferUsage usage, |
- uint32_t flags) { |
+GrBuffer* GrResourceProvider::createBuffer(GrBufferType type, size_t size, |
+ GrAccessPattern accessPattern, uint32_t flags) { |
if (this->isAbandoned()) { |
return nullptr; |
} |
- bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag); |
- bool dynamic = kDynamic_BufferUsage == usage; |
- if (dynamic) { |
+ if (kDynamic_GrAccessPattern == accessPattern) { |
// bin by pow2 with a reasonable min |
static const uint32_t MIN_SIZE = 1 << 12; |
size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size))); |
GrScratchKey key; |
- GrIndexBuffer::ComputeScratchKey(size, true, &key); |
+ GrBuffer::ComputeScratchKeyForDynamicBuffer(type, size, &key); |
uint32_t scratchFlags = 0; |
- if (noPendingIO) { |
+ if (flags & kNoPendingIO_Flag) { |
scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; |
} else { |
scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; |
} |
GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags); |
if (resource) { |
- return static_cast<GrIndexBuffer*>(resource); |
+ return static_cast<GrBuffer*>(resource); |
} |
} |
- return this->gpu()->createIndexBuffer(size, dynamic); |
-} |
- |
-GrVertexBuffer* GrResourceProvider::createVertexBuffer(size_t size, BufferUsage usage, |
- uint32_t flags) { |
- if (this->isAbandoned()) { |
- return nullptr; |
- } |
- |
- bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag); |
- bool dynamic = kDynamic_BufferUsage == usage; |
- if (dynamic) { |
- // bin by pow2 with a reasonable min |
- static const uint32_t MIN_SIZE = 1 << 12; |
- size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size))); |
- |
- GrScratchKey key; |
- GrVertexBuffer::ComputeScratchKey(size, true, &key); |
- uint32_t scratchFlags = 0; |
- if (noPendingIO) { |
- scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; |
- } else { |
- scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; |
- } |
- GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags); |
- if (resource) { |
- return static_cast<GrVertexBuffer*>(resource); |
- } |
- } |
- return this->gpu()->createVertexBuffer(size, dynamic); |
-} |
- |
-GrTransferBuffer* GrResourceProvider::createTransferBuffer(size_t size, TransferType type, |
- uint32_t flags) { |
- if (this->isAbandoned()) { |
- return nullptr; |
- } |
- |
- //bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag); |
- return this->gpu()->createTransferBuffer(size, type); |
+ return this->gpu()->createBuffer(type, size, accessPattern); |
} |
GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config, |