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

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

Issue 26702002: force readbuffer clients to use specialized readFoo for flattenables (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | src/core/SkAnnotation.cpp » ('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 /* 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
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 kColorFilter_SkEffectType,
43 kDrawLooper_SkEffectType,
44 kImageFilter_SkEffectType,
45 kMaskFilter_SkEffectType,
46 kPathEffect_SkEffectType,
47 kPixelRef_SkEffectType,
48 kRasterizer_SkEffectType,
49 kShader_SkEffectType,
50 kUnitMapper_SkEffectType,
51 kXfermode_SkEffectType,
52
53 kLight_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
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 SkFlattenable* readEffect(SkEffectType);
91
92 SkColorFilter* readColorFilter() {
93 return (SkColorFilter*)this->readEffect(kColorFilter_SkEffectType);
94 }
95 SkDrawLooper* readDrawLooper() {
96 return (SkDrawLooper*)this->readEffect(kDrawLooper_SkEffectType);
97 }
98 SkImageFilter* readImageFilter() {
99 return (SkImageFilter*)this->readEffect(kImageFilter_SkEffectType);
100 }
101 SkMaskFilter* readMaskFilter() {
102 return (SkMaskFilter*)this->readEffect(kMaskFilter_SkEffectType);
103 }
104 SkPathEffect* readPathEffect() {
105 return (SkPathEffect*)this->readEffect(kPathEffect_SkEffectType);
106 }
107 SkPixelRef* readPixelRef() {
108 return (SkPixelRef*)this->readEffect(kPixelRef_SkEffectType);
109 }
110 SkRasterizer* readRasterizer() {
111 return (SkRasterizer*)this->readEffect(kRasterizer_SkEffectType);
112 }
113 SkShader* readShader() {
114 return (SkShader*)this->readEffect(kShader_SkEffectType);
115 }
116 SkUnitMapper* readUnitMapper() {
117 return (SkUnitMapper*)this->readEffect(kUnitMapper_SkEffectType);
118 }
119 SkXfermode* readXfermode() {
120 return (SkXfermode*)this->readEffect(kXfermode_SkEffectType);
121 }
122
123 // Does support subclasses, but is internal to our impl, and is not in
124 // core...
125 //
126 SkLight* readLight() {
127 return (SkLight*)this->readEffect(kLight_SkEffectType);
128 }
129
130 // These flattenables do *not* support subclassing, so perhaps need not
131 // actually inherit from SkFlattenable
132 //
133 SkAnnotation* readAnnotation() {
134 return (SkAnnotation*)this->readAnnotation();
135 }
136 SkColorTable* readColorTable() {
137 return (SkColorTable*)this->readColorTable();
138 }
139 SkData* readData() {
140 return (SkData*)this->readFlattenable();
141 }
142 SkDataSet* readDataSet() {
143 return (SkDataSet*)this->readFlattenable();
144 }
145
66 // common data structures 146 // common data structures
67 virtual SkFlattenable* readFlattenable() = 0;
68 virtual void readPoint(SkPoint* point) = 0; 147 virtual void readPoint(SkPoint* point) = 0;
69 virtual void readMatrix(SkMatrix* matrix) = 0; 148 virtual void readMatrix(SkMatrix* matrix) = 0;
70 virtual void readIRect(SkIRect* rect) = 0; 149 virtual void readIRect(SkIRect* rect) = 0;
71 virtual void readRect(SkRect* rect) = 0; 150 virtual void readRect(SkRect* rect) = 0;
72 virtual void readRegion(SkRegion* region) = 0; 151 virtual void readRegion(SkRegion* region) = 0;
73 virtual void readPath(SkPath* path) = 0; 152 virtual void readPath(SkPath* path) = 0;
74 153
75 // binary data and arrays 154 // binary data and arrays
76 virtual uint32_t readByteArray(void* value) = 0; 155 virtual uint32_t readByteArray(void* value) = 0;
77 virtual uint32_t readColorArray(SkColor* colors) = 0; 156 virtual uint32_t readColorArray(SkColor* colors) = 0;
(...skipping 13 matching lines...) Expand all
91 virtual void readBitmap(SkBitmap* bitmap) = 0; 170 virtual void readBitmap(SkBitmap* bitmap) = 0;
92 virtual SkTypeface* readTypeface() = 0; 171 virtual SkTypeface* readTypeface() = 0;
93 172
94 // helper function for classes with const SkPoint members 173 // helper function for classes with const SkPoint members
95 SkPoint readPoint() { 174 SkPoint readPoint() {
96 SkPoint point; 175 SkPoint point;
97 this->readPoint(&point); 176 this->readPoint(&point);
98 return point; 177 return point;
99 } 178 }
100 179
180 #if 0
101 template <typename T> T* readFlattenableT() { 181 template <typename T> T* readFlattenableT() {
sugoi 2013/10/09 20:26:55 Ok, so I've been thinking about this. Even though
102 return static_cast<T*>(this->readFlattenable()); 182 return static_cast<T*>(this->readFlattenable());
103 } 183 }
184 #endif
104 185
105 private: 186 private:
187 virtual SkFlattenable* readFlattenable() = 0;
188
106 uint32_t fFlags; 189 uint32_t fFlags;
107 }; 190 };
108 191
109 /////////////////////////////////////////////////////////////////////////////// 192 ///////////////////////////////////////////////////////////////////////////////
110 193
111 class SkFlattenableWriteBuffer { 194 class SkFlattenableWriteBuffer {
112 public: 195 public:
113 SkFlattenableWriteBuffer(); 196 SkFlattenableWriteBuffer();
114 virtual ~SkFlattenableWriteBuffer(); 197 virtual ~SkFlattenableWriteBuffer();
115 198
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } 249 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
167 250
168 protected: 251 protected:
169 // A helper function so that each subclass does not have to be a friend of S kFlattenable 252 // A helper function so that each subclass does not have to be a friend of S kFlattenable
170 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); 253 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
171 254
172 uint32_t fFlags; 255 uint32_t fFlags;
173 }; 256 };
174 257
175 #endif 258 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkAnnotation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698