| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 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 "SkCodec_libpng.h" | 8 #include "SkCodec_libpng.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL); | 385 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL); |
| 386 fPng_ptr = NULL; | 386 fPng_ptr = NULL; |
| 387 fInfo_ptr = NULL; | 387 fInfo_ptr = NULL; |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 /////////////////////////////////////////////////////////////////////////////// | 391 /////////////////////////////////////////////////////////////////////////////// |
| 392 // Getting the pixels | 392 // Getting the pixels |
| 393 /////////////////////////////////////////////////////////////////////////////// | 393 /////////////////////////////////////////////////////////////////////////////// |
| 394 | 394 |
| 395 static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
{ | |
| 396 // TODO: Support other conversions | |
| 397 if (dst.profileType() != src.profileType()) { | |
| 398 return false; | |
| 399 } | |
| 400 | |
| 401 // Ensure the alpha type is valid | |
| 402 if (!valid_alpha(dst.alphaType(), src.alphaType())) { | |
| 403 return false; | |
| 404 } | |
| 405 | |
| 406 // Check for supported color types | |
| 407 switch (dst.colorType()) { | |
| 408 case kN32_SkColorType: | |
| 409 return true; | |
| 410 case kRGB_565_SkColorType: | |
| 411 return src.alphaType() == kOpaque_SkAlphaType; | |
| 412 default: | |
| 413 return dst.colorType() == src.colorType(); | |
| 414 } | |
| 415 } | |
| 416 | |
| 417 SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo, | 395 SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo, |
| 418 const Options& options, | 396 const Options& options, |
| 419 SkPMColor ctable[], | 397 SkPMColor ctable[], |
| 420 int* ctableCount) { | 398 int* ctableCount) { |
| 421 // FIXME: Could we use the return value of setjmp to specify the type of | 399 // FIXME: Could we use the return value of setjmp to specify the type of |
| 422 // error? | 400 // error? |
| 423 if (setjmp(png_jmpbuf(fPng_ptr))) { | 401 if (setjmp(png_jmpbuf(fPng_ptr))) { |
| 424 SkCodecPrintf("setjmp long jump!\n"); | 402 SkCodecPrintf("setjmp long jump!\n"); |
| 425 return kInvalidInput; | 403 return kInvalidInput; |
| 426 } | 404 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 780 |
| 803 const SkImageInfo& srcInfo = codec->getInfo(); | 781 const SkImageInfo& srcInfo = codec->getInfo(); |
| 804 if (codec->fNumberPasses > 1) { | 782 if (codec->fNumberPasses > 1) { |
| 805 // interlaced image | 783 // interlaced image |
| 806 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach
())); | 784 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach
())); |
| 807 } | 785 } |
| 808 | 786 |
| 809 return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach())); | 787 return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach())); |
| 810 } | 788 } |
| 811 | 789 |
| OLD | NEW |