Chromium Code Reviews| 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 bytes) of the pointer parameter. In the case where isValidating () is true, then |
| 106 virtual uint32_t readScalarArray(SkScalar* values) = 0; | 106 * if the pointer parameter's size does not match the size to be read, the pointer |
| 107 * parameter's memory will then stay uninitialized, the cursor will not mov e, the function | |
| 108 * will return 0 and an error flag will be set internally (see SkValidating ReadBuffer). | |
| 109 * If the sizes match, then the amount of memory actually read will be retu rned. | |
| 110 * If isValidating() is false, then the size parameter is used as the maxim um amount of memory | |
|
reed1
2013/10/30 14:50:30
It seems like we're saying the following:
if we'r
sugoi1
2013/10/30 17:43:51
Done.
| |
| 111 * that can be read and at most this much memory will be read. | |
| 112 */ | |
| 113 virtual size_t readByteArray(void* value, size_t size) = 0; | |
| 114 virtual size_t readColorArray(SkColor* colors, size_t size) = 0; | |
| 115 virtual size_t readIntArray(int32_t* values, size_t size) = 0; | |
| 116 virtual size_t readPointArray(SkPoint* points, size_t size) = 0; | |
| 117 virtual size_t readScalarArray(SkScalar* values, size_t size) = 0; | |
| 107 | 118 |
| 108 /** This helper peeks into the buffer and reports back the length of the nex t array in | 119 /** 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. | 120 * the buffer but does not change the state of the buffer. |
| 110 */ | 121 */ |
| 111 virtual uint32_t getArrayCount() = 0; | 122 virtual uint32_t getArrayCount() = 0; |
| 112 | 123 |
| 113 // helper functions | 124 // helper functions |
| 114 virtual void* readFunctionPtr(); | 125 virtual void* readFunctionPtr(); |
| 115 virtual void readPaint(SkPaint* paint); | 126 virtual void readPaint(SkPaint* paint); |
| 116 | 127 |
| 117 virtual void readBitmap(SkBitmap* bitmap) = 0; | 128 virtual void readBitmap(SkBitmap* bitmap) = 0; |
| 118 virtual SkTypeface* readTypeface() = 0; | 129 virtual SkTypeface* readTypeface() = 0; |
| 119 | 130 |
| 120 // helper function for classes with const SkPoint members | 131 // helper function for classes with const SkPoint members |
| 121 SkPoint readPoint() { | 132 SkPoint readPoint() { |
| 122 SkPoint point; | 133 SkPoint point; |
| 123 this->readPoint(&point); | 134 this->readPoint(&point); |
| 124 return point; | 135 return point; |
| 125 } | 136 } |
| 126 | 137 |
| 127 SkData* readByteArrayAsData() { | 138 SkData* readByteArrayAsData() { |
| 128 size_t len = this->getArrayCount(); | 139 size_t len = this->getArrayCount(); |
| 129 void* buffer = sk_malloc_throw(len); | 140 void* buffer = sk_malloc_throw(len); |
| 130 (void)this->readByteArray(buffer); | 141 (void)this->readByteArray(buffer, len); |
| 131 return SkData::NewFromMalloc(buffer, len); | 142 return SkData::NewFromMalloc(buffer, len); |
| 132 } | 143 } |
| 133 | 144 |
| 134 virtual void validate(bool isValid) {} | 145 virtual void validate(bool isValid) {} |
| 135 | 146 |
| 136 private: | 147 private: |
| 137 template <typename T> T* readFlattenableT(); | 148 template <typename T> T* readFlattenableT(); |
| 138 uint32_t fFlags; | 149 uint32_t fFlags; |
| 139 }; | 150 }; |
| 140 | 151 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 } | 222 } |
| 212 | 223 |
| 213 protected: | 224 protected: |
| 214 // A helper function so that each subclass does not have to be a friend of S kFlattenable | 225 // 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); | 226 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe r); |
| 216 | 227 |
| 217 uint32_t fFlags; | 228 uint32_t fFlags; |
| 218 }; | 229 }; |
| 219 | 230 |
| 220 #endif | 231 #endif |
| OLD | NEW |