Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkAvifCodec.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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 SkAvifCodec_DEFINED
9#define SkAvifCodec_DEFINED
10
13#include "include/core/SkData.h"
18
19#include <cstddef>
20#include <memory>
21#include <vector>
22
23class SkCodec;
24class SkStream;
25struct SkImageInfo;
26struct avifDecoder;
28 void operator()(avifDecoder* decoder) const;
29};
30using AvifDecoder = std::unique_ptr<avifDecoder, AvifDecoderDeleter>;
31
33public:
34 /*
35 * Returns true if an AVIF image is detected. Returns false otherwise.
36 */
37 static bool IsAvif(const void*, size_t);
38
39 /*
40 * Assumes IsAvif() was called and it returned true.
41 */
42 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
43
44protected:
46 void* dst,
47 size_t dstRowBytes,
48 const Options& options,
49 int* rowsDecoded) override;
50
52
53 int onGetFrameCount() override;
54 bool onGetFrameInfo(int, FrameInfo*) const override;
55 int onGetRepetitionCount() override;
56 const SkFrameHolder* getFrameHolder() const override { return &fFrameHolder; }
57
58private:
60 std::unique_ptr<SkStream>,
64 bool);
65
66 // fAvifDecoder has a pointer to this data. This should not be freed until
67 // the decode is completed. To ensure that, we declare this before
68 // fAvifDecoder.
69 sk_sp<SkData> fData;
70
71 AvifDecoder fAvifDecoder;
72 bool fUseAnimation;
73
74 class Frame : public SkFrame {
75 public:
76 Frame(int i, SkEncodedInfo::Alpha alpha) : INHERITED(i), fReportedAlpha(alpha) {}
77
78 protected:
79 SkEncodedInfo::Alpha onReportedAlpha() const override { return fReportedAlpha; }
80
81 private:
82 const SkEncodedInfo::Alpha fReportedAlpha;
83
84 using INHERITED = SkFrame;
85 };
86
87 class FrameHolder : public SkFrameHolder {
88 public:
89 ~FrameHolder() override {}
90 void setScreenSize(int w, int h) {
93 }
94 Frame* appendNewFrame(bool hasAlpha);
95 const Frame* frame(int i) const;
96 int size() const { return static_cast<int>(fFrames.size()); }
97 void reserve(int size) { fFrames.reserve(size); }
98
99 protected:
100 const SkFrame* onGetFrame(int i) const override;
101
102 private:
103 std::vector<Frame> fFrames;
104 };
105
106 FrameHolder fFrameHolder;
107 using INHERITED = SkScalingCodec;
108};
109
110#endif // SkAvifCodec_DEFINED
std::unique_ptr< avifDecoder, AvifDecoderDeleter > AvifDecoder
Definition SkAvifCodec.h:30
SkEncodedImageFormat
SkEncodedOrigin
#define INHERITED(method,...)
int onGetRepetitionCount() override
const SkFrameHolder * getFrameHolder() const override
Definition SkAvifCodec.h:56
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *)
static bool IsAvif(const void *, size_t)
bool onGetFrameInfo(int, FrameInfo *) const override
int onGetFrameCount() override
Result onGetPixels(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &options, int *rowsDecoded) override
SkEncodedImageFormat onGetEncodedFormat() const override
Definition SkAvifCodec.h:51
const SkImageInfo & dstInfo() const
Definition SkCodec.h:878
const Options & options() const
Definition SkCodec.h:880
double frame
Definition examples.cpp:31
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
SkScalar w
SkScalar h
void operator()(avifDecoder *decoder) const