Chromium Code Reviews| Index: include/core/SkFlattenable.h |
| diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h |
| index 58e69fd416cb049b56d881942f6f77ebb676e93d..e743762abb3cedb988195d3cbe050fe25964278f 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()); |
|
mtklein
2013/10/16 18:54:09
Sadly this has wrapped to 102 columns.
sugoi1
2013/10/16 20:07:41
Noooooo ! Fixed
|
| #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables(); |
| @@ -35,6 +35,27 @@ 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 { |
| + 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 +76,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 bool NameToType(const char name[], SkEffectType& type); |
| + |
| + 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 +102,7 @@ protected: |
| virtual void flatten(SkFlattenableWriteBuffer&) const; |
| private: |
| - static void InitializeFlattenables(); |
| + static void InitializeFlattenablesIfNeeded(); |
| friend class SkGraphics; |
| friend class SkFlattenableWriteBuffer; |