| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkFlattenable_DEFINED | 10 #ifndef SkFlattenable_DEFINED |
| 11 #define SkFlattenable_DEFINED | 11 #define SkFlattenable_DEFINED |
| 12 | 12 |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 | 14 |
| 15 class SkFlattenableReadBuffer; | 15 class SkFlattenableReadBuffer; |
| 16 class SkFlattenableWriteBuffer; | 16 class SkFlattenableWriteBuffer; |
| 17 | 17 |
| 18 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ | 18 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
| 19 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc); | 19 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc); |
| 20 | 20 |
| 21 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); | 21 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); |
| 22 | 22 |
| 23 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ | 23 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ |
| 24 void flattenable::InitializeFlattenables() { | 24 void flattenable::InitializeFlattenables() { |
| 25 | 25 |
| 26 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ | 26 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ |
| 27 } | 27 } |
| 28 | 28 |
| 29 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ | 29 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ |
| 30 virtual Factory getFactory() SK_OVERRIDE { return NULL; } | 30 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } |
| 31 | 31 |
| 32 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ | 32 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ |
| 33 virtual Factory getFactory() SK_OVERRIDE { return CreateProc; } \ | 33 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \ |
| 34 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { \ | 34 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { \ |
| 35 return SkNEW_ARGS(flattenable, (buffer)); \ | 35 return SkNEW_ARGS(flattenable, (buffer)); \ |
| 36 } | 36 } |
| 37 | 37 |
| 38 /** \class SkFlattenable | 38 /** \class SkFlattenable |
| 39 | 39 |
| 40 SkFlattenable is the base class for objects that need to be flattened | 40 SkFlattenable is the base class for objects that need to be flattened |
| 41 into a data stream for either transport or as part of the key to the | 41 into a data stream for either transport or as part of the key to the |
| 42 font cache. | 42 font cache. |
| 43 */ | 43 */ |
| 44 class SK_API SkFlattenable : public SkRefCnt { | 44 class SK_API SkFlattenable : public SkRefCnt { |
| 45 public: | 45 public: |
| 46 SK_DECLARE_INST_COUNT(SkFlattenable) | 46 SK_DECLARE_INST_COUNT(SkFlattenable) |
| 47 | 47 |
| 48 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); | 48 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); |
| 49 | 49 |
| 50 SkFlattenable() {} | 50 SkFlattenable() {} |
| 51 | 51 |
| 52 /** Implement this to return a factory function pointer that can be called | 52 /** Implement this to return a factory function pointer that can be called |
| 53 to recreate your class given a buffer (previously written to by your | 53 to recreate your class given a buffer (previously written to by your |
| 54 override of flatten(). | 54 override of flatten(). |
| 55 */ | 55 */ |
| 56 virtual Factory getFactory() = 0; | 56 virtual Factory getFactory() const = 0; |
| 57 | 57 |
| 58 static Factory NameToFactory(const char name[]); | 58 static Factory NameToFactory(const char name[]); |
| 59 static const char* FactoryToName(Factory); | 59 static const char* FactoryToName(Factory); |
| 60 static void Register(const char name[], Factory); | 60 static void Register(const char name[], Factory); |
| 61 | 61 |
| 62 class Registrar { | 62 class Registrar { |
| 63 public: | 63 public: |
| 64 Registrar(const char name[], Factory factory) { | 64 Registrar(const char name[], Factory factory) { |
| 65 SkFlattenable::Register(name, factory); | 65 SkFlattenable::Register(name, factory); |
| 66 } | 66 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 77 private: | 77 private: |
| 78 static void InitializeFlattenables(); | 78 static void InitializeFlattenables(); |
| 79 | 79 |
| 80 friend class SkGraphics; | 80 friend class SkGraphics; |
| 81 friend class SkFlattenableWriteBuffer; | 81 friend class SkFlattenableWriteBuffer; |
| 82 | 82 |
| 83 typedef SkRefCnt INHERITED; | 83 typedef SkRefCnt INHERITED; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 #endif | 86 #endif |
| OLD | NEW |