Flutter Engine
The Flutter Engine
SkHeifCodec.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 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 SkHeifCodec_DEFINED
9#define SkHeifCodec_DEFINED
10
18
19#if __has_include("HeifDecoderAPI.h")
20 #include "HeifDecoderAPI.h"
21#else
23#endif
24
25class SkHeifCodec : public SkCodec {
26public:
27 /*
28 * Returns true if one of kHEIF or kAVIF images were detected. If |format|
29 * is not nullptr, it will contain the detected format. Returns false
30 * otherwise.
31 */
32 static bool IsSupported(const void*, size_t, SkEncodedImageFormat* format);
33
34 /*
35 * Assumes IsSupported was called and it returned a non-nullopt value.
36 */
37 static std::unique_ptr<SkCodec> MakeFromStream(
38 std::unique_ptr<SkStream>, SkCodec::SelectionPolicy selectionPolicy,
39 Result*);
40
41protected:
42
44 const SkImageInfo& dstInfo,
45 void* dst, size_t dstRowBytes,
46 const Options& options,
47 int* rowsDecoded) override;
48
50 return fFormat;
51 }
52
53 int onGetFrameCount() override;
54 bool onGetFrameInfo(int, FrameInfo*) const override;
55 int onGetRepetitionCount() override;
56 const SkFrameHolder* getFrameHolder() const override {
57 return &fFrameHolder;
58 }
59
60 bool conversionSupported(const SkImageInfo&, bool, bool) override;
61
62 bool onRewind() override;
63
64private:
65 /*
66 * Creates an instance of the decoder
67 * Called only by NewFromStream
68 */
71
72 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options);
73 void allocateStorage(const SkImageInfo& dstInfo);
74 int readRows(const SkImageInfo& dstInfo, void* dst,
75 size_t rowBytes, int count, const Options&);
76
77 /*
78 * Scanline decoding.
79 */
80 SkSampler* getSampler(bool createIfNecessary) override;
81 Result onStartScanlineDecode(const SkImageInfo& dstInfo,
82 const Options& options) override;
83 int onGetScanlines(void* dst, int count, size_t rowBytes) override;
84 bool onSkipScanlines(int count) override;
85
86 std::unique_ptr<HeifDecoder> fHeifDecoder;
87 HeifFrameInfo fFrameInfo;
89 uint8_t* fSwizzleSrcRow;
90 uint32_t* fColorXformSrcRow;
91
92 std::unique_ptr<SkSwizzler> fSwizzler;
93 bool fUseAnimation;
94 const SkEncodedImageFormat fFormat;
95
96 class Frame : public SkFrame {
97 public:
98 Frame(int i) : INHERITED(i) {}
99
100 protected:
101 SkEncodedInfo::Alpha onReportedAlpha() const override {
102 return SkEncodedInfo::Alpha::kOpaque_Alpha;
103 }
104
105 private:
106 using INHERITED = SkFrame;
107 };
108
109 class FrameHolder : public SkFrameHolder {
110 public:
111 ~FrameHolder() override {}
112 void setScreenSize(int w, int h) {
113 fScreenWidth = w;
115 }
116 Frame* appendNewFrame();
117 const Frame* frame(int i) const;
118 Frame* editFrameAt(int i);
119 int size() const {
120 return static_cast<int>(fFrames.size());
121 }
122 void reserve(int size) {
123 fFrames.reserve(size);
124 }
125
126 protected:
127 const SkFrame* onGetFrame(int i) const override;
128
129 private:
130 std::vector<Frame> fFrames;
131 };
132
133 FrameHolder fFrameHolder;
134 using INHERITED = SkCodec;
135};
136
137#endif // SkHeifCodec_DEFINED
int count
Definition: FontMgrTest.cpp:50
SkEncodedImageFormat
SkEncodedOrigin
#define INHERITED(method,...)
Definition: SkRecorder.cpp:128
const SkImageInfo & dstInfo() const
Definition: SkCodec.h:878
SkCodec(SkEncodedInfo &&, XformFormat srcFormat, std::unique_ptr< SkStream >, SkEncodedOrigin=kTopLeft_SkEncodedOrigin)
Definition: SkCodec.cpp:250
Result
Definition: SkCodec.h:76
SelectionPolicy
Definition: SkCodec.h:136
const Options & options() const
Definition: SkCodec.h:880
int onGetFrameCount() override
SkEncodedImageFormat onGetEncodedFormat() const override
Definition: SkHeifCodec.h:49
static bool IsSupported(const void *, size_t, SkEncodedImageFormat *format)
Definition: SkHeifCodec.cpp:21
const SkFrameHolder * getFrameHolder() const override
Definition: SkHeifCodec.h:56
bool onRewind() override
int onGetRepetitionCount() override
bool conversionSupported(const SkImageInfo &, bool, bool) override
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkCodec::SelectionPolicy selectionPolicy, Result *)
bool onGetFrameInfo(int, FrameInfo *) const override
Result onGetPixels(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &options, int *rowsDecoded) override
double frame
Definition: examples.cpp:31
uint32_t uint32_t * format
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
dst
Definition: cp.py:12
SkScalar w
SkScalar h