#include "src/gpu/ganesh/GrBufferAllocPool.h"
#include "include/gpu/ganesh/GrDirectContext.h"
#include "include/private/base/SkMacros.h"
#include "src/base/SkSafeMath.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrCpuBuffer.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrGpuBuffer.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <memory>
sk_sp<GrBufferAllocPool::CpuBufferCache> GrBufferAllocPool::CpuBufferCache::Make(
int maxBuffersToCache) { … }
GrBufferAllocPool::CpuBufferCache::CpuBufferCache(int maxBuffersToCache)
: … { … }
sk_sp<GrCpuBuffer> GrBufferAllocPool::CpuBufferCache::makeBuffer(size_t size,
bool mustBeInitialized) { … }
void GrBufferAllocPool::CpuBufferCache::releaseAll() { … }
#ifdef SK_DEBUG
#define VALIDATE …
#else
static void VALIDATE(bool = false) {}
#endif
#define UNMAP_BUFFER(block) …
GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, GrGpuBufferType bufferType,
sk_sp<CpuBufferCache> cpuBufferCache)
: … { … }
void GrBufferAllocPool::deleteBlocks() { … }
GrBufferAllocPool::~GrBufferAllocPool() { … }
void GrBufferAllocPool::reset() { … }
void GrBufferAllocPool::unmap() { … }
#ifdef SK_DEBUG
void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { … }
#endif
static inline size_t align_up_pad(size_t x, size_t alignment) { … }
static inline size_t align_down(size_t x, uint32_t alignment) { … }
void* GrBufferAllocPool::makeSpace(size_t size,
size_t alignment,
sk_sp<const GrBuffer>* buffer,
size_t* offset) { … }
void* GrBufferAllocPool::makeSpaceAtLeast(size_t minSize,
size_t fallbackSize,
size_t alignment,
sk_sp<const GrBuffer>* buffer,
size_t* offset,
size_t* actualSize) { … }
void GrBufferAllocPool::putBack(size_t bytes) { … }
bool GrBufferAllocPool::createBlock(size_t requestSize) { … }
void GrBufferAllocPool::destroyBlock() { … }
void GrBufferAllocPool::resetCpuData(size_t newSize) { … }
void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize) { … }
sk_sp<GrBuffer> GrBufferAllocPool::getBuffer(size_t size) { … }
GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu, sk_sp<CpuBufferCache> cpuBufferCache)
: … { … }
void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
int vertexCount,
sk_sp<const GrBuffer>* buffer,
int* startVertex) { … }
void* GrVertexBufferAllocPool::makeSpaceAtLeast(size_t vertexSize, int minVertexCount,
int fallbackVertexCount,
sk_sp<const GrBuffer>* buffer, int* startVertex,
int* actualVertexCount) { … }
GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu, sk_sp<CpuBufferCache> cpuBufferCache)
: … { … }
void* GrIndexBufferAllocPool::makeSpace(int indexCount, sk_sp<const GrBuffer>* buffer,
int* startIndex) { … }
void* GrIndexBufferAllocPool::makeSpaceAtLeast(int minIndexCount, int fallbackIndexCount,
sk_sp<const GrBuffer>* buffer, int* startIndex,
int* actualIndexCount) { … }