未验证 提交 fc780527 编写于 作者: J Jason Simmons 提交者: GitHub

Convert lazy SkImages to raster images when extracting pixel data (#5713)

Fixes https://github.com/flutter/flutter/issues/19214
上级 0c33c2e1
......@@ -57,12 +57,23 @@ void InvokeDataCallback(std::unique_ptr<DartPersistentValue> callback,
sk_sp<SkImage> ConvertToRasterImageIfNecessary(sk_sp<SkImage> image,
GrContext* context) {
if (context == nullptr) {
// The context was null (software rendering contexts) so the image is likely
// already a raster image. Nothing more to do.
SkPixmap pixmap;
if (image->peekPixels(&pixmap)) {
// This is already a raster image.
return image;
}
if (sk_sp<SkImage> raster_image = image->makeRasterImage()) {
// The image can be converted to a raster image.
return raster_image;
}
// Cross-context images do not support makeRasterImage. Convert these images
// by drawing them into a surface.
if (context == nullptr) {
return nullptr;
}
TRACE_EVENT0("flutter", __FUNCTION__);
// Create a GPU surface with the context and then do a device to host copy of
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册