OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
10 #include "SkValidatingReadBuffer.h" | 10 #include "SkValidatingReadBuffer.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 size_t size = 0; | 164 size_t size = 0; |
165 if (!fError) { | 165 if (!fError) { |
166 size = path->readFromMemory(fReader.peek(), fReader.available()); | 166 size = path->readFromMemory(fReader.peek(), fReader.available()); |
167 this->validate((SkAlign4(size) == size) && (0 != size)); | 167 this->validate((SkAlign4(size) == size) && (0 != size)); |
168 } | 168 } |
169 if (!fError) { | 169 if (!fError) { |
170 (void)this->skip(size); | 170 (void)this->skip(size); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
| 174 void SkValidatingReadBuffer::readPatch(SkPatch* patch) { |
| 175 size_t size = 0; |
| 176 if (!fError) { |
| 177 size = patch->readFromMemory(fReader.peek(), fReader.available()); |
| 178 this->validate((SkAlign4(size) == size) && (0 != size)); |
| 179 } |
| 180 if (!fError) { |
| 181 (void)this->skip(size); |
| 182 } |
| 183 } |
| 184 |
174 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS
ize) { | 185 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS
ize) { |
175 const uint32_t count = this->getArrayCount(); | 186 const uint32_t count = this->getArrayCount(); |
176 this->validate(size == count); | 187 this->validate(size == count); |
177 (void)this->skip(sizeof(uint32_t)); // Skip array count | 188 (void)this->skip(sizeof(uint32_t)); // Skip array count |
178 const size_t byteLength = count * elementSize; | 189 const size_t byteLength = count * elementSize; |
179 const void* ptr = this->skip(SkAlign4(byteLength)); | 190 const void* ptr = this->skip(SkAlign4(byteLength)); |
180 if (!fError) { | 191 if (!fError) { |
181 memcpy(value, ptr, byteLength); | 192 memcpy(value, ptr, byteLength); |
182 return true; | 193 return true; |
183 } | 194 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 274 |
264 void SkValidatingReadBuffer::skipFlattenable() { | 275 void SkValidatingReadBuffer::skipFlattenable() { |
265 SkString name; | 276 SkString name; |
266 this->readString(&name); | 277 this->readString(&name); |
267 if (fError) { | 278 if (fError) { |
268 return; | 279 return; |
269 } | 280 } |
270 uint32_t sizeRecorded = this->readUInt(); | 281 uint32_t sizeRecorded = this->readUInt(); |
271 this->skip(sizeRecorded); | 282 this->skip(sizeRecorded); |
272 } | 283 } |
OLD | NEW |