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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 // This case can only be reached if extractSubset was called, so | 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 | 205 // the recorded width and height must be smaller than (or equal
to |
206 // the encoded width and height. | 206 // the encoded width and height. |
207 SkASSERT(width <= bitmap->width() && height <= bitmap->height())
; | 207 SkASSERT(width <= bitmap->width() && height <= bitmap->height())
; |
208 | 208 |
209 // FIXME: Once the writer is changed to record the (x,y) offset, | 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
. | 210 // they will be used to store the correct portion of the picture
. |
211 SkBitmap subsetBm; | 211 SkBitmap subsetBm; |
| 212 #ifdef BUMP_PICTURE_VERSION |
| 213 int32_t x = fReader.readS32(); |
| 214 int32_t y = fReader.readS32(); |
| 215 SkIRect subset = SkIRect::MakeXYWH(x, y, width, height); |
| 216 #else |
212 SkIRect subset = SkIRect::MakeWH(width, height); | 217 SkIRect subset = SkIRect::MakeWH(width, height); |
| 218 #endif |
213 if (bitmap->extractSubset(&subsetBm, subset)) { | 219 if (bitmap->extractSubset(&subsetBm, subset)) { |
214 bitmap->swap(subsetBm); | 220 bitmap->swap(subsetBm); |
215 return; | 221 return; |
216 } | 222 } |
217 } | 223 } |
218 // This bitmap was encoded when written, but we are unable to decode
, possibly due to | 224 // This bitmap was encoded when written, but we are unable to decode
, possibly due to |
219 // not having a decoder. | 225 // not having a decoder. |
220 SkErrorInternals::SetError(kParseError_SkError, | 226 SkErrorInternals::SetError(kParseError_SkError, |
221 "Could not decode bitmap. Resulting bitma
p will be red."); | 227 "Could not decode bitmap. Resulting bitma
p will be red."); |
222 } else { | 228 } else { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (sizeRecorded != sizeRead) { | 288 if (sizeRecorded != sizeRead) { |
283 // we could try to fix up the offset... | 289 // we could try to fix up the offset... |
284 sk_throw(); | 290 sk_throw(); |
285 } | 291 } |
286 } else { | 292 } else { |
287 // we must skip the remaining data | 293 // we must skip the remaining data |
288 fReader.skip(sizeRecorded); | 294 fReader.skip(sizeRecorded); |
289 } | 295 } |
290 return obj; | 296 return obj; |
291 } | 297 } |
OLD | NEW |