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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 fDecodedBitmapIndex, width, height, length, xOf
fset, | 219 fDecodedBitmapIndex, width, height, length, xOf
fset, |
220 yOffset); | 220 yOffset); |
221 } | 221 } |
222 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 222 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
223 // If the width and height match, there should be no offset. | 223 // If the width and height match, there should be no offset. |
224 SkASSERT(0 == xOffset && 0 == yOffset); | 224 SkASSERT(0 == xOffset && 0 == yOffset); |
225 return; | 225 return; |
226 } | 226 } |
227 | 227 |
228 // This case can only be reached if extractSubset was called, so | 228 // This case can only be reached if extractSubset was called, so |
229 // the recorded width and height must be smaller than (or equal
to | 229 // the recorded width and height must be smaller than or equal t
o |
230 // the encoded width and height. | 230 // the encoded width and height. |
231 SkASSERT(width <= bitmap->width() && height <= bitmap->height())
; | 231 // FIXME (scroggo): This assert assumes that our decoder and the |
| 232 // sources encoder agree on the width and height which may not |
| 233 // always be the case. Removing until it can be investigated |
| 234 // further. |
| 235 //SkASSERT(width <= bitmap->width() && height <= bitmap->height(
)); |
232 | 236 |
233 SkBitmap subsetBm; | 237 SkBitmap subsetBm; |
234 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig
ht); | 238 SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, heig
ht); |
235 if (bitmap->extractSubset(&subsetBm, subset)) { | 239 if (bitmap->extractSubset(&subsetBm, subset)) { |
236 bitmap->swap(subsetBm); | 240 bitmap->swap(subsetBm); |
237 return; | 241 return; |
238 } | 242 } |
239 } | 243 } |
240 // This bitmap was encoded when written, but we are unable to decode
, possibly due to | 244 // This bitmap was encoded when written, but we are unable to decode
, possibly due to |
241 // not having a decoder. | 245 // not having a decoder. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (sizeRecorded != sizeRead) { | 312 if (sizeRecorded != sizeRead) { |
309 // we could try to fix up the offset... | 313 // we could try to fix up the offset... |
310 sk_throw(); | 314 sk_throw(); |
311 } | 315 } |
312 } else { | 316 } else { |
313 // we must skip the remaining data | 317 // we must skip the remaining data |
314 fReader.skip(sizeRecorded); | 318 fReader.skip(sizeRecorded); |
315 } | 319 } |
316 return obj; | 320 return obj; |
317 } | 321 } |
OLD | NEW |