aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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 /include
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 'include')
-rw-r--r--include/core/SkPostConfig.h3
-rw-r--r--include/gpu/GrContextFactory.h10
-rw-r--r--include/gpu/GrProgramStageFactory.h5
3 files changed, 11 insertions, 7 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;
}