Remove GrAuto*Malloc, replace with SkAuto*Malloc
Review URL: http://codereview.appspot.com/4629088
git-svn-id: http://skia.googlecode.com/svn/trunk@1774 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrAtlas.cpp b/gpu/src/GrAtlas.cpp
index c623952..6f2ed9e 100644
--- a/gpu/src/GrAtlas.cpp
+++ b/gpu/src/GrAtlas.cpp
@@ -17,7 +17,6 @@
#include "GrAtlas.h"
#include "GrGpu.h"
-#include "GrMemory.h"
#include "GrRectanizer.h"
#include "GrPlotMgr.h"
@@ -97,7 +96,7 @@
return false;
}
- GrAutoSMalloc<1024> storage;
+ SkAutoSMalloc<1024> storage;
int dstW = width + 2*BORDER;
int dstH = height + 2*BORDER;
if (BORDER) {
diff --git a/gpu/src/GrBufferAllocPool.cpp b/gpu/src/GrBufferAllocPool.cpp
index 73d707f..5e9dbea 100644
--- a/gpu/src/GrBufferAllocPool.cpp
+++ b/gpu/src/GrBufferAllocPool.cpp
@@ -98,7 +98,7 @@
fFirstPreallocBuffer = (fFirstPreallocBuffer + fPreallocBuffersInUse) %
fPreallocBuffers.count();
}
- fCpuData.realloc(fGpu->supportsBufferLocking() ? 0 : fMinBlockSize);
+ fCpuData.alloc(fGpu->supportsBufferLocking() ? 0 : fMinBlockSize);
GrAssert(0 == fPreallocBuffersInUse);
VALIDATE();
}
@@ -128,7 +128,6 @@
GrAssert(buf->lockPtr() == fBufferPtr);
} else {
GrAssert(fCpuData.get() == fBufferPtr);
- GrAssert(fCpuData.size() == fBlocks.back().fBuffer->size());
}
} else {
GrAssert(fBlocks.empty() || !fBlocks.back().fBuffer->isLocked());
@@ -286,7 +285,7 @@
}
if (NULL == fBufferPtr) {
- fBufferPtr = fCpuData.realloc(size);
+ fBufferPtr = fCpuData.alloc(size);
}
VALIDATE(true);
@@ -318,7 +317,6 @@
GrAssert(NULL != buffer);
GrAssert(!buffer->isLocked());
GrAssert(fCpuData.get() == fBufferPtr);
- GrAssert(fCpuData.size() == buffer->size());
GrAssert(flushSize <= buffer->size());
bool updated = false;
diff --git a/gpu/src/GrBufferAllocPool.h b/gpu/src/GrBufferAllocPool.h
index c18e36b..79036f2 100644
--- a/gpu/src/GrBufferAllocPool.h
+++ b/gpu/src/GrBufferAllocPool.h
@@ -21,7 +21,6 @@
#include "GrNoncopyable.h"
#include "GrTDArray.h"
#include "GrTArray.h"
-#include "GrMemory.h"
class GrGeometryBuffer;
class GrGpu;
@@ -184,8 +183,8 @@
GrTArray<BufferBlock> fBlocks;
int fPreallocBuffersInUse;
int fFirstPreallocBuffer;
- GrAutoMalloc fCpuData;
- void* fBufferPtr;
+ SkAutoMalloc fCpuData;
+ void* fBufferPtr;
};
class GrVertexBuffer;
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index d97974a..4982704 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -20,7 +20,6 @@
#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrInOrderDrawBuffer.h"
-#include "GrMemory.h"
#include "GrPathRenderer.h"
#include "GrPathUtils.h"
#include "GrTextureCache.h"
@@ -291,7 +290,7 @@
rtDesc.fWidth = GrNextPow2(desc.fWidth);
rtDesc.fHeight = GrNextPow2(desc.fHeight);
int bpp = GrBytesPerPixel(desc.fFormat);
- GrAutoSMalloc<128*128*4> stretchedPixels(bpp *
+ SkAutoSMalloc<128*128*4> stretchedPixels(bpp *
rtDesc.fWidth *
rtDesc.fHeight);
stretchImage(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight,
diff --git a/gpu/src/GrGLProgram.cpp b/gpu/src/GrGLProgram.cpp
index 319995c..733e705 100644
--- a/gpu/src/GrGLProgram.cpp
+++ b/gpu/src/GrGLProgram.cpp
@@ -18,7 +18,6 @@
#include "GrBinHashKey.h"
#include "GrGLConfig.h"
-#include "GrMemory.h"
#include "SkXfermode.h"
#include SK_USER_TRACE_INCLUDE_FILE
@@ -775,7 +774,7 @@
if (!compiled) {
GrGLint infoLen = GR_GL_INIT_ZERO;
GR_GL(GetShaderiv(shader, GR_GL_INFO_LOG_LENGTH, &infoLen));
- GrAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
+ SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
if (infoLen > 0) {
GR_GL(GetShaderInfoLog(shader, infoLen+1, NULL, (char*)log.get()));
for (int i = 0; i < stringCnt; ++i) {
@@ -853,7 +852,7 @@
if (!linked) {
GrGLint infoLen = GR_GL_INIT_ZERO;
GR_GL(GetProgramiv(progID, GR_GL_INFO_LOG_LENGTH, &infoLen));
- GrAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
+ SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
if (infoLen > 0) {
GR_GL(GetProgramInfoLog(progID,
infoLen+1,
diff --git a/gpu/src/GrGLTexture.cpp b/gpu/src/GrGLTexture.cpp
index d36e21b..207246b 100644
--- a/gpu/src/GrGLTexture.cpp
+++ b/gpu/src/GrGLTexture.cpp
@@ -17,7 +17,6 @@
#include "GrGLTexture.h"
#include "GrGpuGL.h"
-#include "GrMemory.h"
#define GPUGL static_cast<GrGpuGL*>(getGpu())
@@ -168,7 +167,7 @@
GrAssert(fUploadFormat != GR_GL_PALETTE8_RGBA8);
// in case we need a temporary, trimmed copy of the src pixels
- GrAutoSMalloc<128 * 128> trimStorage;
+ SkAutoSMalloc<128 * 128> trimStorage;
/*
* check if our srcData has extra bytes past each row. If so, we need
diff --git a/gpu/src/GrGpu.cpp b/gpu/src/GrGpu.cpp
index db7de2c..192d29b 100644
--- a/gpu/src/GrGpu.cpp
+++ b/gpu/src/GrGpu.cpp
@@ -15,7 +15,6 @@
*/
#include "GrGpu.h"
-#include "GrMemory.h"
#include "GrTextStrike.h"
#include "GrTextureCache.h"
#include "GrClipIterator.h"
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index ffdf496..fe51875 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -15,8 +15,8 @@
*/
#include "GrGpuGL.h"
-#include "GrMemory.h"
#include "GrTypes.h"
+#include "SkTemplates.h"
static const GrGLuint GR_MAX_GLUINT = ~0;
static const GrGLint GR_INVAL_GLINT = ~0;
@@ -312,7 +312,7 @@
GrGLint numFormats;
GR_GL_GetIntegerv(GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
- GrAutoSTMalloc<10, GrGLint> formats(numFormats);
+ SkAutoSTMalloc<10, GrGLint> formats(numFormats);
GR_GL_GetIntegerv(GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < numFormats; ++i) {
if (formats[i] == GR_GL_PALETTE8_RGBA8) {
@@ -780,7 +780,7 @@
glDesc.fUploadByteCount = GrBytesPerPixel(desc.fFormat);
// in case we need a temporary, trimmed copy of the src pixels
- GrAutoSMalloc<128 * 128> trimStorage;
+ SkAutoSMalloc<128 * 128> trimStorage;
/*
* check if our srcData has extra bytes past each row. If so, we need
@@ -875,7 +875,7 @@
maxTexels = GrMax(extraW * desc.fHeight, maxTexels);
maxTexels = GrMax(desc.fWidth * extraH, maxTexels);
- GrAutoSMalloc<128*128> texels(glDesc.fUploadByteCount * maxTexels);
+ SkAutoSMalloc<128*128> texels(glDesc.fUploadByteCount * maxTexels);
uint32_t rowSize = desc.fWidth * glDesc.fUploadByteCount;
if (extraH) {
@@ -1325,7 +1325,7 @@
// API presents top-to-bottom
{
size_t stride = width * GrBytesPerPixel(config);
- GrAutoMalloc rowStorage(stride);
+ SkAutoMalloc rowStorage(stride);
void* tmp = rowStorage.get();
const int halfY = height >> 1;
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index 0b8aad7..b474be2 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -18,7 +18,6 @@
#include "GrGLProgram.h"
#include "GrGpuGLShaders.h"
#include "GrGpuVertex.h"
-#include "GrMemory.h"
#include "GrNoncopyable.h"
#include "GrStringBuilder.h"
#include "GrRandom.h"
diff --git a/gpu/src/GrMemory.cpp b/gpu/src/GrMemory.cpp
index 3da924a..02ac025 100644
--- a/gpu/src/GrMemory.cpp
+++ b/gpu/src/GrMemory.cpp
@@ -15,8 +15,6 @@
*/
-#include "GrMemory.h"
-
#include <stdlib.h>
void* GrMalloc(size_t bytes) {
diff --git a/gpu/src/GrPathRenderer.cpp b/gpu/src/GrPathRenderer.cpp
index b565838..1e3c645 100644
--- a/gpu/src/GrPathRenderer.cpp
+++ b/gpu/src/GrPathRenderer.cpp
@@ -3,10 +3,11 @@
#include "GrPoint.h"
#include "GrDrawTarget.h"
#include "GrPathUtils.h"
-#include "GrMemory.h"
#include "GrTexture.h"
#include "SkString.h"
+#include "SkTemplates.h"
+
#include SK_USER_TRACE_INCLUDE_FILE
GrPathRenderer::GrPathRenderer()
@@ -234,7 +235,7 @@
GrPoint* vert = base;
GrPoint* subpathBase = base;
- GrAutoSTMalloc<8, uint16_t> subpathVertCount(subpathCnt);
+ SkAutoSTMalloc<8, uint16_t> subpathVertCount(subpathCnt);
// TODO: use primitve restart if available rather than multiple draws
GrPrimitiveType type;
diff --git a/gpu/src/GrTesselatedPathRenderer.cpp b/gpu/src/GrTesselatedPathRenderer.cpp
index c1d5ac0..5ddba99 100644
--- a/gpu/src/GrTesselatedPathRenderer.cpp
+++ b/gpu/src/GrTesselatedPathRenderer.cpp
@@ -16,11 +16,12 @@
#include "GrTesselatedPathRenderer.h"
-#include "GrMemory.h"
#include "GrPathUtils.h"
#include "GrPoint.h"
#include "GrTDArray.h"
+#include "SkTemplates.h"
+
#include <limits.h>
#include <sk_glu.h>
@@ -393,12 +394,12 @@
if (maxPts > USHRT_MAX) {
return;
}
- GrAutoSTMalloc<8, GrPoint> baseMem(maxPts);
- GrPoint* base = (GrPoint*) baseMem;
+ SkAutoSTMalloc<8, GrPoint> baseMem(maxPts);
+ GrPoint* base = baseMem;
GrPoint* vert = base;
GrPoint* subpathBase = base;
- GrAutoSTMalloc<8, uint16_t> subpathVertCount(subpathCnt);
+ SkAutoSTMalloc<8, uint16_t> subpathVertCount(subpathCnt);
GrPoint pts[4];
SkPath::Iter iter(path, false);
diff --git a/gpu/src/GrTextStrike.cpp b/gpu/src/GrTextStrike.cpp
index 455f88a..c44ad38 100644
--- a/gpu/src/GrTextStrike.cpp
+++ b/gpu/src/GrTextStrike.cpp
@@ -17,7 +17,6 @@
#include "GrAtlas.h"
#include "GrGpu.h"
-#include "GrMemory.h"
#include "GrRectanizer.h"
#include "GrTextStrike.h"
#include "GrTextStrike_impl.h"
@@ -189,7 +188,7 @@
int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
size_t size = glyph->fBounds.area() * bytesPerPixel;
- GrAutoSMalloc<1024> storage(size);
+ SkAutoSMalloc<1024> storage(size);
if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
glyph->height(),
glyph->width() * bytesPerPixel,