| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 190                                        "SkOrderedReadBuffer has no SkBitmapHeapR
     eader to " | 190                                        "SkOrderedReadBuffer has no SkBitmapHeapR
     eader to " | 
| 191                                        "retrieve the SkBitmap."); | 191                                        "retrieve the SkBitmap."); | 
| 192         } | 192         } | 
| 193     } else { | 193     } else { | 
| 194         // The writer stored false, meaning the SkBitmap was not stored in an Sk
     BitmapHeap. | 194         // The writer stored false, meaning the SkBitmap was not stored in an Sk
     BitmapHeap. | 
| 195         const size_t length = this->readUInt(); | 195         const size_t length = this->readUInt(); | 
| 196         if (length > 0) { | 196         if (length > 0) { | 
| 197             // A non-zero size means the SkBitmap was encoded. | 197             // A non-zero size means the SkBitmap was encoded. | 
| 198             const void* data = this->skip(length); | 198             const void* data = this->skip(length); | 
| 199             if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) 
     { | 199             if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) 
     { | 
| 200                 SkASSERT(bitmap->width() == width && bitmap->height() == height)
     ; | 200                 if (bitmap->width() == width && bitmap->height() == height) { | 
| 201                 return; | 201                     return; | 
|  | 202                 } | 
|  | 203 | 
|  | 204                 // This case can only be reached if extractSubset was called, so | 
|  | 205                 // the recorded width and height must be smaller than (or equal 
     to | 
|  | 206                 // the encoded width and height. | 
|  | 207                 SkASSERT(width <= bitmap->width() && height <= bitmap->height())
     ; | 
|  | 208 | 
|  | 209                 // FIXME: Once the writer is changed to record the (x,y) offset, | 
|  | 210                 // they will be used to store the correct portion of the picture
     . | 
|  | 211                 SkBitmap subsetBm; | 
|  | 212                 SkIRect subset = SkIRect::MakeWH(width, height); | 
|  | 213                 if (bitmap->extractSubset(&subsetBm, subset)) { | 
|  | 214                     bitmap->swap(subsetBm); | 
|  | 215                     return; | 
|  | 216                 } | 
| 202             } | 217             } | 
| 203             // This bitmap was encoded when written, but we are unable to decode
     , possibly due to | 218             // This bitmap was encoded when written, but we are unable to decode
     , possibly due to | 
| 204             // not having a decoder. | 219             // not having a decoder. | 
| 205             SkErrorInternals::SetError(kParseError_SkError, | 220             SkErrorInternals::SetError(kParseError_SkError, | 
| 206                                        "Could not decode bitmap. Resulting bitma
     p will be red."); | 221                                        "Could not decode bitmap. Resulting bitma
     p will be red."); | 
| 207         } else { | 222         } else { | 
| 208             // A size of zero means the SkBitmap was simply flattened. | 223             // A size of zero means the SkBitmap was simply flattened. | 
| 209             bitmap->unflatten(*this); | 224             bitmap->unflatten(*this); | 
| 210             return; | 225             return; | 
| 211         } | 226         } | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 267         if (sizeRecorded != sizeRead) { | 282         if (sizeRecorded != sizeRead) { | 
| 268             // we could try to fix up the offset... | 283             // we could try to fix up the offset... | 
| 269             sk_throw(); | 284             sk_throw(); | 
| 270         } | 285         } | 
| 271     } else { | 286     } else { | 
| 272         // we must skip the remaining data | 287         // we must skip the remaining data | 
| 273         fReader.skip(sizeRecorded); | 288         fReader.skip(sizeRecorded); | 
| 274     } | 289     } | 
| 275     return obj; | 290     return obj; | 
| 276 } | 291 } | 
| OLD | NEW | 
|---|