Chromium Code Reviews| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { | 203 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { |
| 204 return readArray(values, size, sizeof(SkScalar)); | 204 return readArray(values, size, sizeof(SkScalar)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 uint32_t SkValidatingReadBuffer::getArrayCount() { | 207 uint32_t SkValidatingReadBuffer::getArrayCount() { |
| 208 const size_t inc = sizeof(uint32_t); | 208 const size_t inc = sizeof(uint32_t); |
| 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; | 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; |
| 210 return fError ? 0 : *(uint32_t*)fReader.peek(); | 210 return fError ? 0 : *(uint32_t*)fReader.peek(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { | |
| 214 const int width = this->readInt(); | |
| 215 const int height = this->readInt(); | |
| 216 const bool useBitmapHeap = this->readBool(); | |
| 217 const size_t length = this->readUInt(); | |
| 218 // A size of zero means the SkBitmap was simply flattened. | |
| 219 if (!this->validate(!useBitmapHeap && (0 == length))) { | |
|
scroggo
2014/05/20 13:27:50
I don't understand what this code was doing before
reed1
2014/05/20 17:49:58
1. I agree that it seems broken, and probably wasn
| |
| 220 return; | |
| 221 } | |
| 222 bitmap->unflatten(*this); | |
| 223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); | |
| 224 } | |
| 225 | |
| 226 SkTypeface* SkValidatingReadBuffer::readTypeface() { | 213 SkTypeface* SkValidatingReadBuffer::readTypeface() { |
| 227 // TODO: Implement this (securely) when needed | 214 // TODO: Implement this (securely) when needed |
| 228 return NULL; | 215 return NULL; |
| 229 } | 216 } |
| 230 | 217 |
| 231 bool SkValidatingReadBuffer::validateAvailable(size_t size) { | 218 bool SkValidatingReadBuffer::validateAvailable(size_t size) { |
| 232 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size))); | 219 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size))); |
| 233 } | 220 } |
| 234 | 221 |
| 235 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) { | 222 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 266 delete obj; | 253 delete obj; |
| 267 obj = NULL; | 254 obj = NULL; |
| 268 } | 255 } |
| 269 } else { | 256 } else { |
| 270 // we must skip the remaining data | 257 // we must skip the remaining data |
| 271 this->skip(sizeRecorded); | 258 this->skip(sizeRecorded); |
| 272 SkASSERT(false); | 259 SkASSERT(false); |
| 273 } | 260 } |
| 274 return obj; | 261 return obj; |
| 275 } | 262 } |
| OLD | NEW |