OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkDeduper.h" | 9 #include "SkDeduper.h" |
10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 SkASSERT(fReader.available() > 0); | 135 SkASSERT(fReader.available() > 0); |
136 return *((uint8_t*) fReader.peek()); | 136 return *((uint8_t*) fReader.peek()); |
137 } | 137 } |
138 | 138 |
139 void SkReadBuffer::readString(SkString* string) { | 139 void SkReadBuffer::readString(SkString* string) { |
140 size_t len; | 140 size_t len; |
141 const char* strContents = fReader.readString(&len); | 141 const char* strContents = fReader.readString(&len); |
142 string->set(strContents, len); | 142 string->set(strContents, len); |
143 } | 143 } |
144 | 144 |
| 145 void SkReadBuffer::readColor4f(SkColor4f* color) { |
| 146 memcpy(color, fReader.skip(sizeof(SkColor4f)), sizeof(SkColor4f)); |
| 147 } |
| 148 |
145 void SkReadBuffer::readPoint(SkPoint* point) { | 149 void SkReadBuffer::readPoint(SkPoint* point) { |
146 point->fX = fReader.readScalar(); | 150 point->fX = fReader.readScalar(); |
147 point->fY = fReader.readScalar(); | 151 point->fY = fReader.readScalar(); |
148 } | 152 } |
149 | 153 |
150 void SkReadBuffer::readMatrix(SkMatrix* matrix) { | 154 void SkReadBuffer::readMatrix(SkMatrix* matrix) { |
151 fReader.readMatrix(matrix); | 155 fReader.readMatrix(matrix); |
152 } | 156 } |
153 | 157 |
154 void SkReadBuffer::readIRect(SkIRect* rect) { | 158 void SkReadBuffer::readIRect(SkIRect* rect) { |
(...skipping 30 matching lines...) Expand all Loading... |
185 } | 189 } |
186 | 190 |
187 bool SkReadBuffer::readByteArray(void* value, size_t size) { | 191 bool SkReadBuffer::readByteArray(void* value, size_t size) { |
188 return readArray(static_cast<unsigned char*>(value), size, sizeof(unsigned c
har)); | 192 return readArray(static_cast<unsigned char*>(value), size, sizeof(unsigned c
har)); |
189 } | 193 } |
190 | 194 |
191 bool SkReadBuffer::readColorArray(SkColor* colors, size_t size) { | 195 bool SkReadBuffer::readColorArray(SkColor* colors, size_t size) { |
192 return readArray(colors, size, sizeof(SkColor)); | 196 return readArray(colors, size, sizeof(SkColor)); |
193 } | 197 } |
194 | 198 |
| 199 bool SkReadBuffer::readColor4fArray(SkColor4f* colors, size_t size) { |
| 200 return readArray(colors, size, sizeof(SkColor4f)); |
| 201 } |
| 202 |
195 bool SkReadBuffer::readIntArray(int32_t* values, size_t size) { | 203 bool SkReadBuffer::readIntArray(int32_t* values, size_t size) { |
196 return readArray(values, size, sizeof(int32_t)); | 204 return readArray(values, size, sizeof(int32_t)); |
197 } | 205 } |
198 | 206 |
199 bool SkReadBuffer::readPointArray(SkPoint* points, size_t size) { | 207 bool SkReadBuffer::readPointArray(SkPoint* points, size_t size) { |
200 return readArray(points, size, sizeof(SkPoint)); | 208 return readArray(points, size, sizeof(SkPoint)); |
201 } | 209 } |
202 | 210 |
203 bool SkReadBuffer::readScalarArray(SkScalar* values, size_t size) { | 211 bool SkReadBuffer::readScalarArray(SkScalar* values, size_t size) { |
204 return readArray(values, size, sizeof(SkScalar)); | 212 return readArray(values, size, sizeof(SkScalar)); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (sizeRecorded != sizeRead) { | 390 if (sizeRecorded != sizeRead) { |
383 this->validate(false); | 391 this->validate(false); |
384 return nullptr; | 392 return nullptr; |
385 } | 393 } |
386 } else { | 394 } else { |
387 // we must skip the remaining data | 395 // we must skip the remaining data |
388 fReader.skip(sizeRecorded); | 396 fReader.skip(sizeRecorded); |
389 } | 397 } |
390 return obj.release(); | 398 return obj.release(); |
391 } | 399 } |
OLD | NEW |