Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: include/core/SkFlattenable.h

Issue 1853383002: Revert of Delete SkFlattenable::Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkDrawLooper.h ('k') | include/core/SkFlattenableSerialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkFlattenable_DEFINED 8 #ifndef SkFlattenable_DEFINED
9 #define SkFlattenable_DEFINED 9 #define SkFlattenable_DEFINED
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab les(); 37 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab les();
38 38
39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ 39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \
40 void flattenable::InitializeFlattenables() { 40 void flattenable::InitializeFlattenables() {
41 41
42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ 42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
43 } 43 }
44 44
45 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ 45 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
46 SkFlattenable::Register(#flattenable, flattenable::CreateProc); 46 SkFlattenable::Register(#flattenable, flattenable::CreateProc, \
47 flattenable::GetFlattenableType());
47 48
48 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ 49 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
49 private: \ 50 private: \
50 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \ 51 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
51 friend class SkFlattenable::PrivateInitializer; \ 52 friend class SkFlattenable::PrivateInitializer; \
52 public: \ 53 public: \
53 Factory getFactory() const override { return CreateProc; } 54 Factory getFactory() const override { return CreateProc; }
54 55
56 /** For SkFlattenable derived objects with a valid type
57 This macro should only be used in base class objects in core
58 */
59 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
60 static Type GetFlattenableType() { \
61 return k##flattenable##_Type; \
62 }
63
55 /** \class SkFlattenable 64 /** \class SkFlattenable
56 65
57 SkFlattenable is the base class for objects that need to be flattened 66 SkFlattenable is the base class for objects that need to be flattened
58 into a data stream for either transport or as part of the key to the 67 into a data stream for either transport or as part of the key to the
59 font cache. 68 font cache.
60 */ 69 */
61 class SK_API SkFlattenable : public SkRefCnt { 70 class SK_API SkFlattenable : public SkRefCnt {
62 public: 71 public:
72 enum Type {
73 kSkColorFilter_Type,
74 kSkDrawLooper_Type,
75 kSkImageFilter_Type,
76 kSkMaskFilter_Type,
77 kSkPathEffect_Type,
78 kSkPixelRef_Type,
79 kSkRasterizer_Type,
80 kSkShader_Type,
81 kSkUnused_Type, // used to be SkUnitMapper
82 kSkXfermode_Type,
83 };
84
63 typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&); 85 typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&);
64 86
65 SkFlattenable() {} 87 SkFlattenable() {}
66 88
67 /** Implement this to return a factory function pointer that can be called 89 /** Implement this to return a factory function pointer that can be called
68 to recreate your class given a buffer (previously written to by your 90 to recreate your class given a buffer (previously written to by your
69 override of flatten(). 91 override of flatten().
70 */ 92 */
71 virtual Factory getFactory() const = 0; 93 virtual Factory getFactory() const = 0;
72 94
73 /** Returns the name of the object's class 95 /** Returns the name of the object's class
74 */ 96 */
75 const char* getTypeName() const { return FactoryToName(getFactory()); } 97 const char* getTypeName() const { return FactoryToName(getFactory()); }
76 98
77 static Factory NameToFactory(const char name[]); 99 static Factory NameToFactory(const char name[]);
78 static const char* FactoryToName(Factory); 100 static const char* FactoryToName(Factory);
101 static bool NameToType(const char name[], Type* type);
79 102
80 static void Register(const char name[], Factory); 103 static void Register(const char name[], Factory, Type);
81 104
82 /** 105 /**
83 * Override this if your subclass needs to record data that it will need to recreate itself 106 * Override this if your subclass needs to record data that it will need to recreate itself
84 * from its CreateProc (returned by getFactory()). 107 * from its CreateProc (returned by getFactory()).
85 */ 108 */
86 virtual void flatten(SkWriteBuffer&) const {} 109 virtual void flatten(SkWriteBuffer&) const {}
87 110
88 protected: 111 protected:
89 class PrivateInitializer { 112 class PrivateInitializer {
90 public: 113 public:
91 static void InitCore(); 114 static void InitCore();
92 static void InitEffects(); 115 static void InitEffects();
93 }; 116 };
94 117
95 private: 118 private:
96 static void InitializeFlattenablesIfNeeded(); 119 static void InitializeFlattenablesIfNeeded();
97 120
98 friend class SkGraphics; 121 friend class SkGraphics;
99 122
100 typedef SkRefCnt INHERITED; 123 typedef SkRefCnt INHERITED;
101 }; 124 };
102 125
103 #endif 126 #endif
OLDNEW
« no previous file with comments | « include/core/SkDrawLooper.h ('k') | include/core/SkFlattenableSerialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698