diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 73e12f8f72..83462f6138 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -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', diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index b78976361b..0585074697 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -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); -} - /////////////////////////////////////////////////////////////////////////////// /** diff --git a/src/gpu/GrAllocPool.cpp b/src/gpu/GrAllocPool.cpp index 127511f164..d7b553176d 100644 --- a/src/gpu/GrAllocPool.cpp +++ b/src/gpu/GrAllocPool.cpp @@ -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;) } diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h index 57ca03cd32..23bb6b76c9 100755 --- a/src/gpu/GrAllocator.h +++ b/src/gpu/GrAllocator.h @@ -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); diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp index 29f2a54ed7..b3340a02d9 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -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); diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index a4aa00eac1..910c57146b 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -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); } } } diff --git a/src/gpu/GrMemoryPool.cpp b/src/gpu/GrMemoryPool.cpp index 83b02bd9e5..deb7d1a814 100644 --- a/src/gpu/GrMemoryPool.cpp +++ b/src/gpu/GrMemoryPool.cpp @@ -104,7 +104,7 @@ void GrMemoryPool::release(void* p) { GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) { BlockHeader* block = - reinterpret_cast(GrMalloc(size + kHeaderSize)); + reinterpret_cast(sk_malloc_throw(size + kHeaderSize)); // we assume malloc gives us aligned memory SkASSERT(!(reinterpret_cast(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() { diff --git a/src/gpu/GrPlotMgr.h b/src/gpu/GrPlotMgr.h index 3aa8cf6c8a..6ea6086b06 100644 --- a/src/gpu/GrPlotMgr.h +++ b/src/gpu/GrPlotMgr.h @@ -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) { diff --git a/src/gpu/GrRectanizer.cpp b/src/gpu/GrRectanizer.cpp index 6f4b49e1ae..7b49530366 100644 --- a/src/gpu/GrRectanizer.cpp +++ b/src/gpu/GrRectanizer.cpp @@ -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() { diff --git a/src/gpu/GrRectanizer_fifo.cpp b/src/gpu/GrRectanizer_fifo.cpp index 0c36f49bf6..9dd808618b 100644 --- a/src/gpu/GrRectanizer_fifo.cpp +++ b/src/gpu/GrRectanizer_fifo.cpp @@ -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() { diff --git a/src/gpu/GrTHashCache.h b/src/gpu/GrTHashCache.h index c614b1dd7c..a9b4918b3d 100644 --- a/src/gpu/GrTHashCache.h +++ b/src/gpu/GrTHashCache.h @@ -34,7 +34,7 @@ public: */ template 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::removeAt(int elemIndex, uint32_t hash) { template void GrTHashTable::removeAll() { fSorted.reset(); - Gr_bzero(fHash, sizeof(fHash)); + sk_bzero(fHash, sizeof(fHash)); } template void GrTHashTable::deleteAll() { fSorted.deleteAll(); - Gr_bzero(fHash, sizeof(fHash)); + sk_bzero(fHash, sizeof(fHash)); } template void GrTHashTable::unrefAll() { fSorted.unrefAll(); - Gr_bzero(fHash, sizeof(fHash)); + sk_bzero(fHash, sizeof(fHash)); } #ifdef SK_DEBUG