OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
9 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 SkAutoUnref aur(colorTable); | 356 SkAutoUnref aur(colorTable); |
357 | 357 |
358 if (!this->allocPixelRef(decodedBitmap, | 358 if (!this->allocPixelRef(decodedBitmap, |
359 kIndex_8_SkColorType == colorType ? colorTable : NU
LL)) { | 359 kIndex_8_SkColorType == colorType ? colorTable : NU
LL)) { |
360 return kFailure; | 360 return kFailure; |
361 } | 361 } |
362 | 362 |
363 SkAutoLockPixels alp(*decodedBitmap); | 363 SkAutoLockPixels alp(*decodedBitmap); |
364 | 364 |
365 // Repeat setjmp, otherwise variables declared since the last call (e.g. alp | |
366 // and aur) won't get their destructors called in case of a failure. | |
367 if (setjmp(png_jmpbuf(png_ptr))) { | |
368 return kFailure; | |
369 } | |
370 | |
371 /* Turn on interlace handling. REQUIRED if you are not using | 365 /* Turn on interlace handling. REQUIRED if you are not using |
372 * png_read_image(). To see how to handle interlacing passes, | 366 * png_read_image(). To see how to handle interlacing passes, |
373 * see the png_read_row() method below: | 367 * see the png_read_row() method below: |
374 */ | 368 */ |
375 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ? | 369 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ? |
376 png_set_interlace_handling(png_ptr) : 1; | 370 png_set_interlace_handling(png_ptr) : 1; |
377 | 371 |
378 /* Optional call to gamma correct and add the background to the palette | 372 /* Optional call to gamma correct and add the background to the palette |
379 * and update info structure. REQUIRED if you are expecting libpng to | 373 * and update info structure. REQUIRED if you are expecting libpng to |
380 * update the palette for you (ie you selected such a transform above). | 374 * update the palette for you (ie you selected such a transform above). |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 return SkImageDecoder::kUnknown_Format; | 1270 return SkImageDecoder::kUnknown_Format; |
1277 } | 1271 } |
1278 | 1272 |
1279 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1273 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1280 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1274 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1281 } | 1275 } |
1282 | 1276 |
1283 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1277 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1284 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1278 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1285 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1279 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |