| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL); | 384 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL); |
| 385 fPng_ptr = NULL; | 385 fPng_ptr = NULL; |
| 386 fInfo_ptr = NULL; | 386 fInfo_ptr = NULL; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 /////////////////////////////////////////////////////////////////////////////// | 390 /////////////////////////////////////////////////////////////////////////////// |
| 391 // Getting the pixels | 391 // Getting the pixels |
| 392 /////////////////////////////////////////////////////////////////////////////// | 392 /////////////////////////////////////////////////////////////////////////////// |
| 393 | 393 |
| 394 static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
{ | |
| 395 // TODO: Support other conversions | |
| 396 if (dst.profileType() != src.profileType()) { | |
| 397 return false; | |
| 398 } | |
| 399 | |
| 400 // Ensure the alpha type is valid | |
| 401 if (!valid_alpha(dst.alphaType(), src.alphaType())) { | |
| 402 return false; | |
| 403 } | |
| 404 | |
| 405 // Check for supported color types | |
| 406 switch (dst.colorType()) { | |
| 407 case kN32_SkColorType: | |
| 408 return true; | |
| 409 case kRGB_565_SkColorType: | |
| 410 return src.alphaType() == kOpaque_SkAlphaType; | |
| 411 default: | |
| 412 return dst.colorType() == src.colorType(); | |
| 413 } | |
| 414 } | |
| 415 | |
| 416 SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo, | 394 SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo, |
| 417 const Options& options, | 395 const Options& options, |
| 418 SkPMColor ctable[], | 396 SkPMColor ctable[], |
| 419 int* ctableCount) { | 397 int* ctableCount) { |
| 420 // FIXME: Could we use the return value of setjmp to specify the type of | 398 // FIXME: Could we use the return value of setjmp to specify the type of |
| 421 // error? | 399 // error? |
| 422 if (setjmp(png_jmpbuf(fPng_ptr))) { | 400 if (setjmp(png_jmpbuf(fPng_ptr))) { |
| 423 SkCodecPrintf("setjmp long jump!\n"); | 401 SkCodecPrintf("setjmp long jump!\n"); |
| 424 return kInvalidInput; | 402 return kInvalidInput; |
| 425 } | 403 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 | 763 |
| 786 const SkImageInfo& srcInfo = codec->getInfo(); | 764 const SkImageInfo& srcInfo = codec->getInfo(); |
| 787 if (codec->fNumberPasses > 1) { | 765 if (codec->fNumberPasses > 1) { |
| 788 // interlaced image | 766 // interlaced image |
| 789 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach
())); | 767 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach
())); |
| 790 } | 768 } |
| 791 | 769 |
| 792 return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach())); | 770 return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach())); |
| 793 } | 771 } |
| 794 | 772 |
| OLD | NEW |