/src/skia/include/android/SkHeifDecoder.h
Line | Count | Source |
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 | | |
10 | | #include "include/codec/SkCodec.h" |
11 | | #include "include/core/SkRefCnt.h" |
12 | | |
13 | | class SkData; |
14 | | class 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. |
23 | | namespace SkHeifDecoder { |
24 | | |
25 | | /** Returns true if this data claims to be a HEIF (or AVIF) image. */ |
26 | | SK_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 | | */ |
35 | | SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>, |
36 | | SkCodec::Result*, |
37 | | SkCodecs::DecodeContext = nullptr); |
38 | | SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>, |
39 | | SkCodec::Result*, |
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. |
44 | 7 | inline SkCodecs::Decoder Decoder() { |
45 | 7 | return { "heif", IsHeif, Decode }; |
46 | 7 | } |
47 | | |
48 | | } // namespace SkHeifDecoder |
49 | | |
50 | | #endif // SkHeifDecoder_DEFINED |