OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
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 #ifndef SkFlattenableBuffers_DEFINED | 9 #ifndef SkFlattenableBuffers_DEFINED |
10 #define SkFlattenableBuffers_DEFINED | 10 #define SkFlattenableBuffers_DEFINED |
(...skipping 11 matching lines...) Expand all Loading... | |
22 class SkPath; | 22 class SkPath; |
23 class SkPixelRef; | 23 class SkPixelRef; |
24 struct SkRect; | 24 struct SkRect; |
25 class SkRefCnt; | 25 class SkRefCnt; |
26 class SkRegion; | 26 class SkRegion; |
27 class SkStream; | 27 class SkStream; |
28 class SkString; | 28 class SkString; |
29 class SkTypeface; | 29 class SkTypeface; |
30 class SkWStream; | 30 class SkWStream; |
31 | 31 |
32 class SkAnnotation; | |
33 class SkColorTable; | |
34 class SkData; | |
35 class SkDataSet; | |
36 class SkDrawLooper; | |
37 class SkLight; | |
38 class SkPixelRef; | |
39 class SkUnitMapper; | |
40 | |
41 enum SkEffectType { | |
42 kUnknown_SkEffectType, | |
sugoi
2013/10/10 18:15:14
Having an "unknown" type defeats the purpose of ha
| |
43 | |
44 kColorFilter_SkEffectType, | |
45 kDrawLooper_SkEffectType, | |
46 kImageFilter_SkEffectType, | |
47 kMaskFilter_SkEffectType, | |
48 kPathEffect_SkEffectType, | |
49 kPixelRef_SkEffectType, | |
50 kRasterizer_SkEffectType, | |
51 kShader_SkEffectType, | |
52 kUnitMapper_SkEffectType, | |
53 kXfermode_SkEffectType, | |
54 }; | |
55 | |
32 class SkFlattenableReadBuffer { | 56 class SkFlattenableReadBuffer { |
33 public: | 57 public: |
34 SkFlattenableReadBuffer(); | 58 SkFlattenableReadBuffer(); |
35 virtual ~SkFlattenableReadBuffer(); | 59 virtual ~SkFlattenableReadBuffer(); |
36 | 60 |
37 bool isOrderedBinaryBuffer() { return NULL != getOrderedBinaryBuffer(); } | 61 bool isOrderedBinaryBuffer() { return NULL != getOrderedBinaryBuffer(); } |
38 virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() { return NULL; } | 62 virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() { return NULL; } |
39 | 63 |
40 enum Flags { | 64 enum Flags { |
41 kCrossProcess_Flag = 1 << 0, | 65 kCrossProcess_Flag = 1 << 0, |
(...skipping 14 matching lines...) Expand all Loading... | |
56 virtual SkFixed readFixed() = 0; | 80 virtual SkFixed readFixed() = 0; |
57 virtual int32_t readInt() = 0; | 81 virtual int32_t readInt() = 0; |
58 virtual SkScalar readScalar() = 0; | 82 virtual SkScalar readScalar() = 0; |
59 virtual uint32_t readUInt() = 0; | 83 virtual uint32_t readUInt() = 0; |
60 virtual int32_t read32() = 0; | 84 virtual int32_t read32() = 0; |
61 | 85 |
62 // strings -- the caller is responsible for freeing the string contents | 86 // strings -- the caller is responsible for freeing the string contents |
63 virtual void readString(SkString* string) = 0; | 87 virtual void readString(SkString* string) = 0; |
64 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0; | 88 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0; |
65 | 89 |
90 SkColorFilter* readColorFilter() { | |
91 return (SkColorFilter*)this->readFlattenable(kColorFilter_SkEffectType); | |
92 } | |
93 SkDrawLooper* readDrawLooper() { | |
94 return (SkDrawLooper*)this->readFlattenable(kDrawLooper_SkEffectType); | |
95 } | |
96 SkImageFilter* readImageFilter() { | |
97 return (SkImageFilter*)this->readFlattenable(kImageFilter_SkEffectType); | |
98 } | |
99 SkMaskFilter* readMaskFilter() { | |
100 return (SkMaskFilter*)this->readFlattenable(kMaskFilter_SkEffectType); | |
101 } | |
102 SkPathEffect* readPathEffect() { | |
103 return (SkPathEffect*)this->readFlattenable(kPathEffect_SkEffectType); | |
104 } | |
105 SkPixelRef* readPixelRef() { | |
106 return (SkPixelRef*)this->readFlattenable(kPixelRef_SkEffectType); | |
107 } | |
108 SkRasterizer* readRasterizer() { | |
109 return (SkRasterizer*)this->readFlattenable(kRasterizer_SkEffectType); | |
110 } | |
111 SkShader* readShader() { | |
112 return (SkShader*)this->readFlattenable(kShader_SkEffectType); | |
113 } | |
114 SkUnitMapper* readUnitMapper() { | |
115 return (SkUnitMapper*)this->readFlattenable(kUnitMapper_SkEffectType); | |
116 } | |
117 SkXfermode* readXfermode() { | |
118 return (SkXfermode*)this->readFlattenable(kXfermode_SkEffectType); | |
119 } | |
120 | |
121 // Does support subclasses, but is internal to our impl, and is not in | |
122 // core... | |
123 // | |
124 SkLight* readLight() { | |
125 return (SkLight*)this->readFlattenable(kUnknown_SkEffectType); | |
126 } | |
127 | |
128 // These flattenables do *not* support subclassing, so perhaps need not | |
129 // actually inherit from SkFlattenable | |
130 // | |
131 SkAnnotation* readAnnotation() { | |
132 return (SkAnnotation*)this->readFlattenable(kUnknown_SkEffectType); | |
133 } | |
134 SkColorTable* readColorTable() { | |
135 return (SkColorTable*)this->readFlattenable(kUnknown_SkEffectType); | |
136 } | |
137 SkData* readData() { | |
138 return (SkData*)this->readFlattenable(kUnknown_SkEffectType); | |
139 } | |
140 SkDataSet* readDataSet() { | |
141 return (SkDataSet*)this->readFlattenable(kUnknown_SkEffectType); | |
142 } | |
143 | |
66 // common data structures | 144 // common data structures |
67 virtual SkFlattenable* readFlattenable() = 0; | |
68 virtual void readPoint(SkPoint* point) = 0; | 145 virtual void readPoint(SkPoint* point) = 0; |
69 virtual void readMatrix(SkMatrix* matrix) = 0; | 146 virtual void readMatrix(SkMatrix* matrix) = 0; |
70 virtual void readIRect(SkIRect* rect) = 0; | 147 virtual void readIRect(SkIRect* rect) = 0; |
71 virtual void readRect(SkRect* rect) = 0; | 148 virtual void readRect(SkRect* rect) = 0; |
72 virtual void readRegion(SkRegion* region) = 0; | 149 virtual void readRegion(SkRegion* region) = 0; |
73 virtual void readPath(SkPath* path) = 0; | 150 virtual void readPath(SkPath* path) = 0; |
74 | 151 |
75 // binary data and arrays | 152 // binary data and arrays |
76 virtual uint32_t readByteArray(void* value) = 0; | 153 virtual uint32_t readByteArray(void* value) = 0; |
77 virtual uint32_t readColorArray(SkColor* colors) = 0; | 154 virtual uint32_t readColorArray(SkColor* colors) = 0; |
(...skipping 13 matching lines...) Expand all Loading... | |
91 virtual void readBitmap(SkBitmap* bitmap) = 0; | 168 virtual void readBitmap(SkBitmap* bitmap) = 0; |
92 virtual SkTypeface* readTypeface() = 0; | 169 virtual SkTypeface* readTypeface() = 0; |
93 | 170 |
94 // helper function for classes with const SkPoint members | 171 // helper function for classes with const SkPoint members |
95 SkPoint readPoint() { | 172 SkPoint readPoint() { |
96 SkPoint point; | 173 SkPoint point; |
97 this->readPoint(&point); | 174 this->readPoint(&point); |
98 return point; | 175 return point; |
99 } | 176 } |
100 | 177 |
101 template <typename T> T* readFlattenableT() { | 178 private: |
102 return static_cast<T*>(this->readFlattenable()); | 179 virtual SkFlattenable* readFlattenable(SkEffectType) = 0; |
103 } | |
104 | 180 |
105 private: | |
106 uint32_t fFlags; | 181 uint32_t fFlags; |
107 }; | 182 }; |
108 | 183 |
109 /////////////////////////////////////////////////////////////////////////////// | 184 /////////////////////////////////////////////////////////////////////////////// |
110 | 185 |
111 class SkFlattenableWriteBuffer { | 186 class SkFlattenableWriteBuffer { |
112 public: | 187 public: |
113 SkFlattenableWriteBuffer(); | 188 SkFlattenableWriteBuffer(); |
114 virtual ~SkFlattenableWriteBuffer(); | 189 virtual ~SkFlattenableWriteBuffer(); |
115 | 190 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } | 241 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } |
167 | 242 |
168 protected: | 243 protected: |
169 // A helper function so that each subclass does not have to be a friend of S kFlattenable | 244 // A helper function so that each subclass does not have to be a friend of S kFlattenable |
170 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); | 245 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); |
171 | 246 |
172 uint32_t fFlags; | 247 uint32_t fFlags; |
173 }; | 248 }; |
174 | 249 |
175 #endif | 250 #endif |
OLD | NEW |