OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 258 } |
259 // This bitmap was encoded when written, but we are unable to decode
, possibly due to | 259 // This bitmap was encoded when written, but we are unable to decode
, possibly due to |
260 // not having a decoder. | 260 // not having a decoder. |
261 SkErrorInternals::SetError(kParseError_SkError, | 261 SkErrorInternals::SetError(kParseError_SkError, |
262 "Could not decode bitmap. Resulting bitma
p will be empty."); | 262 "Could not decode bitmap. Resulting bitma
p will be empty."); |
263 // Even though we weren't able to decode the pixels, the readbuffer
should still be | 263 // Even though we weren't able to decode the pixels, the readbuffer
should still be |
264 // intact, so we return true with an empty bitmap, so we don't force
an abort of the | 264 // intact, so we return true with an empty bitmap, so we don't force
an abort of the |
265 // larger deserialize. | 265 // larger deserialize. |
266 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height)); | 266 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height)); |
267 return true; | 267 return true; |
268 } else { | 268 } else if (SkBitmap::ReadRawPixels(this, bitmap)) { |
269 // A size of zero means the SkBitmap was simply flattened. | 269 return true; |
270 if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) { | |
271 SkBitmap tmp; | |
272 tmp.legacyUnflatten(*this); | |
273 // just throw this guy away | |
274 } else { | |
275 if (SkBitmap::ReadRawPixels(this, bitmap)) { | |
276 return true; | |
277 } | |
278 } | |
279 } | 270 } |
280 } | 271 } |
281 // Could not read the SkBitmap. Use a placeholder bitmap. | 272 // Could not read the SkBitmap. Use a placeholder bitmap. |
282 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height)); | 273 bitmap->setInfo(SkImageInfo::MakeUnknown(width, height)); |
283 return false; | 274 return false; |
284 } | 275 } |
285 | 276 |
286 SkTypeface* SkReadBuffer::readTypeface() { | 277 SkTypeface* SkReadBuffer::readTypeface() { |
287 | 278 |
288 uint32_t index = fReader.readU32(); | 279 uint32_t index = fReader.readU32(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 return; | 351 return; |
361 } | 352 } |
362 } else { | 353 } else { |
363 if (NULL == this->readFunctionPtr()) { | 354 if (NULL == this->readFunctionPtr()) { |
364 return; | 355 return; |
365 } | 356 } |
366 } | 357 } |
367 uint32_t sizeRecorded = fReader.readU32(); | 358 uint32_t sizeRecorded = fReader.readU32(); |
368 fReader.skip(sizeRecorded); | 359 fReader.skip(sizeRecorded); |
369 } | 360 } |
OLD | NEW |