Flutter Engine
The Flutter Engine
SkJpegxlCodec.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkJpegxlCodec_DEFINED
9#define SkJpegxlCodec_DEFINED
10
12#include "include/core/SkData.h"
15
16#include <cstddef>
17#include <memory>
18
19class SkCodec;
20class SkFrameHolder;
22class SkStream;
23struct SkEncodedInfo;
24struct SkImageInfo;
25
26/*
27 *
28 * This class implements the decoding for jpegxl images
29 *
30 */
32public:
33 static bool IsJpegxl(const void*, size_t);
34
35 /*
36 * Assumes IsJpegxl was called and returned true
37 * Takes ownership of the stream
38 */
39 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
40
41protected:
42 /* TODO(eustas): implement when downscaling is supported. */
43 /* SkISize onGetScaledDimensions(float desiredScale) const override; */
44
45 /* TODO(eustas): implement when up-/down-scaling is supported. */
46 /* bool onDimensionsSupported(const SkISize&) override; */
47
50 }
51
52 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
53 const Options& options, int* rowsDecodedPtr) override;
54
55 /* TODO(eustas): add support for transcoded JPEG images? */
56 /* bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
57 SkYUVAPixmapInfo*) const override; */
58
59 /* TODO(eustas): add support for transcoded JPEG images? */
60 /* Result onGetYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps) override; */
61
62 /* TODO(eustas): implement when cropped output is supported. */
63 /* bool onGetValidSubset(SkIRect* desiredSubset) const override; */
64
65 bool onRewind() override;
66
67 /* TODO(eustas): top-down by default; do we need something else? */
68 /* SkScanlineOrder onGetScanlineOrder() const override; */
69 /* int onOutputScanline(int inputScanline) const override; */
70
71 bool conversionSupported(const SkImageInfo&, bool, bool) override;
72
73 int onGetFrameCount() override;
74
75 bool onGetFrameInfo(int, FrameInfo*) const override;
76
77 int onGetRepetitionCount() override;
78
79private:
80 const SkFrameHolder* getFrameHolder() const override;
81
82 // Result onStartScanlineDecode(
83 // const SkImageInfo& /*dstInfo*/, const Options& /*options*/) override;
84 // Result onStartIncrementalDecode(
85 // const SkImageInfo& /*dstInfo*/, void*, size_t, const Options&) override;
86 // Result onIncrementalDecode(int*) override;
87 // bool onSkipScanlines(int /*countLines*/) override;
88 // int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) override;
89 // SkSampler* getSampler(bool /*createIfNecessary*/) override;
90
91 // Opaque codec implementation for lightweight header file.
92 std::unique_ptr<SkJpegxlCodecPriv> fCodec;
93 sk_sp<SkData> fData;
94
95 bool scanFrames();
96 static void imageOutCallback(
97 void* opaque, size_t x, size_t y, size_t num_pixels, const void* pixels);
98
99 SkJpegxlCodec(std::unique_ptr<SkJpegxlCodecPriv> codec,
101 std::unique_ptr<SkStream> stream,
103
104 using INHERITED = SkScalingCodec;
105};
106
107#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkEncodedImageFormat
const SkImageInfo & dstInfo() const
Definition: SkCodec.h:878
SkStream * stream()
Definition: SkCodec.h:865
Result
Definition: SkCodec.h:76
const Options & options() const
Definition: SkCodec.h:880
Result onGetPixels(const SkImageInfo &dstInfo, void *dst, size_t rowBytes, const Options &options, int *rowsDecodedPtr) override
int onGetRepetitionCount() override
int onGetFrameCount() override
bool conversionSupported(const SkImageInfo &, bool, bool) override
bool onGetFrameInfo(int, FrameInfo *) const override
static bool IsJpegxl(const void *, size_t)
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *)
SkEncodedImageFormat onGetEncodedFormat() const override
Definition: SkJpegxlCodec.h:48
bool onRewind() override
SkScalingCodec(SkEncodedInfo &&info, XformFormat srcFormat, std::unique_ptr< SkStream > stream, SkEncodedOrigin origin=kTopLeft_SkEncodedOrigin)
double y
double x
dst
Definition: cp.py:12
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63