Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkHeifDecoder Namespace Reference

Functions

SK_API bool IsHeif (const void *, size_t)
 
SK_API std::unique_ptr< SkCodecDecode (std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 
SK_API std::unique_ptr< SkCodecDecode (sk_sp< SkData >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 
SkCodecs::Decoder Decoder ()
 

Function Documentation

◆ Decode() [1/2]

std::unique_ptr< SkCodec > SkHeifDecoder::Decode ( sk_sp< SkData data,
SkCodec::Result outResult,
SkCodecs::DecodeContext  ctx = nullptr 
)

Definition at line 556 of file SkHeifCodec.cpp.

558 {
559 if (!data) {
560 if (outResult) {
561 *outResult = SkCodec::kInvalidInput;
562 }
563 return nullptr;
564 }
565 return Decode(SkMemoryStream::Make(std::move(data)), outResult, ctx);
566}
@ kInvalidInput
Definition SkCodec.h:109
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition SkStream.cpp:314
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)

◆ Decode() [2/2]

std::unique_ptr< SkCodec > SkHeifDecoder::Decode ( std::unique_ptr< SkStream stream,
SkCodec::Result outResult,
SkCodecs::DecodeContext  ctx = nullptr 
)

Attempts to decode the given bytes as a HEIF (or AVIF).

If the bytes are not a HEIF (or AVIF), returns nullptr.

DecodeContext is treated as a SkCodec::SelectionPolicy*

Definition at line 544 of file SkHeifCodec.cpp.

546 {
547 SkASSERT(ctx);
548 SkCodec::Result resultStorage;
549 if (!outResult) {
550 outResult = &resultStorage;
551 }
552 auto policy = static_cast<SkCodec::SelectionPolicy*>(ctx);
553 return SkHeifCodec::MakeFromStream(std::move(stream), *policy, outResult);
554}
#define SkASSERT(cond)
Definition SkAssert.h:116
SelectionPolicy
Definition SkCodec.h:136
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkCodec::SelectionPolicy selectionPolicy, Result *)

◆ Decoder()

SkCodecs::Decoder SkHeifDecoder::Decoder ( )
inline

Definition at line 44 of file SkHeifDecoder.h.

44 {
45 return { "heif", IsHeif, Decode };
46}
SK_API bool IsHeif(const void *, size_t)

◆ IsHeif()

bool SkHeifDecoder::IsHeif ( const void *  data,
size_t  len 
)

Returns true if this data claims to be a HEIF (or AVIF) image.

Definition at line 540 of file SkHeifCodec.cpp.

540 {
541 return SkHeifCodec::IsSupported(data, len, nullptr);
542}
static bool IsSupported(const void *, size_t, SkEncodedImageFormat *format)