| 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 | |
| 185 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS
ize) { | 174 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS
ize) { |
| 186 const uint32_t count = this->getArrayCount(); | 175 const uint32_t count = this->getArrayCount(); |
| 187 this->validate(size == count); | 176 this->validate(size == count); |
| 188 (void)this->skip(sizeof(uint32_t)); // Skip array count | 177 (void)this->skip(sizeof(uint32_t)); // Skip array count |
| 189 const size_t byteLength = count * elementSize; | 178 const size_t byteLength = count * elementSize; |
| 190 const void* ptr = this->skip(SkAlign4(byteLength)); | 179 const void* ptr = this->skip(SkAlign4(byteLength)); |
| 191 if (!fError) { | 180 if (!fError) { |
| 192 memcpy(value, ptr, byteLength); | 181 memcpy(value, ptr, byteLength); |
| 193 return true; | 182 return true; |
| 194 } | 183 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 263 |
| 275 void SkValidatingReadBuffer::skipFlattenable() { | 264 void SkValidatingReadBuffer::skipFlattenable() { |
| 276 SkString name; | 265 SkString name; |
| 277 this->readString(&name); | 266 this->readString(&name); |
| 278 if (fError) { | 267 if (fError) { |
| 279 return; | 268 return; |
| 280 } | 269 } |
| 281 uint32_t sizeRecorded = this->readUInt(); | 270 uint32_t sizeRecorded = this->readUInt(); |
| 282 this->skip(sizeRecorded); | 271 this->skip(sizeRecorded); |
| 283 } | 272 } |
| OLD | NEW |