Remove overly complicated GR_CREATE_STATIC_PROCESSOR macro
This macro was responsible for producing code like: static SkAlignedStorage<sizeof(Foo)> g_gFoo_Storage; static Foo* gFoo = new(g_gFoo_Storage.get()) Foo; static SkAutoTDestroy<Foo> gFoo_ad(gFoo); which would allocate static storage for an object of type Foo (g_gFoo_Storage), lazily instantiate the object in that memory (via gFoo's initializer), and then ensure that at global destruction time the object is destroyed (via gFoo_Ad's destructor). However, the exact same effect is achieved by just writing: static Foo gFoo; Review URL: https://codereview.chromium.org/1314763009
This commit is contained in:
parent
6904d1d3f1
commit
38f1f6f9e5
@ -52,8 +52,7 @@ private:
|
||||
immutable: after being constructed, their fields may not change.
|
||||
|
||||
Dynamically allocated GrProcessors are managed by a per-thread memory pool. The ref count of an
|
||||
processor must reach 0 before the thread terminates and the pool is destroyed. To create a
|
||||
static processor use the helper macro GR_CREATE_STATIC_PROCESSOR declared below.
|
||||
processor must reach 0 before the thread terminates and the pool is destroyed.
|
||||
*/
|
||||
class GrProcessor : public GrProgramElement {
|
||||
public:
|
||||
@ -143,13 +142,4 @@ private:
|
||||
typedef GrProgramElement INHERITED;
|
||||
};
|
||||
|
||||
/**
|
||||
* This creates a processor outside of the memory pool. The processor's destructor will be called
|
||||
* at global destruction time. NAME will be the name of the created instance.
|
||||
*/
|
||||
#define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \
|
||||
static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \
|
||||
static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLASS, ARGS); \
|
||||
static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME);
|
||||
|
||||
#endif
|
||||
|
@ -55,8 +55,8 @@ void SkLumaColorFilter::toString(SkString* str) const {
|
||||
class LumaColorFilterEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
GR_CREATE_STATIC_PROCESSOR(gLumaEffect, LumaColorFilterEffect, ());
|
||||
return SkRef(gLumaEffect);
|
||||
static LumaColorFilterEffect gLumaEffect;
|
||||
return SkRef(&gLumaEffect);
|
||||
}
|
||||
|
||||
const char* name() const override { return "Luminance-to-Alpha"; }
|
||||
|
@ -17,8 +17,8 @@
|
||||
class DitherEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
GR_CREATE_STATIC_PROCESSOR(gDitherEffect, DitherEffect, ())
|
||||
return SkRef(gDitherEffect);
|
||||
static DitherEffect gDitherEffect;
|
||||
return SkRef(&gDitherEffect);
|
||||
}
|
||||
|
||||
virtual ~DitherEffect() {};
|
||||
|
@ -62,8 +62,8 @@ private:
|
||||
class BigKeyProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create() {
|
||||
GR_CREATE_STATIC_PROCESSOR(gBigKeyProcessor, BigKeyProcessor, ())
|
||||
return SkRef(gBigKeyProcessor);
|
||||
static BigKeyProcessor gBigKeyProcessor;
|
||||
return SkRef(&gBigKeyProcessor);
|
||||
}
|
||||
|
||||
const char* name() const override { return "Big Ole Key"; }
|
||||
|
Loading…
Reference in New Issue
Block a user