提交 c992b1ee 编写于 作者: J Jason Simmons 提交者: GitHub

Use a new Skia API for safe passing of images across threads and GrContexts (#3705)

Fixes https://github.com/flutter/flutter/issues/9439
上级 8b09c723
......@@ -16,10 +16,6 @@
#include "lib/tonic/typed_data/uint8_list.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
#ifdef OS_ANDROID
#include <GLES2/gl2.h>
#endif
using tonic::DartInvoke;
using tonic::DartPersistentValue;
using tonic::ToDart;
......@@ -34,24 +30,14 @@ sk_sp<SkImage> DecodeImage(sk_sp<SkData> buffer) {
return nullptr;
}
auto raster_image = SkImage::MakeFromEncoded(std::move(buffer));
if (raster_image == nullptr) {
return nullptr;
}
if (auto context = ResourceContext::Get()) {
GrContext* context = ResourceContext::Get();
if (context) {
// TODO: Supply actual destination color space once available
if (auto texture_image =
raster_image->makeTextureImage(context, nullptr)) {
#ifdef OS_ANDROID
glFlush();
#endif
return texture_image;
}
return SkImage::MakeCrossContextFromEncoded(context, std::move(buffer),
false, nullptr);
} else {
return SkImage::MakeFromEncoded(std::move(buffer));
}
return raster_image;
}
void InvokeImageCallback(sk_sp<SkImage> image,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册