Flutter Engine
The Flutter Engine
Functions
SkRawDecoder Namespace Reference

Functions

bool IsRaw (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 > SkRawDecoder::Decode ( sk_sp< SkData data,
SkCodec::Result outResult,
SkCodecs::DecodeContext  = nullptr 
)

Definition at line 845 of file SkRawCodec.cpp.

847 {
848 if (!data) {
849 if (outResult) {
850 *outResult = SkCodec::kInvalidInput;
851 }
852 return nullptr;
853 }
854 return Decode(SkMemoryStream::Make(std::move(data)), outResult, nullptr);
855}
@ 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)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Decode() [2/2]

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

Attempts to decode the given bytes as a raw image.

If the bytes are not a raw, returns nullptr.

DecodeContext is ignored

Definition at line 835 of file SkRawCodec.cpp.

837 {
838 SkCodec::Result resultStorage;
839 if (!outResult) {
840 outResult = &resultStorage;
841 }
842 return SkRawCodec::MakeFromStream(std::move(stream), outResult);
843}
Result
Definition: SkCodec.h:76
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *)
Definition: SkRawCodec.cpp:649

◆ Decoder()

constexpr SkCodecs::Decoder SkRawDecoder::Decoder ( )
inlineconstexpr

Definition at line 44 of file SkRawDecoder.h.

44 {
45 return { "raw", IsRaw, Decode };
46}
bool IsRaw(const void *, size_t)
Definition: SkRawDecoder.h:21
SK_API std::unique_ptr< SkCodec > Decode(sk_sp< SkData >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
Definition: SkRawCodec.cpp:845

◆ IsRaw()

bool SkRawDecoder::IsRaw ( const void *  ,
size_t   
)
inline

Definition at line 21 of file SkRawDecoder.h.

21 {
22 // Raw formats are tricky to detect just by reading in the first several bytes.
23 // For example, PIEX might need to read 10k bytes to detect Sony's arw format
24 // https://github.com/google/piex/blob/f1e15dd837c04347504149f71db67a78fbeddc73/src/image_type_recognition/image_type_recognition_lite.cc#L152
25 // Thus, we just assume everything might be a RAW file and check it last.
26 return true;
27}