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

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

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Cleanup Created 7 years, 1 month 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 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
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. If the pointer parameter's siz e does not match
106 virtual uint32_t readScalarArray(SkScalar* values) = 0; 106 * the size to be read, the pointer parameter's memory will then stay unini tialized, the
107 * cursor will be moved to the end of the stream and, in the case where isV alidating() is
108 * true, an error flag will be set internally (see SkValidatingReadBuffer).
109 * If the sizes match, then "size" amount of memory will be read.
110 *
111 * @param size amount of memory expected to be read
112 * @return true if the size parameter matches the size to be read, false ot herwise
113 */
114 virtual bool readByteArray(void* value, size_t size) = 0;
Stephen White 2013/10/30 20:33:20 Sorry to get back so late on this one, but would i
sugoi1 2013/10/31 14:16:24 Done. Although I kept void* and assumed that the s
115 virtual bool readColorArray(SkColor* colors, size_t size) = 0;
116 virtual bool readIntArray(int32_t* values, size_t size) = 0;
117 virtual bool readPointArray(SkPoint* points, size_t size) = 0;
118 virtual bool readScalarArray(SkScalar* values, size_t size) = 0;
107 119
108 /** This helper peeks into the buffer and reports back the length of the nex t array in 120 /** 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. 121 * the buffer but does not change the state of the buffer.
110 */ 122 */
111 virtual uint32_t getArrayCount() = 0; 123 virtual uint32_t getArrayCount() = 0;
112 124
113 // helper functions 125 // helper functions
114 virtual void* readFunctionPtr(); 126 virtual void* readFunctionPtr();
115 virtual void readPaint(SkPaint* paint); 127 virtual void readPaint(SkPaint* paint);
116 128
117 virtual void readBitmap(SkBitmap* bitmap) = 0; 129 virtual void readBitmap(SkBitmap* bitmap) = 0;
118 virtual SkTypeface* readTypeface() = 0; 130 virtual SkTypeface* readTypeface() = 0;
119 131
120 // helper function for classes with const SkPoint members 132 // helper function for classes with const SkPoint members
121 SkPoint readPoint() { 133 SkPoint readPoint() {
122 SkPoint point; 134 SkPoint point;
123 this->readPoint(&point); 135 this->readPoint(&point);
124 return point; 136 return point;
125 } 137 }
126 138
127 SkData* readByteArrayAsData() { 139 SkData* readByteArrayAsData() {
128 size_t len = this->getArrayCount(); 140 size_t len = this->getArrayCount();
129 void* buffer = sk_malloc_throw(len); 141 void* buffer = sk_malloc_throw(len);
130 (void)this->readByteArray(buffer); 142 (void)this->readByteArray(buffer, len);
131 return SkData::NewFromMalloc(buffer, len); 143 return SkData::NewFromMalloc(buffer, len);
132 } 144 }
133 145
134 virtual void validate(bool isValid) {} 146 virtual void validate(bool isValid) {}
135 147
136 private: 148 private:
137 template <typename T> T* readFlattenableT(); 149 template <typename T> T* readFlattenableT();
138 uint32_t fFlags; 150 uint32_t fFlags;
139 }; 151 };
140 152
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 223 }
212 224
213 protected: 225 protected:
214 // A helper function so that each subclass does not have to be a friend of S kFlattenable 226 // 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); 227 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe r);
216 228
217 uint32_t fFlags; 229 uint32_t fFlags;
218 }; 230 };
219 231
220 #endif 232 #endif
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkColorTable.cpp » ('j') | src/core/SkColorTable.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698