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

Functions

SK_API bool IsGif (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)
 
constexpr SkCodecs::Decoder Decoder ()
 

Function Documentation

◆ Decode() [1/2]

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

Definition at line 1096 of file SkWuffsCodec.cpp.

1098 {
1099 if (!data) {
1100 if (outResult) {
1101 *outResult = SkCodec::kInvalidInput;
1102 }
1103 return nullptr;
1104 }
1105 return Decode(SkMemoryStream::Make(std::move(data)), outResult, ctx);
1106}
@ 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 > SkGifDecoder::Decode ( std::unique_ptr< SkStream stream,
SkCodec::Result outResult,
SkCodecs::DecodeContext  ctx = nullptr 
)

Attempts to decode the given bytes as a GIF.

If the bytes are not a GIF, returns nullptr.

DecodeContext is ignored

Definition at line 1082 of file SkWuffsCodec.cpp.

1084 {
1085 SkCodec::Result resultStorage;
1086 if (!outResult) {
1087 outResult = &resultStorage;
1088 }
1090 if (ctx) {
1091 policy = *static_cast<SkCodec::SelectionPolicy*>(ctx);
1092 }
1093 return MakeFromStream(std::move(stream), policy, outResult);
1094}
SelectionPolicy
Definition SkCodec.h:136

◆ Decoder()

constexpr SkCodecs::Decoder SkGifDecoder::Decoder ( )
inlineconstexpr

Definition at line 38 of file SkGifDecoder.h.

38 {
39 return { "gif", IsGif, Decode };
40}
SK_API bool IsGif(const void *, size_t)

◆ IsGif()

bool SkGifDecoder::IsGif ( const void *  buf,
size_t  bytesRead 
)

Returns true if this data claims to be a GIF image.

Definition at line 977 of file SkWuffsCodec.cpp.

977 {
978 constexpr const char* gif_ptr = "GIF8";
979 constexpr size_t gif_len = 4;
980 return (bytesRead >= gif_len) && (memcmp(buf, gif_ptr, gif_len) == 0);
981}