diff options
30 files changed, 126 insertions, 109 deletions
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h index 8d52f70012..90caf7f6c3 100644 --- a/include/core/SkPostConfig.h +++ b/include/core/SkPostConfig.h @@ -85,6 +85,9 @@ #define SkNEW(type_name) new type_name #define SkNEW_ARGS(type_name, args) new type_name args #define SkNEW_ARRAY(type_name, count) new type_name[count] + #define SkNEW_PLACEMENT(buf, type_name) new (buf) type_name + #define SkNEW_PLACEMENT_ARGS(buf, type_name, args) \ + new (buf) type_name args #define SkDELETE(obj) delete obj #define SkDELETE_ARRAY(array) delete[] array #endif diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h index 0a662745af..65bf597aa9 100644 --- a/include/gpu/GrContextFactory.h +++ b/include/gpu/GrContextFactory.h @@ -68,23 +68,23 @@ public: SkAutoTUnref<GrContext> grCtx; switch (type) { case kNative_GLContextType: - glCtx.reset(new SkNativeGLContext()); + glCtx.reset(SkNEW(SkNativeGLContext)); break; #ifdef SK_ANGLE case kANGLE_GLContextType: - glCtx.reset(new SkANGLEGLContext()); + glCtx.reset(SkNEW(SkANGLEGLContext)); break; #endif #ifdef SK_MESA case kMESA_GLContextType: - glCtx.reset(new SkMesaGLContext()); + glCtx.reset(SkNEW(SkMesaGLContext)); break; #endif case kNull_GLContextType: - glCtx.reset(new SkNullGLContext()); + glCtx.reset(SkNEW(SkNullGLContext)); break; case kDebug_GLContextType: - glCtx.reset(new SkDebugGLContext()); + glCtx.reset(SkNEW(SkDebugGLContext)); break; } static const int kBogusSize = 1; diff --git a/include/gpu/GrProgramStageFactory.h b/include/gpu/GrProgramStageFactory.h index c01b3f08a0..d133beb9fc 100644 --- a/include/gpu/GrProgramStageFactory.h +++ b/include/gpu/GrProgramStageFactory.h @@ -95,7 +95,7 @@ public: the object. */ virtual GLProgramStage* createGLInstance( const GrCustomStage& stage) const SK_OVERRIDE { - return new GLProgramStage(*this, stage); + return SkNEW_ARGS(GLProgramStage, (*this, stage)); } /** This class is a singleton. This function returns the single instance. @@ -104,7 +104,8 @@ public: static SkAlignedSTStorage<1, GrTProgramStageFactory> gInstanceMem; static const GrTProgramStageFactory* gInstance; if (!gInstance) { - gInstance = new (gInstanceMem.get()) GrTProgramStageFactory(); + gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), + GrTProgramStageFactory); } return *gInstance; } diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index 2b8c7c17e5..8aed4b03db 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -35,7 +35,7 @@ bool push_quad_index_data(GrIndexBuffer* qIdxBuffer) { 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 @@ GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) { !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 32b2a07e2c..24f10171e7 100644 --- a/src/gpu/GrAddPathRenderers_default.cpp +++ b/src/gpu/GrAddPathRenderers_default.cpp @@ -23,6 +23,6 @@ void GrPathRenderer::AddPathRenderers(GrContext* ctx, 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 f333d42e37..ae456cd170 100755 --- a/src/gpu/GrAllocator.h +++ b/src/gpu/GrAllocator.h @@ -163,14 +163,14 @@ public: 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 fb127194a5..2b76d13048 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -131,7 +131,7 @@ GrAtlasMgr::GrAtlasMgr(GrGpu* gpu) { 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* GrAtlasMgr::addToAtlas(GrAtlas* atlas, } } - 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 bb597ba63f..810618522b 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -38,7 +38,7 @@ public: , 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 @@ public: * 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 6326f4d24e..f79249cf84 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -66,7 +66,7 @@ GrContext* GrContext::Create(GrEngine engine, 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 @@ GrContext* GrContext::Create(GrEngine engine, 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 @@ void apply_morphology(GrGpu* gpu, 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 @@ void convolve_gaussian(GrGpu* gpu, 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 @@ GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, 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 @@ GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, if (NULL == pr && allowSW) { if (NULL == fSoftwarePathRenderer) { - fSoftwarePathRenderer = new GrSoftwarePathRenderer(this); + fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); } pr = fSoftwarePathRenderer; @@ -1751,15 +1752,16 @@ GrContext::GrContext(GrGpu* gpu) { 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 @@ GrContext::GrContext(GrGpu* gpu) { fDrawBufferVBAllocPool = NULL; fDrawBufferIBAllocPool = NULL; - fAARectRenderer = new GrAARectRenderer; + fAARectRenderer = SkNEW(GrAARectRenderer); this->setupDrawBuffer(); } @@ -1780,17 +1782,17 @@ void GrContext::setupDrawBuffer() { #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 71e341b318..0385b25285 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -466,9 +466,9 @@ void GrGpu::finalizeReservedIndices() { 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::prepareVertexPool() { 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 4a9bcf6ad2..0d4c3814dd 100644 --- a/src/gpu/GrGpuFactory.cpp +++ b/src/gpu/GrGpuFactory.cpp @@ -36,7 +36,7 @@ GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) { } 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 648225e567..038f83697a 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -54,6 +54,7 @@ void GrPathRendererChain::init() { 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 0e631a9ade..38589f361c 100644 --- a/src/gpu/GrPlotMgr.h +++ b/src/gpu/GrPlotMgr.h @@ -22,7 +22,7 @@ public: 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 628b89074c..8df3b05121 100644 --- a/src/gpu/GrRectanizer.cpp +++ b/src/gpu/GrRectanizer.cpp @@ -117,7 +117,7 @@ bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) { /////////////////////////////////////////////////////////////////////////////// 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 3bfc46f4a3..0f412b83fa 100644 --- a/src/gpu/GrRectanizer_fifo.cpp +++ b/src/gpu/GrRectanizer_fifo.cpp @@ -117,7 +117,7 @@ bool GrRectanizerFIFO::addRect(int width, int height, GrIPoint16* loc) { /////////////////////////////////////////////////////////////////////////////// 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 da5ae3e3b2..8187d8160d 100644 --- a/src/gpu/GrRedBlackTree.h +++ b/src/gpu/GrRedBlackTree.h @@ -343,7 +343,7 @@ typename GrRedBlackTree<T,C>::Iter GrRedBlackTree<T,C>::insert(const T& t) { ++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 633cd23222..b82cdb2d4b 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -190,7 +190,7 @@ GrResourceEntry* GrResourceCache::create(const GrResourceKey& key, 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 81dc1db00a..a1388573ac 100644 --- a/src/gpu/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp @@ -16,7 +16,7 @@ GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrContext* context) { 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 d642f13d84..93ef23d9e1 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -209,7 +209,7 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, } 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 e61c46e3b8..aebaaf81b7 100644 --- a/src/gpu/GrTextStrike.cpp +++ b/src/gpu/GrTextStrike.cpp @@ -36,10 +36,11 @@ GrFontCache::~GrFontCache() { 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 fa573354c0..55880a6cf3 100644 --- a/src/gpu/SkGpuCanvas.cpp +++ b/src/gpu/SkGpuCanvas.cpp @@ -20,7 +20,7 @@ SkGpuCanvas::SkGpuCanvas(GrContext* context, GrRenderTarget* renderTarget) { 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 491e273216..fc73f0d020 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -194,9 +194,9 @@ void SkGpuDevice::initFromRenderTarget(GrContext* context, // 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 @@ SkGpuDevice::SkGpuDevice(GrContext* context, 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 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev, 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 @@ bool SkGpuDevice::filterImage(SkImageFilter* filter, const SkBitmap& src, 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 @@ static GrFontScaler* get_gr_font_scaler(SkGlyphCache* cache) { 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 @@ SkDrawProcs* SkGpuDevice::initDrawForText(GrTextContext* context) { // 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 430b5993eb..26412f4a35 100644 --- a/src/gpu/SkGrFontScaler.cpp +++ b/src/gpu/SkGrFontScaler.cpp @@ -95,7 +95,7 @@ GrMaskFormat SkGrFontScaler::getMaskFormat() { 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 7280a6411a..7e0e2cdceb 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -81,7 +81,7 @@ static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, 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 2dad1f902e..56a96a66c6 100644 --- a/src/gpu/app-android.cpp +++ b/src/gpu/app-android.cpp @@ -246,7 +246,7 @@ void State::applyMatrix(SkCanvas* canvas) { 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 b9a3c5ea24..6451fcafe9 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -388,7 +388,7 @@ const GrGLInterface* GrGLCreateNullInterface() { // 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 9c6743a3b8..16a50159a7 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -31,9 +31,10 @@ void GrGLTexture::init(GrGpuGL* gpu, 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 @@ void GrGLTexture::init(GrGpuGL* gpu, 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 5baca24a37..0e2036ced0 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -176,7 +176,7 @@ GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo) : fGLContextInfo(ctxInfo) { this->initCaps(); fProgramData = NULL; - fProgramCache = new ProgramCache(this->glContextInfo()); + fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContextInfo())); fLastSuccessfulStencilFmtIdx = 0; fCanPreserveUnpremulRoundtrip = kUnknown_CanPreserveUnpremulRoundtrip; @@ -592,9 +592,9 @@ GrTexture* GrGpuGL::onCreatePlatformTexture(const GrPlatformTextureDesc& desc) { &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 @@ GrRenderTarget* GrGpuGL::onCreatePlatformRenderTarget(const GrPlatformRenderTarg 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 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, 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 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, // 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 @@ GrVertexBuffer* GrGpuGL::onCreateVertexBuffer(uint32_t size, bool dynamic) { 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 @@ GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(uint32_t size, bool dynamic) { 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 @@ GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(uint32_t size, bool dynamic) { 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 5845919f49..7f71f48203 100644 --- a/src/gpu/gl/GrGpuGL_unittest.cpp +++ b/src/gpu/gl/GrGpuGL_unittest.cpp @@ -65,9 +65,10 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc, // 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 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc, // 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 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc, // 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 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc, } 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 b19f9b4164..e9e8f8dfd0 100644 --- a/src/gpu/gr_hello_world.cpp +++ b/src/gpu/gr_hello_world.cpp @@ -17,7 +17,7 @@ extern "C" { void gr_hello_world() { static GrGpu* gGpu; if (NULL == gGpu) { - gGpu = new SkGpuGLShaders; + gGpu = SkNEW(SkGpuGLShaders); } SkGLCanvas canvas(gGpu); |