Flutter Engine
The Flutter Engine
Static Public Member Functions | Public Attributes | List of all members
SkSharingDeserialContext Struct Reference

#include <SkSharingProc.h>

Static Public Member Functions

static sk_sp< SkImagedeserializeImage (const void *data, size_t length, void *ctx)
 

Public Attributes

std::vector< sk_sp< SkImage > > fImages
 

Detailed Description

Definition at line 66 of file SkSharingProc.h.

Member Function Documentation

◆ deserializeImage()

sk_sp< SkImage > SkSharingDeserialContext::deserializeImage ( const void *  data,
size_t  length,
void *  ctx 
)
static

Definition at line 62 of file SkSharingProc.cpp.

63 {
64 if (!data || !length || !ctx) {
65 SkDebugf("SkSharingDeserialContext::deserializeImage arguments invalid %p %zu %p.\n",
66 data, length, ctx);
67 // Return something so the rest of the debugger can proceed.
68 SkBitmap bm;
70 return bm.asImage();
71 }
72 SkSharingDeserialContext* context = reinterpret_cast<SkSharingDeserialContext*>(ctx);
73 uint32_t fid;
74 // If the data is an image fid, look up an already deserialized image from our map
75 if (length == sizeof(fid)) {
76 memcpy(&fid, data, sizeof(fid));
77 if (fid >= context->fImages.size()) {
78 SkDebugf("Cannot deserialize using id, We do not have the data for image %u.\n", fid);
79 return nullptr;
80 }
81 return context->fImages[fid];
82 }
83 // Otherwise, the data is an image, deserialise it, store it in our map at its fid.
84 // TODO(nifong): make DeserialProcs accept sk_sp<SkData> so we don't have to copy this.
86 auto codec = SkPngDecoder::Decode(std::move(dataView), nullptr);
87 if (!codec) {
88 SkDebugf("Cannot deserialize image - might not be a PNG.\n");
89 return nullptr;
90 }
91 SkImageInfo info = codec->getInfo().makeAlphaType(kPremul_SkAlphaType);
92 auto [image, result] = codec->getImage(info);
94 SkDebugf("Error decoding image %d.\n", result);
95 // Might have partially decoded.
96 }
97 context->fImages.push_back(image);
98 return image;
99}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
@ kSuccess
Definition: embedder.h:73
GAsyncResult * result
size_t length
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static SkImageInfo MakeN32Premul(int width, int height)
std::vector< sk_sp< SkImage > > fImages
Definition: SkSharingProc.h:69
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

Member Data Documentation

◆ fImages

std::vector<sk_sp<SkImage> > SkSharingDeserialContext::fImages

Definition at line 69 of file SkSharingProc.h.


The documentation for this struct was generated from the following files: