Skip to content

use egl platform display #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Sebastian Urban <[email protected]>
Athaariq Ardhiansyah <[email protected]>
Anton Sakhon <[email protected]>
Bari Rao <[email protected]>
Wang Bin <[email protected]>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_SHELL_PLATFORM_LINUX_EMBEDDED_SURFACE_ENVIRONMENT_EGL_H_

#include <EGL/egl.h>
#include <EGL/eglext.h>

#include "flutter/shell/platform/linux_embedded/logger.h"
#include "flutter/shell/platform/linux_embedded/surface/egl_utils.h"
Expand All @@ -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();
Expand Down Expand Up @@ -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<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
eglGetProcAddress("eglGetPlatformDisplayEXT"));
}
}

protected:
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplay_ = nullptr;
EGLDisplay display_;
bool valid_ = false;
bool sub_environment_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,8 @@ bool ELinuxWindowWayland::CreateRenderSurface(int32_t width_px,
wl_surface_commit(native_window_->Surface());

render_surface_ = std::make_unique<SurfaceGl>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(wl_display_), enable_impeller));
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_WAYLAND_KHR, wl_display_),
enable_impeller));
render_surface_->SetNativeWindow(native_window_.get());

if (view_properties_.use_window_decoration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ bool ELinuxWindowX11::CreateRenderSurface(int32_t width,
int32_t height,
bool enable_impeller) {
auto context_egl = std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(display_), enable_impeller);
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_X11_KHR, display_),
enable_impeller);

if (current_rotation_ == 90 || current_rotation_ == 270) {
std::swap(width, height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ bool NativeWindowDrmGbm::DismissCursor() {
std::unique_ptr<SurfaceGl> NativeWindowDrmGbm::CreateRenderSurface(
bool enable_impeller) {
return std::make_unique<SurfaceGl>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(gbm_device_), enable_impeller));
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_GBM_KHR, gbm_device_),
enable_impeller));
}

bool NativeWindowDrmGbm::IsNeedRecreateSurfaceAfterResize() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ WindowDecorationsWayland::WindowDecorationsWayland(
compositor, subcompositor, root_surface, width_dip * pixel_ratio,
kTitleBarHeightDIP * pixel_ratio, enable_vsync),
std::make_unique<SurfaceDecoration>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(display, sub_egl_display),
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_WAYLAND_KHR, display,
sub_egl_display),
enable_impeller)));
titlebar_->SetPosition(0, -kTitleBarHeightDIP);

Expand All @@ -48,7 +49,8 @@ WindowDecorationsWayland::WindowDecorationsWayland(
kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio,
enable_vsync),
std::make_unique<SurfaceDecoration>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(display, sub_egl_display),
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_WAYLAND_KHR, display,
sub_egl_display),
enable_impeller))));
buttons_[type]->SetPosition(
width_dip * pixel_ratio - kButtonWidthDIP - kButtonMarginDIP,
Expand All @@ -63,7 +65,8 @@ WindowDecorationsWayland::WindowDecorationsWayland(
kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio,
enable_vsync),
std::make_unique<SurfaceDecoration>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(display, sub_egl_display),
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_WAYLAND_KHR, display,
sub_egl_display),
enable_impeller))));
buttons_[type]->SetPosition(
width_dip * pixel_ratio - kButtonWidthDIP * 2 - kButtonMarginDIP * 2,
Expand All @@ -78,7 +81,8 @@ WindowDecorationsWayland::WindowDecorationsWayland(
kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio,
enable_vsync),
std::make_unique<SurfaceDecoration>(std::make_unique<ContextEgl>(
std::make_unique<EnvironmentEgl>(display, sub_egl_display),
std::make_unique<EnvironmentEgl>(EGL_PLATFORM_WAYLAND_KHR, display,
sub_egl_display),
enable_impeller))));
buttons_[type]->SetPosition(
width_dip * pixel_ratio - kButtonWidthDIP * 3 - kButtonMarginDIP * 3,
Expand Down