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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 uint32_t value = this->readInt(); | 59 uint32_t value = this->readInt(); |
60 // Boolean value should be either 0 or 1 | 60 // Boolean value should be either 0 or 1 |
61 this->validate(!(value & ~1)); | 61 this->validate(!(value & ~1)); |
62 return value != 0; | 62 return value != 0; |
63 } | 63 } |
64 | 64 |
65 SkColor SkValidatingReadBuffer::readColor() { | 65 SkColor SkValidatingReadBuffer::readColor() { |
66 return this->readInt(); | 66 return this->readInt(); |
67 } | 67 } |
68 | 68 |
69 SkFixed SkValidatingReadBuffer::readFixed() { | |
70 return this->readInt(); | |
71 } | |
72 | |
73 int32_t SkValidatingReadBuffer::readInt() { | 69 int32_t SkValidatingReadBuffer::readInt() { |
74 const size_t inc = sizeof(int32_t); | 70 const size_t inc = sizeof(int32_t); |
75 this->validate(IsPtrAlign4(fReader.peek()) && fReader.isAvailable(inc)); | 71 this->validate(IsPtrAlign4(fReader.peek()) && fReader.isAvailable(inc)); |
76 return fError ? 0 : fReader.readInt(); | 72 return fError ? 0 : fReader.readInt(); |
77 } | 73 } |
78 | 74 |
79 SkScalar SkValidatingReadBuffer::readScalar() { | 75 SkScalar SkValidatingReadBuffer::readScalar() { |
80 const size_t inc = sizeof(SkScalar); | 76 const size_t inc = sizeof(SkScalar); |
81 this->validate(IsPtrAlign4(fReader.peek()) && fReader.isAvailable(inc)); | 77 this->validate(IsPtrAlign4(fReader.peek()) && fReader.isAvailable(inc)); |
82 return fError ? 0 : fReader.readScalar(); | 78 return fError ? 0 : fReader.readScalar(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 262 |
267 void SkValidatingReadBuffer::skipFlattenable() { | 263 void SkValidatingReadBuffer::skipFlattenable() { |
268 SkString name; | 264 SkString name; |
269 this->readString(&name); | 265 this->readString(&name); |
270 if (fError) { | 266 if (fError) { |
271 return; | 267 return; |
272 } | 268 } |
273 uint32_t sizeRecorded = this->readUInt(); | 269 uint32_t sizeRecorded = this->readUInt(); |
274 this->skip(sizeRecorded); | 270 this->skip(sizeRecorded); |
275 } | 271 } |
OLD | NEW |