mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Windows] Decouple the GL context from the view (flutter/engine#48636)
In the future, the GL context will be shared between zero or more views. The engine will also need to be able to make the GL context current even if the app is currently in headless mode. No tests are updated as this is a refactoring with no functionality changes. Part of https://github.com/flutter/flutter/issues/137267 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
673fca77cf
commit
20e5300477
@ -53,17 +53,17 @@ FlutterRendererConfig GetOpenGLRendererConfig() {
|
||||
config.open_gl.struct_size = sizeof(config.open_gl);
|
||||
config.open_gl.make_current = [](void* user_data) -> bool {
|
||||
auto host = static_cast<FlutterWindowsEngine*>(user_data);
|
||||
if (!host->view()) {
|
||||
if (!host->surface_manager()) {
|
||||
return false;
|
||||
}
|
||||
return host->view()->MakeCurrent();
|
||||
return host->surface_manager()->MakeCurrent();
|
||||
};
|
||||
config.open_gl.clear_current = [](void* user_data) -> bool {
|
||||
auto host = static_cast<FlutterWindowsEngine*>(user_data);
|
||||
if (!host->view()) {
|
||||
if (!host->surface_manager()) {
|
||||
return false;
|
||||
}
|
||||
return host->view()->ClearContext();
|
||||
return host->surface_manager()->ClearContext();
|
||||
};
|
||||
config.open_gl.present = [](void* user_data) -> bool {
|
||||
auto host = static_cast<FlutterWindowsEngine*>(user_data);
|
||||
@ -89,10 +89,10 @@ FlutterRendererConfig GetOpenGLRendererConfig() {
|
||||
};
|
||||
config.open_gl.make_resource_current = [](void* user_data) -> bool {
|
||||
auto host = static_cast<FlutterWindowsEngine*>(user_data);
|
||||
if (!host->view()) {
|
||||
if (!host->surface_manager()) {
|
||||
return false;
|
||||
}
|
||||
return host->view()->MakeResourceCurrent();
|
||||
return host->surface_manager()->MakeResourceCurrent();
|
||||
};
|
||||
config.open_gl.gl_external_texture_frame_callback =
|
||||
[](void* user_data, int64_t texture_id, size_t width, size_t height,
|
||||
|
||||
@ -535,18 +535,6 @@ void FlutterWindowsView::SendPointerEventWithData(
|
||||
}
|
||||
}
|
||||
|
||||
bool FlutterWindowsView::MakeCurrent() {
|
||||
return engine_->surface_manager()->MakeCurrent();
|
||||
}
|
||||
|
||||
bool FlutterWindowsView::MakeResourceCurrent() {
|
||||
return engine_->surface_manager()->MakeResourceCurrent();
|
||||
}
|
||||
|
||||
bool FlutterWindowsView::ClearContext() {
|
||||
return engine_->surface_manager()->ClearContext();
|
||||
}
|
||||
|
||||
bool FlutterWindowsView::SwapBuffers() {
|
||||
// Called on an engine-controlled (non-platform) thread.
|
||||
std::unique_lock<std::mutex> lock(resize_mutex_);
|
||||
|
||||
@ -65,11 +65,12 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
|
||||
// Tells the engine to generate a new frame
|
||||
void ForceRedraw();
|
||||
|
||||
// Callbacks for clearing context, settings context and swapping buffers,
|
||||
// these are typically called on an engine-controlled (non-platform) thread.
|
||||
bool ClearContext();
|
||||
bool MakeCurrent();
|
||||
bool MakeResourceCurrent();
|
||||
// Swap the view's surface buffers. Must be called on the engine's raster
|
||||
// thread. Returns true if the buffers were swapped.
|
||||
//
|
||||
// If the view is resizing, this returns false if the frame is not the target
|
||||
// size. Otherwise, it unblocks the platform thread and blocks the raster
|
||||
// thread until the v-blank.
|
||||
bool SwapBuffers();
|
||||
|
||||
// Callback for presenting a software bitmap.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user