| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 SkBitmap subsetBm; | 252 SkBitmap subsetBm; |
| 253 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig
ht); | 253 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig
ht); |
| 254 if (bitmap->extractSubset(&subsetBm, subset)) { | 254 if (bitmap->extractSubset(&subsetBm, subset)) { |
| 255 bitmap->swap(subsetBm); | 255 bitmap->swap(subsetBm); |
| 256 return true; | 256 return true; |
| 257 } | 257 } |
| 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 red."); | 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 for a
n 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 { |
| 269 // A size of zero means the SkBitmap was simply flattened. | 269 // A size of zero means the SkBitmap was simply flattened. |
| 270 if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) { | 270 if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) { |
| 271 SkBitmap tmp; | 271 SkBitmap tmp; |
| 272 tmp.legacyUnflatten(*this); | 272 tmp.legacyUnflatten(*this); |
| 273 // just throw this guy away | 273 // just throw this guy away |
| 274 } else { | 274 } else { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return; | 360 return; |
| 361 } | 361 } |
| 362 } else { | 362 } else { |
| 363 if (NULL == this->readFunctionPtr()) { | 363 if (NULL == this->readFunctionPtr()) { |
| 364 return; | 364 return; |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 uint32_t sizeRecorded = fReader.readU32(); | 367 uint32_t sizeRecorded = fReader.readU32(); |
| 368 fReader.skip(sizeRecorded); | 368 fReader.skip(sizeRecorded); |
| 369 } | 369 } |
| OLD | NEW |