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

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: Added dox in SkFlattenableBuffers.h 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
105 virtual uint32_t readPointArray(SkPoint* points) = 0; 105 * the allocation size (in bytes) of the pointer parameter.
reed1 2013/10/24 16:10:33 // What does the return value indicate? What is th
sugoi1 2013/10/24 19:40:04 Done.
106 virtual uint32_t readScalarArray(SkScalar* values) = 0; 106 */
107 virtual uint32_t readByteArray(void* value, uint32_t size) = 0;
108 virtual uint32_t readColorArray(SkColor* colors, uint32_t size) = 0;
109 virtual uint32_t readIntArray(int32_t* values, uint32_t size) = 0;
110 virtual uint32_t readPointArray(SkPoint* points, uint32_t size) = 0;
111 virtual uint32_t readScalarArray(SkScalar* values, uint32_t size) = 0;
107 112
108 /** This helper peeks into the buffer and reports back the length of the nex t array in 113 /** 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. 114 * the buffer but does not change the state of the buffer.
110 */ 115 */
111 virtual uint32_t getArrayCount() = 0; 116 virtual uint32_t getArrayCount() = 0;
112 117
113 // helper functions 118 // helper functions
114 virtual void* readFunctionPtr(); 119 virtual void* readFunctionPtr();
115 virtual void readPaint(SkPaint* paint); 120 virtual void readPaint(SkPaint* paint);
116 121
117 virtual void readBitmap(SkBitmap* bitmap) = 0; 122 virtual void readBitmap(SkBitmap* bitmap) = 0;
118 virtual SkTypeface* readTypeface() = 0; 123 virtual SkTypeface* readTypeface() = 0;
119 124
120 // helper function for classes with const SkPoint members 125 // helper function for classes with const SkPoint members
121 SkPoint readPoint() { 126 SkPoint readPoint() {
122 SkPoint point; 127 SkPoint point;
123 this->readPoint(&point); 128 this->readPoint(&point);
124 return point; 129 return point;
125 } 130 }
126 131
127 SkData* readByteArrayAsData() { 132 SkData* readByteArrayAsData() {
128 size_t len = this->getArrayCount(); 133 size_t len = this->getArrayCount();
129 void* buffer = sk_malloc_throw(len); 134 void* buffer = sk_malloc_throw(len);
130 (void)this->readByteArray(buffer); 135 (void)this->readByteArray(buffer, len);
131 return SkData::NewFromMalloc(buffer, len); 136 return SkData::NewFromMalloc(buffer, len);
132 } 137 }
133 138
134 virtual void validate(bool isValid) {} 139 virtual void validate(bool isValid) {}
135 140
136 private: 141 private:
137 template <typename T> T* readFlattenableT(); 142 template <typename T> T* readFlattenableT();
138 uint32_t fFlags; 143 uint32_t fFlags;
139 }; 144 };
140 145
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 216 }
212 217
213 protected: 218 protected:
214 // A helper function so that each subclass does not have to be a friend of S kFlattenable 219 // 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); 220 void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffe r);
216 221
217 uint32_t fFlags; 222 uint32_t fFlags;
218 }; 223 };
219 224
220 #endif 225 #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