diff --git a/AUTHORS b/AUTHORS index 6a816263..d01de650 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,3 +18,4 @@ Sebastian Urban Athaariq Ardhiansyah Anton Sakhon Bari Rao +Wang Bin diff --git a/src/flutter/shell/platform/linux_embedded/surface/environment_egl.h b/src/flutter/shell/platform/linux_embedded/surface/environment_egl.h index 83d94472..c2af8d91 100644 --- a/src/flutter/shell/platform/linux_embedded/surface/environment_egl.h +++ b/src/flutter/shell/platform/linux_embedded/surface/environment_egl.h @@ -6,6 +6,7 @@ #define FLUTTER_SHELL_PLATFORM_LINUX_EMBEDDED_SURFACE_ENVIRONMENT_EGL_H_ #include +#include #include "flutter/shell/platform/linux_embedded/logger.h" #include "flutter/shell/platform/linux_embedded/surface/egl_utils.h" @@ -14,10 +15,17 @@ namespace flutter { class EnvironmentEgl { public: - EnvironmentEgl(EGLNativeDisplayType platform_display, + EnvironmentEgl(EGLenum platform, + EGLNativeDisplayType platform_display, bool sub_environment = false) : display_(EGL_NO_DISPLAY), sub_environment_(sub_environment) { - display_ = eglGetDisplay(platform_display); + InitPlatformFuns(); + if (platform && eglGetPlatformDisplay_) { + display_ = eglGetPlatformDisplay_(platform, platform_display, nullptr); + } + if (display_ == EGL_NO_DISPLAY) { + display_ = eglGetDisplay(platform_display); + } if (display_ == EGL_NO_DISPLAY) { ELINUX_LOG(ERROR) << "Failed to get the EGL display: " << get_egl_error_cause(); @@ -66,7 +74,20 @@ class EnvironmentEgl { EGLDisplay Display() const { return display_; } + private: + void InitPlatformFuns() { + static const char* client_exts = + eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (client_exts && + has_egl_extension(client_exts, "EGL_EXT_platform_base")) { + eglGetPlatformDisplay_ = + reinterpret_cast( + eglGetProcAddress("eglGetPlatformDisplayEXT")); + } + } + protected: + PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplay_ = nullptr; EGLDisplay display_; bool valid_ = false; bool sub_environment_; diff --git a/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.cc b/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.cc index 6467bf94..99c45d3c 100644 --- a/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.cc +++ b/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.cc @@ -1443,7 +1443,8 @@ bool ELinuxWindowWayland::CreateRenderSurface(int32_t width_px, wl_surface_commit(native_window_->Surface()); render_surface_ = std::make_unique(std::make_unique( - std::make_unique(wl_display_), enable_impeller)); + std::make_unique(EGL_PLATFORM_WAYLAND_KHR, wl_display_), + enable_impeller)); render_surface_->SetNativeWindow(native_window_.get()); if (view_properties_.use_window_decoration) { diff --git a/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.cc b/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.cc index 862c4d64..d007bcd2 100644 --- a/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.cc +++ b/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.cc @@ -125,7 +125,8 @@ bool ELinuxWindowX11::CreateRenderSurface(int32_t width, int32_t height, bool enable_impeller) { auto context_egl = std::make_unique( - std::make_unique(display_), enable_impeller); + std::make_unique(EGL_PLATFORM_X11_KHR, display_), + enable_impeller); if (current_rotation_ == 90 || current_rotation_ == 270) { std::swap(width, height); diff --git a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc index 4565fcb8..59a651f7 100644 --- a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc +++ b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc @@ -134,7 +134,8 @@ bool NativeWindowDrmGbm::DismissCursor() { std::unique_ptr NativeWindowDrmGbm::CreateRenderSurface( bool enable_impeller) { return std::make_unique(std::make_unique( - std::make_unique(gbm_device_), enable_impeller)); + std::make_unique(EGL_PLATFORM_GBM_KHR, gbm_device_), + enable_impeller)); } bool NativeWindowDrmGbm::IsNeedRecreateSurfaceAfterResize() const { diff --git a/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.cc b/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.cc index b6c63c3b..8b1a275e 100644 --- a/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.cc +++ b/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.cc @@ -35,7 +35,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( compositor, subcompositor, root_surface, width_dip * pixel_ratio, kTitleBarHeightDIP * pixel_ratio, enable_vsync), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display), + std::make_unique(EGL_PLATFORM_WAYLAND_KHR, display, + sub_egl_display), enable_impeller))); titlebar_->SetPosition(0, -kTitleBarHeightDIP); @@ -48,7 +49,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio, enable_vsync), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display), + std::make_unique(EGL_PLATFORM_WAYLAND_KHR, display, + sub_egl_display), enable_impeller)))); buttons_[type]->SetPosition( width_dip * pixel_ratio - kButtonWidthDIP - kButtonMarginDIP, @@ -63,7 +65,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio, enable_vsync), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display), + std::make_unique(EGL_PLATFORM_WAYLAND_KHR, display, + sub_egl_display), enable_impeller)))); buttons_[type]->SetPosition( width_dip * pixel_ratio - kButtonWidthDIP * 2 - kButtonMarginDIP * 2, @@ -78,7 +81,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio, enable_vsync), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display), + std::make_unique(EGL_PLATFORM_WAYLAND_KHR, display, + sub_egl_display), enable_impeller)))); buttons_[type]->SetPosition( width_dip * pixel_ratio - kButtonWidthDIP * 3 - kButtonMarginDIP * 3,