aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkColorFilter.h3
-rw-r--r--include/core/SkFlattenable.h39
-rw-r--r--include/core/SkGraphics.h8
-rw-r--r--include/core/SkMallocPixelRef.h1
-rw-r--r--include/core/SkPathEffect.h1
-rw-r--r--include/core/SkPixelRef.h23
-rw-r--r--include/core/SkPostConfig.h5
-rw-r--r--include/core/SkShape.h2
-rw-r--r--include/core/SkXfermode.h1
-rw-r--r--include/effects/Sk1DPathEffect.h2
-rw-r--r--include/effects/Sk2DPathEffect.h4
-rw-r--r--include/effects/SkAvoidXfermode.h2
-rw-r--r--include/effects/SkBlurDrawLooper.h1
-rw-r--r--include/effects/SkBlurImageFilter.h3
-rw-r--r--include/effects/SkBlurMaskFilter.h2
-rw-r--r--include/effects/SkColorMatrixFilter.h2
-rw-r--r--include/effects/SkCornerPathEffect.h2
-rw-r--r--include/effects/SkDashPathEffect.h2
-rw-r--r--include/effects/SkDiscretePathEffect.h2
-rw-r--r--include/effects/SkEffects.h16
-rw-r--r--include/effects/SkEmbossMaskFilter.h2
-rw-r--r--include/effects/SkGradientShader.h2
-rw-r--r--include/effects/SkGroupShape.h2
-rw-r--r--include/effects/SkLayerDrawLooper.h2
-rw-r--r--include/effects/SkLayerRasterizer.h2
-rw-r--r--include/effects/SkPixelXorXfermode.h2
-rw-r--r--include/effects/SkRectShape.h2
-rw-r--r--include/images/SkFlipPixelRef.h4
-rw-r--r--include/images/SkImageRef_GlobalPool.h2
29 files changed, 138 insertions, 3 deletions
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 3b9bb4d643..e346996832 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -92,7 +92,8 @@ public:
are ignored.
*/
static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
-
+
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
protected:
SkColorFilter() {}
SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {}
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index af6a636bc4..99127afab7 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -20,6 +20,40 @@ class SkFlattenableReadBuffer;
class SkFlattenableWriteBuffer;
class SkString;
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+
+#define SK_DECLARE_FLATTENABLE_REGISTRAR()
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) \
+ static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \
+ flattenable::CreateProc);
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable)
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
+ static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \
+ flattenable::CreateProc);
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
+
+#else
+
+#define SK_DECLARE_FLATTENABLE_REGISTRAR() static void Init();
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) \
+ void flattenable::Init() { \
+ SkFlattenable::Registrar(#flattenable, CreateProc); \
+ }
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \
+ void flattenable::Init() {
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
+ SkFlattenable::Registrar(#flattenable, flattenable::CreateProc);
+
+#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
+ }
+
+#endif
+
/** \class SkFlattenable
SkFlattenable is the base class for objects that need to be flattened
@@ -61,6 +95,11 @@ public:
protected:
SkFlattenable(SkFlattenableReadBuffer&) {}
+
+private:
+#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+ static void InitializeFlattenables();
+#endif
};
// helpers for matrix and region
diff --git a/include/core/SkGraphics.h b/include/core/SkGraphics.h
index b41da327cf..90c92e3219 100644
--- a/include/core/SkGraphics.h
+++ b/include/core/SkGraphics.h
@@ -14,7 +14,13 @@
class SkGraphics {
public:
+ /**
+ * Call this at process initialization time if your environment does not
+ * permit static global initializers that execute code. Note that
+ * Init() is not thread-safe.
+ */
static void Init();
+
static void Term();
/**
@@ -55,7 +61,7 @@ public:
* This format is subject to change.
*/
static void SetFlags(const char* flags);
-
+
private:
/** This is automatically called by SkGraphics::Init(), and must be
implemented by the host OS. This allows the host OS to register a callback
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index a0abe2089b..903bad334d 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -37,6 +37,7 @@ public:
return SkNEW_ARGS(SkMallocPixelRef, (buffer));
}
+ SK_DECLARE_PIXEL_REF_REGISTRAR()
protected:
// overrides from SkPixelRef
virtual void* onLockPixels(SkColorTable**);
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index 880219fead..1b4cd5f522 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -34,6 +34,7 @@ public:
*/
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width) = 0;
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
private:
// illegal
SkPathEffect(const SkPathEffect&);
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 374868e99e..3a64393eb0 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -23,6 +23,25 @@ class SkFlattenableWriteBuffer;
// this is an opaque class, not interpreted by skia
class SkGpuTexture;
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+
+#define SK_DECLARE_PIXEL_REF_REGISTRAR()
+
+#define SK_DEFINE_PIXEL_REF_REGISTRAR(pixelRef) \
+ static SkPixelRef::Registrar g##pixelRef##Reg(#pixelRef, \
+ pixelRef::Create);
+
+#else
+
+#define SK_DECLARE_PIXEL_REF_REGISTRAR() static void Init();
+
+#define SK_DEFINE_PIXEL_REF_REGISTRAR(pixelRef) \
+ void pixelRef::Init() { \
+ SkPixelRef::Registrar(#pixelRef, Create); \
+ }
+
+#endif
+
/** \class SkPixelRef
This class is the smart container for pixel memory, and is used with
@@ -187,6 +206,10 @@ protected:
SkPixelRef(SkFlattenableReadBuffer&, SkMutex*);
private:
+#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+ static void InitializeFlattenables();
+#endif
+
SkMutex* fMutex; // must remain in scope for the life of this object
void* fPixels;
SkColorTable* fColorTable; // we do not track ownership, subclass does
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index 4433dfca40..edce334259 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -291,3 +291,8 @@
#endif
#endif
+//////////////////////////////////////////////////////////////////////
+
+#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
+#endif
diff --git a/include/core/SkShape.h b/include/core/SkShape.h
index b40d886083..c7cf9ec3cf 100644
--- a/include/core/SkShape.h
+++ b/include/core/SkShape.h
@@ -38,6 +38,8 @@ public:
// public for Registrar
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
virtual void onDraw(SkCanvas*);
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 8295f17ea1..0d1c207b68 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -172,6 +172,7 @@ public:
return AsMode(xfer, mode);
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
protected:
SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {}
diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h
index 51a5a78686..814e547153 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -63,6 +63,8 @@ public:
return SkNEW_ARGS(SkPath1DPathEffect, (buffer));
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkPath1DPathEffect(SkFlattenableReadBuffer& buffer);
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index f0d60ca578..b5d7fbb1b8 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -47,6 +47,8 @@ protected:
// protected so that subclasses can call this during unflattening
Sk2DPathEffect(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
private:
SkMatrix fMatrix, fInverse;
// illegal
@@ -69,6 +71,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h
index 8497265ded..398eaeaf29 100644
--- a/include/effects/SkAvoidXfermode.h
+++ b/include/effects/SkAvoidXfermode.h
@@ -59,6 +59,8 @@ public:
return SkNEW_ARGS(SkAvoidXfermode, (buffer));
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkAvoidXfermode(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h
index 1cfb68c523..be1a78edd5 100644
--- a/include/effects/SkBlurDrawLooper.h
+++ b/include/effects/SkBlurDrawLooper.h
@@ -48,6 +48,7 @@ public:
return SkNEW_ARGS(SkBlurDrawLooper, (buffer));
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
protected:
SkBlurDrawLooper(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h
index c9ef882c69..55cef652bf 100644
--- a/include/effects/SkBlurImageFilter.h
+++ b/include/effects/SkBlurImageFilter.h
@@ -18,6 +18,9 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkBlurImageFilter, (buffer));
}
+
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
explicit SkBlurImageFilter(SkFlattenableReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer& buffer);
diff --git a/include/effects/SkBlurMaskFilter.h b/include/effects/SkBlurMaskFilter.h
index 8128ad9ab4..9e85d877a5 100644
--- a/include/effects/SkBlurMaskFilter.h
+++ b/include/effects/SkBlurMaskFilter.h
@@ -55,6 +55,8 @@ public:
SkScalar ambient, SkScalar specular,
SkScalar blurRadius);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
private:
SkBlurMaskFilter(); // can't be instantiated
};
diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h
index 87d1a8b7a8..32ae7dfd37 100644
--- a/include/effects/SkColorMatrixFilter.h
+++ b/include/effects/SkColorMatrixFilter.h
@@ -38,6 +38,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
// overrides for SkFlattenable
virtual Factory getFactory();
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index b4d7f860f5..990bad0ee3 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -37,6 +37,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkCornerPathEffect(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index 29a6d1b59a..6d34910b8b 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -39,6 +39,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkDashPathEffect(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h
index 02ef391086..5369ddbe33 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -36,6 +36,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkDiscretePathEffect(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkEffects.h b/include/effects/SkEffects.h
new file mode 100644
index 0000000000..04091de85b
--- /dev/null
+++ b/include/effects/SkEffects.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkEffects_DEFINED
+#define SkEffects_DEFINED
+
+class SkEffects {
+public:
+ static void Init();
+};
+
+#endif
diff --git a/include/effects/SkEmbossMaskFilter.h b/include/effects/SkEmbossMaskFilter.h
index c0e6b7e1a1..257e19ac78 100644
--- a/include/effects/SkEmbossMaskFilter.h
+++ b/include/effects/SkEmbossMaskFilter.h
@@ -41,6 +41,8 @@ public:
// This method is not exported to java.
virtual void flatten(SkFlattenableWriteBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkEmbossMaskFilter(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkGradientShader.h b/include/effects/SkGradientShader.h
index bb0fb23bf8..3232703c92 100644
--- a/include/effects/SkGradientShader.h
+++ b/include/effects/SkGradientShader.h
@@ -112,6 +112,8 @@ public:
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
const SkColor colors[], const SkScalar pos[],
int count, SkUnitMapper* mapper = NULL);
+
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
};
#endif
diff --git a/include/effects/SkGroupShape.h b/include/effects/SkGroupShape.h
index 76dd13d696..7764003c87 100644
--- a/include/effects/SkGroupShape.h
+++ b/include/effects/SkGroupShape.h
@@ -138,6 +138,8 @@ public:
// public for Registrar
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
// overrides
virtual void onDraw(SkCanvas*);
diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h
index b9b080232d..697d7b2f56 100644
--- a/include/effects/SkLayerDrawLooper.h
+++ b/include/effects/SkLayerDrawLooper.h
@@ -106,6 +106,8 @@ public:
return SkNEW_ARGS(SkLayerDrawLooper, (buffer));
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkLayerDrawLooper(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkLayerRasterizer.h b/include/effects/SkLayerRasterizer.h
index 50758b16dc..91deb61ff6 100644
--- a/include/effects/SkLayerRasterizer.h
+++ b/include/effects/SkLayerRasterizer.h
@@ -38,6 +38,8 @@ public:
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkLayerRasterizer(SkFlattenableReadBuffer&);
diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h
index b9975cffa5..a7197abe9a 100644
--- a/include/effects/SkPixelXorXfermode.h
+++ b/include/effects/SkPixelXorXfermode.h
@@ -29,6 +29,8 @@ public:
return SkNEW_ARGS(SkPixelXorXfermode, (buffer));
}
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
// override from SkXfermode
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst);
diff --git a/include/effects/SkRectShape.h b/include/effects/SkRectShape.h
index b521846ad5..519398c460 100644
--- a/include/effects/SkRectShape.h
+++ b/include/effects/SkRectShape.h
@@ -47,6 +47,8 @@ public:
// public for Registrar
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+ SK_DECLARE_FLATTENABLE_REGISTRAR()
+
protected:
SkRectShape(SkFlattenableReadBuffer&);
diff --git a/include/images/SkFlipPixelRef.h b/include/images/SkFlipPixelRef.h
index e82c713a31..455a3dace3 100644
--- a/include/images/SkFlipPixelRef.h
+++ b/include/images/SkFlipPixelRef.h
@@ -56,7 +56,9 @@ public:
virtual Factory getFactory() const { return Create; }
virtual void flatten(SkFlattenableWriteBuffer&) const;
static SkPixelRef* Create(SkFlattenableReadBuffer& buffer);
-
+
+ SK_DECLARE_PIXEL_REF_REGISTRAR()
+
protected:
virtual void* onLockPixels(SkColorTable**);
virtual void onUnlockPixels();
diff --git a/include/images/SkImageRef_GlobalPool.h b/include/images/SkImageRef_GlobalPool.h
index ce573194f1..909ee71050 100644
--- a/include/images/SkImageRef_GlobalPool.h
+++ b/include/images/SkImageRef_GlobalPool.h
@@ -23,6 +23,8 @@ public:
return Create;
}
static SkPixelRef* Create(SkFlattenableReadBuffer&);
+
+ SK_DECLARE_PIXEL_REF_REGISTRAR()
// API to control the global pool