aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-09 20:17:56 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-09 20:17:56 +0000
commitc377baf406996aed18d82d328029c82dbc3b8dda (patch)
tree215bc5ea788578b459423064e4ab17513a82c91d /src/gpu/gl
parent70b4222344fc290ba03922ce246da2b3e980071d (diff)
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
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCreateNullInterface.cpp2
-rw-r--r--src/gpu/gl/GrGLTexture.cpp10
-rw-r--r--src/gpu/gl/GrGpuGL.cpp42
-rw-r--r--src/gpu/gl/GrGpuGL_unittest.cpp27
4 files changed, 45 insertions, 36 deletions
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");