Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkHeifDecoder.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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#ifndef SkHeifDecoder_DEFINED
8#define SkHeifDecoder_DEFINED
9
12
13class SkData;
14class SkStream;
15
16#include <memory>
17
18// This codec depends on heif libraries that are only part of the Android framework.
19// It will not work on other platforms currently.
20//
21// For historical reasons, this codec also decodes AVIF images.
22// There is a newer, dedicated SkAvifDecoder which could be used instead.
23namespace SkHeifDecoder {
24
25/** Returns true if this data claims to be a HEIF (or AVIF) image. */
26SK_API bool IsHeif(const void*, size_t);
27
28/**
29 * Attempts to decode the given bytes as a HEIF (or AVIF).
30 *
31 * If the bytes are not a HEIF (or AVIF), returns nullptr.
32 *
33 * DecodeContext is treated as a SkCodec::SelectionPolicy*
34 */
35SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
37 SkCodecs::DecodeContext = nullptr);
38SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
40 SkCodecs::DecodeContext = nullptr);
41
42// Do not register this codec using "avif" as the key (even though it can handle that type).
43// Doing so would cause internal codec sniffing to choose the wrong sampler.
44inline SkCodecs::Decoder Decoder() {
45 return { "heif", IsHeif, Decode };
46}
47
48} // namespace SkHeifDecoder
49
50#endif // SkHeifDecoder_DEFINED
#define SK_API
Definition SkAPI.h:35
SK_API bool IsHeif(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SkCodecs::Decoder Decoder()