move GrMalloc, GrFree, Gr_bzero to their sk equivalents

BUG=
R=bsalomon@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11486 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2013-09-26 19:56:51 +00:00
parent baed71fbfe
commit 939ca7ce86
11 changed files with 20 additions and 31 deletions

View File

@ -79,7 +79,6 @@
'<(skia_src_path)/gpu/GrIndexBuffer.h',
'<(skia_src_path)/gpu/GrInOrderDrawBuffer.cpp',
'<(skia_src_path)/gpu/GrInOrderDrawBuffer.h',
'<(skia_src_path)/gpu/GrMemory.cpp',
'<(skia_src_path)/gpu/GrMemoryPool.cpp',
'<(skia_src_path)/gpu/GrMemoryPool.h',
'<(skia_src_path)/gpu/GrOvalRenderer.cpp',

View File

@ -125,16 +125,6 @@ static inline size_t GrSizeAlignDown(size_t x, uint32_t alignment) {
*/
#define GR_ARRAY_COUNT(array) SK_ARRAY_COUNT(array)
//!< allocate a block of memory, will never return NULL
extern void* GrMalloc(size_t bytes);
//!< free block allocated by GrMalloc. ptr may be NULL
extern void GrFree(void* ptr);
static inline void Gr_bzero(void* dst, size_t size) {
memset(dst, 0, size);
}
///////////////////////////////////////////////////////////////////////////////
/**

View File

@ -20,7 +20,7 @@ struct GrAllocPool::Block {
static Block* Create(size_t size, Block* next) {
SkASSERT(size >= GrAllocPool_MIN_BLOCK_SIZE);
Block* block = (Block*)GrMalloc(sizeof(Block) + size);
Block* block = (Block*)sk_malloc_throw(sizeof(Block) + size);
block->fNext = next;
block->fPtr = (char*)block + sizeof(Block);
block->fBytesFree = size;
@ -69,7 +69,7 @@ void GrAllocPool::reset() {
Block* block = fBlock;
while (block) {
Block* next = block->fNext;
GrFree(block);
sk_free(block);
block = next;
}
fBlock = NULL;
@ -94,7 +94,7 @@ void GrAllocPool::release(size_t bytes) {
bytes = fBlock->release(bytes);
if (fBlock->empty()) {
Block* next = fBlock->fNext;
GrFree(fBlock);
sk_free(fBlock);
fBlock = next;
SkDEBUGCODE(fBlocksAllocated -= 1;)
}

View File

@ -49,9 +49,9 @@ public:
// we always have at least one block
if (0 == indexInBlock) {
if (0 != fCount) {
fBlocks.push_back() = GrMalloc(fBlockSize);
fBlocks.push_back() = sk_malloc_throw(fBlockSize);
} else if (fOwnFirstBlock) {
fBlocks[0] = GrMalloc(fBlockSize);
fBlocks[0] = sk_malloc_throw(fBlockSize);
}
}
void* ret = (char*)fBlocks[fCount/fItemsPerBlock] +
@ -67,10 +67,10 @@ public:
int blockCount = GrMax((unsigned)1,
GrUIDivRoundUp(fCount, fItemsPerBlock));
for (int i = 1; i < blockCount; ++i) {
GrFree(fBlocks[i]);
sk_free(fBlocks[i]);
}
if (fOwnFirstBlock) {
GrFree(fBlocks[0]);
sk_free(fBlocks[0]);
fBlocks[0] = NULL;
}
fBlocks.pop_back_n(blockCount-1);

View File

@ -125,7 +125,7 @@ bool GrAtlas::addSubImage(int width, int height, const void* image,
if (BORDER) {
const size_t dstRB = dstW * fBytesPerPixel;
uint8_t* dst = (uint8_t*)storage.reset(dstH * dstRB);
Gr_bzero(dst, dstRB); // zero top row
sk_bzero(dst, dstRB); // zero top row
dst += dstRB;
for (int y = 0; y < height; y++) {
dst = zerofill(dst, fBytesPerPixel); // zero left edge
@ -134,7 +134,7 @@ bool GrAtlas::addSubImage(int width, int height, const void* image,
dst = zerofill(dst, fBytesPerPixel); // zero right edge
image = (const void*)((const char*)image + width * fBytesPerPixel);
}
Gr_bzero(dst, dstRB); // zero bottom row
sk_bzero(dst, dstRB); // zero bottom row
image = storage.get();
}
adjustForPlot(loc, fPlot);

View File

@ -276,14 +276,14 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
fill_indices(indices, MAX_QUADS);
fQuadIndexBuffer->unlock();
} else {
indices = (uint16_t*)GrMalloc(SIZE);
indices = (uint16_t*)sk_malloc_throw(SIZE);
fill_indices(indices, MAX_QUADS);
if (!fQuadIndexBuffer->updateData(indices, SIZE)) {
fQuadIndexBuffer->unref();
fQuadIndexBuffer = NULL;
GrCrash("Can't get indices into buffer!");
}
GrFree(indices);
sk_free(indices);
}
}
}

View File

@ -104,7 +104,7 @@ void GrMemoryPool::release(void* p) {
GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) {
BlockHeader* block =
reinterpret_cast<BlockHeader*>(GrMalloc(size + kHeaderSize));
reinterpret_cast<BlockHeader*>(sk_malloc_throw(size + kHeaderSize));
// we assume malloc gives us aligned memory
SkASSERT(!(reinterpret_cast<intptr_t>(block) % kAlignment));
block->fLiveCount = 0;
@ -115,7 +115,7 @@ GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) {
}
void GrMemoryPool::DeleteBlock(BlockHeader* block) {
GrFree(block);
sk_free(block);
}
void GrMemoryPool::validate() {

View File

@ -32,7 +32,7 @@ public:
}
void reset() {
Gr_bzero(fBusy, fDim.fX * fDim.fY);
sk_bzero(fBusy, fDim.fX * fDim.fY);
}
bool newPlot(GrIPoint16* loc) {

View File

@ -18,7 +18,7 @@ public:
GrRectanizerPow2(int w, int h) : GrRectanizer(w, h) {
fNextStripY = 0;
fAreaSoFar = 0;
Gr_bzero(fRows, sizeof(fRows));
sk_bzero(fRows, sizeof(fRows));
}
virtual ~GrRectanizerPow2() {

View File

@ -18,7 +18,7 @@ public:
GrRectanizerFIFO(int w, int h) : GrRectanizer(w, h) {
fNextStripY = 0;
fAreaSoFar = 0;
Gr_bzero(fRows, sizeof(fRows));
sk_bzero(fRows, sizeof(fRows));
}
virtual ~GrRectanizerFIFO() {

View File

@ -34,7 +34,7 @@ public:
*/
template <typename T, typename Key, size_t kHashBits> class GrTHashTable {
public:
GrTHashTable() { Gr_bzero(fHash, sizeof(fHash)); }
GrTHashTable() { sk_bzero(fHash, sizeof(fHash)); }
~GrTHashTable() {}
int count() const { return fSorted.count(); }
@ -210,19 +210,19 @@ T* GrTHashTable<T, Key, kHashBits>::removeAt(int elemIndex, uint32_t hash) {
template <typename T, typename Key, size_t kHashBits>
void GrTHashTable<T, Key, kHashBits>::removeAll() {
fSorted.reset();
Gr_bzero(fHash, sizeof(fHash));
sk_bzero(fHash, sizeof(fHash));
}
template <typename T, typename Key, size_t kHashBits>
void GrTHashTable<T, Key, kHashBits>::deleteAll() {
fSorted.deleteAll();
Gr_bzero(fHash, sizeof(fHash));
sk_bzero(fHash, sizeof(fHash));
}
template <typename T, typename Key, size_t kHashBits>
void GrTHashTable<T, Key, kHashBits>::unrefAll() {
fSorted.unrefAll();
Gr_bzero(fHash, sizeof(fHash));
sk_bzero(fHash, sizeof(fHash));
}
#ifdef SK_DEBUG