未验证 提交 2dd385fd 编写于 作者: A Abhishek Amit 提交者: GitHub

Allow embedder clients to provide a resource context (#4588)

* Allow embedder clients to provide a resource context. Closes flutter/flutter#14263.
上级 7c34dfaf
......@@ -125,6 +125,15 @@ FlutterResult FlutterEngineRun(size_t version,
};
}
const FlutterOpenGLRendererConfig* open_gl_config = &config->open_gl;
std::function<bool()> make_resource_current_callback = nullptr;
if (SAFE_ACCESS(open_gl_config, make_resource_current, nullptr) != nullptr) {
make_resource_current_callback =
[ ptr = config->open_gl.make_resource_current, user_data ]() {
return ptr(user_data);
};
}
std::string icu_data_path;
if (SAFE_ACCESS(args, icu_data_path, nullptr) != nullptr) {
icu_data_path = SAFE_ACCESS(args, icu_data_path, nullptr);
......@@ -154,6 +163,7 @@ FlutterResult FlutterEngineRun(size_t version,
.gl_present_callback = present,
.gl_fbo_callback = fbo_callback,
.platform_message_response_callback = platform_message_response_callback,
.gl_make_resource_current_callback = make_resource_current_callback,
};
auto platform_view = std::make_shared<shell::PlatformViewEmbedder>(table);
......
......@@ -41,6 +41,7 @@ typedef struct {
BoolCallback clear_current;
BoolCallback present;
UIntCallback fbo_callback;
BoolCallback make_resource_current;
} FlutterOpenGLRendererConfig;
typedef struct {
......
......@@ -34,11 +34,17 @@ intptr_t PlatformViewEmbedder::GLContextFBO() const {
void PlatformViewEmbedder::Attach() {
CreateEngine();
NotifyCreated(std::make_unique<shell::GPUSurfaceGL>(this));
if (dispatch_table_.gl_make_resource_current_callback != nullptr) {
SetupResourceContextOnIOThread();
}
}
bool PlatformViewEmbedder::ResourceContextMakeCurrent() {
// Unsupported.
return false;
if (dispatch_table_.gl_make_resource_current_callback == nullptr) {
return false;
}
return dispatch_table_.gl_make_resource_current_callback();
}
void PlatformViewEmbedder::RunFromSource(const std::string& assets_directory,
......
......@@ -22,7 +22,8 @@ class PlatformViewEmbedder : public PlatformView, public GPUSurfaceGLDelegate {
std::function<bool(void)> gl_present_callback; // required
std::function<intptr_t(void)> gl_fbo_callback; // required
PlatformMessageResponseCallback
platform_message_response_callback; // optional
platform_message_response_callback; // optional
std::function<bool(void)> gl_make_resource_current_callback; // optional
};
PlatformViewEmbedder(DispatchTable dispatch_table);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册