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

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: Bad upload, retrying 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/SkColorTable.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 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. 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 function will retur n 0 and an error
108 * flag will be set internally (see SkValidatingReadBuffer).
109 * If isValidating() is false, then the size parameter is ignored.
reed1 2013/10/29 19:39:43 What gets return if there is *not* an error? (in b
sugoi1 2013/10/29 20:04:50 It returns the size (or amount) of memory actually
110 */
111 virtual uint32_t readByteArray(void* value, uint32_t size) = 0;
reed1 2013/10/29 19:39:43 shouldn't these be size_t instead of uint32_t, jus
reed1 2013/10/29 19:44:09 What is the state of the buffer if we get an error
sugoi1 2013/10/29 20:04:50 Will add in the description. Thanks.
sugoi1 2013/10/29 20:04:50 Sure, but I'll just mention that, currently, the u
112 virtual uint32_t readColorArray(SkColor* colors, uint32_t size) = 0;
113 virtual uint32_t readIntArray(int32_t* values, uint32_t size) = 0;
114 virtual uint32_t readPointArray(SkPoint* points, uint32_t size) = 0;
115 virtual uint32_t readScalarArray(SkScalar* values, uint32_t size) = 0;
107 116
108 /** This helper peeks into the buffer and reports back the length of the nex t array in 117 /** 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. 118 * the buffer but does not change the state of the buffer.
110 */ 119 */
111 virtual uint32_t getArrayCount() = 0; 120 virtual uint32_t getArrayCount() = 0;
112 121
113 // helper functions 122 // helper functions
114 virtual void* readFunctionPtr(); 123 virtual void* readFunctionPtr();
115 virtual void readPaint(SkPaint* paint); 124 virtual void readPaint(SkPaint* paint);
116 125
117 virtual void readBitmap(SkBitmap* bitmap) = 0; 126 virtual void readBitmap(SkBitmap* bitmap) = 0;
118 virtual SkTypeface* readTypeface() = 0; 127 virtual SkTypeface* readTypeface() = 0;
119 128
120 // helper function for classes with const SkPoint members 129 // helper function for classes with const SkPoint members
121 SkPoint readPoint() { 130 SkPoint readPoint() {
122 SkPoint point; 131 SkPoint point;
123 this->readPoint(&point); 132 this->readPoint(&point);
124 return point; 133 return point;
125 } 134 }
126 135
127 SkData* readByteArrayAsData() { 136 SkData* readByteArrayAsData() {
128 size_t len = this->getArrayCount(); 137 size_t len = this->getArrayCount();
129 void* buffer = sk_malloc_throw(len); 138 void* buffer = sk_malloc_throw(len);
130 (void)this->readByteArray(buffer); 139 (void)this->readByteArray(buffer, len);
131 return SkData::NewFromMalloc(buffer, len); 140 return SkData::NewFromMalloc(buffer, len);
132 } 141 }
133 142
134 virtual void validate(bool isValid) {} 143 virtual void validate(bool isValid) {}
135 144
136 private: 145 private:
137 template <typename T> T* readFlattenableT(); 146 template <typename T> T* readFlattenableT();
138 uint32_t fFlags; 147 uint32_t fFlags;
139 }; 148 };
140 149
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 220 }
212 221
213 protected: 222 protected:
214 // A helper function so that each subclass does not have to be a friend of S kFlattenable 223 // 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); 224 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe r);
216 225
217 uint32_t fFlags; 226 uint32_t fFlags;
218 }; 227 };
219 228
220 #endif 229 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkColorTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698