Add placement new macros to SkPostConfig, call SkNEW* from Ganesh.
TODO: unify with the placement new implementation in SkTemplatesPriv.h,
once various issues there are overcome. reed@ should be taking the lead
there.
http://codereview.appspot.com/6384043/
git-svn-id: http://skia.googlecode.com/svn/trunk@4492 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 2b8c7c1..8aed4b0 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -35,7 +35,7 @@
uint16_t* data = (uint16_t*) qIdxBuffer->lock();
bool tempData = NULL == data;
if (tempData) {
- data = new uint16_t[kNumQuadsInIdxBuffer * kIdxsPerQuad];
+ data = SkNEW_ARRAY(uint16_t, kNumQuadsInIdxBuffer * kIdxsPerQuad);
}
for (int i = 0; i < kNumQuadsInIdxBuffer; ++i) {
@@ -86,9 +86,8 @@
!push_quad_index_data(qIdxBuf)) {
return NULL;
}
- return new GrAAHairLinePathRenderer(context,
- lIdxBuffer,
- qIdxBuf);
+ return SkNEW_ARGS(GrAAHairLinePathRenderer,
+ (context, lIdxBuffer, qIdxBuf));
}
GrAAHairLinePathRenderer::GrAAHairLinePathRenderer(
diff --git a/src/gpu/GrAddPathRenderers_default.cpp b/src/gpu/GrAddPathRenderers_default.cpp
index 32b2a07..24f1017 100644
--- a/src/gpu/GrAddPathRenderers_default.cpp
+++ b/src/gpu/GrAddPathRenderers_default.cpp
@@ -23,6 +23,6 @@
if (GrPathRenderer* pr = GrAAHairLinePathRenderer::Create(ctx)) {
chain->addPathRenderer(pr)->unref();
}
- chain->addPathRenderer(new GrAAConvexPathRenderer())->unref();
+ chain->addPathRenderer(SkNEW(GrAAConvexPathRenderer))->unref();
}
}
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h
index f333d42..ae456cd 100755
--- a/src/gpu/GrAllocator.h
+++ b/src/gpu/GrAllocator.h
@@ -163,14 +163,14 @@
T& push_back() {
void* item = fAllocator.push_back();
GrAssert(NULL != item);
- new (item) T;
+ SkNEW_PLACEMENT(item, T);
return *(T*)item;
}
T& push_back(const T& t) {
void* item = fAllocator.push_back();
GrAssert(NULL != item);
- new (item) T(t);
+ SkNEW_PLACEMENT_ARGS(item, T, (t));
return *(T*)item;
}
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp
index fb12719..2b76d13 100644
--- a/src/gpu/GrAtlas.cpp
+++ b/src/gpu/GrAtlas.cpp
@@ -131,7 +131,7 @@
fGpu = gpu;
gpu->ref();
Gr_bzero(fTexture, sizeof(fTexture));
- fPlotMgr = new GrPlotMgr(GR_PLOT_WIDTH, GR_PLOT_HEIGHT);
+ fPlotMgr = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT));
}
GrAtlasMgr::~GrAtlasMgr() {
@@ -189,7 +189,7 @@
}
}
- GrAtlas* newAtlas = new GrAtlas(this, plot.fX, plot.fY, format);
+ GrAtlas* newAtlas = SkNEW_ARGS(GrAtlas, (this, plot.fX, plot.fY, format));
if (!newAtlas->addSubImage(width, height, image, loc)) {
delete newAtlas;
return NULL;
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index bb597ba..8106185 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -38,7 +38,7 @@
, fStack(sizeof(GrClipStackFrame)) {
// We need an initial frame to capture the clip state prior to
// any pushes
- new (fStack.push_back()) GrClipStackFrame();
+ SkNEW_PLACEMENT(fStack.push_back(), GrClipStackFrame);
}
~GrClipMaskCache() {
@@ -87,7 +87,7 @@
* reduce the mask creation cost?
*/
void push() {
- new (fStack.push_back()) GrClipStackFrame();
+ SkNEW_PLACEMENT(fStack.push_back(), GrClipStackFrame);
}
void pop() {
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6326f4d..f79249c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -66,7 +66,7 @@
GrContext* ctx = NULL;
GrGpu* fGpu = GrGpu::Create(engine, context3D);
if (NULL != fGpu) {
- ctx = new GrContext(fGpu);
+ ctx = SkNEW_ARGS(GrContext, (fGpu));
fGpu->unref();
}
return ctx;
@@ -74,7 +74,7 @@
namespace {
void* CreateThreadInstanceCount() {
- return new int(0);
+ return SkNEW_ARGS(int, (0));
}
void DeleteThreadInstanceCount(void* v) {
delete reinterpret_cast<int*>(v);
@@ -244,7 +244,7 @@
sampleM.setIDiv(texture->width(), texture->height());
drawState->sampler(0)->reset(sampleM);
SkAutoTUnref<GrCustomStage> morph(
- new GrMorphologyEffect(direction, radius, morphType));
+ SkNEW_ARGS(GrMorphologyEffect, (direction, radius, morphType)));
drawState->sampler(0)->setCustomStage(morph);
drawState->setTexture(0, texture);
gpu->drawSimpleRect(rect, NULL, 1 << 0);
@@ -263,8 +263,8 @@
GrMatrix sampleM;
sampleM.setIDiv(texture->width(), texture->height());
drawState->sampler(0)->reset(sampleM);
- SkAutoTUnref<GrConvolutionEffect> conv(new
- GrConvolutionEffect(direction, radius));
+ SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
+ (direction, radius)));
conv->setGaussianKernel(sigma);
drawState->sampler(0)->setCustomStage(conv);
drawState->setTexture(0, texture);
@@ -1682,7 +1682,8 @@
bool allowSW) {
if (NULL == fPathRendererChain) {
fPathRendererChain =
- new GrPathRendererChain(this, GrPathRendererChain::kNone_UsageFlag);
+ SkNEW_ARGS(GrPathRendererChain,
+ (this, GrPathRendererChain::kNone_UsageFlag));
}
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path, fill,
@@ -1691,7 +1692,7 @@
if (NULL == pr && allowSW) {
if (NULL == fSoftwarePathRenderer) {
- fSoftwarePathRenderer = new GrSoftwarePathRenderer(this);
+ fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this));
}
pr = fSoftwarePathRenderer;
@@ -1751,15 +1752,16 @@
fGpu->ref();
fGpu->setContext(this);
- fDrawState = new GrDrawState();
+ fDrawState = SkNEW(GrDrawState);
fGpu->setDrawState(fDrawState);
fPathRendererChain = NULL;
fSoftwarePathRenderer = NULL;
- fTextureCache = new GrResourceCache(MAX_TEXTURE_CACHE_COUNT,
- MAX_TEXTURE_CACHE_BYTES);
- fFontCache = new GrFontCache(fGpu);
+ fTextureCache = SkNEW_ARGS(GrResourceCache,
+ (MAX_TEXTURE_CACHE_COUNT,
+ MAX_TEXTURE_CACHE_BYTES));
+ fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
fLastDrawCategory = kUnbuffered_DrawCategory;
@@ -1767,7 +1769,7 @@
fDrawBufferVBAllocPool = NULL;
fDrawBufferIBAllocPool = NULL;
- fAARectRenderer = new GrAARectRenderer;
+ fAARectRenderer = SkNEW(GrAARectRenderer);
this->setupDrawBuffer();
}
@@ -1780,17 +1782,17 @@
#if DEFER_TEXT_RENDERING || BATCH_RECT_TO_RECT || DEFER_PATHS
fDrawBufferVBAllocPool =
- new GrVertexBufferAllocPool(fGpu, false,
+ SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu, false,
DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
- DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS);
+ DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS));
fDrawBufferIBAllocPool =
- new GrIndexBufferAllocPool(fGpu, false,
+ SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, false,
DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
- DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS);
+ DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS));
- fDrawBuffer = new GrInOrderDrawBuffer(fGpu,
+ fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (fGpu,
fDrawBufferVBAllocPool,
- fDrawBufferIBAllocPool);
+ fDrawBufferIBAllocPool));
#endif
#if BATCH_RECT_TO_RECT
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 71e341b..0385b25 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -466,9 +466,9 @@
void GrGpu::prepareVertexPool() {
if (NULL == fVertexPool) {
GrAssert(0 == fVertexPoolUseCnt);
- fVertexPool = new GrVertexBufferAllocPool(this, true,
+ fVertexPool = SkNEW_ARGS(GrVertexBufferAllocPool, (this, true,
VERTEX_POOL_VB_SIZE,
- VERTEX_POOL_VB_COUNT);
+ VERTEX_POOL_VB_COUNT));
fVertexPool->releaseGpuRef();
} else if (!fVertexPoolUseCnt) {
// the client doesn't have valid data in the pool
@@ -479,9 +479,9 @@
void GrGpu::prepareIndexPool() {
if (NULL == fIndexPool) {
GrAssert(0 == fIndexPoolUseCnt);
- fIndexPool = new GrIndexBufferAllocPool(this, true,
+ fIndexPool = SkNEW_ARGS(GrIndexBufferAllocPool, (this, true,
INDEX_POOL_IB_SIZE,
- INDEX_POOL_IB_COUNT);
+ INDEX_POOL_IB_COUNT));
fIndexPool->releaseGpuRef();
} else if (!fIndexPoolUseCnt) {
// the client doesn't have valid data in the pool
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index 4a9bcf6..0d4c381 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -36,7 +36,7 @@
}
GrGLContextInfo ctxInfo(glInterface);
if (ctxInfo.isInitialized()) {
- return new GrGpuGL(ctxInfo);
+ return SkNEW_ARGS(GrGpuGL, (ctxInfo));
}
}
return NULL;
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index 648225e..038f836 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -54,6 +54,7 @@
bool twoSided = gpu->getCaps().fTwoSidedStencilSupport;
bool wrapOp = gpu->getCaps().fStencilWrapOpsSupport;
GrPathRenderer::AddPathRenderers(fOwner, fFlags, this);
- this->addPathRenderer(new GrDefaultPathRenderer(twoSided, wrapOp))->unref();
+ this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
+ (twoSided, wrapOp)))->unref();
fInit = true;
}
diff --git a/src/gpu/GrPlotMgr.h b/src/gpu/GrPlotMgr.h
index 0e631a9..38589f3 100644
--- a/src/gpu/GrPlotMgr.h
+++ b/src/gpu/GrPlotMgr.h
@@ -22,7 +22,7 @@
if (needed <= sizeof(fStorage)) {
fBusy = fStorage;
} else {
- fBusy = new char[needed];
+ fBusy = SkNEW_ARRAY(char, needed);
}
this->reset();
}
diff --git a/src/gpu/GrRectanizer.cpp b/src/gpu/GrRectanizer.cpp
index 628b890..8df3b05 100644
--- a/src/gpu/GrRectanizer.cpp
+++ b/src/gpu/GrRectanizer.cpp
@@ -117,7 +117,7 @@
///////////////////////////////////////////////////////////////////////////////
GrRectanizer* GrRectanizer::Factory(int width, int height) {
- return new GrRectanizerPow2(width, height);
+ return SkNEW_ARGS(GrRectanizerPow2, (width, height));
}
diff --git a/src/gpu/GrRectanizer_fifo.cpp b/src/gpu/GrRectanizer_fifo.cpp
index 3bfc46f..0f412b8 100644
--- a/src/gpu/GrRectanizer_fifo.cpp
+++ b/src/gpu/GrRectanizer_fifo.cpp
@@ -117,7 +117,7 @@
///////////////////////////////////////////////////////////////////////////////
GrRectanizer* GrRectanizer::Factory(int width, int height) {
- return new GrRectanizerFIFO(width, height);
+ return SkNEW_ARGS(GrRectanizerFIFO, (width, height));
}
diff --git a/src/gpu/GrRedBlackTree.h b/src/gpu/GrRedBlackTree.h
index da5ae3e..8187d81 100644
--- a/src/gpu/GrRedBlackTree.h
+++ b/src/gpu/GrRedBlackTree.h
@@ -343,7 +343,7 @@
++fCount;
- Node* x = new Node;
+ Node* x = SkNEW(Node);
x->fChildren[kLeft_Child] = NULL;
x->fChildren[kRight_Child] = NULL;
x->fItem = t;
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 633cd23..b82cdb2 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -190,7 +190,7 @@
GrAssert(!fPurging);
GrAutoResourceCacheValidate atcv(this);
- GrResourceEntry* entry = new GrResourceEntry(key, resource);
+ GrResourceEntry* entry = SkNEW_ARGS(GrResourceEntry, (key, resource));
if (lock) {
// mark the entry as "busy" so it doesn't get purged
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 81dc1db..a138857 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -16,7 +16,7 @@
GrAssert(NULL != context);
GrAssert(NULL != context->getGpu());
if (context->getGpu()->getCaps().fPathStencilingSupport) {
- return new GrStencilAndCoverPathRenderer(context->getGpu());
+ return SkNEW_ARGS(GrStencilAndCoverPathRenderer, (context->getGpu()));
} else {
return NULL;
}
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index d642f13..93ef23d 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -209,7 +209,7 @@
}
if (NULL == glyph->fPath) {
- SkPath* path = new SkPath;
+ SkPath* path = SkNEW(SkPath);
if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
// flag the glyph as being dead?
delete path;
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index e61c46e..aebaaf8 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -36,10 +36,11 @@
GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
const Key& key) {
if (NULL == fAtlasMgr) {
- fAtlasMgr = new GrAtlasMgr(fGpu);
+ fAtlasMgr = SkNEW_ARGS(GrAtlasMgr, (fGpu));
}
- GrTextStrike* strike = new GrTextStrike(this, scaler->getKey(),
- scaler->getMaskFormat(), fAtlasMgr);
+ GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
+ (this, scaler->getKey(),
+ scaler->getMaskFormat(), fAtlasMgr));
fCache.insert(key, strike);
if (fHead) {
diff --git a/src/gpu/SkGpuCanvas.cpp b/src/gpu/SkGpuCanvas.cpp
index fa57335..55880a6 100644
--- a/src/gpu/SkGpuCanvas.cpp
+++ b/src/gpu/SkGpuCanvas.cpp
@@ -20,7 +20,7 @@
fContext = context;
fContext->ref();
- this->setDevice(new SkGpuDevice(context, renderTarget))->unref();
+ this->setDevice(SkNEW_ARGS(SkGpuDevice, (context, renderTarget)))->unref();
}
SkGpuCanvas::~SkGpuCanvas() {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 491e273..fc73f0d 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -194,9 +194,9 @@
// are ensuring that both objects will live as long as the pixel ref.
SkPixelRef* pr;
if (fTexture) {
- pr = new SkGrTexturePixelRef(fTexture);
+ pr = SkNEW_ARGS(SkGrTexturePixelRef, (fTexture));
} else {
- pr = new SkGrRenderTargetPixelRef(fRenderTarget);
+ pr = SkNEW_ARGS(SkGrRenderTargetPixelRef, (fRenderTarget));
}
this->setPixelRef(pr, 0)->unref();
}
@@ -237,7 +237,7 @@
GrAssert(NULL != fRenderTarget);
// wrap the bitmap with a pixelref to expose our texture
- SkGrTexturePixelRef* pr = new SkGrTexturePixelRef(fTexture);
+ SkGrTexturePixelRef* pr = SkNEW_ARGS(SkGrTexturePixelRef, (fTexture));
this->setPixelRef(pr, 0)->unref();
} else {
GrPrintf("--- failed to create gpu-offscreen [%d %d]\n",
@@ -533,25 +533,25 @@
GrSamplerState* sampler = grPaint->textureSampler(kShaderTextureIdx);
switch (bmptype) {
case SkShader::kRadial_BitmapType:
- sampler->setCustomStage(new GrRadialGradient())->unref();
+ sampler->setCustomStage(SkNEW(GrRadialGradient))->unref();
sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kSweep_BitmapType:
- sampler->setCustomStage(new GrSweepGradient())->unref();
+ sampler->setCustomStage(SkNEW(GrSweepGradient))->unref();
sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kTwoPointRadial_BitmapType:
- sampler->setCustomStage(new
- GrRadial2Gradient(twoPointParams[0],
- twoPointParams[1],
- twoPointParams[2] < 0))->unref();
+ sampler->setCustomStage(SkNEW_ARGS(GrRadial2Gradient,
+ (twoPointParams[0],
+ twoPointParams[1],
+ twoPointParams[2] < 0)))->unref();
sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kTwoPointConical_BitmapType:
- sampler->setCustomStage(new
- GrConical2Gradient(twoPointParams[0],
- twoPointParams[1],
- twoPointParams[2]))->unref();
+ sampler->setCustomStage(SkNEW_ARGS(GrConical2Gradient,
+ (twoPointParams[0],
+ twoPointParams[1],
+ twoPointParams[2])))->unref();
sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
default:
@@ -1596,7 +1596,8 @@
SkIntToScalar(src.height()));
GrTexture* resultTexture = filter_texture(fContext, texture, filter, rect);
if (resultTexture) {
- result->setPixelRef(new SkGrTexturePixelRef(resultTexture))->unref();
+ result->setPixelRef(SkNEW_ARGS(SkGrTexturePixelRef,
+ (resultTexture)))->unref();
resultTexture->unref();
}
return true;
@@ -1681,7 +1682,7 @@
scaler = (GrFontScaler*)auxData;
}
if (NULL == scaler) {
- scaler = new SkGrFontScaler(cache);
+ scaler = SkNEW_ARGS(SkGrFontScaler, (cache));
cache->setAuxProc(GlyphCacheAuxProc, scaler);
}
return scaler;
@@ -1710,7 +1711,7 @@
// deferred allocation
if (NULL == fDrawProcs) {
- fDrawProcs = new GrSkDrawProcs;
+ fDrawProcs = SkNEW(GrSkDrawProcs);
fDrawProcs->fD1GProc = SkGPU_Draw1Glyph;
fDrawProcs->fContext = fContext;
}
diff --git a/src/gpu/SkGrFontScaler.cpp b/src/gpu/SkGrFontScaler.cpp
index 430b599..26412f4 100644
--- a/src/gpu/SkGrFontScaler.cpp
+++ b/src/gpu/SkGrFontScaler.cpp
@@ -95,7 +95,7 @@
const GrKey* SkGrFontScaler::getKey() {
if (NULL == fKey) {
- fKey = new SkGrDescKey(fStrike->getDescriptor());
+ fKey = SkNEW_ARGS(SkGrDescKey, (fStrike->getDescriptor()));
}
return fKey;
}
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 7280a64..7e0e2cd 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -81,7 +81,7 @@
dst->releaseRenderTarget();
#endif
- SkGrPixelRef* pixelRef = new SkGrPixelRef(dst);
+ SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst));
GrSafeUnref(dst);
return pixelRef;
}
diff --git a/src/gpu/app-android.cpp b/src/gpu/app-android.cpp
index 2dad1f9..56a96a6 100644
--- a/src/gpu/app-android.cpp
+++ b/src/gpu/app-android.cpp
@@ -246,7 +246,7 @@
static State* get_state() {
static State* gState;
if (NULL == gState) {
- gState = new State;
+ gState = SkNEW(State);
}
return gState;
}
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index b9a3c5e..6451fca 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -388,7 +388,7 @@
// interface
static SkAutoTUnref<GrGLInterface> glInterface;
if (!glInterface.get()) {
- GrGLInterface* interface = new GrGLInterface;
+ GrGLInterface* interface = SkNEW(GrGLInterface);
glInterface.reset(interface);
interface->fBindingsExported = kDesktop_GrGLBinding;
interface->fActiveTexture = nullGLActiveTexture;
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 9c6743a..16a5015 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -31,9 +31,10 @@
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
- fTexIDObj = new GrGLTexID(GPUGL->glInterface(),
- textureDesc.fTextureID,
- textureDesc.fOwnsID);
+ fTexIDObj = SkNEW_ARGS(GrGLTexID,
+ (GPUGL->glInterface(),
+ textureDesc.fTextureID,
+ textureDesc.fOwnsID));
fOrientation = textureDesc.fOrientation;
if (NULL != rtDesc) {
@@ -44,7 +45,8 @@
vp.fBottom = 0;
vp.fHeight = textureDesc.fHeight;
- fRenderTarget = new GrGLRenderTarget(gpu, *rtDesc, vp, fTexIDObj, this);
+ fRenderTarget = SkNEW_ARGS(GrGLRenderTarget,
+ (gpu, *rtDesc, vp, fTexIDObj, this));
}
}
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 5baca24..0e2036c 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -176,7 +176,7 @@
this->initCaps();
fProgramData = NULL;
- fProgramCache = new ProgramCache(this->glContextInfo());
+ fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContextInfo()));
fLastSuccessfulStencilFmtIdx = 0;
fCanPreserveUnpremulRoundtrip = kUnknown_CanPreserveUnpremulRoundtrip;
@@ -592,9 +592,9 @@
&glRTDesc)) {
return NULL;
}
- texture = new GrGLTexture(this, glTexDesc, glRTDesc);
+ texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc));
} else {
- texture = new GrGLTexture(this, glTexDesc);
+ texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc));
}
if (NULL == texture) {
return NULL;
@@ -618,19 +618,21 @@
viewport.fWidth = desc.fWidth;
viewport.fHeight = desc.fHeight;
- GrRenderTarget* tgt = new GrGLRenderTarget(this, glDesc, viewport);
+ GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget,
+ (this, glDesc, viewport));
if (desc.fStencilBits) {
GrGLStencilBuffer::Format format;
format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat;
format.fPacked = false;
format.fStencilBits = desc.fStencilBits;
format.fTotalBits = desc.fStencilBits;
- GrGLStencilBuffer* sb = new GrGLStencilBuffer(this,
- 0,
- desc.fWidth,
- desc.fHeight,
- desc.fSampleCnt,
- format);
+ GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer,
+ (this,
+ 0,
+ desc.fWidth,
+ desc.fHeight,
+ desc.fSampleCnt,
+ format));
tgt->setStencilBuffer(sb);
sb->unref();
}
@@ -1106,9 +1108,9 @@
GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID));
return return_null_texture();
}
- tex = new GrGLTexture(this, glTexDesc, glRTDesc);
+ tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc));
} else {
- tex = new GrGLTexture(this, glTexDesc);
+ tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc));
}
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
@@ -1193,8 +1195,9 @@
// whatever sizes GL gives us. In that case we query for the size.
GrGLStencilBuffer::Format format = sFmt;
get_stencil_rb_sizes(this->glInterface(), sbID, &format);
- sb = new GrGLStencilBuffer(this, sbID, width, height,
- samples, format);
+ sb = SkNEW_ARGS(GrGLStencilBuffer,
+ (this, sbID, width, height,
+ samples, format));
if (this->attachStencilBufferToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
rt->setStencilBuffer(sb);
@@ -1295,8 +1298,9 @@
fHWGeometryState.fVertexBuffer = NULL;
return NULL;
}
- GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, id,
- size, dynamic);
+ GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer,
+ (this, id,
+ size, dynamic));
fHWGeometryState.fVertexBuffer = vertexBuffer;
return vertexBuffer;
}
@@ -1322,8 +1326,8 @@
fHWGeometryState.fIndexBuffer = NULL;
return NULL;
}
- GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, id,
- size, dynamic);
+ GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer,
+ (this, id, size, dynamic));
fHWGeometryState.fIndexBuffer = indexBuffer;
return indexBuffer;
}
@@ -1332,7 +1336,7 @@
GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) {
GrAssert(fCaps.fPathStencilingSupport);
- return new GrGLPath(this, inPath);
+ return SkNEW_ARGS(GrGLPath, (this, inPath));
}
void GrGpuGL::flushScissor() {
diff --git a/src/gpu/gl/GrGpuGL_unittest.cpp b/src/gpu/gl/GrGpuGL_unittest.cpp
index 5845919..7f71f48 100644
--- a/src/gpu/gl/GrGpuGL_unittest.cpp
+++ b/src/gpu/gl/GrGpuGL_unittest.cpp
@@ -65,9 +65,10 @@
// does not work with perspective or mul-by-alpha-mask
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
- return new GrConvolutionEffect(gKernelDirections[direction],
- kernelRadius,
- kernel);
+ return SkNEW_ARGS(GrConvolutionEffect,
+ (gKernelDirections[direction],
+ kernelRadius,
+ kernel));
}
case kErode_EffectType: {
int direction = random_int(random, 2);
@@ -75,9 +76,10 @@
// does not work with perspective or mul-by-alpha-mask
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
- return new GrMorphologyEffect(gKernelDirections[direction],
- kernelRadius,
- GrContext::kErode_MorphologyType);
+ return SkNEW_ARGS(GrMorphologyEffect,
+ (gKernelDirections[direction],
+ kernelRadius,
+ GrContext::kErode_MorphologyType));
}
case kDilate_EffectType: {
int direction = random_int(random, 2);
@@ -85,12 +87,13 @@
// does not work with perspective or mul-by-alpha-mask
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
- return new GrMorphologyEffect(gKernelDirections[direction],
- kernelRadius,
- GrContext::kDilate_MorphologyType);
+ return SkNEW_ARGS(GrMorphologyEffect,
+ (gKernelDirections[direction],
+ kernelRadius,
+ GrContext::kDilate_MorphologyType));
}
case kRadialGradient_EffectType: {
- return new GrRadialGradient();
+ return SkNEW(GrRadialGradient);
}
case kRadial2Gradient_EffectType: {
float center;
@@ -99,10 +102,10 @@
} while (GR_Scalar1 == center);
float radius = random->nextF();
bool root = random_bool(random);
- return new GrRadial2Gradient(center, radius, root);
+ return SkNEW_ARGS(GrRadial2Gradient, (center, radius, root));
}
case kSweepGradient_EffectType: {
- return new GrSweepGradient();
+ return SkNEW(GrSweepGradient);
}
default:
GrCrash("Unexpected custom effect type");
diff --git a/src/gpu/gr_hello_world.cpp b/src/gpu/gr_hello_world.cpp
index b19f9b4..e9e8f8d 100644
--- a/src/gpu/gr_hello_world.cpp
+++ b/src/gpu/gr_hello_world.cpp
@@ -17,7 +17,7 @@
void gr_hello_world() {
static GrGpu* gGpu;
if (NULL == gGpu) {
- gGpu = new SkGpuGLShaders;
+ gGpu = SkNEW(SkGpuGLShaders);
}
SkGLCanvas canvas(gGpu);