#include "src/codec/SkPngCodec.h"
#include "include/codec/SkPngChunkReader.h"
#include "include/codec/SkPngDecoder.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRect.h"
#include "include/core/SkSize.h"
#include "include/core/SkSpan.h"
#include "include/core/SkStream.h"
#include "include/core/SkTypes.h"
#include "include/private/SkEncodedInfo.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkTemplates.h"
#include "modules/skcms/skcms.h"
#include "src/codec/SkCodecPriv.h"
#include "src/codec/SkPngPriv.h"
#include "src/codec/SkSwizzler.h"
#include <csetjmp>
#include <algorithm>
#include <cstring>
#include <utility>
#include <png.h>
#include <pngconf.h>
usingnamespaceskia_private;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "include/android/SkAndroidFrameworkUtils.h"
#endif
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wclobbered"
#endif
#define PNG_JMPBUF(x) …
constexpr int kSetJmpOkay = …;
constexpr int kPngError = …;
constexpr int kStopDecoding = …;
static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { … }
void sk_warning_fn(png_structp, png_const_charp msg) { … }
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { … }
#endif
class AutoCleanPng : public SkNoncopyable { … };
static inline bool is_chunk(const png_byte* chunk, const char* tag) { … }
static inline bool process_data(png_structp png_ptr, png_infop info_ptr,
SkStream* stream, void* buffer, size_t bufferSize, size_t length) { … }
bool AutoCleanPng::decodeBounds() { … }
bool SkPngCodec::processData() { … }
std::optional<SkSpan<const SkPngCodecBase::PaletteColorEntry>> SkPngCodec::onTryGetPlteChunk() { … }
std::optional<SkSpan<const uint8_t>> SkPngCodec::onTryGetTrnsChunk() { … }
bool SkPngCodec::IsPng(const void* buf, size_t bytesRead) { … }
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
static float png_fixed_point_to_float(png_fixed_point x) { … }
static float png_inverted_fixed_point_to_float(png_fixed_point x) { … }
#endif
std::unique_ptr<SkEncodedInfo::ICCProfile> read_color_profile(png_structp png_ptr,
png_infop info_ptr) { … }
static SkCodec::Result log_and_return_error(bool success) { … }
class SkPngNormalDecoder : public SkPngCodec { … };
class SkPngInterlacedDecoder : public SkPngCodec { … };
static SkCodec::Result read_header(SkStream* stream, SkPngChunkReader* chunkReader,
SkCodec** outCodec,
png_structp* png_ptrp, png_infop* info_ptrp) { … }
void AutoCleanPng::infoCallback(size_t idatLength) { … }
SkPngCodec::SkPngCodec(SkEncodedInfo&& encodedInfo,
std::unique_ptr<SkStream> stream,
SkPngChunkReader* chunkReader,
void* png_ptr,
void* info_ptr)
: … { … }
SkPngCodec::~SkPngCodec() { … }
void SkPngCodec::destroyReadStruct() { … }
SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& options) { … }
bool SkPngCodec::onRewind() { … }
SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
size_t rowBytes, const Options& options,
int* rowsDecoded) { … }
SkCodec::Result SkPngCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
void* dst, size_t rowBytes, const SkCodec::Options& options) { … }
SkCodec::Result SkPngCodec::onIncrementalDecode(int* rowsDecoded) { … }
std::unique_ptr<SkCodec> SkPngCodec::MakeFromStream(std::unique_ptr<SkStream> stream,
Result* result, SkPngChunkReader* chunkReader) { … }
namespace SkPngDecoder {
bool IsPng(const void* data, size_t len) { … }
std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream> stream,
SkCodec::Result* outResult,
SkCodecs::DecodeContext ctx) { … }
std::unique_ptr<SkCodec> Decode(sk_sp<SkData> data,
SkCodec::Result* outResult,
SkCodecs::DecodeContext ctx) { … }
}