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

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

Issue 22799007: I'm investigating how to make the IPC transfer a bit more secure on the (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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() 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() 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 enum Type { FLATTENABLE, IMAGE_FILTER };
sugoi 2013/08/13 15:20:26 This, of course, could be extended to other types.
49
48 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); 50 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&);
49 51
50 SkFlattenable() {} 52 SkFlattenable() {}
51 53
52 /** Implement this to return a factory function pointer that can be called 54 /** 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 55 to recreate your class given a buffer (previously written to by your
54 override of flatten(). 56 override of flatten().
55 */ 57 */
56 virtual Factory getFactory() = 0; 58 virtual Factory getFactory() = 0;
59 virtual bool isA(Type type) const { return FLATTENABLE == type; }
57 60
58 static Factory NameToFactory(const char name[]); 61 static Factory NameToFactory(const char name[]);
59 static const char* FactoryToName(Factory); 62 static const char* FactoryToName(Factory);
60 static void Register(const char name[], Factory); 63 static void Register(const char name[], Factory);
61 64
62 class Registrar { 65 class Registrar {
63 public: 66 public:
64 Registrar(const char name[], Factory factory) { 67 Registrar(const char name[], Factory factory) {
65 SkFlattenable::Register(name, factory); 68 SkFlattenable::Register(name, factory);
66 } 69 }
(...skipping 10 matching lines...) Expand all
77 private: 80 private:
78 static void InitializeFlattenables(); 81 static void InitializeFlattenables();
79 82
80 friend class SkGraphics; 83 friend class SkGraphics;
81 friend class SkFlattenableWriteBuffer; 84 friend class SkFlattenableWriteBuffer;
82 85
83 typedef SkRefCnt INHERITED; 86 typedef SkRefCnt INHERITED;
84 }; 87 };
85 88
86 #endif 89 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkFlattenableSerialization.h » ('j') | src/core/SkOrderedReadBuffer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698