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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 // common data structures | 93 // common data structures |
94 virtual void readPoint(SkPoint* point) = 0; | 94 virtual void readPoint(SkPoint* point) = 0; |
95 virtual void readMatrix(SkMatrix* matrix) = 0; | 95 virtual void readMatrix(SkMatrix* matrix) = 0; |
96 virtual void readIRect(SkIRect* rect) = 0; | 96 virtual void readIRect(SkIRect* rect) = 0; |
97 virtual void readRect(SkRect* rect) = 0; | 97 virtual void readRect(SkRect* rect) = 0; |
98 virtual void readRegion(SkRegion* region) = 0; | 98 virtual void readRegion(SkRegion* region) = 0; |
99 virtual void readPath(SkPath* path) = 0; | 99 virtual void readPath(SkPath* path) = 0; |
100 | 100 |
101 // binary data and arrays | 101 // binary data and arrays |
102 virtual uint32_t readByteArray(void* value) = 0; | 102 |
103 virtual uint32_t readColorArray(SkColor* colors) = 0; | 103 /** |
104 virtual uint32_t readIntArray(int32_t* values) = 0; | 104 * In the following read.*Array(...) functions, the size parameter specifie
s the allocation |
105 virtual uint32_t readPointArray(SkPoint* points) = 0; | 105 * size in number of elements (or in bytes, for void*) of the pointer param
eter. If the |
106 virtual uint32_t readScalarArray(SkScalar* values) = 0; | 106 * pointer parameter's size does not match the size to be read, the pointer
parameter's memory |
| 107 * will then stay uninitialized, the cursor will be moved to the end of the
stream and, in the |
| 108 * case where isValidating() is true, an error flag will be set internally
(see |
| 109 * SkValidatingReadBuffer). |
| 110 * If the sizes match, then "size" amount of memory will be read. |
| 111 * |
| 112 * @param size amount of memory expected to be read |
| 113 * @return true if the size parameter matches the size to be read, false ot
herwise |
| 114 */ |
| 115 virtual bool readByteArray(void* value, size_t size) = 0; |
| 116 virtual bool readColorArray(SkColor* colors, size_t size) = 0; |
| 117 virtual bool readIntArray(int32_t* values, size_t size) = 0; |
| 118 virtual bool readPointArray(SkPoint* points, size_t size) = 0; |
| 119 virtual bool readScalarArray(SkScalar* values, size_t size) = 0; |
107 | 120 |
108 /** This helper peeks into the buffer and reports back the length of the nex
t array in | 121 /** This helper peeks into the buffer and reports back the length of the nex
t array in |
109 * the buffer but does not change the state of the buffer. | 122 * the buffer but does not change the state of the buffer. |
110 */ | 123 */ |
111 virtual uint32_t getArrayCount() = 0; | 124 virtual uint32_t getArrayCount() = 0; |
112 | 125 |
113 // helper functions | 126 // helper functions |
114 virtual void* readFunctionPtr(); | 127 virtual void* readFunctionPtr(); |
115 virtual void readPaint(SkPaint* paint); | 128 virtual void readPaint(SkPaint* paint); |
116 | 129 |
117 virtual void readBitmap(SkBitmap* bitmap) = 0; | 130 virtual void readBitmap(SkBitmap* bitmap) = 0; |
118 virtual SkTypeface* readTypeface() = 0; | 131 virtual SkTypeface* readTypeface() = 0; |
119 | 132 |
120 // helper function for classes with const SkPoint members | 133 // helper function for classes with const SkPoint members |
121 SkPoint readPoint() { | 134 SkPoint readPoint() { |
122 SkPoint point; | 135 SkPoint point; |
123 this->readPoint(&point); | 136 this->readPoint(&point); |
124 return point; | 137 return point; |
125 } | 138 } |
126 | 139 |
127 SkData* readByteArrayAsData() { | 140 SkData* readByteArrayAsData() { |
128 size_t len = this->getArrayCount(); | 141 size_t len = this->getArrayCount(); |
129 void* buffer = sk_malloc_throw(len); | 142 void* buffer = sk_malloc_throw(len); |
130 (void)this->readByteArray(buffer); | 143 (void)this->readByteArray(buffer, len); |
131 return SkData::NewFromMalloc(buffer, len); | 144 return SkData::NewFromMalloc(buffer, len); |
132 } | 145 } |
133 | 146 |
134 virtual void validate(bool isValid) {} | 147 virtual void validate(bool isValid) {} |
135 | 148 |
136 private: | 149 private: |
137 template <typename T> T* readFlattenableT(); | 150 template <typename T> T* readFlattenableT(); |
138 uint32_t fFlags; | 151 uint32_t fFlags; |
139 }; | 152 }; |
140 | 153 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 224 } |
212 | 225 |
213 protected: | 226 protected: |
214 // A helper function so that each subclass does not have to be a friend of S
kFlattenable | 227 // A helper function so that each subclass does not have to be a friend of S
kFlattenable |
215 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe
r); | 228 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe
r); |
216 | 229 |
217 uint32_t fFlags; | 230 uint32_t fFlags; |
218 }; | 231 }; |
219 | 232 |
220 #endif | 233 #endif |
OLD | NEW |