From 9f08f4ce8d0c0e3ff21c581404919a78e7ee3f26 Mon Sep 17 00:00:00 2001 From: Hidenori Matsubayashi Date: Fri, 4 Aug 2023 12:28:45 +0000 Subject: [PATCH] impeller: add impeller initial implementation (#355) Signed-off-by: Hidenori Matsubayashi --- .../shell/platform/common/engine_switches.cc | 2 - .../platform/linux_embedded/flutter_elinux.cc | 5 +- .../linux_embedded/flutter_elinux_engine.cc | 10 ++++ .../linux_embedded/flutter_elinux_engine.h | 8 +++ .../linux_embedded/flutter_elinux_view.cc | 5 +- .../linux_embedded/flutter_project_bundle.cc | 17 +++++- .../linux_embedded/flutter_project_bundle.h | 6 ++ .../linux_embedded/surface/context_egl.cc | 57 +++++++++++++++++-- .../linux_embedded/surface/context_egl.h | 1 + .../linux_embedded/window/elinux_window_drm.h | 8 ++- .../window/elinux_window_wayland.cc | 10 ++-- .../window/elinux_window_wayland.h | 6 +- .../window/elinux_window_x11.cc | 10 ++-- .../linux_embedded/window/elinux_window_x11.h | 6 +- .../linux_embedded/window/native_window_drm.h | 5 +- .../window/native_window_drm_eglstream.cc | 5 +- .../window/native_window_drm_eglstream.h | 4 +- .../window/native_window_drm_gbm.cc | 7 ++- .../window/native_window_drm_gbm.h | 4 +- .../renderer/window_decorations_wayland.cc | 15 +++-- .../renderer/window_decorations_wayland.h | 3 +- .../linux_embedded/window_binding_handler.h | 9 ++- 22 files changed, 155 insertions(+), 48 deletions(-) diff --git a/src/flutter/shell/platform/common/engine_switches.cc b/src/flutter/shell/platform/common/engine_switches.cc index 5c750f13..37b98fae 100644 --- a/src/flutter/shell/platform/common/engine_switches.cc +++ b/src/flutter/shell/platform/common/engine_switches.cc @@ -16,7 +16,6 @@ std::vector GetSwitchesFromEnvironment() { // Read engine switches from the environment in debug/profile. If release mode // support is needed in the future, it should likely use a whitelist. #ifndef FLUTTER_RELEASE -#ifndef WINUWP const char* switch_count_key = "FLUTTER_ENGINE_SWITCHES"; const int kMaxSwitchCount = 50; const char* switch_count_string = std::getenv(switch_count_key); @@ -37,7 +36,6 @@ std::vector GetSwitchesFromEnvironment() { << ", but " << switch_key.str() << " is missing." << std::endl; } } -#endif // !WINUWP #endif // !FLUTTER_RELEASE return switches; } diff --git a/src/flutter/shell/platform/linux_embedded/flutter_elinux.cc b/src/flutter/shell/platform/linux_embedded/flutter_elinux.cc index 990a2cdc..99313f2d 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_elinux.cc +++ b/src/flutter/shell/platform/linux_embedded/flutter_elinux.cc @@ -92,13 +92,10 @@ FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate( auto state = std::make_unique(); state->view = std::make_unique(std::move(window_wrapper)); - if (!state->view->CreateRenderSurface()) { - return nullptr; - } - // Take ownership of the engine, starting it if necessary. state->view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); + state->view->CreateRenderSurface(); if (!state->view->GetEngine()->running()) { if (!state->view->GetEngine()->RunWithEntrypoint(nullptr)) { return nullptr; diff --git a/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.cc b/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.cc index c0ef315c..d081cdfb 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.cc +++ b/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.cc @@ -142,6 +142,11 @@ FlutterELinuxEngine::FlutterELinuxEngine(const FlutterProjectBundle& project) } }); + // Check for impeller support. + auto& switches = project_->GetSwitches(); + enable_impeller_ = std::find(switches.begin(), switches.end(), + "--enable-impeller=true") != switches.end(); + // Set up the legacy structs backing the API handles. messenger_ = FlutterDesktopMessengerReferenceOwner( FlutterDesktopMessengerAddRef(new FlutterDesktopMessenger()), @@ -173,6 +178,11 @@ FlutterELinuxEngine::~FlutterELinuxEngine() { Stop(); } +void FlutterELinuxEngine::SetSwitches( + const std::vector& switches) { + project_->SetSwitches(switches); +} + bool FlutterELinuxEngine::RunWithEntrypoint(const char* entrypoint) { if (!project_->HasValidPaths()) { ELINUX_LOG(ERROR) << "Missing or unresolvable paths to assets."; diff --git a/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.h b/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.h index 11283307..e6595262 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.h +++ b/src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.h @@ -68,6 +68,9 @@ class FlutterELinuxEngine { void SetPluginRegistrarDestructionCallback( FlutterDesktopOnPluginRegistrarDestroyed callback); + // Sets switches member to the given switches. + void SetSwitches(const std::vector& switches); + FlutterDesktopMessengerRef messenger() { return messenger_.get(); } IncomingMessageDispatcher* message_dispatcher() { @@ -121,6 +124,9 @@ class FlutterELinuxEngine { void OnVsync(uint64_t last_frame_time_nanos, uint64_t vsync_interval_time_nanos); + // Gets the status whether Impeller is enabled. + bool IsImpellerEnabled() const { return enable_impeller_; } + private: // Allows swapping out embedder_api_ calls in tests. friend class EngineEmbedderApiModifier; @@ -176,6 +182,8 @@ class FlutterELinuxEngine { // The vsync waiter. std::unique_ptr vsync_waiter_; + + bool enable_impeller_ = false; }; } // namespace flutter diff --git a/src/flutter/shell/platform/linux_embedded/flutter_elinux_view.cc b/src/flutter/shell/platform/linux_embedded/flutter_elinux_view.cc index ce02b388..131d114c 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_elinux_view.cc +++ b/src/flutter/shell/platform/linux_embedded/flutter_elinux_view.cc @@ -434,7 +434,10 @@ bool FlutterELinuxView::MakeResourceCurrent() { bool FlutterELinuxView::CreateRenderSurface() { PhysicalWindowBounds bounds = binding_handler_->GetPhysicalWindowBounds(); - return binding_handler_->CreateRenderSurface(bounds.width, bounds.height); + auto impeller_enable = engine_.get()->IsImpellerEnabled(); + std::cout << "impeller: " << impeller_enable << std::endl; + return binding_handler_->CreateRenderSurface(bounds.width, bounds.height, + impeller_enable); } void FlutterELinuxView::DestroyRenderSurface() { diff --git a/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.cc b/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.cc index bd974261..31681244 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.cc +++ b/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.cc @@ -85,8 +85,23 @@ UniqueAotDataPtr FlutterProjectBundle::LoadAotData( return UniqueAotDataPtr(data); } +void FlutterProjectBundle::SetSwitches( + const std::vector& switches) { + engine_switches_ = switches; +} + const std::vector FlutterProjectBundle::GetSwitches() { - return GetSwitchesFromEnvironment(); + if (engine_switches_.size() == 0) { + return GetSwitchesFromEnvironment(); + } + std::vector switches; + switches.insert(switches.end(), engine_switches_.begin(), + engine_switches_.end()); + + auto env_switches = GetSwitchesFromEnvironment(); + switches.insert(switches.end(), env_switches.begin(), env_switches.end()); + + return switches; } const std::string FlutterProjectBundle::GetExecutableDirectory() { diff --git a/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.h b/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.h index fdec398d..503fcd38 100644 --- a/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.h +++ b/src/flutter/shell/platform/linux_embedded/flutter_project_bundle.h @@ -45,6 +45,9 @@ class FlutterProjectBundle { // Returns any switches that should be passed to the engine. const std::vector GetSwitches(); + // Sets engine switches. + void SetSwitches(const std::vector& switches); + // Attempts to load AOT data for this bundle. The returned data must be // retained until any engine instance it is passed to has been shut down. // @@ -69,6 +72,9 @@ class FlutterProjectBundle { // Dart entrypoint arguments. std::vector dart_entrypoint_arguments_; + + // Engine switches. + std::vector engine_switches_; }; } // namespace flutter diff --git a/src/flutter/shell/platform/linux_embedded/surface/context_egl.cc b/src/flutter/shell/platform/linux_embedded/surface/context_egl.cc index f723bd57..bea6dbb4 100644 --- a/src/flutter/shell/platform/linux_embedded/surface/context_egl.cc +++ b/src/flutter/shell/platform/linux_embedded/surface/context_egl.cc @@ -10,6 +10,7 @@ namespace flutter { ContextEgl::ContextEgl(std::unique_ptr environment, + bool enable_impeller, EGLint egl_surface_type) : environment_(std::move(environment)), config_(nullptr) { EGLint config_count = 0; @@ -28,11 +29,57 @@ ContextEgl::ContextEgl(std::unique_ptr environment, EGL_NONE // clang-format on }; - if (eglChooseConfig(environment_->Display(), attribs, &config_, 1, - &config_count) != EGL_TRUE) { - ELINUX_LOG(ERROR) << "Failed to choose EGL surface config: " - << get_egl_error_cause(); - return; + const EGLint impeller_config_attributes[] = { + // clang-format off + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, +#if defined(ENABLE_EGL_ALPHA_COMPONENT_OF_COLOR_BUFFER) + EGL_ALPHA_SIZE, 8, +#endif + EGL_DEPTH_SIZE, 0, + EGL_STENCIL_SIZE, 8, + EGL_SAMPLE_BUFFERS, 1, + EGL_SAMPLES, 4, + EGL_NONE + // clang-format on + }; + const EGLint impeller_config_attributes_no_msaa[] = { + // clang-format off + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, +#if defined(ENABLE_EGL_ALPHA_COMPONENT_OF_COLOR_BUFFER) + EGL_ALPHA_SIZE, 8, +#endif + EGL_DEPTH_SIZE, 0, + EGL_STENCIL_SIZE, 8, + EGL_NONE + // clang-format on + }; + + if (enable_impeller) { + // First try the MSAA configuration. + if ((eglChooseConfig(environment_->Display(), impeller_config_attributes, + &config_, 1, &config_count) == EGL_FALSE) || + (config_count == 0)) { + // Next fall back to disabled MSAA. + if ((eglChooseConfig(environment_->Display(), + impeller_config_attributes_no_msaa, &config_, 1, + &config_count) == EGL_FALSE) || + (config_count == 0)) { + ELINUX_LOG(ERROR) << "Failed to choose EGL surface config: " + << get_egl_error_cause(); + return; + } + } + } else { + if (eglChooseConfig(environment_->Display(), attribs, &config_, 1, + &config_count) != EGL_TRUE) { + ELINUX_LOG(ERROR) << "Failed to choose EGL surface config: " + << get_egl_error_cause(); + return; + } } if (config_count == 0 || config_ == nullptr) { diff --git a/src/flutter/shell/platform/linux_embedded/surface/context_egl.h b/src/flutter/shell/platform/linux_embedded/surface/context_egl.h index b443e191..4950a816 100644 --- a/src/flutter/shell/platform/linux_embedded/surface/context_egl.h +++ b/src/flutter/shell/platform/linux_embedded/surface/context_egl.h @@ -18,6 +18,7 @@ namespace flutter { class ContextEgl { public: ContextEgl(std::unique_ptr environment, + bool enable_impeller, EGLint egl_surface_type = EGL_WINDOW_BIT); ~ContextEgl() = default; diff --git a/src/flutter/shell/platform/linux_embedded/window/elinux_window_drm.h b/src/flutter/shell/platform/linux_embedded/window/elinux_window_drm.h index e9e5edcc..beaec990 100644 --- a/src/flutter/shell/platform/linux_embedded/window/elinux_window_drm.h +++ b/src/flutter/shell/platform/linux_embedded/window/elinux_window_drm.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -109,7 +109,9 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler { } // |FlutterWindowBindingHandler| - bool CreateRenderSurface(int32_t width, int32_t height) override { + bool CreateRenderSurface(int32_t width, + int32_t height, + bool enable_impeller) override { std::vector devices; auto device_filename = std::getenv(kFlutterDrmDeviceEnvironmentKey); if (device_filename && device_filename[0] != '\0') { @@ -148,7 +150,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler { display_valid_ = true; - render_surface_ = native_window_->CreateRenderSurface(); + render_surface_ = native_window_->CreateRenderSurface(enable_impeller); if (!render_surface_->SetNativeWindow(native_window_.get())) { return false; } 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 64b72e4e..2e684e56 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 @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1147,7 +1147,8 @@ bool ELinuxWindowWayland::DispatchEvent() { } bool ELinuxWindowWayland::CreateRenderSurface(int32_t width_px, - int32_t height_px) { + int32_t height_px, + bool enable_impeller) { if (!display_valid_) { ELINUX_LOG(ERROR) << "Wayland display is invalid."; return false; @@ -1225,7 +1226,7 @@ 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_))); + std::make_unique(wl_display_), enable_impeller)); render_surface_->SetNativeWindow(native_window_.get()); if (view_properties_.use_window_decoration) { @@ -1233,7 +1234,8 @@ bool ELinuxWindowWayland::CreateRenderSurface(int32_t width_px, int32_t height_dip = height_px / current_scale_; window_decorations_ = std::make_unique( wl_display_, wl_compositor_, wl_subcompositor_, - native_window_->Surface(), width_dip, height_dip, current_scale_); + native_window_->Surface(), width_dip, height_dip, current_scale_, + enable_impeller); } // Wait for making sure that xdg_surface has been configured. diff --git a/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.h b/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.h index 00bf0b09..fad7dc1d 100644 --- a/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.h +++ b/src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -45,7 +45,9 @@ class ELinuxWindowWayland : public ELinuxWindow, public WindowBindingHandler { bool DispatchEvent() override; // |FlutterWindowBindingHandler| - bool CreateRenderSurface(int32_t width_px, int32_t height_px) override; + bool CreateRenderSurface(int32_t width_px, + int32_t height_px, + bool enable_impeller) override; // |FlutterWindowBindingHandler| void DestroyRenderSurface() override; 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 9d52a494..15ede0d4 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 @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -121,9 +121,11 @@ bool ELinuxWindowX11::DispatchEvent() { return true; } -bool ELinuxWindowX11::CreateRenderSurface(int32_t width, int32_t height) { - auto context_egl = - std::make_unique(std::make_unique(display_)); +bool ELinuxWindowX11::CreateRenderSurface(int32_t width, + int32_t height, + bool enable_impeller) { + auto context_egl = std::make_unique( + std::make_unique(display_), enable_impeller); if (current_rotation_ == 90 || current_rotation_ == 270) { std::swap(width, height); diff --git a/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.h b/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.h index 80683534..9d364526 100644 --- a/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.h +++ b/src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,9 @@ class ELinuxWindowX11 : public ELinuxWindow, public WindowBindingHandler { bool DispatchEvent() override; // |FlutterWindowBindingHandler| - bool CreateRenderSurface(int32_t width, int32_t height) override; + bool CreateRenderSurface(int32_t width, + int32_t height, + bool enable_impeller) override; // |FlutterWindowBindingHandler| void DestroyRenderSurface() override; diff --git a/src/flutter/shell/platform/linux_embedded/window/native_window_drm.h b/src/flutter/shell/platform/linux_embedded/window/native_window_drm.h index 6259f6aa..9a40b100 100644 --- a/src/flutter/shell/platform/linux_embedded/window/native_window_drm.h +++ b/src/flutter/shell/platform/linux_embedded/window/native_window_drm.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,7 +31,8 @@ class NativeWindowDrm : public NativeWindow { virtual bool DismissCursor() = 0; - virtual std::unique_ptr CreateRenderSurface() = 0; + virtual std::unique_ptr CreateRenderSurface( + bool enable_impeller) = 0; protected: drmModeConnectorPtr FindConnector(drmModeResPtr resources); diff --git a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc index a78fd033..97242219 100644 --- a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc +++ b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,7 +91,8 @@ bool NativeWindowDrmEglstream::DismissCursor() { return true; } -std::unique_ptr NativeWindowDrmEglstream::CreateRenderSurface() { +std::unique_ptr NativeWindowDrmEglstream::CreateRenderSurface( + bool enable_impeller) { return std::make_unique(std::make_unique( std::make_unique())); } diff --git a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.h b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.h index f3e469d5..27561a61 100644 --- a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.h +++ b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ class NativeWindowDrmEglstream : public NativeWindowDrm { bool DismissCursor() override; // |NativeWindowDrm| - std::unique_ptr CreateRenderSurface() override; + std::unique_ptr CreateRenderSurface(bool enable_impeller) override; // |NativeWindow| bool Resize(const size_t width, const size_t height) override; 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 8c342c00..10f4779c 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 @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -129,9 +129,10 @@ bool NativeWindowDrmGbm::DismissCursor() { return true; } -std::unique_ptr NativeWindowDrmGbm::CreateRenderSurface() { +std::unique_ptr NativeWindowDrmGbm::CreateRenderSurface( + bool enable_impeller) { return std::make_unique(std::make_unique( - std::make_unique(gbm_device_))); + std::make_unique(gbm_device_), enable_impeller)); } bool NativeWindowDrmGbm::IsNeedRecreateSurfaceAfterResize() const { diff --git a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.h b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.h index 6b9b9ecd..e888b269 100644 --- a/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.h +++ b/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.h @@ -1,4 +1,4 @@ -// Copyright 2021 Sony Corporation. All rights reserved. +// Copyright 2023 Sony Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ class NativeWindowDrmGbm : public NativeWindowDrm { bool DismissCursor() override; // |NativeWindowDrm| - std::unique_ptr CreateRenderSurface() override; + std::unique_ptr CreateRenderSurface(bool enable_impeller) override; // |NativeWindow| bool IsNeedRecreateSurfaceAfterResize() const override; 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 d118573b..531cb5bc 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 @@ -24,7 +24,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( wl_surface* root_surface, int32_t width_dip, int32_t height_dip, - double pixel_ratio) { + double pixel_ratio, + bool enable_impeller) { constexpr bool sub_egl_display = true; // title-bar. @@ -33,7 +34,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( compositor, subcompositor, root_surface, width_dip * pixel_ratio, kTitleBarHeightDIP * pixel_ratio), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display)))); + std::make_unique(display, sub_egl_display), + enable_impeller))); titlebar_->SetPosition(0, -kTitleBarHeightDIP); // close button. @@ -44,7 +46,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( compositor, subcompositor, root_surface, kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display))))); + std::make_unique(display, sub_egl_display), + enable_impeller)))); buttons_[type]->SetPosition( width_dip - kButtonWidthDIP - kButtonMarginDIP, -(kButtonHeightDIP + (kTitleBarHeightDIP - kButtonHeightDIP) / 2)); @@ -57,7 +60,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( compositor, subcompositor, root_surface, kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display))))); + std::make_unique(display, sub_egl_display), + enable_impeller)))); buttons_[type]->SetPosition( width_dip - kButtonWidthDIP * 2 - kButtonMarginDIP * 2, -(kButtonHeightDIP + (kTitleBarHeightDIP - kButtonHeightDIP) / 2)); @@ -70,7 +74,8 @@ WindowDecorationsWayland::WindowDecorationsWayland( compositor, subcompositor, root_surface, kButtonWidthDIP * pixel_ratio, kButtonHeightDIP * pixel_ratio), std::make_unique(std::make_unique( - std::make_unique(display, sub_egl_display))))); + std::make_unique(display, sub_egl_display), + enable_impeller)))); buttons_[type]->SetPosition( width_dip - kButtonWidthDIP * 3 - kButtonMarginDIP * 3, -(kButtonHeightDIP + (kTitleBarHeightDIP - kButtonHeightDIP) / 2)); diff --git a/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.h b/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.h index 9910841e..3e60b3ed 100644 --- a/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.h +++ b/src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.h @@ -35,7 +35,8 @@ class WindowDecorationsWayland { wl_surface* root_surface, int32_t width_dip, int32_t height_dip, - double pixel_ratio); + double pixel_ratio, + bool enable_impeller); ~WindowDecorationsWayland(); void Draw(); diff --git a/src/flutter/shell/platform/linux_embedded/window_binding_handler.h b/src/flutter/shell/platform/linux_embedded/window_binding_handler.h index ce8fffb4..34499df8 100644 --- a/src/flutter/shell/platform/linux_embedded/window_binding_handler.h +++ b/src/flutter/shell/platform/linux_embedded/window_binding_handler.h @@ -34,9 +34,12 @@ class WindowBindingHandler { virtual bool DispatchEvent() = 0; // Create a surface. - // @param[in] width_px Physical width of the surface. - // @param[in] height_px Physical height of the surface. - virtual bool CreateRenderSurface(int32_t width_px, int32_t height_px) = 0; + // @param[in] width_px Physical width of the surface. + // @param[in] height_px Physical height of the surface. + // @param[in] enable_impeller Enable impeller. + virtual bool CreateRenderSurface(int32_t width_px, + int32_t height_px, + bool enable_impeller) = 0; // Destroy a surface which is currently used. virtual void DestroyRenderSurface() = 0;