#include "ui/gfx/codec/png_codec.h"
#include <stdint.h>
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "third_party/skia/include/codec/SkPngDecoder.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "third_party/skia/include/encode/SkPngEncoder.h"
#include "third_party/zlib/zlib.h"
#include "ui/gfx/codec/vector_wstream.h"
#include "ui/gfx/geometry/size.h"
namespace gfx {
static bool PrepareForPNGDecode(const unsigned char* input,
size_t input_size,
PNGCodec::ColorFormat format,
std::unique_ptr<SkCodec>* codec,
SkImageInfo* image_info) { … }
bool PNGCodec::Decode(const unsigned char* input,
size_t input_size,
ColorFormat format,
std::vector<unsigned char>* output,
int* w,
int* h) { … }
bool PNGCodec::Decode(const unsigned char* input,
size_t input_size,
SkBitmap* bitmap) { … }
namespace {
void AddComments(SkPngEncoder::Options& options,
const std::vector<PNGCodec::Comment>& comments) { … }
bool EncodeSkPixmap(const SkPixmap& src,
const std::vector<PNGCodec::Comment>& comments,
std::vector<unsigned char>* output,
int zlib_level,
bool disable_filters) { … }
bool EncodeSkPixmap(const SkPixmap& src,
bool discard_transparency,
const std::vector<PNGCodec::Comment>& comments,
std::vector<unsigned char>* output,
int zlib_level,
bool disable_filters) { … }
bool EncodeSkBitmap(const SkBitmap& input,
bool discard_transparency,
std::vector<unsigned char>* output,
int zlib_level,
bool disable_filters) { … }
}
bool PNGCodec::Encode(const unsigned char* input,
ColorFormat format,
const Size& size,
int row_byte_width,
bool discard_transparency,
const std::vector<Comment>& comments,
std::vector<unsigned char>* output) { … }
bool PNGCodec::EncodeBGRASkBitmap(const SkBitmap& input,
bool discard_transparency,
std::vector<unsigned char>* output) { … }
bool PNGCodec::EncodeA8SkBitmap(const SkBitmap& input,
std::vector<unsigned char>* output) { … }
bool PNGCodec::FastEncodeBGRASkBitmap(const SkBitmap& input,
bool discard_transparency,
std::vector<unsigned char>* output) { … }
PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
: … { … }
PNGCodec::Comment::~Comment() = default;
}