Hi all, initially I pick the SkYUVAPixmaps::FromExternalMemory() to use passed in memory as backing store for pixmaps' pixels. After initialized, yuva_pixmaps will have a backing memory shared with decoded_pixmap. Then I can put decoded YUVA data directly into yuva_pixmaps.
Old codes:
SkBitmap bitmap;
if (!bitmap->tryAllocPixels(decode_info)) {
return false;
}
SkPixmap decoded_pixmap;
decode_pixmap = bitmap->pixmap();
SkYUVAPixmaps yuva_pixmaps;
yuva_pixmaps = SkYUVAPixmaps::FromExternalMemory(yuva_pixmap_info,
decode_pixmap.writable_addr());
Then I find there is another function SkYUVAPixmaps::Allocate(), which might have the same usage. But after done with "yuva_pixmaps->Allocate(yuva_pixmap_info);", the yuva_pixmaps doesn't get a backing memory to use. I look into its code path, I see that SkYUVAPixmaps::Allocate() will call SkData::MakeUninitialized(size_t length). In SkData::MakeUninitialized(size_t length), it returns PrivateNewWithCopy(nullptr, length), here the first inputted parameter is nullptr.
Does this cause the yuva_pixmaps couldn't get a backing memory?
If so, how to correctly use SkYUVAPixmaps::Allocate() to get a real allocated backing memory for the yuva_pixmaps?
Thanks