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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 } else { | 770 } else { |
771 *outCodec = new SkPngInterlacedCodec(encodedInfo, imageInfo, stream, | 771 *outCodec = new SkPngInterlacedCodec(encodedInfo, imageInfo, stream, |
772 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses); | 772 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses); |
773 } | 773 } |
774 } | 774 } |
775 | 775 |
776 return true; | 776 return true; |
777 } | 777 } |
778 | 778 |
779 SkPngCodec::SkPngCodec(const SkEncodedInfo& encodedInfo, const SkImageInfo& imag
eInfo, | 779 SkPngCodec::SkPngCodec(const SkEncodedInfo& encodedInfo, const SkImageInfo& imag
eInfo, |
780 SkStream* stream, SkPngChunkReader* chunkReader, png_stru
ctp png_ptr, | 780 SkStream* stream, SkPngChunkReader* chunkReader, void* pn
g_ptr, |
781 png_infop info_ptr, int bitDepth, int numberPasses) | 781 void* info_ptr, int bitDepth, int numberPasses) |
782 : INHERITED(encodedInfo, imageInfo, stream) | 782 : INHERITED(encodedInfo, imageInfo, stream) |
783 , fPngChunkReader(SkSafeRef(chunkReader)) | 783 , fPngChunkReader(SkSafeRef(chunkReader)) |
784 , fPng_ptr(png_ptr) | 784 , fPng_ptr(png_ptr) |
785 , fInfo_ptr(info_ptr) | 785 , fInfo_ptr(info_ptr) |
786 , fSwizzlerSrcRow(nullptr) | 786 , fSwizzlerSrcRow(nullptr) |
787 , fColorXformSrcRow(nullptr) | 787 , fColorXformSrcRow(nullptr) |
788 , fSrcRowBytes(imageInfo.width() * (bytes_per_pixel(this->getEncodedInfo().b
itsPerPixel()))) | 788 , fSrcRowBytes(imageInfo.width() * (bytes_per_pixel(this->getEncodedInfo().b
itsPerPixel()))) |
789 , fNumberPasses(numberPasses) | 789 , fNumberPasses(numberPasses) |
790 , fBitDepth(bitDepth) | 790 , fBitDepth(bitDepth) |
791 {} | 791 {} |
792 | 792 |
793 SkPngCodec::~SkPngCodec() { | 793 SkPngCodec::~SkPngCodec() { |
794 this->destroyReadStruct(); | 794 this->destroyReadStruct(); |
795 } | 795 } |
796 | 796 |
797 void SkPngCodec::destroyReadStruct() { | 797 void SkPngCodec::destroyReadStruct() { |
798 if (fPng_ptr) { | 798 if (fPng_ptr) { |
799 // We will never have a nullptr fInfo_ptr with a non-nullptr fPng_ptr | 799 // We will never have a nullptr fInfo_ptr with a non-nullptr fPng_ptr |
800 SkASSERT(fInfo_ptr); | 800 SkASSERT(fInfo_ptr); |
801 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, nullptr); | 801 png_destroy_read_struct((png_struct**)&fPng_ptr, (png_info**)&fInfo_ptr,
nullptr); |
802 fPng_ptr = nullptr; | 802 fPng_ptr = nullptr; |
803 fInfo_ptr = nullptr; | 803 fInfo_ptr = nullptr; |
804 } | 804 } |
805 } | 805 } |
806 | 806 |
807 /////////////////////////////////////////////////////////////////////////////// | 807 /////////////////////////////////////////////////////////////////////////////// |
808 // Getting the pixels | 808 // Getting the pixels |
809 /////////////////////////////////////////////////////////////////////////////// | 809 /////////////////////////////////////////////////////////////////////////////// |
810 | 810 |
811 bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
ions, | 811 bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
ions, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 SkCodec* outCodec; | 926 SkCodec* outCodec; |
927 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { | 927 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { |
928 // Codec has taken ownership of the stream. | 928 // Codec has taken ownership of the stream. |
929 SkASSERT(outCodec); | 929 SkASSERT(outCodec); |
930 streamDeleter.release(); | 930 streamDeleter.release(); |
931 return outCodec; | 931 return outCodec; |
932 } | 932 } |
933 | 933 |
934 return nullptr; | 934 return nullptr; |
935 } | 935 } |
OLD | NEW |