31 return sampleSize > 0;
51 0.67f, 0.33f, 0.21f, 0.71f, 0.14f, 0.08f, 0.31f, 0.316f, sk_primaries);
54 0.64f, 0.33f, 0.29f, 0.60f, 0.15f, 0.06f, 0.3127f, 0.3290f, sk_primaries);
57 0.630f, 0.340f, 0.310f, 0.595f, 0.155f, 0.070f, 0.3127f, 0.3290f, sk_primaries);
60 0.630f, 0.340f, 0.310f, 0.595f, 0.155f, 0.070f, 0.3127f, 0.3290f, sk_primaries);
63 0.681f, 0.319f, 0.243f, 0.692f, 0.145f, 0.049f, 0.310f, 0.316f, sk_primaries);
69 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f / 3.f, 1.f / 3.f, sk_primaries);
72 0.680f, 0.320f, 0.265f, 0.690f, 0.150f, 0.060f, 0.314f, 0.351f, sk_primaries);
75 0.680f, 0.320f, 0.265f, 0.690f, 0.150f, 0.060f, 0.3127f, 0.3290f, sk_primaries);
78 0.630f, 0.340f, 0.295f, 0.605f, 0.155f, 0.077f, 0.3127f, 0.3290f, sk_primaries);
89 switch (transfer_characteristics) {
103 *trfn = {2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
106 *trfn = {2.8f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
112 *trfn = {2.222222222222f,
159 *trfn = {2.6f, 1.034080527699f, 0.f, 0.f, 0.f, 0.f, 0.f};
183 uint8_t transfer_characteristics,
184 uint8_t matrix_coefficients,
185 uint8_t full_range_flag) {
186 if (matrix_coefficients != 0)
return nullptr;
188 if (full_range_flag != 1)
return nullptr;
200 : fInfo(codec->getInfo())
213 if (
nullptr ==
codec) {
222 return std::make_unique<SkAndroidCodecAdapter>(
codec.release());
225 return std::make_unique<SkSampledCodec>(
codec.release());
235 return std::make_unique<SkSampledCodec>(
codec.release());
239 return std::make_unique<SkAndroidCodecAdapter>(
codec.release());
260 bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
261 uint8_t colorDepth = fCodec->getEncodedInfo().getColorDepth();
262 switch (requestedColorType) {
264 return kN32_SkColorType;
265 case kN32_SkColorType:
282 if (colorDepth == 10) {
306 switch (outputColorType) {
313 if (prefColorSpace) {
314 return prefColorSpace;
317 const skcms_ICCProfile* encodedProfile = fCodec->getEncodedInfo().profile();
318 if (encodedProfile) {
321 const auto cicpColorSpace =
326 if (cicpColorSpace) {
327 return cicpColorSpace;
359 return a.width() <
b.width() ||
a.height() <
b.height();
364 return a.width() >
b.width() &&
a.height() >
b.height();
370 const auto origDims = fCodec->dimensions();
371 if (!desiredSize || *desiredSize == origDims) {
376 *desiredSize = origDims;
381 if (desiredSize->
width() < 1 || desiredSize->
height() < 1) {
390 int sampleX = origDims.width() / desiredSize->
width();
391 int sampleY = origDims.height() / desiredSize->
height();
392 int sampleSize =
std::min(sampleX, sampleY);
394 if (computedSize == *desiredSize) {
398 if (computedSize == origDims || sampleSize == 1) {
400 *desiredSize = computedSize;
408 if (smaller == *desiredSize) {
409 return sampleSize + 1;
411 if (smaller == computedSize ||
smaller_than(smaller, *desiredSize)) {
413 *desiredSize = computedSize;
418 computedSize = smaller;
427 *desiredSize = computedSize;
432 while (sampleSize > 2) {
434 if (bigger == *desiredSize || !
smaller_than(bigger, *desiredSize)) {
435 *desiredSize = bigger;
436 return sampleSize - 1;
441 *desiredSize = origDims;
451 if (1 == sampleSize) {
452 return fCodec->dimensions();
459 if (!desiredSubset || !
is_valid_subset(*desiredSubset, fCodec->dimensions())) {
480 if (fCodec->dimensions() == subset.
size()) {
492 if (!requestPixels) {
513 defaultOptions.
fSubset =
nullptr;
523 auto getPixelsFn = [&](
const SkImageInfo&
info,
void* pixels,
size_t rowBytes,
531 if (
auto result = fCodec->handleFrameIndex(requestInfo, requestPixels, requestRowBytes,
545 std::unique_ptr<SkStream>* outGainmapImageStream) {
546 return fCodec->onGetGainmapInfo(
info, outGainmapImageStream);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static bool cicp_get_primaries(uint8_t primaries, skcms_Matrix3x3 *sk_primaries)
static bool smaller_than(const SkISize &a, const SkISize &b)
static sk_sp< SkColorSpace > cicp_get_sk_color_space(uint8_t color_primaries, uint8_t transfer_characteristics, uint8_t matrix_coefficients, uint8_t full_range_flag)
static bool strictly_bigger_than(const SkISize &a, const SkISize &b)
static bool supports_any_down_scale(const SkCodec *codec)
static bool cicp_get_transfer_fn(uint8_t transfer_characteristics, skcms_TransferFunction *trfn)
static bool is_valid_sample_size(int sampleSize)
static bool is_valid_subset(const SkIRect &subset, const SkISize &imageDims)
static int get_scaled_dimension(int srcDimension, int sampleSize)
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
bool getSupportedSubset(SkIRect *desiredSubset) const
virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options)=0
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
SkISize getSampledSubsetDimensions(int sampleSize, const SkIRect &subset) const
const SkImageInfo & getInfo() const
virtual ~SkAndroidCodec()
SkCodec::Result getAndroidPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions *options)
static std::unique_ptr< SkAndroidCodec > MakeFromCodec(std::unique_ptr< SkCodec >)
virtual SkISize onGetSampledDimensions(int sampleSize) const =0
SkISize getSampledDimensions(int sampleSize) const
bool getAndroidGainmap(SkGainmapInfo *outInfo, std::unique_ptr< SkStream > *outGainmapImageStream)
SkColorType computeOutputColorType(SkColorType requestedColorType)
SkAndroidCodec(SkCodec *)
SkAlphaType computeOutputAlphaType(bool requestedUnpremul)
int computeSampleSize(SkISize *size) const
virtual bool onGetSupportedSubset(SkIRect *desiredSubset) const =0
sk_sp< SkColorSpace > computeOutputColorSpace(SkColorType outputColorType, sk_sp< SkColorSpace > prefColorSpace=nullptr)
static std::unique_ptr< SkAndroidCodec > MakeFromStream(std::unique_ptr< SkStream >, SkPngChunkReader *=nullptr)
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
SkEncodedImageFormat getEncodedFormat() const
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > Make(const skcms_ICCProfile &)
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
uint32_t uint32_t * format
static float max(float r, float g, float b)
static float min(float r, float g, float b)
bool HasDecoder(std::string_view id)
static constexpr skcms_Matrix3x3 kSRGB
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_TransferFunction kRec2020
static constexpr skcms_TransferFunction kSRGB
static constexpr skcms_TransferFunction kLinear
bool skcms_PrimariesToXYZD50(float rx, float ry, float gx, float gy, float bx, float by, float wx, float wy, skcms_Matrix3x3 *toXYZD50)
bool skcms_TransferFunction_makeScaledHLGish(skcms_TransferFunction *tf, float K, float R, float G, float a, float b, float c)
constexpr SkISize size() const
constexpr int32_t height() const
static constexpr SkIRect MakeSize(const SkISize &size)
constexpr int32_t width() const
static constexpr SkISize Make(int32_t w, int32_t h)
constexpr int32_t width() const
constexpr int32_t height() const
size_t minRowBytes() const
uint8_t matrix_coefficients
uint8_t video_full_range_flag
uint8_t transfer_characteristics
std::shared_ptr< const fml::Mapping > data