Chromium Code Reviews| Index: include/core/SkFlattenable.h |
| diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h |
| index 58e69fd416cb049b56d881942f6f77ebb676e93d..f398c81249507211605148ec8d060a16496f6f12 100644 |
| --- a/include/core/SkFlattenable.h |
| +++ b/include/core/SkFlattenable.h |
| @@ -16,7 +16,7 @@ class SkFlattenableReadBuffer; |
| class SkFlattenableWriteBuffer; |
| #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
| - SkFlattenable::Registrar(#flattenable, flattenable::CreateProc); |
| + SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, flattenable::GetEffectType()); |
| #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables(); |
| @@ -35,6 +35,28 @@ class SkFlattenableWriteBuffer; |
| return SkNEW_ARGS(flattenable, (buffer)); \ |
| } |
| +/** For SkFlattenable derived objects with a valid type |
| + This macro should only be used in base class objects in core |
| + */ |
| +#define SK_DEFINE_FLATTENABLE_EFFECT_TYPE(flattenable) \ |
| + static SkEffectType GetEffectType() { \ |
| + return k##flattenable##_SkEffectType; \ |
| + } |
| + |
| +enum SkEffectType { |
|
sugoi1
2013/10/16 15:05:32
I need this here for NameToType(), and so that all
|
| + kInvalid_SkEffectType, |
|
reed1
2013/10/16 15:20:20
Hmmm, that might be the right way. I think sometim
sugoi1
2013/10/16 15:36:26
Done.
|
| + kColorFilter_SkEffectType, |
| + kDrawLooper_SkEffectType, |
| + kImageFilter_SkEffectType, |
| + kMaskFilter_SkEffectType, |
| + kPathEffect_SkEffectType, |
| + kPixelRef_SkEffectType, |
| + kRasterizer_SkEffectType, |
| + kShader_SkEffectType, |
| + kUnitMapper_SkEffectType, |
| + kXfermode_SkEffectType, |
| +}; |
| + |
| /** \class SkFlattenable |
| SkFlattenable is the base class for objects that need to be flattened |
| @@ -55,14 +77,20 @@ public: |
| */ |
| virtual Factory getFactory() = 0; |
| + /** Returns the name of the object's class |
| + */ |
| + const char* getTypeName() { return FactoryToName(getFactory()); } |
| + |
| static Factory NameToFactory(const char name[]); |
| static const char* FactoryToName(Factory); |
| - static void Register(const char name[], Factory); |
| + static SkEffectType NameToType(const char name[]); |
| + |
| + static void Register(const char name[], Factory, SkEffectType); |
| class Registrar { |
| public: |
| - Registrar(const char name[], Factory factory) { |
| - SkFlattenable::Register(name, factory); |
| + Registrar(const char name[], Factory factory, SkEffectType type) { |
| + SkFlattenable::Register(name, factory, type); |
| } |
| }; |
| @@ -75,7 +103,7 @@ protected: |
| virtual void flatten(SkFlattenableWriteBuffer&) const; |
| private: |
| - static void InitializeFlattenables(); |
| + static void InitializeFlattenablesIfNeeded(); |
| friend class SkGraphics; |
| friend class SkFlattenableWriteBuffer; |