From 8a5e8230dcc6442b87707f49b61b7e641e696803 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 8 Apr 2022 20:41:26 +0900 Subject: [PATCH 01/32] Implement FlutterTizenView foundation * This is Intial commit to refactor engine using View concept. Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 1 + shell/platform/tizen/flutter_tizen.cc | 18 ++++++++--- shell/platform/tizen/flutter_tizen_view.cc | 19 ++++++++++++ shell/platform/tizen/flutter_tizen_view.h | 35 ++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 shell/platform/tizen/flutter_tizen_view.cc create mode 100644 shell/platform/tizen/flutter_tizen_view.h diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index a235bfeabaa9c..19990e59b647e 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -123,6 +123,7 @@ template("embedder") { "flutter_tizen.cc", "flutter_tizen_engine.cc", "flutter_tizen_texture_registrar.cc", + "flutter_tizen_view.cc", "key_event_handler.cc", "logger.cc", "system_utils.cc", diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index b97f78f6c1d82..e63649753baa0 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -10,6 +10,7 @@ #include "flutter/shell/platform/common/incoming_message_dispatcher.h" #include "flutter/shell/platform/tizen/flutter_project_bundle.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" @@ -52,18 +53,27 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine( } flutter::Logger::Start(); - auto engine = std::make_unique(project); + auto flutter_tizen_engine = + std::make_unique(project); + + // Temporarily statically used + static auto flutter_tizen_view_ = + std::make_unique(); + + flutter_tizen_view_->SetFlutterTizenEngine(std::move(flutter_tizen_engine)); + if (window_properties.headed) { - engine->InitializeRenderer( + flutter_tizen_view_->flutter_tizen_engine()->InitializeRenderer( window_properties.x, window_properties.y, window_properties.width, window_properties.height, window_properties.transparent, window_properties.focusable, window_properties.top_level); } - if (!engine->RunEngine(engine_properties.entrypoint)) { + if (!flutter_tizen_view_->flutter_tizen_engine()->RunEngine( + engine_properties.entrypoint)) { FT_LOG(Error) << "Failed to start the Flutter engine."; return nullptr; } - return HandleForEngine(engine.release()); + return HandleForEngine(flutter_tizen_view_->flutter_tizen_engine()); } void FlutterDesktopShutdownEngine(FlutterDesktopEngineRef engine_ref) { diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc new file mode 100644 index 0000000000000..d16002b21055b --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -0,0 +1,19 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter_tizen_view.h" + +namespace flutter { + +FlutterTizenView::FlutterTizenView() {} + +void FlutterTizenView::SetFlutterTizenEngine( + std::unique_ptr flutter_tizen_engine) { + flutter_tizen_engine_ = std::move(flutter_tizen_engine); + + // engine->setFlutterTizenView +} + +} // namespace flutter \ No newline at end of file diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h new file mode 100644 index 0000000000000..1d103451e377e --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -0,0 +1,35 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_FLUTTER_TIZEN_VIEW_H_ +#define EMBEDDER_FLUTTER_TIZEN_VIEW_H_ + +#include + +#include "flutter/shell/platform/embedder/embedder.h" +#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" + +namespace flutter { + +class FlutterTizenView { + public: + FlutterTizenView(); + + // Configures the window instance with an instance of a running Flutter + // engine. + void SetFlutterTizenEngine( + std::unique_ptr flutter_tizen_engine); + + FlutterTizenEngine* flutter_tizen_engine() { + return flutter_tizen_engine_.get(); + } + + private: + // The engine associated with this view. + std::unique_ptr flutter_tizen_engine_; +}; + +} // namespace flutter +#endif From d29bd8f275a6fe629e53ba6683eff2a453cf42c5 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 12 Apr 2022 17:19:10 +0900 Subject: [PATCH 02/32] Add graphics callback to FlutterTizenView * FlutterTizenView is more suitable for top-level graphics-related interfaces than FlutterTizenEngine. Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_engine.cc | 47 +++++++++++++++----- shell/platform/tizen/flutter_tizen_engine.h | 12 +++++ shell/platform/tizen/flutter_tizen_view.cc | 25 ++++++++++- shell/platform/tizen/flutter_tizen_view.h | 9 ++++ 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 2d6c0a0d5e21e..77010f9bc4221 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -13,6 +13,7 @@ #include "flutter/shell/platform/tizen/accessibility_bridge_delegate_tizen.h" #include "flutter/shell/platform/tizen/flutter_platform_node_delegate_tizen.h" #endif +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/system_utils.h" #include "flutter/shell/platform/tizen/tizen_input_method_context.h" @@ -306,6 +307,10 @@ bool FlutterTizenEngine::StopEngine() { return false; } +void FlutterTizenEngine::SetFlutterTizenView(FlutterTizenView* view) { + flutter_tizen_view_ = view; +} + void FlutterTizenEngine::SetPluginRegistrarDestructionCallback( FlutterDesktopOnPluginRegistrarDestroyed callback) { plugin_registrar_destruction_callback_ = callback; @@ -512,24 +517,39 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { config.type = kOpenGL; config.open_gl.struct_size = sizeof(config.open_gl); config.open_gl.make_current = [](void* user_data) -> bool { - return reinterpret_cast(user_data) - ->renderer_->OnMakeCurrent(); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return false; + } + return engine->flutter_tizen_view()->OnMakeCurrent(); }; config.open_gl.make_resource_current = [](void* user_data) -> bool { - return reinterpret_cast(user_data) - ->renderer_->OnMakeResourceCurrent(); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return false; + } + return engine->flutter_tizen_view()->OnMakeResourceCurrent(); }; config.open_gl.clear_current = [](void* user_data) -> bool { - return reinterpret_cast(user_data) - ->renderer_->OnClearCurrent(); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return false; + } + return engine->flutter_tizen_view()->OnClearCurrent(); }; config.open_gl.present = [](void* user_data) -> bool { - return reinterpret_cast(user_data) - ->renderer_->OnPresent(); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return false; + } + return engine->flutter_tizen_view()->OnPresent(); }; config.open_gl.fbo_callback = [](void* user_data) -> uint32_t { - return reinterpret_cast(user_data) - ->renderer_->OnGetFBO(); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return false; + } + return engine->flutter_tizen_view()->OnGetFBO(); }; config.open_gl.surface_transformation = [](void* user_data) -> FlutterTransformation { @@ -537,8 +557,11 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { }; config.open_gl.gl_proc_resolver = [](void* user_data, const char* name) -> void* { - return reinterpret_cast(user_data) - ->renderer_->OnProcResolver(name); + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return nullptr; + } + return engine->flutter_tizen_view()->OnProcResolver(name); }; config.open_gl.gl_external_texture_frame_callback = [](void* user_data, int64_t texture_id, size_t width, size_t height, diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 78c464d890787..a50dda101a14b 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -53,6 +53,8 @@ struct FlutterDesktopMessenger { namespace flutter { +class FlutterTizenView; + // Manages state associated with the underlying FlutterEngine. class FlutterTizenEngine : public TizenRenderer::Delegate { public: @@ -83,6 +85,13 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { // Stops the engine. bool StopEngine(); + // Sets the view that is displaying this engine's content. + void SetFlutterTizenView(FlutterTizenView* view); + + // The view displaying this engine's content, if any. This will be null for + // headless engines. + FlutterTizenView* flutter_tizen_view() { return flutter_tizen_view_; } + FlutterDesktopMessengerRef messenger() { return messenger_.get(); } IncomingMessageDispatcher* message_dispatcher() { @@ -228,6 +237,9 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { // AOT data for this engine instance, if applicable. UniqueAotDataPtr aot_data_; + // The view displaying the content running in this engine, if any. + FlutterTizenView* flutter_tizen_view_ = nullptr; + // An event dispatcher for Ecore key events. std::unique_ptr key_event_handler_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index d16002b21055b..ec28fb3cf4c83 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -13,7 +13,30 @@ void FlutterTizenView::SetFlutterTizenEngine( std::unique_ptr flutter_tizen_engine) { flutter_tizen_engine_ = std::move(flutter_tizen_engine); - // engine->setFlutterTizenView + flutter_tizen_engine_->SetFlutterTizenView(this); +} + +bool FlutterTizenView::OnMakeCurrent() { + return flutter_tizen_engine_->renderer()->OnMakeCurrent(); +} + +bool FlutterTizenView::OnClearCurrent() { + return flutter_tizen_engine_->renderer()->OnClearCurrent(); +} + +bool FlutterTizenView::OnMakeResourceCurrent() { + return flutter_tizen_engine_->renderer()->OnMakeResourceCurrent(); +} + +bool FlutterTizenView::OnPresent() { + return flutter_tizen_engine_->renderer()->OnPresent(); +} +uint32_t FlutterTizenView::OnGetFBO() { + return flutter_tizen_engine_->renderer()->OnGetFBO(); +} + +void* FlutterTizenView::OnProcResolver(const char* name) { + return flutter_tizen_engine_->renderer()->OnProcResolver(name); } } // namespace flutter \ No newline at end of file diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 1d103451e377e..287bb487a0fa4 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -26,6 +26,15 @@ class FlutterTizenView { return flutter_tizen_engine_.get(); } + // Callbacks for clearing context, settings context and swapping buffers, + // these are typically called on an engine-controlled (non-platform) thread. + bool OnMakeCurrent(); + bool OnClearCurrent(); + bool OnMakeResourceCurrent(); + bool OnPresent(); + uint32_t OnGetFBO() ; + void* OnProcResolver(const char* name); + private: // The engine associated with this view. std::unique_ptr flutter_tizen_engine_; From aaed4a7b9596d7651236c7b417e855237ff60212 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 13 Apr 2022 12:04:41 +0900 Subject: [PATCH 03/32] Change flutter-tizen API names * Name of APIs based on handle must start with handle type name. Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen.cc | 26 +++++++------- shell/platform/tizen/flutter_tizen_view.h | 2 +- shell/platform/tizen/public/flutter_tizen.h | 40 +++++++++++---------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index e63649753baa0..302c188e7a0bd 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -40,7 +40,7 @@ FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar( } // namespace -FlutterDesktopEngineRef FlutterDesktopRunEngine( +FlutterDesktopEngineRef FlutterDesktopEngineRun( const FlutterDesktopWindowProperties& window_properties, const FlutterDesktopEngineProperties& engine_properties) { flutter::FlutterProjectBundle project(engine_properties); @@ -76,7 +76,7 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine( return HandleForEngine(flutter_tizen_view_->flutter_tizen_engine()); } -void FlutterDesktopShutdownEngine(FlutterDesktopEngineRef engine_ref) { +void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { flutter::Logger::Stop(); flutter::FlutterTizenEngine* engine = EngineFromHandle(engine_ref); @@ -84,7 +84,8 @@ void FlutterDesktopShutdownEngine(FlutterDesktopEngineRef engine_ref) { delete engine; } -void* FlutterDesktopGetWindow(FlutterDesktopPluginRegistrarRef registrar) { +void* FlutterDesktopPluginRegistrarGetNativeWindow( + FlutterDesktopPluginRegistrarRef registrar) { return registrar->engine->renderer()->GetWindowHandle(); } @@ -95,7 +96,7 @@ void FlutterDesktopPluginRegistrarEnableInputBlocking( channel); } -FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar( +FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar( FlutterDesktopEngineRef engine, const char* plugin_name) { // Currently, one registrar acts as the registrar for all plugins, so the @@ -154,33 +155,34 @@ void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, user_data); } -void FlutterDesktopNotifyAppControl(FlutterDesktopEngineRef engine, - void* app_control) { +void FlutterDesktopEngineNotifyAppControl(FlutterDesktopEngineRef engine, + void* app_control) { EngineFromHandle(engine)->app_control_channel()->NotifyAppControl( app_control); } -void FlutterDesktopNotifyLocaleChange(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyLocaleChange(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->SetupLocales(); } -void FlutterDesktopNotifyLowMemoryWarning(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyLowMemoryWarning( + FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->NotifyLowMemoryWarning(); } -void FlutterDesktopNotifyAppIsInactive(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyAppIsInactive(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->lifecycle_channel()->AppIsInactive(); } -void FlutterDesktopNotifyAppIsResumed(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyAppIsResumed(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->lifecycle_channel()->AppIsResumed(); } -void FlutterDesktopNotifyAppIsPaused(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyAppIsPaused(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->lifecycle_channel()->AppIsPaused(); } -void FlutterDesktopNotifyAppIsDetached(FlutterDesktopEngineRef engine) { +void FlutterDesktopEngineNotifyAppIsDetached(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->lifecycle_channel()->AppIsDetached(); } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 287bb487a0fa4..d7b2bc5eb0eb0 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -32,7 +32,7 @@ class FlutterTizenView { bool OnClearCurrent(); bool OnMakeResourceCurrent(); bool OnPresent(); - uint32_t OnGetFBO() ; + uint32_t OnGetFBO(); void* OnProcResolver(const char* name); private: diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index f311611a9ad3e..72ffde7895932 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -67,68 +67,72 @@ typedef struct { const char** dart_entrypoint_argv; } FlutterDesktopEngineProperties; +// ========== Engine ========== + // Runs an instance of a Flutter engine with the given properties. // // If |headed| is false, the engine is run in headless mode. -FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopRunEngine( +FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineRun( const FlutterDesktopWindowProperties& window_properties, const FlutterDesktopEngineProperties& engine_properties); // Shuts down the given engine instance. // // |engine| is no longer valid after this call. -FLUTTER_EXPORT void FlutterDesktopShutdownEngine( +FLUTTER_EXPORT void FlutterDesktopEngineShutdown( FlutterDesktopEngineRef engine); // Returns the plugin registrar handle for the plugin with the given name. // // The name must be unique across the application. FLUTTER_EXPORT FlutterDesktopPluginRegistrarRef -FlutterDesktopGetPluginRegistrar(FlutterDesktopEngineRef engine, - const char* plugin_name); +FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, + const char* plugin_name); // Returns the messenger associated with the engine. FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine); -// Returns the window associated with this registrar's engine instance. -// -// If the app runs on a wearable device, cast void* to Evas_Object*, -// otherwise cast it to Ecore_Wl2_Window*. -FLUTTER_EXPORT void* FlutterDesktopGetWindow( - FlutterDesktopPluginRegistrarRef registrar); - // Posts an app control to the engine instance. -FLUTTER_EXPORT void FlutterDesktopNotifyAppControl( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppControl( FlutterDesktopEngineRef engine, void* app_control); // Posts a locale change notification to the engine instance. -FLUTTER_EXPORT void FlutterDesktopNotifyLocaleChange( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyLocaleChange( FlutterDesktopEngineRef engine); // Posts a low memory notification to the engine instance. -FLUTTER_EXPORT void FlutterDesktopNotifyLowMemoryWarning( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyLowMemoryWarning( FlutterDesktopEngineRef engine); // Notifies the engine that the app is in an inactive state and not receiving // user input. -FLUTTER_EXPORT void FlutterDesktopNotifyAppIsInactive( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsInactive( FlutterDesktopEngineRef engine); // Notifies the engine that the app is visible and responding to user input. -FLUTTER_EXPORT void FlutterDesktopNotifyAppIsResumed( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsResumed( FlutterDesktopEngineRef engine); // Notifies the engine that the app is not currently visible to the user, not // responding to user input, and running in the background. -FLUTTER_EXPORT void FlutterDesktopNotifyAppIsPaused( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsPaused( FlutterDesktopEngineRef engine); // Notifies the engine that the engine is detached from any host views. -FLUTTER_EXPORT void FlutterDesktopNotifyAppIsDetached( +FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsDetached( FlutterDesktopEngineRef engine); +// ========== Plugin Registrar (extensions) ========== + +// Returns the window associated with this registrar's engine instance. +// +// If the app runs on a wearable device, cast void* to Evas_Object*, +// otherwise cast it to Ecore_Wl2_Window*. +FLUTTER_EXPORT void* FlutterDesktopPluginRegistrarGetNativeWindow( + FlutterDesktopPluginRegistrarRef registrar); + #if defined(__cplusplus) } // extern "C" #endif From 9ebdd2ea8516558402d7b5e01c0fa126e2dfeeae Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 18 Apr 2022 17:08:42 +0900 Subject: [PATCH 04/32] Implement FlutterTizenView, FlutterTizenWindow * This is initial implementation based on ecore. * There is a lot of to-do things (event handler, rework based on enligntment). Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 9 +- .../tizen/channels/platform_channel.cc | 9 +- .../platform/tizen/channels/window_channel.cc | 35 +-- .../platform/tizen/channels/window_channel.h | 8 +- shell/platform/tizen/flutter_tizen.cc | 33 +-- shell/platform/tizen/flutter_tizen_ecore.cc | 58 ++++ .../tizen/flutter_tizen_elementary.cc | 42 +++ shell/platform/tizen/flutter_tizen_engine.cc | 145 ++-------- shell/platform/tizen/flutter_tizen_engine.h | 23 +- shell/platform/tizen/flutter_tizen_view.cc | 108 +++++++- shell/platform/tizen/flutter_tizen_view.h | 41 ++- shell/platform/tizen/flutter_tizen_window.h | 79 ++++++ .../tizen/flutter_tizen_window_ecore_wl2.cc | 254 +++++++++++++++++ .../tizen/flutter_tizen_window_ecore_wl2.h | 72 +++++ shell/platform/tizen/key_event_handler.cc | 11 +- shell/platform/tizen/public/flutter_tizen.h | 33 ++- .../tizen/tizen_input_method_context.cc | 10 +- shell/platform/tizen/tizen_renderer.cc | 11 +- shell/platform/tizen/tizen_renderer.h | 60 +--- .../tizen/tizen_renderer_ecore_wl2.cc | 256 ++---------------- .../platform/tizen/tizen_renderer_ecore_wl2.h | 56 +--- shell/platform/tizen/touch_event_handler.cc | 98 +++---- 22 files changed, 867 insertions(+), 584 deletions(-) create mode 100644 shell/platform/tizen/flutter_tizen_ecore.cc create mode 100644 shell/platform/tizen/flutter_tizen_elementary.cc create mode 100644 shell/platform/tizen/flutter_tizen_window.h create mode 100644 shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc create mode 100644 shell/platform/tizen/flutter_tizen_window_ecore_wl2.h diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 19990e59b647e..2aa1570536c50 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -186,7 +186,10 @@ template("embedder") { ] if (use_evas_gl_renderer) { - sources += [ "tizen_renderer_evas_gl.cc" ] + sources += [ + "flutter_tizen_elementary.cc", + "tizen_renderer_evas_gl.cc" + ] libs += [ "ecore_evas", @@ -197,6 +200,8 @@ template("embedder") { public_configs += [ ":evas_gl_renderer" ] } else { sources += [ + "flutter_tizen_ecore.cc", + "flutter_tizen_window_ecore_wl2.cc", "tizen_renderer_ecore_wl2.cc", "tizen_vsync_waiter.cc", ] @@ -233,7 +238,7 @@ embedder("flutter_tizen_mobile") { embedder("flutter_tizen_wearable") { target_type = "shared_library" - use_evas_gl_renderer = true + use_evas_gl_renderer = false defines = [ "WEARABLE_PROFILE" ] } diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 95f89ccf1eb8c..8221cbfa2786f 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -170,7 +170,8 @@ void PlatformChannel::RestoreSystemUiOverlays() { #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - shell.InitializeSoftkey(renderer_->GetWindowId()); + // TODO + // shell.InitializeSoftkey(renderer_->GetWindowId()); if (shell.IsSoftkeyShown()) { shell.ShowSoftkey(); @@ -188,7 +189,8 @@ void PlatformChannel::SetEnabledSystemUiOverlays( #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - shell.InitializeSoftkey(renderer_->GetWindowId()); + // TODO + // shell.InitializeSoftkey(renderer_->GetWindowId()); if (std::find(overlays.begin(), overlays.end(), kSystemUiOverlayBottom) != overlays.end()) { @@ -220,7 +222,8 @@ void PlatformChannel::SetPreferredOrientations( // default. rotations = {0, 90, 180, 270}; } - renderer_->SetPreferredOrientations(rotations); + // TODO + // renderer_->SetPreferredOrientations(rotations); } } // namespace flutter diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index 53a221d6cad72..dc15a282bedb7 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -16,10 +16,10 @@ constexpr char kChannelName[] = "tizen/internal/window"; } // namespace -WindowChannel::WindowChannel(BinaryMessenger* messenger, - TizenRenderer* renderer, - TizenRenderer::Delegate* delegate) - : renderer_(renderer), delegate_(delegate) { +// TODO +WindowChannel::WindowChannel(BinaryMessenger* messenger) /* + : renderer_(renderer), delegate_(delegate)*/ +{ channel_ = std::make_unique>( messenger, kChannelName, &StandardMethodCodec::GetInstance()); channel_->SetMethodCallHandler( @@ -37,12 +37,13 @@ void WindowChannel::HandleMethodCall( const std::string& method_name = method_call.method_name(); if (method_name == "getWindowGeometry") { - TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); + // TODO + // TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); EncodableMap map; - map[EncodableValue("x")] = EncodableValue(geometry.x); - map[EncodableValue("y")] = EncodableValue(geometry.y); - map[EncodableValue("width")] = EncodableValue(geometry.w); - map[EncodableValue("height")] = EncodableValue(geometry.h); + // map[EncodableValue("x")] = EncodableValue(geometry.x); + // map[EncodableValue("y")] = EncodableValue(geometry.y); + // map[EncodableValue("width")] = EncodableValue(geometry.w); + // map[EncodableValue("height")] = EncodableValue(geometry.h); result->Success(EncodableValue(map)); } else if (method_name == "setWindowGeometry") { #ifdef TIZEN_RENDERER_EVAS_GL @@ -59,18 +60,20 @@ void WindowChannel::HandleMethodCall( EncodableValueHolder width(arguments, "width"); EncodableValueHolder height(arguments, "height"); - TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); + // TODO + // TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); - delegate_->OnGeometryChange(x ? *x : geometry.x, y ? *y : geometry.y, - width ? *width : geometry.w, - height ? *height : geometry.h); + // delegate_->OnGeometryChange(x ? *x : geometry.x, y ? *y : geometry.y, + // width ? *width : geometry.w, + // height ? *height : geometry.h); result->Success(); #endif } else if (method_name == "getScreenGeometry") { - TizenRenderer::Geometry geometry = renderer_->GetScreenGeometry(); + // TODO + // TizenRenderer::Geometry geometry = renderer_->GetScreenGeometry(); EncodableMap map; - map[EncodableValue("width")] = EncodableValue(geometry.w); - map[EncodableValue("height")] = EncodableValue(geometry.h); + // map[EncodableValue("width")] = EncodableValue(geometry.w); + // map[EncodableValue("height")] = EncodableValue(geometry.h); result->Success(EncodableValue(map)); } else { result->NotImplemented(); diff --git a/shell/platform/tizen/channels/window_channel.h b/shell/platform/tizen/channels/window_channel.h index 19a9a442fe36a..8ef6521bab620 100644 --- a/shell/platform/tizen/channels/window_channel.h +++ b/shell/platform/tizen/channels/window_channel.h @@ -17,9 +17,9 @@ namespace flutter { // Channel to get/set application's window size and device's screen size. class WindowChannel { public: - explicit WindowChannel(BinaryMessenger* messenger, + explicit WindowChannel(BinaryMessenger* messenger/*, TizenRenderer* renderer, - TizenRenderer::Delegate* delegate); + TizenRenderer::Delegate* delegate*/); virtual ~WindowChannel(); private: @@ -30,9 +30,9 @@ class WindowChannel { // A reference to the renderer object managed by FlutterTizenEngine. // This can be nullptr if the engine is running in headless mode. - TizenRenderer* renderer_; + // TizenRenderer* renderer_; - [[maybe_unused]] TizenRenderer::Delegate* delegate_; + // [[maybe_unused]] TizenRenderer::Delegate* delegate_; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 302c188e7a0bd..4f02acb3280c3 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -14,6 +14,8 @@ #include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h" + namespace { // Returns the engine corresponding to the given opaque API handle. @@ -40,8 +42,7 @@ FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar( } // namespace -FlutterDesktopEngineRef FlutterDesktopEngineRun( - const FlutterDesktopWindowProperties& window_properties, +FlutterDesktopEngineRef FlutterDesktopEngineCreate( const FlutterDesktopEngineProperties& engine_properties) { flutter::FlutterProjectBundle project(engine_properties); if (project.HasArgument("--verbose-logging")) { @@ -52,28 +53,14 @@ FlutterDesktopEngineRef FlutterDesktopEngineRun( flutter::Logger::SetLoggingPort(std::stoi(logging_port)); } flutter::Logger::Start(); - auto flutter_tizen_engine = std::make_unique(project); + return HandleForEngine(flutter_tizen_engine.release()); +} - // Temporarily statically used - static auto flutter_tizen_view_ = - std::make_unique(); - - flutter_tizen_view_->SetFlutterTizenEngine(std::move(flutter_tizen_engine)); - - if (window_properties.headed) { - flutter_tizen_view_->flutter_tizen_engine()->InitializeRenderer( - window_properties.x, window_properties.y, window_properties.width, - window_properties.height, window_properties.transparent, - window_properties.focusable, window_properties.top_level); - } - if (!flutter_tizen_view_->flutter_tizen_engine()->RunEngine( - engine_properties.entrypoint)) { - FT_LOG(Error) << "Failed to start the Flutter engine."; - return nullptr; - } - return HandleForEngine(flutter_tizen_view_->flutter_tizen_engine()); +bool FlutterDesktopEngineRun(const FlutterDesktopEngineRef engine, + const char* entry_point) { + return EngineFromHandle(engine)->RunEngine(entry_point); } void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { @@ -86,7 +73,9 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { void* FlutterDesktopPluginRegistrarGetNativeWindow( FlutterDesktopPluginRegistrarRef registrar) { - return registrar->engine->renderer()->GetWindowHandle(); + // TODO + // return registrar->engine->renderer()->GetWindowHandle(); + return nullptr; } void FlutterDesktopPluginRegistrarEnableInputBlocking( diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc new file mode 100644 index 0000000000000..17935bf22a5ce --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -0,0 +1,58 @@ +// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "public/flutter_tizen.h" + +#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h" +#include "flutter/shell/platform/tizen/logger.h" + +namespace { + +// Returns the engine corresponding to the given opaque API handle. +flutter::FlutterTizenEngine* EngineFromHandle(FlutterDesktopEngineRef ref) { + return reinterpret_cast(ref); +} + +FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { + return reinterpret_cast(view); +} + +} // namespace + +FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( + const FlutterDesktopWindowProperties& window_properties, + FlutterDesktopEngineRef engine) { + // Todo : Use view and window imple; + + std::unique_ptr flutter_tizen_window = + std::make_unique( + flutter::FlutterTizenWindow::Geometry( + {window_properties.x, window_properties.y, + window_properties.width, window_properties.height}), + window_properties.transparent, window_properties.focusable, + window_properties.top_level); + + // Take ownership of the engine, starting it if necessary. + FT_LOG(Error) << "create view"; + auto flutter_tizen_view = std::make_unique( + std::move(flutter_tizen_window)); + + FT_LOG(Error) << "Set engine to view"; + flutter_tizen_view->SetFlutterTizenEngine( + std::unique_ptr(EngineFromHandle(engine))); + + FT_LOG(Error) << "Create render surface"; + flutter_tizen_view->CreateRenderSurface(); + + if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { + flutter_tizen_view->flutter_tizen_engine()->RunEngine(nullptr); + } + + flutter_tizen_view->OnRotate(0); + + return HandleForView(flutter_tizen_view.release()); +} diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc new file mode 100644 index 0000000000000..d4bc2275ea58e --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -0,0 +1,42 @@ +// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "public/flutter_tizen.h" + +#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/logger.h" + +namespace { + +// Returns the engine corresponding to the given opaque API handle. +flutter::FlutterTizenEngine* EngineFromHandle(FlutterDesktopEngineRef ref) { + return reinterpret_cast(ref); +} + +FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { + return reinterpret_cast(view); +} + +} // namespace + +FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( + const FlutterDesktopWindowProperties& window_properties, + FlutterDesktopEngineRef engine) { + // Todo : Use view and window imple; + + // EngineFromHandle(engine)->InitializeRenderer( + // window_properties.x, window_properties.y, window_properties.width, + // window_properties.height, window_properties.transparent, + // window_properties.focusable, window_properties.top_level); + // auto flutter_tizen_view_ = std::make_unique(); + + // flutter::FlutterTizenWindowEcoreWl2 window; + + flutter_tizen_view_->SetFlutterTizenEngine( + std::unique_ptr(EngineFromHandle(engine))); + + return HandleForView(flutter_tizen_view_.release()); +} diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 77010f9bc4221..f42a7d705a5e8 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -28,16 +28,6 @@ constexpr size_t kPlatformTaskRunnerIdentifier = 1; constexpr size_t kRenderTaskRunnerIdentifier = 2; #endif -#if defined(MOBILE_PROFILE) -constexpr double kProfileFactor = 0.7; -#elif defined(WEARABLE_PROFILE) -constexpr double kProfileFactor = 0.4; -#elif defined(TV_PROFILE) -constexpr double kProfileFactor = 2.0; -#else -constexpr double kProfileFactor = 1.0; -#endif - // Converts a LanguageInfo struct to a FlutterLocale struct. |info| must outlive // the returned value, since the returned FlutterLocale has pointers into it. FlutterLocale CovertToFlutterLocale(const LanguageInfo& info) { @@ -61,6 +51,7 @@ FlutterLocale CovertToFlutterLocale(const LanguageInfo& info) { FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) : project_(std::make_unique(project)), aot_data_(nullptr, nullptr) { + FT_LOG(Error) << "enter"; embedder_api_.struct_size = sizeof(FlutterEngineProcTable); FlutterEngineGetProcAddresses(&embedder_api_); @@ -75,33 +66,8 @@ FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) } }); - messenger_ = std::make_unique(); - messenger_->engine = this; - message_dispatcher_ = - std::make_unique(messenger_.get()); - - plugin_registrar_ = std::make_unique(); - plugin_registrar_->engine = this; - - transformation_ = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; -} - -FlutterTizenEngine::~FlutterTizenEngine() { - renderer_ = nullptr; -} - -void FlutterTizenEngine::InitializeRenderer(int32_t x, - int32_t y, - int32_t width, - int32_t height, - bool transparent, - bool focusable, - bool top_level) { - TizenRenderer::Geometry geometry = {x, y, width, height}; - #ifdef TIZEN_RENDERER_EVAS_GL - renderer_ = std::make_unique( - geometry, transparent, focusable, top_level, *this); + renderer_ = std::make_unique(); render_loop_ = std::make_unique( std::this_thread::get_id(), // main thread @@ -113,14 +79,26 @@ void FlutterTizenEngine::InitializeRenderer(int32_t x, }, renderer_.get()); #else - renderer_ = std::make_unique( - geometry, transparent, focusable, top_level, *this); - + renderer_ = std::make_unique(); tizen_vsync_waiter_ = std::make_unique(this); #endif + + messenger_ = std::make_unique(); + messenger_->engine = this; + message_dispatcher_ = + std::make_unique(messenger_.get()); + + plugin_registrar_ = std::make_unique(); + plugin_registrar_->engine = this; + FT_LOG(Error) << "done"; +} + +FlutterTizenEngine::~FlutterTizenEngine() { + renderer_ = nullptr; } bool FlutterTizenEngine::RunEngine(const char* entrypoint) { + FT_LOG(Error) << "enter"; if (engine_ != nullptr) { FT_LOG(Error) << "The engine has already started."; return false; @@ -273,19 +251,21 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), std::make_unique(this)); + // TODO window_channel_ = std::make_unique( - internal_plugin_registrar_->messenger(), renderer_.get(), this); + internal_plugin_registrar_->messenger() /*, renderer_.get(), this*/); key_event_handler_ = std::make_unique(this); touch_event_handler_ = std::make_unique(this); - SetWindowOrientation(0); + // SetWindowOrientation(0); } accessibility_settings_ = std::make_unique(this); SetupLocales(); + FT_LOG(Error) << "done"; return true; } @@ -372,80 +352,10 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t x, event.top = static_cast(y); event.width = static_cast(width); event.height = static_cast(height); - if (pixel_ratio == 0.0) { - // The scale factor is computed based on the display DPI and the current - // profile. A fixed DPI value (72) is used on TVs. See: - // https://docs.tizen.org/application/native/guides/ui/efl/multiple-screens -#ifdef TV_PROFILE - double dpi = 72.0; -#else - double dpi = static_cast(renderer_->GetDpi()); -#endif - double scale_factor = dpi / 90.0 * kProfileFactor; - event.pixel_ratio = std::max(scale_factor, 1.0); - } else { - event.pixel_ratio = pixel_ratio; - } + event.pixel_ratio = pixel_ratio; embedder_api_.SendWindowMetricsEvent(engine_, &event); } -// This must be called at least once in order to initialize the value of -// transformation_. -void FlutterTizenEngine::SetWindowOrientation(int32_t degree) { - if (!renderer_->IsValid()) { - return; - } - - renderer_->SetRotate(degree); - // Compute renderer transformation based on the angle of rotation. - double rad = (360 - degree) * M_PI / 180; - TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); - double width = geometry.w; - double height = geometry.h; - - double trans_x = 0.0, trans_y = 0.0; - if (degree == 90) { - trans_y = height; - } else if (degree == 180) { - trans_x = width; - trans_y = height; - } else if (degree == 270) { - trans_x = width; - } - transformation_ = { - cos(rad), -sin(rad), trans_x, // x - sin(rad), cos(rad), trans_y, // y - 0.0, 0.0, 1.0 // perspective - }; - touch_event_handler_->rotation = degree; - if (degree == 90 || degree == 270) { - std::swap(width, height); - } - renderer_->ResizeWithRotation(geometry.x, geometry.y, width, height, degree); - // Window position does not change on rotation regardless of its orientation. - SendWindowMetrics(geometry.x, geometry.y, width, height, 0.0); -} - -void FlutterTizenEngine::OnOrientationChange(int32_t degree) { - SetWindowOrientation(degree); -} - -void FlutterTizenEngine::OnGeometryChange(int32_t x, - int32_t y, - int32_t width, - int32_t height) { -#ifdef TIZEN_RENDERER_EVAS_GL - FT_UNIMPLEMENTED(); -#else - if (!renderer_->IsValid()) { - return; - } - renderer_->SetGeometry(x, y, width, height); - renderer_->ResizeWithRotation(x, y, width, height, 0); - SendWindowMetrics(x, y, width, height, 0.0); -#endif -} - void FlutterTizenEngine::OnVsync(intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos) { @@ -553,7 +463,11 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { }; config.open_gl.surface_transformation = [](void* user_data) -> FlutterTransformation { - return reinterpret_cast(user_data)->transformation_; + auto engine = reinterpret_cast(user_data); + if (!engine->flutter_tizen_view()) { + return FlutterTransformation(); + } + return engine->flutter_tizen_view()->GetFlutterTransformation(); }; config.open_gl.gl_proc_resolver = [](void* user_data, const char* name) -> void* { @@ -639,8 +553,9 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions( bridge->GetFlutterPlatformNodeDelegateFromID(0); std::shared_ptr window = FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock(); - TizenRenderer::Geometry geometry = engine->renderer_->GetWindowGeometry(); - window->SetGeometry(geometry.x, geometry.y, geometry.w, geometry.h); + // TODO + // auto geometry = engine->renderer_->GetWindowGeometry(); + // window->SetGeometry(geometry.x, geometry.y, geometry.w, geometry.h); window->SetRootNode(root); return; } diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index a50dda101a14b..da6fda9109e16 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -56,7 +56,7 @@ namespace flutter { class FlutterTizenView; // Manages state associated with the underlying FlutterEngine. -class FlutterTizenEngine : public TizenRenderer::Delegate { +class FlutterTizenEngine { public: // Creates a new Flutter engine object configured to run |project|. explicit FlutterTizenEngine(const FlutterProjectBundle& project); @@ -67,21 +67,15 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { FlutterTizenEngine(FlutterTizenEngine const&) = delete; FlutterTizenEngine& operator=(FlutterTizenEngine const&) = delete; - // Sets up an instance of TizenRenderer. - void InitializeRenderer(int32_t x, - int32_t y, - int32_t width, - int32_t height, - bool transparent, - bool focusable, - bool top_level); - // Starts running the engine with the given entrypoint. If null, defaults to // main(). // // Returns false if the engine couldn't be started. bool RunEngine(const char* entrypoint); + // Returns true if the engine is currently running. + bool IsRunning() { return engine_ != nullptr; } + // Stops the engine. bool StopEngine(); @@ -159,12 +153,6 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { int32_t height, double pixel_ratio); - void SetWindowOrientation(int32_t degree); - void OnOrientationChange(int32_t degree) override; - void OnGeometryChange(int32_t x, - int32_t y, - int32_t width, - int32_t height) override; void OnVsync(intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos); @@ -317,9 +305,6 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { // The vsync waiter for the embedder. std::unique_ptr tizen_vsync_waiter_; #endif - - // The current renderer transformation. - FlutterTransformation transformation_; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index ec28fb3cf4c83..7cf2025d2e626 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -5,15 +5,55 @@ #include "flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" +#include "flutter/shell/platform/tizen/logger.h" + +namespace { + +#if defined(MOBILE_PROFILE) +constexpr double kProfileFactor = 0.7; +#elif defined(WEARABLE_PROFILE) +constexpr double kProfileFactor = 0.4; +#elif defined(TV_PROFILE) +constexpr double kProfileFactor = 2.0; +#else +constexpr double kProfileFactor = 1.0; +#endif + +} // namespace + namespace flutter { -FlutterTizenView::FlutterTizenView() {} +FlutterTizenView::FlutterTizenView( + std::unique_ptr flutter_tizen_window) + : flutter_tizen_window_(std::move(flutter_tizen_window)) { + flutter_tizen_window_->SetFlutterTizenView(this); +} + +FlutterTizenView::~FlutterTizenView() { + FT_LOG(Info) << "enter"; +} void FlutterTizenView::SetFlutterTizenEngine( std::unique_ptr flutter_tizen_engine) { flutter_tizen_engine_ = std::move(flutter_tizen_engine); - flutter_tizen_engine_->SetFlutterTizenView(this); + + // registrar + // keyboard? + // platform handler? + // corsor handler? + FT_LOG(Info) << "done"; +} + +void FlutterTizenView::CreateRenderSurface() { + if (flutter_tizen_engine_ && flutter_tizen_engine_->renderer()) { + auto geometry = flutter_tizen_window_->GetWindowGeometry(); + flutter_tizen_engine_->renderer()->CreateSurface( + flutter_tizen_window_->GetRenderTarget(), + flutter_tizen_window_->GetRenderTargetDisplay(), geometry.width, + geometry.height); + } } bool FlutterTizenView::OnMakeCurrent() { @@ -39,4 +79,66 @@ void* FlutterTizenView::OnProcResolver(const char* name) { return flutter_tizen_engine_->renderer()->OnProcResolver(name); } -} // namespace flutter \ No newline at end of file +void FlutterTizenView::OnRotate(int32_t degree) { + // Compute renderer transformation based on the angle of rotation. + double rad = (360 - degree) * M_PI / 180; + auto geometry = flutter_tizen_window_->GetWindowGeometry(); + int32_t width = geometry.width; + int32_t height = geometry.height; + + double trans_x = 0.0, trans_y = 0.0; + if (degree == 90) { + trans_y = height; + } else if (degree == 180) { + trans_x = width; + trans_y = height; + } else if (degree == 270) { + trans_x = width; + } + + // view settransform + flutter_trans_formation_ = { + cos(rad), -sin(rad), trans_x, // x + sin(rad), cos(rad), trans_y, // y + 0.0, 0.0, 1.0 // perspective + }; + + // touch_event_handler_->rotation = degree; + + if (degree == 90 || degree == 270) { + std::swap(width, height); + } + + flutter_tizen_window_->ResizeWithRotation( + {geometry.left, geometry.top, width, height}, degree); + + // Window position does not change on rotation regardless of its orientation. + SendWindowMetrics(geometry.left, geometry.top, width, height, 0.0); +} + +void FlutterTizenView::SendWindowMetrics(int32_t left, + int32_t top, + int32_t width, + int32_t height, + double pixel_ratio) { + double computed_pixel_ratio = pixel_ratio; + if (pixel_ratio == 0.0) { + // The scale factor is computed based on the display DPI and the current + // profile. A fixed DPI value (72) is used on TVs. See: + // https://docs.tizen.org/application/native/guides/ui/efl/multiple-screens +#ifdef TV_PROFILE + double dpi = 72.0; +#else + double dpi = static_cast(flutter_tizen_window_->GetDpi()); +#endif + double scale_factor = dpi / 90.0 * kProfileFactor; + computed_pixel_ratio = std::max(scale_factor, 1.0); + } else { + computed_pixel_ratio = pixel_ratio; + } + + flutter_tizen_engine_->SendWindowMetrics(left, top, width, height, + computed_pixel_ratio); +} + +} // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index d7b2bc5eb0eb0..8f432e00e415e 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -13,9 +13,13 @@ namespace flutter { +class FlutterTizenWindow; + class FlutterTizenView { public: - FlutterTizenView(); + FlutterTizenView(std::unique_ptr flutter_tizen_window); + + ~FlutterTizenView(); // Configures the window instance with an instance of a running Flutter // engine. @@ -26,18 +30,53 @@ class FlutterTizenView { return flutter_tizen_engine_.get(); } + // Creates rendering surface for Flutter engine to draw into. + // Should be called before calling FlutterEngineRun using this view. + void CreateRenderSurface(); + + // Destroys current rendering surface if one has been allocated. + void DestroyRenderSurface(); + // Callbacks for clearing context, settings context and swapping buffers, // these are typically called on an engine-controlled (non-platform) thread. bool OnMakeCurrent(); + bool OnClearCurrent(); + bool OnMakeResourceCurrent(); + bool OnPresent(); + uint32_t OnGetFBO(); + void* OnProcResolver(const char* name); + void OnRotate(int32_t degree); + + FlutterTransformation GetFlutterTransformation() { + return flutter_trans_formation_; + } + private: + // Sends a window metrics update to the Flutter engine using current window + // dimensions in physical + void SendWindowMetrics(int32_t left, + int32_t top, + int32_t width, + int32_t height, + double pixel_ratio); + // The engine associated with this view. std::unique_ptr flutter_tizen_engine_; + + // TODO + public: + std::unique_ptr flutter_tizen_window_; + + private: + // The current renderer transformation. + FlutterTransformation flutter_trans_formation_ = {1.0, 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 0.0, 1.0}; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_window.h b/shell/platform/tizen/flutter_tizen_window.h new file mode 100644 index 0000000000000..3d5fd6979bd9d --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_window.h @@ -0,0 +1,79 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_H_ +#define EMBEDDER_FLUTTER_TIZEN_WINDOW_H_ + +#include +#include +#include + +namespace flutter { + +class FlutterTizenView; + +class FlutterTizenWindow { + public: + struct Geometry { + int32_t left = 0, top = 0, width = 0, height = 0; + }; + + FlutterTizenWindow(); + + virtual ~FlutterTizenWindow() = default; + + // Sets the delegate used to communicate state changes from window to view + // such as key presses, mouse position updates etc. + void SetFlutterTizenView(FlutterTizenView* view) { + flutter_tizen_view_ = view; + } + + // Returns the geometry of the current window. + virtual Geometry GetWindowGeometry() = 0; + + // Returns the geometry of the display screen. + virtual Geometry GetScreenGeometry() = 0; + + // Returns a valid pointer the platform object that rendering can be bound to + // by rendering backend. + virtual void* GetRenderTarget() = 0; + + virtual void* GetRenderTargetDisplay() = 0; + + // Returns the scale factor for the backing window. + virtual int32_t GetDpi() = 0; + + virtual uintptr_t GetWindowId() = 0; + + virtual void* GetWindowHandle() = 0; + + virtual void ResizeWithRotation(Geometry geometry, int32_t degree) = 0; + + virtual void SetPreferredOrientations(const std::vector& rotations) = 0; + + virtual void BindKeys(const std::vector& keys) = 0; + + virtual void Show() = 0; + + protected: + explicit FlutterTizenWindow(Geometry geometry, + bool transparent, + bool focusable, + bool top_level) + : initial_geometry_(geometry), + transparent_(transparent), + focusable_(focusable), + top_level_(top_level) {} + + Geometry initial_geometry_ = {0, 0, 0, 0}; + bool transparent_ = false; + bool focusable_ = false; + bool top_level_ = false; + + FlutterTizenView* flutter_tizen_view_ = nullptr; +}; + +} // namespace flutter +#endif diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc new file mode 100644 index 0000000000000..26a17d6fa94c4 --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -0,0 +1,254 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter_tizen_window_ecore_wl2.h" + +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/logger.h" + +namespace flutter { + +FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, + bool transparent, + bool focusable, + bool top_level) + : FlutterTizenWindow(geometry, transparent, focusable, top_level) { + FT_LOG(Error) << "enter"; + if (!CreateWindow()) { + FT_LOG(Error) << "Failed to create platform window"; + return; + } + + SetWindowOptions(); + RegisterEventHandlers(); + Show(); + FT_LOG(Error) << "done"; +} + +FlutterTizenWindowEcoreWl2::~FlutterTizenWindowEcoreWl2() { + FT_LOG(Info) << "enter"; + DestroyEcoreWl2(); +} + +bool FlutterTizenWindowEcoreWl2::CreateWindow() { + if (!ecore_wl2_init()) { + FT_LOG(Error) << "Could not initialize Ecore Wl2."; + return false; + } + + ecore_wl2_display_ = ecore_wl2_display_connect(nullptr); + if (!ecore_wl2_display_) { + FT_LOG(Error) << "Ecore Wl2 display not found."; + return false; + } + wl2_display_ = ecore_wl2_display_get(ecore_wl2_display_); + + ecore_wl2_sync(); + + int32_t width, height; + ecore_wl2_display_screen_size_get(ecore_wl2_display_, &width, &height); + if (width == 0 || height == 0) { + FT_LOG(Error) << "Invalid screen size: " << width << " x " << height; + return false; + } + + if (initial_geometry_.width == 0) { + initial_geometry_.width = width; + } + + if (initial_geometry_.height == 0) { + initial_geometry_.height = height; + } + + FT_LOG(Error) << "left" << initial_geometry_.left; + FT_LOG(Error) << "top" << initial_geometry_.top; + FT_LOG(Error) << "width " << initial_geometry_.width; + FT_LOG(Error) << "height " << initial_geometry_.height; + ecore_wl2_window_ = ecore_wl2_window_new( + ecore_wl2_display_, nullptr, initial_geometry_.left, + initial_geometry_.top, initial_geometry_.width, initial_geometry_.height); + + ecore_wl2_egl_window_ = ecore_wl2_egl_window_create( + ecore_wl2_window_, initial_geometry_.width, initial_geometry_.height); + + return ecore_wl2_egl_window_ && wl2_display_; +} + +void FlutterTizenWindowEcoreWl2::SetWindowOptions() { + // Change the window type to use the tizen policy for notification window + // according to top_level_. + // Note: ECORE_WL2_WINDOW_TYPE_TOPLEVEL is similar to "ELM_WIN_BASIC" and it + // does not mean that the window always will be overlaid on other apps :( + ecore_wl2_window_type_set(ecore_wl2_window_, + top_level_ ? ECORE_WL2_WINDOW_TYPE_NOTIFICATION + : ECORE_WL2_WINDOW_TYPE_TOPLEVEL); + if (top_level_) { + SetTizenPolicyNotificationLevel(TIZEN_POLICY_LEVEL_TOP); + } + + ecore_wl2_window_position_set(ecore_wl2_window_, initial_geometry_.left, + initial_geometry_.top); + ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0, + "wm.policy.win.user.geometry", "1"); + + if (transparent_) { + ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_TRUE); + } else { + ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE); + } + + if (!focusable_) { + ecore_wl2_window_focus_skip_set(ecore_wl2_window_, EINA_TRUE); + } + + ecore_wl2_window_indicator_state_set(ecore_wl2_window_, + ECORE_WL2_INDICATOR_STATE_ON); + ecore_wl2_window_indicator_opacity_set(ecore_wl2_window_, + ECORE_WL2_INDICATOR_OPAQUE); + ecore_wl2_indicator_visible_type_set(ecore_wl2_window_, + ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN); + + int rotations[4] = {0, 90, 180, 270}; + ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations, + sizeof(rotations) / sizeof(int)); +} + +void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { + ecore_event_handlers_.push_back( + ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, + FlutterTizenWindowEcoreWl2::OnRotate, this)); +} + +void FlutterTizenWindowEcoreWl2::DestroyEcoreWl2() { + if (ecore_wl2_egl_window_) { + ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); + ecore_wl2_egl_window_ = nullptr; + } + + if (ecore_wl2_window_) { + ecore_wl2_window_free(ecore_wl2_window_); + ecore_wl2_window_ = nullptr; + } + + if (ecore_wl2_display_) { + ecore_wl2_display_disconnect(ecore_wl2_display_); + ecore_wl2_display_ = nullptr; + } + ecore_wl2_shutdown(); +} + +FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetWindowGeometry() { + Geometry result; + ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.left, &result.top, + &result.width, &result.height); + FT_LOG(Error) << "left" << result.left; + FT_LOG(Error) << "top" << result.top; + FT_LOG(Error) << "width " << result.width; + FT_LOG(Error) << "height" << result.height; + return result; +} + +FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetScreenGeometry() { + Geometry result = {}; + ecore_wl2_display_screen_size_get(ecore_wl2_display_, &result.width, + &result.height); + return result; +} + +int32_t FlutterTizenWindowEcoreWl2::GetDpi() { + auto* output = ecore_wl2_window_output_find(ecore_wl2_window_); + if (!output) { + FT_LOG(Error) << "Could not find an output associated with the window."; + return 0; + } + return ecore_wl2_output_dpi_get(output); +} + +uintptr_t FlutterTizenWindowEcoreWl2::GetWindowId() { + return ecore_wl2_window_id_get(ecore_wl2_window_); +} + +// void FlutterTizenWindowEcoreWl2::SetGeometry(Geometry geometry) { +// ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, +// geometry.top, +// geometry.width, geometry.height); +// ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, +// geometry.top); +// } + +void FlutterTizenWindowEcoreWl2::ResizeWithRotation(Geometry geometry, + int32_t angle) { + ecore_wl2_egl_window_resize_with_rotation( + ecore_wl2_egl_window_, geometry.left, geometry.top, geometry.width, + geometry.height, angle); +} + +void FlutterTizenWindowEcoreWl2::SetPreferredOrientations( + const std::vector& rotations) { + ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations.data(), + rotations.size()); +} + +void FlutterTizenWindowEcoreWl2::BindKeys( + const std::vector& keys) { + for (const auto& key : keys) { + ecore_wl2_window_keygrab_set(ecore_wl2_window_, key.c_str(), 0, 0, 0, + ECORE_WL2_WINDOW_KEYGRAB_TOPMOST); + } +} + +void FlutterTizenWindowEcoreWl2::Show() { + ecore_wl2_window_show(ecore_wl2_window_); +} + +Eina_Bool FlutterTizenWindowEcoreWl2::OnRotate(void* data, + int type, + void* event) { + auto* self = reinterpret_cast(data); + auto* rotation_event = + reinterpret_cast(event); + if (self->flutter_tizen_view_) { + int32_t degree = rotation_event->angle; + self->flutter_tizen_view_->OnRotate(degree); + auto geometry = self->GetWindowGeometry(); + ecore_wl2_window_rotation_change_done_send(self->ecore_wl2_window_, + rotation_event->rotation, + geometry.width, geometry.height); + } + FT_LOG(Error) << "done"; + return ECORE_CALLBACK_PASS_ON; +} + +void FlutterTizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { + Eina_Iterator* iter = ecore_wl2_display_globals_get(ecore_wl2_display_); + struct wl_registry* registry = + ecore_wl2_display_registry_get(ecore_wl2_display_); + + if (iter && registry) { + Ecore_Wl2_Global* global = nullptr; + + // Retrieve global objects to bind tizen policy + EINA_ITERATOR_FOREACH(iter, global) { + if (strcmp(global->interface, tizen_policy_interface.name) == 0) { + tizen_policy_ = static_cast( + wl_registry_bind(registry, global->id, &tizen_policy_interface, 1)); + break; + } + } + } + eina_iterator_free(iter); + + if (tizen_policy_ == nullptr) { + FT_LOG(Error) + << "Failed to initialize the tizen policy handle, the top_level " + "attribute is ignored."; + return; + } + + tizen_policy_set_notification_level( + tizen_policy_, ecore_wl2_window_surface_get(ecore_wl2_window_), level); +} + +} // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h new file mode 100644 index 0000000000000..93b5e57a73630 --- /dev/null +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h @@ -0,0 +1,72 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ +#define EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ + +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" + +#define EFL_BETA_API_SUPPORT +#include +#include + +namespace flutter { + +class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { + public: + FlutterTizenWindowEcoreWl2(Geometry geometry, + bool transparent, + bool focusable, + bool top_level); + + ~FlutterTizenWindowEcoreWl2(); + + Geometry GetWindowGeometry() override; + + Geometry GetScreenGeometry() override; + + void* GetRenderTarget() override { return ecore_wl2_egl_window_; } + + void* GetRenderTargetDisplay() override { return wl2_display_; } + + int32_t GetDpi() override; + + uintptr_t GetWindowId() override; + + void* GetWindowHandle() override { return ecore_wl2_window_; } + + void ResizeWithRotation(Geometry geometry, int32_t angle) override; + + void SetPreferredOrientations(const std::vector& rotations) override; + + void BindKeys(const std::vector& keys) override; + + void Show() override; + + private: + bool CreateWindow(); + + void SetWindowOptions(); + + void RegisterEventHandlers(); + + void DestroyEcoreWl2(); + + void SetTizenPolicyNotificationLevel(int level); + + static Eina_Bool OnRotate(void* data, int type, void* event); + + Ecore_Wl2_Display* ecore_wl2_display_ = nullptr; + Ecore_Wl2_Window* ecore_wl2_window_ = nullptr; + + Ecore_Wl2_Egl_Window* ecore_wl2_egl_window_ = nullptr; + wl_display* wl2_display_ = nullptr; + std::vector ecore_event_handlers_; + + tizen_policy* tizen_policy_ = nullptr; +}; + +} // namespace flutter +#endif diff --git a/shell/platform/tizen/key_event_handler.cc b/shell/platform/tizen/key_event_handler.cc index 86de311969341..a86a0da20dce6 100644 --- a/shell/platform/tizen/key_event_handler.cc +++ b/shell/platform/tizen/key_event_handler.cc @@ -38,7 +38,9 @@ KeyEventHandler::KeyEventHandler(FlutterTizenEngine* engine) : engine_(engine) { if (!engine->renderer() || !engine->renderer()->IsValid()) { return; } - engine->renderer()->BindKeys(kBindableSystemKeys); + + // TODO + // engine->renderer()->BindKeys(kBindableSystemKeys); key_event_handlers_.push_back( ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, OnKey, this)); @@ -59,9 +61,10 @@ Eina_Bool KeyEventHandler::OnKey(void* data, int type, void* raw_event) { FlutterTizenEngine* engine = self->engine_; bool is_down = type == ECORE_EVENT_KEY_DOWN; - if (engine->renderer()->GetWindowId() != event->window) { - return ECORE_CALLBACK_PASS_ON; - } + // TODO + // if (engine->renderer()->GetWindowId() != event->window) { + // return ECORE_CALLBACK_PASS_ON; + // } if (is_down) { FT_LOG(Info) << "Key symbol: " << event->key << ", code: 0x" << std::setw(8) diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 72ffde7895932..7989d9e24ead7 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -21,6 +21,10 @@ extern "C" { struct FlutterDesktopEngine; typedef struct FlutterDesktopEngine* FlutterDesktopEngineRef; +// Opaque reference to a Flutter view instance. +struct FlutterDesktopView; +typedef struct FlutterDesktopView* FlutterDesktopViewRef; + // Properties for configuring the initial settings of a Flutter window. typedef struct { // Whether the app is headed or headless. Other properties are ignored if @@ -69,13 +73,27 @@ typedef struct { // ========== Engine ========== -// Runs an instance of a Flutter engine with the given properties. +// Creates a Flutter engine with the given properties. // -// If |headed| is false, the engine is run in headless mode. -FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineRun( - const FlutterDesktopWindowProperties& window_properties, +// The caller owns the returned reference, and is responsible for calling +// FlutterDesktopEngineDestroy. The lifetime of |engine_properties| is required +// to extend only until the end of this call. +FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineCreate( const FlutterDesktopEngineProperties& engine_properties); +// Starts running the given engine instance and optional entry point in the Dart +// project. If the entry point is null, defaults to main(). +// +// If provided, entry_point must be the name of a top-level function from the +// same Dart library that contains the app's main() function, and must be +// decorated with `@pragma(vm:entry-point)` to ensure the method is not +// tree-shaken by the Dart compiler. +// +// Returns false if running the engine failed. +FLUTTER_EXPORT bool FlutterDesktopEngineRun( + const FlutterDesktopEngineRef engine, + const char* entry_point); + // Shuts down the given engine instance. // // |engine| is no longer valid after this call. @@ -124,6 +142,13 @@ FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsPaused( FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsDetached( FlutterDesktopEngineRef engine); +// ========== View ========== + +// Creates a view that hosts and displays the given engine instance. +FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( + const FlutterDesktopWindowProperties& window_properties, + FlutterDesktopEngineRef engine); + // ========== Plugin Registrar (extensions) ========== // Returns the window associated with this registrar's engine instance. diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 98c8a9be45826..9083dfa885965 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -124,9 +124,13 @@ TizenInputMethodContext::TizenInputMethodContext(FlutterTizenEngine* engine) return; } - ecore_imf_context_client_window_set( - imf_context_, - reinterpret_cast(engine_->renderer()->GetWindowId())); + // TODO + // ecore_imf_context_client_window_set( + // imf_context_, + // reinterpret_cast(engine_->renderer()->GetWindowId())); + if (engine_) { + // + } SetContextOptions(); SetInputPanelOptions(); RegisterEventCallbacks(); diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index 314f75f05adac..f37732b22d22f 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -6,16 +6,7 @@ namespace flutter { -TizenRenderer::TizenRenderer(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate) - : initial_geometry_(geometry), - transparent_(transparent), - focusable_(focusable), - top_level_(top_level), - delegate_(delegate) {} +TizenRenderer::TizenRenderer() {} TizenRenderer::~TizenRenderer() = default; diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 8dc9abbc205f1..4b335ce883461 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -12,71 +12,33 @@ namespace flutter { class TizenRenderer { public: - struct Geometry { - int32_t x{0}, y{0}, w{0}, h{0}; - }; - - class Delegate { - public: - virtual void OnOrientationChange(int32_t degree) = 0; - virtual void OnGeometryChange(int32_t x, - int32_t y, - int32_t width, - int32_t height) = 0; - }; + TizenRenderer(); virtual ~TizenRenderer(); + virtual bool CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) = 0; + bool IsValid() { return is_valid_; } virtual bool OnMakeCurrent() = 0; + virtual bool OnClearCurrent() = 0; - virtual bool OnMakeResourceCurrent() = 0; - virtual bool OnPresent() = 0; - virtual uint32_t OnGetFBO() = 0; - virtual void* OnProcResolver(const char* name) = 0; - // Returns the geometry of the current window. - virtual Geometry GetWindowGeometry() = 0; + virtual bool OnMakeResourceCurrent() = 0; - // Returns the geometry of the display screen. - virtual Geometry GetScreenGeometry() = 0; + virtual bool OnPresent() = 0; - virtual int32_t GetDpi() = 0; - virtual uintptr_t GetWindowId() = 0; - virtual void* GetWindowHandle() = 0; + virtual uint32_t OnGetFBO() = 0; - virtual void SetRotate(int angle) = 0; - virtual void SetGeometry(int32_t x, - int32_t y, - int32_t width, - int32_t height) = 0; - virtual void ResizeWithRotation(int32_t x, - int32_t y, - int32_t width, - int32_t height, - int32_t degree) = 0; - virtual void SetPreferredOrientations(const std::vector& rotations) = 0; + virtual void* OnProcResolver(const char* name) = 0; virtual bool IsSupportedExtension(const char* name) = 0; - virtual void BindKeys(const std::vector& keys) = 0; - protected: - explicit TizenRenderer(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate); - - Geometry initial_geometry_; - bool transparent_; - bool focusable_; - bool top_level_; - Delegate& delegate_; - bool is_valid_ = false; - bool received_rotation_ = false; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index f20334052c76d..40abbc229345e 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -11,28 +11,12 @@ namespace flutter { -TizenRendererEcoreWl2::TizenRendererEcoreWl2(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate) - : TizenRenderer(geometry, transparent, focusable, top_level, delegate) { - if (!SetupEcoreWl2()) { - FT_LOG(Error) << "Could not set up Ecore Wl2."; - return; - } - if (!SetupEGL()) { - FT_LOG(Error) << "Could not set up EGL."; - return; - } - Show(); - - is_valid_ = true; +TizenRendererEcoreWl2::TizenRendererEcoreWl2() { + FT_LOG(Error) << "enter"; } TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { DestroyEGL(); - DestroyEcoreWl2(); } bool TizenRendererEcoreWl2::OnMakeCurrent() { @@ -79,11 +63,6 @@ bool TizenRendererEcoreWl2::OnPresent() { return false; } - if (received_rotation_) { - SendRotationChangeDone(); - received_rotation_ = false; - } - if (eglSwapBuffers(egl_display_, egl_surface_) != EGL_TRUE) { PrintEGLError(); FT_LOG(Error) << "Could not swap EGL buffers."; @@ -221,113 +200,16 @@ void* TizenRendererEcoreWl2::OnProcResolver(const char* name) { return nullptr; } -TizenRenderer::Geometry TizenRendererEcoreWl2::GetWindowGeometry() { - Geometry result; - ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.x, &result.y, - &result.w, &result.h); - return result; -} - -TizenRenderer::Geometry TizenRendererEcoreWl2::GetScreenGeometry() { - Geometry result = {}; - ecore_wl2_display_screen_size_get(ecore_wl2_display_, &result.w, &result.h); - return result; -} - -int32_t TizenRendererEcoreWl2::GetDpi() { - Ecore_Wl2_Output* output = ecore_wl2_window_output_find(ecore_wl2_window_); - if (!output) { - FT_LOG(Error) << "Could not find an output associated with the window."; - return 0; - } - return ecore_wl2_output_dpi_get(output); -} - -uintptr_t TizenRendererEcoreWl2::GetWindowId() { - return ecore_wl2_window_id_get(ecore_wl2_window_); -} - -void TizenRendererEcoreWl2::Show() { - ecore_wl2_window_show(ecore_wl2_window_); -} - -bool TizenRendererEcoreWl2::SetupEcoreWl2() { - if (!ecore_wl2_init()) { - FT_LOG(Error) << "Could not initialize Ecore Wl2."; - return false; - } - - ecore_wl2_display_ = ecore_wl2_display_connect(nullptr); - if (!ecore_wl2_display_) { - FT_LOG(Error) << "Ecore Wl2 display not found."; - return false; - } - ecore_wl2_sync(); - - int32_t width, height; - ecore_wl2_display_screen_size_get(ecore_wl2_display_, &width, &height); - if (width == 0 || height == 0) { - FT_LOG(Error) << "Invalid screen size: " << width << " x " << height; - return false; - } - - if (initial_geometry_.w == 0) { - initial_geometry_.w = width; - } - if (initial_geometry_.h == 0) { - initial_geometry_.h = height; - } - - ecore_wl2_window_ = ecore_wl2_window_new( - ecore_wl2_display_, nullptr, initial_geometry_.x, initial_geometry_.y, - initial_geometry_.w, initial_geometry_.h); - - // Change the window type to use the tizen policy for notification window - // according to top_level_. - // Note: ECORE_WL2_WINDOW_TYPE_TOPLEVEL is similar to "ELM_WIN_BASIC" and it - // does not mean that the window always will be overlaid on other apps :( - ecore_wl2_window_type_set(ecore_wl2_window_, - top_level_ ? ECORE_WL2_WINDOW_TYPE_NOTIFICATION - : ECORE_WL2_WINDOW_TYPE_TOPLEVEL); - if (top_level_) { - SetTizenPolicyNotificationLevel(TIZEN_POLICY_LEVEL_TOP); - } - - ecore_wl2_window_position_set(ecore_wl2_window_, initial_geometry_.x, - initial_geometry_.y); - ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0, - "wm.policy.win.user.geometry", "1"); - - if (transparent_) { - ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_TRUE); - } else { - ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE); - } - - if (!focusable_) { - ecore_wl2_window_focus_skip_set(ecore_wl2_window_, EINA_TRUE); - } - - ecore_wl2_window_indicator_state_set(ecore_wl2_window_, - ECORE_WL2_INDICATOR_STATE_ON); - ecore_wl2_window_indicator_opacity_set(ecore_wl2_window_, - ECORE_WL2_INDICATOR_OPAQUE); - ecore_wl2_indicator_visible_type_set(ecore_wl2_window_, - ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN); - - int rotations[4] = {0, 90, 180, 270}; - ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations, - sizeof(rotations) / sizeof(int)); - ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, RotationEventCb, this); - - return true; -} +bool TizenRendererEcoreWl2::CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) { + FT_LOG(Error) << "enter"; + egl_display_ = eglGetDisplay(static_cast(render_target_display)); -bool TizenRendererEcoreWl2::SetupEGL() { - ecore_wl2_egl_window_ = ecore_wl2_egl_window_create( - ecore_wl2_window_, initial_geometry_.w, initial_geometry_.h); - if (!ecore_wl2_egl_window_) { - FT_LOG(Error) << "Could not create an EGL window."; + if (EGL_NO_DISPLAY == egl_display_) { + PrintEGLError(); + FT_LOG(Error) << "Could not get EGL display."; return false; } @@ -361,8 +243,9 @@ bool TizenRendererEcoreWl2::SetupEGL() { { const EGLint attribs[] = {EGL_NONE}; - auto* egl_window = static_cast( - ecore_wl2_egl_window_native_get(ecore_wl2_egl_window_)); + auto* egl_window = + static_cast(ecore_wl2_egl_window_native_get( + static_cast(render_target))); egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, egl_window, attribs); if (egl_surface_ == EGL_NO_SURFACE) { @@ -381,7 +264,8 @@ bool TizenRendererEcoreWl2::SetupEGL() { return false; } } - + is_valid_ = true; + FT_LOG(Error) << "done"; return true; } @@ -400,13 +284,6 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { // clang-format on }; - egl_display_ = eglGetDisplay(ecore_wl2_display_get(ecore_wl2_display_)); - if (EGL_NO_DISPLAY == egl_display_) { - PrintEGLError(); - FT_LOG(Error) << "Could not get EGL display."; - return false; - } - if (!eglInitialize(egl_display_, nullptr, nullptr)) { PrintEGLError(); FT_LOG(Error) << "Could not initialize the EGL display."; @@ -483,19 +360,6 @@ void TizenRendererEcoreWl2::PrintEGLError() { } } -void TizenRendererEcoreWl2::DestroyEcoreWl2() { - if (ecore_wl2_window_) { - ecore_wl2_window_free(ecore_wl2_window_); - ecore_wl2_window_ = nullptr; - } - - if (ecore_wl2_display_) { - ecore_wl2_display_disconnect(ecore_wl2_display_); - ecore_wl2_display_ = nullptr; - } - ecore_wl2_shutdown(); -} - void TizenRendererEcoreWl2::DestroyEGL() { if (egl_display_) { eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, @@ -524,98 +388,10 @@ void TizenRendererEcoreWl2::DestroyEGL() { eglTerminate(egl_display_); egl_display_ = EGL_NO_DISPLAY; } - - if (ecore_wl2_egl_window_) { - ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); - ecore_wl2_egl_window_ = nullptr; - } -} - -Eina_Bool TizenRendererEcoreWl2::RotationEventCb(void* data, - int type, - void* event) { - auto* self = reinterpret_cast(data); - auto* rotation_event = - reinterpret_cast(event); - self->delegate_.OnOrientationChange(rotation_event->angle); - return ECORE_CALLBACK_PASS_ON; -} - -void TizenRendererEcoreWl2::SetRotate(int angle) { - ecore_wl2_window_rotation_set(ecore_wl2_window_, angle); - received_rotation_ = true; -} - -void TizenRendererEcoreWl2::SetGeometry(int32_t x, - int32_t y, - int32_t width, - int32_t height) { - ecore_wl2_window_geometry_set(ecore_wl2_window_, x, y, width, height); - ecore_wl2_window_position_set(ecore_wl2_window_, x, y); -} - -void TizenRendererEcoreWl2::ResizeWithRotation(int32_t x, - int32_t y, - int32_t width, - int32_t height, - int32_t angle) { - ecore_wl2_egl_window_resize_with_rotation(ecore_wl2_egl_window_, x, y, width, - height, angle); -} - -void TizenRendererEcoreWl2::SendRotationChangeDone() { - int x, y, w, h; - ecore_wl2_window_geometry_get(ecore_wl2_window_, &x, &y, &w, &h); - ecore_wl2_window_rotation_change_done_send( - ecore_wl2_window_, ecore_wl2_window_rotation_get(ecore_wl2_window_), w, - h); -} - -void TizenRendererEcoreWl2::SetPreferredOrientations( - const std::vector& rotations) { - ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations.data(), - rotations.size()); } bool TizenRendererEcoreWl2::IsSupportedExtension(const char* name) { return strstr(egl_extension_str_.c_str(), name); } -void TizenRendererEcoreWl2::SetTizenPolicyNotificationLevel(int level) { - Eina_Iterator* iter = ecore_wl2_display_globals_get(ecore_wl2_display_); - struct wl_registry* registry = - ecore_wl2_display_registry_get(ecore_wl2_display_); - - if (iter && registry) { - Ecore_Wl2_Global* global = nullptr; - - // Retrieve global objects to bind tizen policy - EINA_ITERATOR_FOREACH(iter, global) { - if (strcmp(global->interface, tizen_policy_interface.name) == 0) { - tizen_policy_ = static_cast( - wl_registry_bind(registry, global->id, &tizen_policy_interface, 1)); - break; - } - } - } - eina_iterator_free(iter); - - if (tizen_policy_ == nullptr) { - FT_LOG(Error) - << "Failed to initialize the tizen policy handle, the top_level " - "attribute is ignored."; - return; - } - - tizen_policy_set_notification_level( - tizen_policy_, ecore_wl2_window_surface_get(ecore_wl2_window_), level); -} - -void TizenRendererEcoreWl2::BindKeys(const std::vector& keys) { - for (const std::string& key : keys) { - ecore_wl2_window_keygrab_set(ecore_wl2_window_, key.c_str(), 0, 0, 0, - ECORE_WL2_WINDOW_KEYGRAB_TOPMOST); - } -} - } // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index 468249802e57d..653f6ff1fdb98 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -18,64 +18,36 @@ namespace flutter { class TizenRendererEcoreWl2 : public TizenRenderer { public: - explicit TizenRendererEcoreWl2(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate); + explicit TizenRendererEcoreWl2(); + virtual ~TizenRendererEcoreWl2(); + bool CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) override; + bool OnMakeCurrent() override; + bool OnClearCurrent() override; + bool OnMakeResourceCurrent() override; + bool OnPresent() override; + uint32_t OnGetFBO() override; - void* OnProcResolver(const char* name) override; - Geometry GetWindowGeometry() override; - Geometry GetScreenGeometry() override; - int32_t GetDpi() override; - uintptr_t GetWindowId() override; - - void* GetWindowHandle() override { return ecore_wl2_window_; } - - void SetRotate(int angle) override; - void SetGeometry(int32_t x, - int32_t y, - int32_t width, - int32_t height) override; - void ResizeWithRotation(int32_t x, - int32_t y, - int32_t width, - int32_t height, - int32_t angle) override; - void SetPreferredOrientations(const std::vector& rotations) override; + void* OnProcResolver(const char* name) override; bool IsSupportedExtension(const char* name) override; - void BindKeys(const std::vector& keys) override; - private: - void Show(); - - bool SetupEcoreWl2(); - bool SetupEGL(); - bool ChooseEGLConfiguration(); + void PrintEGLError(); - void DestroyEcoreWl2(); void DestroyEGL(); - static Eina_Bool RotationEventCb(void* data, int type, void* event); - void SendRotationChangeDone(); - - void SetTizenPolicyNotificationLevel(int level); - - Ecore_Wl2_Display* ecore_wl2_display_ = nullptr; - Ecore_Wl2_Window* ecore_wl2_window_ = nullptr; - Ecore_Wl2_Egl_Window* ecore_wl2_egl_window_ = nullptr; - EGLConfig egl_config_ = nullptr; EGLDisplay egl_display_ = EGL_NO_DISPLAY; EGLContext egl_context_ = EGL_NO_CONTEXT; @@ -84,8 +56,6 @@ class TizenRendererEcoreWl2 : public TizenRenderer { EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; std::string egl_extension_str_; - - tizen_policy* tizen_policy_ = nullptr; }; } // namespace flutter diff --git a/shell/platform/tizen/touch_event_handler.cc b/shell/platform/tizen/touch_event_handler.cc index 12e29d5f843fb..1cecb90e9e7ff 100644 --- a/shell/platform/tizen/touch_event_handler.cc +++ b/shell/platform/tizen/touch_event_handler.cc @@ -41,19 +41,20 @@ void TouchEventHandler::SendFlutterPointerEvent(FlutterPointerPhase phase, size_t timestamp, int device_id = 0) { // Correct errors caused by window rotation. - TizenRenderer::Geometry geometry = engine_->renderer()->GetWindowGeometry(); + // TODO + // auto geometry = engine_->renderer()->GetWindowGeometry(); double new_x = x, new_y = y; - if (rotation == 90) { - new_x = geometry.h - y; - new_y = x; - } else if (rotation == 180) { - new_x = geometry.w - x; - new_y = geometry.h - y; - } else if (rotation == 270) { - new_x = y; - new_y = geometry.w - x; - } + // if (rotation == 90) { + // new_x = geometry.h - y; + // new_y = x; + // } else if (rotation == 180) { + // new_x = geometry.w - x; + // new_y = geometry.h - y; + // } else if (rotation == 270) { + // new_x = y; + // new_y = geometry.w - x; + // } FlutterPointerEvent event = {}; event.struct_size = sizeof(event); @@ -74,54 +75,59 @@ void TouchEventHandler::SendFlutterPointerEvent(FlutterPointerPhase phase, Eina_Bool TouchEventHandler::OnTouch(void* data, int type, void* event) { auto* self = reinterpret_cast(data); +<<<<<<< HEAD uintptr_t window_id = self->engine_->renderer()->GetWindowId(); +======= + // TODO + // auto window_id = self->engine_->renderer()->GetWindowId(); +>>>>>>> Implement FlutterTizenView, FlutterTizenWindow if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { auto* button_event = reinterpret_cast(event); - if (window_id == button_event->window) { - self->pointer_state_ = true; - self->SendFlutterPointerEvent(kDown, button_event->x, button_event->y, 0, - 0, button_event->timestamp, - button_event->multi.device); - return ECORE_CALLBACK_DONE; - } + // if (window_id == button_event->window) { + self->pointer_state_ = true; + self->SendFlutterPointerEvent(kDown, button_event->x, button_event->y, 0, 0, + button_event->timestamp, + button_event->multi.device); + return ECORE_CALLBACK_DONE; + // } } else if (type == ECORE_EVENT_MOUSE_BUTTON_UP) { auto* button_event = reinterpret_cast(event); - if (window_id == button_event->window) { - self->pointer_state_ = false; - self->SendFlutterPointerEvent(kUp, button_event->x, button_event->y, 0, 0, - button_event->timestamp, - button_event->multi.device); - return ECORE_CALLBACK_DONE; - } + // if (window_id == button_event->window) { + self->pointer_state_ = false; + self->SendFlutterPointerEvent(kUp, button_event->x, button_event->y, 0, 0, + button_event->timestamp, + button_event->multi.device); + return ECORE_CALLBACK_DONE; + // } } else if (type == ECORE_EVENT_MOUSE_MOVE) { auto* move_event = reinterpret_cast(event); - if (window_id == move_event->window) { - if (self->pointer_state_) { - self->SendFlutterPointerEvent(kMove, move_event->x, move_event->y, 0, 0, - move_event->timestamp, - move_event->multi.device); - return ECORE_CALLBACK_DONE; - } + // if (window_id == move_event->window) { + if (self->pointer_state_) { + self->SendFlutterPointerEvent(kMove, move_event->x, move_event->y, 0, 0, + move_event->timestamp, + move_event->multi.device); + return ECORE_CALLBACK_DONE; } + // } } else if (type == ECORE_EVENT_MOUSE_WHEEL) { auto* wheel_event = reinterpret_cast(event); - if (window_id == wheel_event->window) { - double scroll_delta_x = 0.0, scroll_delta_y = 0.0; - if (wheel_event->direction == kScrollDirectionVertical) { - scroll_delta_y += wheel_event->z; - } else if (wheel_event->direction == kScrollDirectionHorizontal) { - scroll_delta_x += wheel_event->z; - } - const int kScrollOffsetMultiplier = 20; - scroll_delta_x *= kScrollOffsetMultiplier; - scroll_delta_y *= kScrollOffsetMultiplier; - self->SendFlutterPointerEvent( - self->pointer_state_ ? kMove : kHover, wheel_event->x, wheel_event->y, - scroll_delta_x, scroll_delta_y, wheel_event->timestamp); - return ECORE_CALLBACK_DONE; + // if (window_id == wheel_event->window) { + double scroll_delta_x = 0.0, scroll_delta_y = 0.0; + if (wheel_event->direction == kScrollDirectionVertical) { + scroll_delta_y += wheel_event->z; + } else if (wheel_event->direction == kScrollDirectionHorizontal) { + scroll_delta_x += wheel_event->z; } + const int kScrollOffsetMultiplier = 20; + scroll_delta_x *= kScrollOffsetMultiplier; + scroll_delta_y *= kScrollOffsetMultiplier; + self->SendFlutterPointerEvent( + self->pointer_state_ ? kMove : kHover, wheel_event->x, wheel_event->y, + scroll_delta_x, scroll_delta_y, wheel_event->timestamp); + return ECORE_CALLBACK_DONE; + // } } return ECORE_CALLBACK_PASS_ON; } From 638665d4ec85263ad6f1032f1d8649e0011cb70e Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 19 Apr 2022 16:52:06 +0900 Subject: [PATCH 05/32] Refactor touch event * Touch event handling is now dependent on FlutterTizenWindow and FlutterTizenView. Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 1 - shell/platform/tizen/flutter_tizen_engine.cc | 3 - shell/platform/tizen/flutter_tizen_engine.h | 4 - shell/platform/tizen/flutter_tizen_view.cc | 96 ++++++++++++- shell/platform/tizen/flutter_tizen_view.h | 47 +++++- .../tizen/flutter_tizen_window_ecore_wl2.cc | 115 +++++++++++++-- shell/platform/tizen/touch_event_handler.cc | 135 ------------------ shell/platform/tizen/touch_event_handler.h | 43 ------ 8 files changed, 236 insertions(+), 208 deletions(-) delete mode 100644 shell/platform/tizen/touch_event_handler.cc delete mode 100644 shell/platform/tizen/touch_event_handler.h diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 2aa1570536c50..fb4e7f009f668 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -130,7 +130,6 @@ template("embedder") { "tizen_event_loop.cc", "tizen_input_method_context.cc", "tizen_renderer.cc", - "touch_event_handler.cc", ] if (target_name != "flutter_tizen_wearable") { diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index f42a7d705a5e8..8447329ce8348 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -256,9 +256,6 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { internal_plugin_registrar_->messenger() /*, renderer_.get(), this*/); key_event_handler_ = std::make_unique(this); - touch_event_handler_ = std::make_unique(this); - - // SetWindowOrientation(0); } accessibility_settings_ = std::make_unique(this); diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index da6fda9109e16..4aeb4b8231554 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -37,7 +37,6 @@ #include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h" #include "flutter/shell/platform/tizen/tizen_vsync_waiter.h" #endif -#include "flutter/shell/platform/tizen/touch_event_handler.h" // State associated with the plugin registrar. struct FlutterDesktopPluginRegistrar { @@ -231,9 +230,6 @@ class FlutterTizenEngine { // An event dispatcher for Ecore key events. std::unique_ptr key_event_handler_; - // An event dispatcher for Ecore mouse events. - std::unique_ptr touch_event_handler_; - // The plugin messenger handle given to API clients. std::unique_ptr messenger_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 7cf2025d2e626..b59d2a4f9b57f 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -43,6 +43,7 @@ void FlutterTizenView::SetFlutterTizenEngine( // keyboard? // platform handler? // corsor handler? + // touch_event_handler_ = std::make_unique(this); FT_LOG(Info) << "done"; } @@ -80,19 +81,20 @@ void* FlutterTizenView::OnProcResolver(const char* name) { } void FlutterTizenView::OnRotate(int32_t degree) { + rotation_degree_ = degree; // Compute renderer transformation based on the angle of rotation. - double rad = (360 - degree) * M_PI / 180; + double rad = (360 - rotation_degree_) * M_PI / 180; auto geometry = flutter_tizen_window_->GetWindowGeometry(); int32_t width = geometry.width; int32_t height = geometry.height; double trans_x = 0.0, trans_y = 0.0; - if (degree == 90) { + if (rotation_degree_ == 90) { trans_y = height; - } else if (degree == 180) { + } else if (rotation_degree_ == 180) { trans_x = width; trans_y = height; - } else if (degree == 270) { + } else if (rotation_degree_ == 270) { trans_x = width; } @@ -105,17 +107,59 @@ void FlutterTizenView::OnRotate(int32_t degree) { // touch_event_handler_->rotation = degree; - if (degree == 90 || degree == 270) { + if (rotation_degree_ == 90 || rotation_degree_ == 270) { std::swap(width, height); } flutter_tizen_window_->ResizeWithRotation( - {geometry.left, geometry.top, width, height}, degree); + {geometry.left, geometry.top, width, height}, rotation_degree_); // Window position does not change on rotation regardless of its orientation. SendWindowMetrics(geometry.left, geometry.top, width, height, 0.0); } +void FlutterTizenView::OnPointerMove(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id) { + if (pointer_state_) { + SendFlutterPointerEvent(kMove, x, y, 0, 0, timestamp, device_kind, + device_id); + } +} + +void FlutterTizenView::OnPointerDown(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id) { + pointer_state_ = true; + SendFlutterPointerEvent(kDown, x, y, 0, 0, timestamp, device_kind, device_id); +} + +void FlutterTizenView::OnPointerUp(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id) { + pointer_state_ = false; + SendFlutterPointerEvent(kUp, x, y, 0, 0, timestamp, device_kind, device_id); +} + +void FlutterTizenView::OnScroll(double x, + double y, + double delta_x, + double delta_y, + int scroll_offset_multiplier, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id) { + SendFlutterPointerEvent( + pointer_state_ ? kMove : kHover, x, y, delta_x * scroll_offset_multiplier, + delta_y * scroll_offset_multiplier, timestamp, device_kind, device_id); +} + void FlutterTizenView::SendWindowMetrics(int32_t left, int32_t top, int32_t width, @@ -141,4 +185,44 @@ void FlutterTizenView::SendWindowMetrics(int32_t left, computed_pixel_ratio); } +void FlutterTizenView::SendFlutterPointerEvent( + FlutterPointerPhase phase, + double x, + double y, + double delta_x, + double delta_y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int device_id) { + auto geometry = flutter_tizen_window_->GetWindowGeometry(); + double new_x = x, new_y = y; + + if (rotation_degree_ == 90) { + new_x = geometry.height - y; + new_y = x; + } else if (rotation_degree_ == 180) { + new_x = geometry.width - x; + new_y = geometry.height - y; + } else if (rotation_degree_ == 270) { + new_x = y; + new_y = geometry.width - x; + } + + FlutterPointerEvent event = {}; + event.struct_size = sizeof(event); + event.phase = phase; + event.x = new_x; + event.y = new_y; + if (delta_x != 0 || delta_y != 0) { + event.signal_kind = kFlutterPointerSignalKindScroll; + } + event.scroll_delta_x = delta_x; + event.scroll_delta_y = delta_y; + event.timestamp = timestamp * 1000; + event.device = device_id; + event.device_kind = kFlutterPointerDeviceKindTouch; + + flutter_tizen_engine_->SendPointerEvent(event); +} + } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 8f432e00e415e..d5c053ee629f3 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -51,8 +51,36 @@ class FlutterTizenView { void* OnProcResolver(const char* name); + // ========== Window Event Delegate ========== void OnRotate(int32_t degree); + void OnPointerMove(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id); + + void OnPointerDown(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id); + + void OnPointerUp(double x, + double y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id); + + void OnScroll(double x, + double y, + double delta_x, + double delta_y, + int scroll_offset_multiplier, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int32_t device_id); + FlutterTransformation GetFlutterTransformation() { return flutter_trans_formation_; } @@ -66,15 +94,30 @@ class FlutterTizenView { int32_t height, double pixel_ratio); + // Reports pointer event to Flutter engine + void SendFlutterPointerEvent(FlutterPointerPhase phase, + double x, + double y, + double delta_x, + double delta_y, + size_t timestamp, + FlutterPointerDeviceKind device_kind, + int device_id); + // The engine associated with this view. std::unique_ptr flutter_tizen_engine_; // TODO - public: std::unique_ptr flutter_tizen_window_; private: - // The current renderer transformation. + // The current view rotation degree. + int32_t rotation_degree_ = 0; + + // The current pointer state to distinguish move or hover event. + bool pointer_state_ = false; + + // The current view transformation. FlutterTransformation flutter_trans_formation_ = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; }; diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc index 26a17d6fa94c4..aabe65789941c 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -8,6 +8,14 @@ #include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" +namespace { + +static const int kScrollDirectionVertical = 0; +static const int kScrollDirectionHorizontal = 1; +static const int kScrollOffsetMultiplier = 20; + +} // namespace + namespace flutter { FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, @@ -15,7 +23,6 @@ FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, bool focusable, bool top_level) : FlutterTizenWindow(geometry, transparent, focusable, top_level) { - FT_LOG(Error) << "enter"; if (!CreateWindow()) { FT_LOG(Error) << "Failed to create platform window"; return; @@ -24,11 +31,9 @@ FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, SetWindowOptions(); RegisterEventHandlers(); Show(); - FT_LOG(Error) << "done"; } FlutterTizenWindowEcoreWl2::~FlutterTizenWindowEcoreWl2() { - FT_LOG(Info) << "enter"; DestroyEcoreWl2(); } @@ -62,10 +67,6 @@ bool FlutterTizenWindowEcoreWl2::CreateWindow() { initial_geometry_.height = height; } - FT_LOG(Error) << "left" << initial_geometry_.left; - FT_LOG(Error) << "top" << initial_geometry_.top; - FT_LOG(Error) << "width " << initial_geometry_.width; - FT_LOG(Error) << "height " << initial_geometry_.height; ecore_wl2_window_ = ecore_wl2_window_new( ecore_wl2_display_, nullptr, initial_geometry_.left, initial_geometry_.top, initial_geometry_.width, initial_geometry_.height); @@ -116,9 +117,99 @@ void FlutterTizenWindowEcoreWl2::SetWindowOptions() { } void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { - ecore_event_handlers_.push_back( - ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, - FlutterTizenWindowEcoreWl2::OnRotate, this)); + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_WL2_EVENT_WINDOW_ROTATE, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* rotation_event = + reinterpret_cast(event); + int32_t degree = rotation_event->angle; + self->flutter_tizen_view_->OnRotate(degree); + auto geometry = self->GetWindowGeometry(); + ecore_wl2_window_rotation_change_done_send( + self->ecore_wl2_window_, rotation_event->rotation, geometry.width, + geometry.height); + } + return ECORE_CALLBACK_PASS_ON; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_MOUSE_BUTTON_DOWN, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* button_event = + reinterpret_cast(event); + if (button_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnPointerDown( + button_event->x, button_event->y, button_event->timestamp, + kFlutterPointerDeviceKindTouch, button_event->multi.device); + } + } + return ECORE_CALLBACK_DONE; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_MOUSE_BUTTON_UP, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* button_event = + reinterpret_cast(event); + if (button_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnPointerUp( + button_event->x, button_event->y, button_event->timestamp, + kFlutterPointerDeviceKindTouch, button_event->multi.device); + } + } + return ECORE_CALLBACK_DONE; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_MOUSE_MOVE, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* move_event = reinterpret_cast(event); + if (move_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnPointerMove( + move_event->x, move_event->y, move_event->timestamp, + kFlutterPointerDeviceKindTouch, move_event->multi.device); + } + } + return ECORE_CALLBACK_DONE; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_MOUSE_WHEEL, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* wheel_event = reinterpret_cast(event); + if (wheel_event->window == self->GetWindowId()) { + double delta_x = 0.0; + double delta_y = 0.0; + + if (wheel_event->direction == kScrollDirectionVertical) { + delta_y += wheel_event->z; + } else if (wheel_event->direction == kScrollDirectionHorizontal) { + delta_x += wheel_event->z; + } + + self->flutter_tizen_view_->OnScroll( + wheel_event->x, wheel_event->y, delta_x, delta_y, + kScrollOffsetMultiplier, wheel_event->timestamp, + kFlutterPointerDeviceKindTouch, 0); + } + } + return ECORE_CALLBACK_DONE; + }, + this)); } void FlutterTizenWindowEcoreWl2::DestroyEcoreWl2() { @@ -143,10 +234,6 @@ FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetWindowGeometry() { Geometry result; ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.left, &result.top, &result.width, &result.height); - FT_LOG(Error) << "left" << result.left; - FT_LOG(Error) << "top" << result.top; - FT_LOG(Error) << "width " << result.width; - FT_LOG(Error) << "height" << result.height; return result; } diff --git a/shell/platform/tizen/touch_event_handler.cc b/shell/platform/tizen/touch_event_handler.cc deleted file mode 100644 index 1cecb90e9e7ff..0000000000000 --- a/shell/platform/tizen/touch_event_handler.cc +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "touch_event_handler.h" - -#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" - -static const int kScrollDirectionVertical = 0; -static const int kScrollDirectionHorizontal = 1; - -namespace flutter { - -TouchEventHandler::TouchEventHandler(FlutterTizenEngine* engine) - : engine_(engine) { - if (!engine->renderer() || !engine->renderer()->IsValid()) { - return; - } - touch_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, OnTouch, this)); - touch_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, OnTouch, this)); - touch_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, OnTouch, this)); - touch_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, OnTouch, this)); -} - -TouchEventHandler::~TouchEventHandler() { - for (Ecore_Event_Handler* handler : touch_event_handlers_) { - ecore_event_handler_del(handler); - } - touch_event_handlers_.clear(); -} - -void TouchEventHandler::SendFlutterPointerEvent(FlutterPointerPhase phase, - double x, - double y, - double scroll_delta_x, - double scroll_delta_y, - size_t timestamp, - int device_id = 0) { - // Correct errors caused by window rotation. - // TODO - // auto geometry = engine_->renderer()->GetWindowGeometry(); - double new_x = x, new_y = y; - - // if (rotation == 90) { - // new_x = geometry.h - y; - // new_y = x; - // } else if (rotation == 180) { - // new_x = geometry.w - x; - // new_y = geometry.h - y; - // } else if (rotation == 270) { - // new_x = y; - // new_y = geometry.w - x; - // } - - FlutterPointerEvent event = {}; - event.struct_size = sizeof(event); - event.phase = phase; - event.x = new_x; - event.y = new_y; - if (scroll_delta_x != 0 || scroll_delta_y != 0) { - event.signal_kind = kFlutterPointerSignalKindScroll; - } - event.scroll_delta_x = scroll_delta_x * 2; - event.scroll_delta_y = scroll_delta_y * 2; - event.timestamp = timestamp * 1000; - event.device = device_id; - event.device_kind = kFlutterPointerDeviceKindTouch; - - engine_->SendPointerEvent(event); -} - -Eina_Bool TouchEventHandler::OnTouch(void* data, int type, void* event) { - auto* self = reinterpret_cast(data); -<<<<<<< HEAD - uintptr_t window_id = self->engine_->renderer()->GetWindowId(); -======= - // TODO - // auto window_id = self->engine_->renderer()->GetWindowId(); ->>>>>>> Implement FlutterTizenView, FlutterTizenWindow - - if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { - auto* button_event = reinterpret_cast(event); - // if (window_id == button_event->window) { - self->pointer_state_ = true; - self->SendFlutterPointerEvent(kDown, button_event->x, button_event->y, 0, 0, - button_event->timestamp, - button_event->multi.device); - return ECORE_CALLBACK_DONE; - // } - - } else if (type == ECORE_EVENT_MOUSE_BUTTON_UP) { - auto* button_event = reinterpret_cast(event); - // if (window_id == button_event->window) { - self->pointer_state_ = false; - self->SendFlutterPointerEvent(kUp, button_event->x, button_event->y, 0, 0, - button_event->timestamp, - button_event->multi.device); - return ECORE_CALLBACK_DONE; - // } - } else if (type == ECORE_EVENT_MOUSE_MOVE) { - auto* move_event = reinterpret_cast(event); - // if (window_id == move_event->window) { - if (self->pointer_state_) { - self->SendFlutterPointerEvent(kMove, move_event->x, move_event->y, 0, 0, - move_event->timestamp, - move_event->multi.device); - return ECORE_CALLBACK_DONE; - } - // } - } else if (type == ECORE_EVENT_MOUSE_WHEEL) { - auto* wheel_event = reinterpret_cast(event); - // if (window_id == wheel_event->window) { - double scroll_delta_x = 0.0, scroll_delta_y = 0.0; - if (wheel_event->direction == kScrollDirectionVertical) { - scroll_delta_y += wheel_event->z; - } else if (wheel_event->direction == kScrollDirectionHorizontal) { - scroll_delta_x += wheel_event->z; - } - const int kScrollOffsetMultiplier = 20; - scroll_delta_x *= kScrollOffsetMultiplier; - scroll_delta_y *= kScrollOffsetMultiplier; - self->SendFlutterPointerEvent( - self->pointer_state_ ? kMove : kHover, wheel_event->x, wheel_event->y, - scroll_delta_x, scroll_delta_y, wheel_event->timestamp); - return ECORE_CALLBACK_DONE; - // } - } - return ECORE_CALLBACK_PASS_ON; -} - -} // namespace flutter diff --git a/shell/platform/tizen/touch_event_handler.h b/shell/platform/tizen/touch_event_handler.h deleted file mode 100644 index e5f764af86e9a..0000000000000 --- a/shell/platform/tizen/touch_event_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef EMBEDDER_TOUCH_EVENT_HANDLER_H_ -#define EMBEDDER_TOUCH_EVENT_HANDLER_H_ - -#include - -#include - -#include "flutter/shell/platform/embedder/embedder.h" - -namespace flutter { - -class FlutterTizenEngine; - -class TouchEventHandler { - public: - explicit TouchEventHandler(FlutterTizenEngine* engine); - virtual ~TouchEventHandler(); - - int32_t rotation = 0; - - private: - FlutterTizenEngine* engine_; - std::vector touch_event_handlers_; - bool pointer_state_ = false; - - void SendFlutterPointerEvent(FlutterPointerPhase phase, - double x, - double y, - double scroll_delta_x, - double scroll_delta_y, - size_t timestamp, - int device_id); - - static Eina_Bool OnTouch(void* data, int type, void* event); -}; - -} // namespace flutter - -#endif // EMBEDDER_TOUCH_EVENT_HANDLER_H_ From 0fdd17547ba8c3e1ae75dc77cba84059a05a27c0 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 19 Apr 2022 18:52:40 +0900 Subject: [PATCH 06/32] Add GetRotatoin to FlutterTizenWindow Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_ecore.cc | 2 +- shell/platform/tizen/flutter_tizen_view.cc | 7 ++++++- shell/platform/tizen/flutter_tizen_view.h | 2 ++ shell/platform/tizen/flutter_tizen_window.h | 2 ++ shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc | 4 ++++ shell/platform/tizen/flutter_tizen_window_ecore_wl2.h | 2 ++ 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index 17935bf22a5ce..fc5ea1c695343 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -52,7 +52,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( flutter_tizen_view->flutter_tizen_engine()->RunEngine(nullptr); } - flutter_tizen_view->OnRotate(0); + flutter_tizen_view->SendInitialGeometry(); return HandleForView(flutter_tizen_view.release()); } diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index b59d2a4f9b57f..ae8db6ae07cc7 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -44,7 +44,8 @@ void FlutterTizenView::SetFlutterTizenEngine( // platform handler? // corsor handler? // touch_event_handler_ = std::make_unique(this); - FT_LOG(Info) << "done"; + + OnRotate(flutter_tizen_window_->GetRotatoin()); } void FlutterTizenView::CreateRenderSurface() { @@ -160,6 +161,10 @@ void FlutterTizenView::OnScroll(double x, delta_y * scroll_offset_multiplier, timestamp, device_kind, device_id); } +void FlutterTizenView::SendInitialGeometry() { + OnRotate(flutter_tizen_window_->GetRotatoin()); +} + void FlutterTizenView::SendWindowMetrics(int32_t left, int32_t top, int32_t width, diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index d5c053ee629f3..f9d0f5412f17c 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -85,6 +85,8 @@ class FlutterTizenView { return flutter_trans_formation_; } + void SendInitialGeometry(); + private: // Sends a window metrics update to the Flutter engine using current window // dimensions in physical diff --git a/shell/platform/tizen/flutter_tizen_window.h b/shell/platform/tizen/flutter_tizen_window.h index 3d5fd6979bd9d..7d5fa145bd7db 100644 --- a/shell/platform/tizen/flutter_tizen_window.h +++ b/shell/platform/tizen/flutter_tizen_window.h @@ -42,6 +42,8 @@ class FlutterTizenWindow { virtual void* GetRenderTargetDisplay() = 0; + virtual int32_t GetRotatoin() = 0; + // Returns the scale factor for the backing window. virtual int32_t GetDpi() = 0; diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc index aabe65789941c..7e9e3da3762d0 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -244,6 +244,10 @@ FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetScreenGeometry() { return result; } +int32_t FlutterTizenWindowEcoreWl2::GetRotatoin() { + return ecore_wl2_window_rotation_get(ecore_wl2_window_); +} + int32_t FlutterTizenWindowEcoreWl2::GetDpi() { auto* output = ecore_wl2_window_output_find(ecore_wl2_window_); if (!output) { diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h index 93b5e57a73630..c8ec35f864788 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h @@ -31,6 +31,8 @@ class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { void* GetRenderTargetDisplay() override { return wl2_display_; } + int32_t GetRotatoin() override; + int32_t GetDpi() override; uintptr_t GetWindowId() override; From 43774476ca7aa2ac014355b6b36e6033ecedeb30 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 11:04:58 +0900 Subject: [PATCH 07/32] Move window dependent channels to FlutterTizenView Signed-off-by: Boram Bae --- .../tizen/channels/platform_channel.cc | 19 +++---- .../tizen/channels/platform_channel.h | 9 ++-- .../platform/tizen/channels/window_channel.cc | 36 +++++++------- .../platform/tizen/channels/window_channel.h | 14 ++---- shell/platform/tizen/flutter_tizen_engine.cc | 5 -- shell/platform/tizen/flutter_tizen_engine.h | 6 --- shell/platform/tizen/flutter_tizen_view.cc | 35 ++++++++++--- shell/platform/tizen/flutter_tizen_view.h | 12 ++++- shell/platform/tizen/flutter_tizen_window.h | 6 ++- .../tizen/flutter_tizen_window_ecore_wl2.cc | 49 +++++++++++++------ .../tizen/flutter_tizen_window_ecore_wl2.h | 5 +- shell/platform/tizen/tizen_renderer.h | 2 + .../tizen/tizen_renderer_ecore_wl2.cc | 4 +- .../platform/tizen/tizen_renderer_ecore_wl2.h | 4 +- 14 files changed, 124 insertions(+), 82 deletions(-) diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 8221cbfa2786f..c59ed9316d5e5 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -58,12 +58,12 @@ std::string text_clipboard = ""; } // namespace PlatformChannel::PlatformChannel(BinaryMessenger* messenger, - TizenRenderer* renderer) + FlutterTizenWindow* flutter_tizen_window) : channel_(std::make_unique>( messenger, kChannelName, &JsonMethodCodec::GetInstance())), - renderer_(renderer) { + flutter_tizen_window_(flutter_tizen_window) { channel_->SetMethodCallHandler( [this](const MethodCall& call, std::unique_ptr> result) { @@ -164,14 +164,13 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) { } void PlatformChannel::RestoreSystemUiOverlays() { - if (!renderer_) { + if (!flutter_tizen_window_) { return; } #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - // TODO - // shell.InitializeSoftkey(renderer_->GetWindowId()); + shell.InitializeSoftkey(flutter_tizen_window_->GetWindowId()); if (shell.IsSoftkeyShown()) { shell.ShowSoftkey(); @@ -183,14 +182,13 @@ void PlatformChannel::RestoreSystemUiOverlays() { void PlatformChannel::SetEnabledSystemUiOverlays( const std::vector& overlays) { - if (!renderer_) { + if (!flutter_tizen_window_) { return; } #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - // TODO - // shell.InitializeSoftkey(renderer_->GetWindowId()); + shell.InitializeSoftkey(flutter_tizen_window_->GetWindowId()); if (std::find(overlays.begin(), overlays.end(), kSystemUiOverlayBottom) != overlays.end()) { @@ -203,7 +201,7 @@ void PlatformChannel::SetEnabledSystemUiOverlays( void PlatformChannel::SetPreferredOrientations( const std::vector& orientations) { - if (!renderer_) { + if (!flutter_tizen_window_) { return; } @@ -222,8 +220,7 @@ void PlatformChannel::SetPreferredOrientations( // default. rotations = {0, 90, 180, 270}; } - // TODO - // renderer_->SetPreferredOrientations(rotations); + flutter_tizen_window_->SetPreferredOrientations(rotations); } } // namespace flutter diff --git a/shell/platform/tizen/channels/platform_channel.h b/shell/platform/tizen/channels/platform_channel.h index 49fcb031258d5..b99c0c6c0e1aa 100644 --- a/shell/platform/tizen/channels/platform_channel.h +++ b/shell/platform/tizen/channels/platform_channel.h @@ -11,14 +11,15 @@ #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" -#include "flutter/shell/platform/tizen/tizen_renderer.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" #include "rapidjson/document.h" namespace flutter { class PlatformChannel { public: - explicit PlatformChannel(BinaryMessenger* messenger, TizenRenderer* renderer); + explicit PlatformChannel(BinaryMessenger* messenger, + FlutterTizenWindow* flutter_tizen_window); virtual ~PlatformChannel(); private: @@ -35,9 +36,9 @@ class PlatformChannel { std::unique_ptr> channel_; - // A reference to the renderer object managed by FlutterTizenEngine. + // A reference to the window object managed by FlutterTizenView. // This can be nullptr if the engine is running in headless mode. - TizenRenderer* renderer_; + FlutterTizenWindow* flutter_tizen_window_; }; } // namespace flutter diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index dc15a282bedb7..ba98c5841b196 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -16,10 +16,9 @@ constexpr char kChannelName[] = "tizen/internal/window"; } // namespace -// TODO -WindowChannel::WindowChannel(BinaryMessenger* messenger) /* - : renderer_(renderer), delegate_(delegate)*/ -{ +WindowChannel::WindowChannel(BinaryMessenger* messenger, + FlutterTizenWindow* flutter_tizen_window) + : flutter_tizen_window_(flutter_tizen_window) { channel_ = std::make_unique>( messenger, kChannelName, &StandardMethodCodec::GetInstance()); channel_->SetMethodCallHandler( @@ -37,13 +36,13 @@ void WindowChannel::HandleMethodCall( const std::string& method_name = method_call.method_name(); if (method_name == "getWindowGeometry") { - // TODO - // TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); + FlutterTizenWindow::Geometry geometry = + flutter_tizen_window_->GetWindowGeometry(); EncodableMap map; - // map[EncodableValue("x")] = EncodableValue(geometry.x); - // map[EncodableValue("y")] = EncodableValue(geometry.y); - // map[EncodableValue("width")] = EncodableValue(geometry.w); - // map[EncodableValue("height")] = EncodableValue(geometry.h); + map[EncodableValue("x")] = EncodableValue(geometry.left); + map[EncodableValue("y")] = EncodableValue(geometry.top); + map[EncodableValue("width")] = EncodableValue(geometry.width); + map[EncodableValue("height")] = EncodableValue(geometry.height); result->Success(EncodableValue(map)); } else if (method_name == "setWindowGeometry") { #ifdef TIZEN_RENDERER_EVAS_GL @@ -60,20 +59,21 @@ void WindowChannel::HandleMethodCall( EncodableValueHolder width(arguments, "width"); EncodableValueHolder height(arguments, "height"); - // TODO - // TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); + FlutterTizenWindow::Geometry geometry = + flutter_tizen_window_->GetWindowGeometry(); - // delegate_->OnGeometryChange(x ? *x : geometry.x, y ? *y : geometry.y, - // width ? *width : geometry.w, - // height ? *height : geometry.h); + flutter_tizen_window_->SetWindowGeometry( + {x ? *x : geometry.left, y ? *y : geometry.top, + width ? *width : geometry.width, height ? *height : geometry.height}); result->Success(); #endif } else if (method_name == "getScreenGeometry") { // TODO - // TizenRenderer::Geometry geometry = renderer_->GetScreenGeometry(); + FlutterTizenWindow::Geometry geometry = + flutter_tizen_window_->GetScreenGeometry(); EncodableMap map; - // map[EncodableValue("width")] = EncodableValue(geometry.w); - // map[EncodableValue("height")] = EncodableValue(geometry.h); + map[EncodableValue("width")] = EncodableValue(geometry.width); + map[EncodableValue("height")] = EncodableValue(geometry.height); result->Success(EncodableValue(map)); } else { result->NotImplemented(); diff --git a/shell/platform/tizen/channels/window_channel.h b/shell/platform/tizen/channels/window_channel.h index 8ef6521bab620..9b0c2c3e1f9fa 100644 --- a/shell/platform/tizen/channels/window_channel.h +++ b/shell/platform/tizen/channels/window_channel.h @@ -10,16 +10,15 @@ #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" -#include "flutter/shell/platform/tizen/tizen_renderer.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" namespace flutter { // Channel to get/set application's window size and device's screen size. class WindowChannel { public: - explicit WindowChannel(BinaryMessenger* messenger/*, - TizenRenderer* renderer, - TizenRenderer::Delegate* delegate*/); + explicit WindowChannel(BinaryMessenger* messenger, + FlutterTizenWindow* flutter_tizen_window); virtual ~WindowChannel(); private: @@ -28,11 +27,8 @@ class WindowChannel { std::unique_ptr> channel_; - // A reference to the renderer object managed by FlutterTizenEngine. - // This can be nullptr if the engine is running in headless mode. - // TizenRenderer* renderer_; - - // [[maybe_unused]] TizenRenderer::Delegate* delegate_; + // A reference to the renderer object managed by FlutterTizenView. + FlutterTizenWindow* flutter_tizen_window_; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 8447329ce8348..44850c4dc27c7 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -235,8 +235,6 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { internal_plugin_registrar_->messenger()); lifecycle_channel_ = std::make_unique( internal_plugin_registrar_->messenger()); - platform_channel_ = std::make_unique( - internal_plugin_registrar_->messenger(), renderer_.get()); settings_channel_ = std::make_unique( internal_plugin_registrar_->messenger()); @@ -251,9 +249,6 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), std::make_unique(this)); - // TODO - window_channel_ = std::make_unique( - internal_plugin_registrar_->messenger() /*, renderer_.get(), this*/); key_event_handler_ = std::make_unique(this); } diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 4aeb4b8231554..a3704c4ed7f7f 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -272,9 +272,6 @@ class FlutterTizenEngine { // A plugin that implements the Flutter navigation channel. std::unique_ptr navigation_channel_; - // A plugin that implements the Flutter platform channel. - std::unique_ptr platform_channel_; - // A plugin that implements the Flutter platform_views channel. std::unique_ptr platform_view_channel_; @@ -284,9 +281,6 @@ class FlutterTizenEngine { // A plugin that implements the Flutter textinput channel. std::unique_ptr text_input_channel_; - // A plugin that implements the Tizen window channel. - std::unique_ptr window_channel_; - // The event loop for the main thread that allows for delayed task execution. std::unique_ptr event_loop_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index ae8db6ae07cc7..342193807d81f 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -39,11 +39,15 @@ void FlutterTizenView::SetFlutterTizenEngine( flutter_tizen_engine_ = std::move(flutter_tizen_engine); flutter_tizen_engine_->SetFlutterTizenView(this); - // registrar - // keyboard? - // platform handler? - // corsor handler? - // touch_event_handler_ = std::make_unique(this); + internal_plugin_registrar_ = std::make_unique( + flutter_tizen_engine_->plugin_registrar()); + + // Setup window dependent channels. + BinaryMessenger* messenger = internal_plugin_registrar_->messenger(); + platform_channel_ = + std::make_unique(messenger, flutter_tizen_window_.get()); + window_channel_ = + std::make_unique(messenger, flutter_tizen_window_.get()); OnRotate(flutter_tizen_window_->GetRotatoin()); } @@ -58,6 +62,12 @@ void FlutterTizenView::CreateRenderSurface() { } } +void FlutterTizenView::DestroyRenderSurface() { + if (flutter_tizen_engine_ && flutter_tizen_engine_->renderer()) { + flutter_tizen_engine_->renderer()->DestroySurface(); + } +} + bool FlutterTizenView::OnMakeCurrent() { return flutter_tizen_engine_->renderer()->OnMakeCurrent(); } @@ -81,6 +91,19 @@ void* FlutterTizenView::OnProcResolver(const char* name) { return flutter_tizen_engine_->renderer()->OnProcResolver(name); } +void FlutterTizenView::OnResize(int32_t left, + int32_t top, + int32_t width, + int32_t height) { + if (rotation_degree_ == 90 || rotation_degree_ == 270) { + std::swap(width, height); + } + + flutter_tizen_window_->ResizeRenderTargetWithRotation( + {left, top, width, height}, rotation_degree_); + SendWindowMetrics(left, top, width, height, 0.0); +} + void FlutterTizenView::OnRotate(int32_t degree) { rotation_degree_ = degree; // Compute renderer transformation based on the angle of rotation. @@ -112,7 +135,7 @@ void FlutterTizenView::OnRotate(int32_t degree) { std::swap(width, height); } - flutter_tizen_window_->ResizeWithRotation( + flutter_tizen_window_->ResizeRenderTargetWithRotation( {geometry.left, geometry.top, width, height}, rotation_degree_); // Window position does not change on rotation regardless of its orientation. diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index f9d0f5412f17c..7cd2ae01ae9ce 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -52,6 +52,8 @@ class FlutterTizenView { void* OnProcResolver(const char* name); // ========== Window Event Delegate ========== + void OnResize(int32_t left, int32_t top, int32_t width, int32_t height); + void OnRotate(int32_t degree); void OnPointerMove(double x, @@ -112,7 +114,15 @@ class FlutterTizenView { // TODO std::unique_ptr flutter_tizen_window_; - private: + // The plugin registrar managing internal plugins. + std::unique_ptr internal_plugin_registrar_; + + // A plugin that implements the Tizen window channel. + std::unique_ptr window_channel_; + + // A plugin that implements the Flutter platform channel. + std::unique_ptr platform_channel_; + // The current view rotation degree. int32_t rotation_degree_ = 0; diff --git a/shell/platform/tizen/flutter_tizen_window.h b/shell/platform/tizen/flutter_tizen_window.h index 7d5fa145bd7db..53ada246f032e 100644 --- a/shell/platform/tizen/flutter_tizen_window.h +++ b/shell/platform/tizen/flutter_tizen_window.h @@ -33,6 +33,9 @@ class FlutterTizenWindow { // Returns the geometry of the current window. virtual Geometry GetWindowGeometry() = 0; + // Set the geometry of the current window. + virtual void SetWindowGeometry(Geometry geometry) = 0; + // Returns the geometry of the display screen. virtual Geometry GetScreenGeometry() = 0; @@ -51,7 +54,8 @@ class FlutterTizenWindow { virtual void* GetWindowHandle() = 0; - virtual void ResizeWithRotation(Geometry geometry, int32_t degree) = 0; + virtual void ResizeRenderTargetWithRotation(Geometry geometry, + int32_t degree) = 0; virtual void SetPreferredOrientations(const std::vector& rotations) = 0; diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc index 7e9e3da3762d0..062f5ae12ff06 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -124,12 +124,31 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { if (self->flutter_tizen_view_) { auto* rotation_event = reinterpret_cast(event); - int32_t degree = rotation_event->angle; - self->flutter_tizen_view_->OnRotate(degree); - auto geometry = self->GetWindowGeometry(); - ecore_wl2_window_rotation_change_done_send( - self->ecore_wl2_window_, rotation_event->rotation, geometry.width, - geometry.height); + if (rotation_event->win == self->GetWindowId()) { + int32_t degree = rotation_event->angle; + self->flutter_tizen_view_->OnRotate(degree); + auto geometry = self->GetWindowGeometry(); + ecore_wl2_window_rotation_change_done_send( + self->ecore_wl2_window_, rotation_event->rotation, + geometry.width, geometry.height); + } + } + return ECORE_CALLBACK_PASS_ON; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_WL2_EVENT_WINDOW_CONFIGURE, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* configure_event = + reinterpret_cast(event); + + self->flutter_tizen_view_->OnResize( + configure_event->x, configure_event->y, configure_event->w, + configure_event->h); + ecore_wl2_window_commit(self->ecore_wl2_window_, EINA_FALSE); } return ECORE_CALLBACK_PASS_ON; }, @@ -237,6 +256,11 @@ FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetWindowGeometry() { return result; } +void FlutterTizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { + ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, geometry.top, + geometry.width, geometry.height); +} + FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetScreenGeometry() { Geometry result = {}; ecore_wl2_display_screen_size_get(ecore_wl2_display_, &result.width, @@ -261,16 +285,9 @@ uintptr_t FlutterTizenWindowEcoreWl2::GetWindowId() { return ecore_wl2_window_id_get(ecore_wl2_window_); } -// void FlutterTizenWindowEcoreWl2::SetGeometry(Geometry geometry) { -// ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, -// geometry.top, -// geometry.width, geometry.height); -// ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, -// geometry.top); -// } - -void FlutterTizenWindowEcoreWl2::ResizeWithRotation(Geometry geometry, - int32_t angle) { +void FlutterTizenWindowEcoreWl2::ResizeRenderTargetWithRotation( + Geometry geometry, + int32_t angle) { ecore_wl2_egl_window_resize_with_rotation( ecore_wl2_egl_window_, geometry.left, geometry.top, geometry.width, geometry.height, angle); diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h index c8ec35f864788..ad51517bf3dda 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h @@ -25,6 +25,8 @@ class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { Geometry GetWindowGeometry() override; + void SetWindowGeometry(Geometry geometry) override; + Geometry GetScreenGeometry() override; void* GetRenderTarget() override { return ecore_wl2_egl_window_; } @@ -39,7 +41,8 @@ class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { void* GetWindowHandle() override { return ecore_wl2_window_; } - void ResizeWithRotation(Geometry geometry, int32_t angle) override; + void ResizeRenderTargetWithRotation(Geometry geometry, + int32_t angle) override; void SetPreferredOrientations(const std::vector& rotations) override; diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 4b335ce883461..9de5bf21fff40 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -21,6 +21,8 @@ class TizenRenderer { int32_t width, int32_t height) = 0; + virtual void DestroySurface() = 0; + bool IsValid() { return is_valid_; } virtual bool OnMakeCurrent() = 0; diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 40abbc229345e..20934faf3fb49 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -16,7 +16,7 @@ TizenRendererEcoreWl2::TizenRendererEcoreWl2() { } TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { - DestroyEGL(); + DestroySurface(); } bool TizenRendererEcoreWl2::OnMakeCurrent() { @@ -360,7 +360,7 @@ void TizenRendererEcoreWl2::PrintEGLError() { } } -void TizenRendererEcoreWl2::DestroyEGL() { +void TizenRendererEcoreWl2::DestroySurface() { if (egl_display_) { eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index 653f6ff1fdb98..5d30f5829efbf 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -27,6 +27,8 @@ class TizenRendererEcoreWl2 : public TizenRenderer { int32_t width, int32_t height) override; + void DestroySurface() override; + bool OnMakeCurrent() override; bool OnClearCurrent() override; @@ -46,8 +48,6 @@ class TizenRendererEcoreWl2 : public TizenRenderer { void PrintEGLError(); - void DestroyEGL(); - EGLConfig egl_config_ = nullptr; EGLDisplay egl_display_ = EGL_NO_DISPLAY; EGLContext egl_context_ = EGL_NO_CONTEXT; From b8a42f07c8bb89d59b7dc8a37fbb0bb66e667515 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 14:17:08 +0900 Subject: [PATCH 08/32] Refactor key event * Remove KeyEventHandler * Add key event hander to FlutterTizenWindow impl Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 1 - .../platform/tizen/channels/window_channel.cc | 1 - shell/platform/tizen/flutter_tizen_engine.cc | 5 - shell/platform/tizen/flutter_tizen_engine.h | 12 -- shell/platform/tizen/flutter_tizen_view.cc | 58 +++++++++- shell/platform/tizen/flutter_tizen_view.h | 9 ++ .../tizen/flutter_tizen_window_ecore_wl2.cc | 55 +++++++-- shell/platform/tizen/key_event_handler.cc | 104 ------------------ shell/platform/tizen/key_event_handler.h | 30 ----- .../tizen/tizen_input_method_context.cc | 19 ++-- .../tizen/tizen_input_method_context.h | 8 +- 11 files changed, 124 insertions(+), 178 deletions(-) delete mode 100644 shell/platform/tizen/key_event_handler.cc delete mode 100644 shell/platform/tizen/key_event_handler.h diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index fb4e7f009f668..00063466657ca 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -124,7 +124,6 @@ template("embedder") { "flutter_tizen_engine.cc", "flutter_tizen_texture_registrar.cc", "flutter_tizen_view.cc", - "key_event_handler.cc", "logger.cc", "system_utils.cc", "tizen_event_loop.cc", diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index ba98c5841b196..d39f15d3b2c85 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -68,7 +68,6 @@ void WindowChannel::HandleMethodCall( result->Success(); #endif } else if (method_name == "getScreenGeometry") { - // TODO FlutterTizenWindow::Geometry geometry = flutter_tizen_window_->GetScreenGeometry(); EncodableMap map; diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 44850c4dc27c7..bc0231112d7d8 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -246,11 +246,6 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { internal_plugin_registrar_->messenger()); platform_view_channel_ = std::make_unique( internal_plugin_registrar_->messenger()); - text_input_channel_ = std::make_unique( - internal_plugin_registrar_->messenger(), - std::make_unique(this)); - - key_event_handler_ = std::make_unique(this); } accessibility_settings_ = std::make_unique(this); diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index a3704c4ed7f7f..cca99e88c622c 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -20,14 +20,10 @@ #include "flutter/shell/platform/tizen/channels/key_event_channel.h" #include "flutter/shell/platform/tizen/channels/lifecycle_channel.h" #include "flutter/shell/platform/tizen/channels/navigation_channel.h" -#include "flutter/shell/platform/tizen/channels/platform_channel.h" #include "flutter/shell/platform/tizen/channels/platform_view_channel.h" #include "flutter/shell/platform/tizen/channels/settings_channel.h" -#include "flutter/shell/platform/tizen/channels/text_input_channel.h" -#include "flutter/shell/platform/tizen/channels/window_channel.h" #include "flutter/shell/platform/tizen/flutter_project_bundle.h" #include "flutter/shell/platform/tizen/flutter_tizen_texture_registrar.h" -#include "flutter/shell/platform/tizen/key_event_handler.h" #include "flutter/shell/platform/tizen/public/flutter_tizen.h" #include "flutter/shell/platform/tizen/tizen_event_loop.h" #include "flutter/shell/platform/tizen/tizen_renderer.h" @@ -115,8 +111,6 @@ class FlutterTizenEngine { return platform_view_channel_.get(); } - TextInputChannel* text_input_channel() { return text_input_channel_.get(); } - #ifndef WEARABLE_PROFILE std::weak_ptr accessibility_bridge() { return accessibility_bridge_; @@ -227,9 +221,6 @@ class FlutterTizenEngine { // The view displaying the content running in this engine, if any. FlutterTizenView* flutter_tizen_view_ = nullptr; - // An event dispatcher for Ecore key events. - std::unique_ptr key_event_handler_; - // The plugin messenger handle given to API clients. std::unique_ptr messenger_; @@ -278,9 +269,6 @@ class FlutterTizenEngine { // A plugin that implements the Flutter settings channel. std::unique_ptr settings_channel_; - // A plugin that implements the Flutter textinput channel. - std::unique_ptr text_input_channel_; - // The event loop for the main thread that allows for delayed task execution. std::unique_ptr event_loop_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 342193807d81f..d2154f932af58 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -20,6 +20,22 @@ constexpr double kProfileFactor = 2.0; constexpr double kProfileFactor = 1.0; #endif +constexpr char kBackKey[] = "XF86Back"; +constexpr char kExitKey[] = "XF86Exit"; + +// Keys that should always be handled by the app first but not by the system. +const std::vector kBindableSystemKeys = { + "XF86Menu", "XF86Back", "XF86AudioPlay", + "XF86AudioPause", "XF86AudioStop", "XF86AudioNext", + "XF86AudioPrev", "XF86AudioRewind", "XF86AudioForward", + "XF86AudioPlayPause", "XF86AudioRecord", "XF86LowerChannel", + "XF86RaiseChannel", "XF86ChannelList", "XF86PreviousChannel", + "XF86SysMenu", "XF86SimpleMenu", "XF86History", + "XF86Favorites", "XF86Info", "XF86Red", + "XF86Green", "XF86Yellow", "XF86Blue", + "XF86Subtitle", "XF86PlayBack", "XF86ChannelGuide", + "XF86Caption", "XF86Exit", +}; } // namespace namespace flutter { @@ -48,7 +64,9 @@ void FlutterTizenView::SetFlutterTizenEngine( std::make_unique(messenger, flutter_tizen_window_.get()); window_channel_ = std::make_unique(messenger, flutter_tizen_window_.get()); - + text_input_channel_ = std::make_unique( + internal_plugin_registrar_->messenger(), + std::make_unique(flutter_tizen_window_.get())); OnRotate(flutter_tizen_window_->GetRotatoin()); } @@ -184,6 +202,44 @@ void FlutterTizenView::OnScroll(double x, delta_y * scroll_offset_multiplier, timestamp, device_kind, device_id); } +void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { + FT_LOG(Error) << "enter"; + if (is_down) { + FT_LOG(Info) << "Key symbol: " << event->key << ", code: 0x" << std::setw(8) + << std::setfill('0') << std::right << std::hex + << event->keycode; + } + + if (text_input_channel_) { + if (text_input_channel_->SendKeyEvent(event, is_down)) { + return; + } + } + + if (flutter_tizen_engine_->platform_view_channel()) { + flutter_tizen_engine_->platform_view_channel()->SendKeyEvent(event, + is_down); + } + + if (flutter_tizen_engine_->key_event_channel()) { + flutter_tizen_engine_->key_event_channel()->SendKeyEvent( + event, is_down, + [engine = flutter_tizen_engine_.get(), symbol = std::string(event->key), + is_down](bool handled) { + if (handled) { + return; + } + if (symbol == kBackKey && !is_down) { + if (engine->navigation_channel()) { + engine->navigation_channel()->PopRoute(); + } + } else if (symbol == kExitKey && !is_down) { + ui_app_exit(); + } + }); + } +} + void FlutterTizenView::SendInitialGeometry() { OnRotate(flutter_tizen_window_->GetRotatoin()); } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 7cd2ae01ae9ce..f2b2132d432dc 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -8,7 +8,11 @@ #include +#include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h" #include "flutter/shell/platform/embedder/embedder.h" +#include "flutter/shell/platform/tizen/channels/platform_channel.h" +#include "flutter/shell/platform/tizen/channels/text_input_channel.h" +#include "flutter/shell/platform/tizen/channels/window_channel.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" namespace flutter { @@ -83,6 +87,8 @@ class FlutterTizenView { FlutterPointerDeviceKind device_kind, int32_t device_id); + void OnKey(Ecore_Event_Key* event, bool is_down); + FlutterTransformation GetFlutterTransformation() { return flutter_trans_formation_; } @@ -123,6 +129,9 @@ class FlutterTizenView { // A plugin that implements the Flutter platform channel. std::unique_ptr platform_channel_; + // A plugin that implements the Flutter textinput channel. + std::unique_ptr text_input_channel_; + // The current view rotation degree. int32_t rotation_degree_ = 0; diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc index 062f5ae12ff06..ceb7b538fc90a 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -131,6 +131,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_wl2_window_rotation_change_done_send( self->ecore_wl2_window_, rotation_event->rotation, geometry.width, geometry.height); + return ECORE_CALLBACK_DONE; } } return ECORE_CALLBACK_PASS_ON; @@ -144,11 +145,13 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { if (self->flutter_tizen_view_) { auto* configure_event = reinterpret_cast(event); - - self->flutter_tizen_view_->OnResize( - configure_event->x, configure_event->y, configure_event->w, - configure_event->h); - ecore_wl2_window_commit(self->ecore_wl2_window_, EINA_FALSE); + if (configure_event->win == self->GetWindowId()) { + self->flutter_tizen_view_->OnResize( + configure_event->x, configure_event->y, configure_event->w, + configure_event->h); + ecore_wl2_window_commit(self->ecore_wl2_window_, EINA_FALSE); + return ECORE_CALLBACK_DONE; + } } return ECORE_CALLBACK_PASS_ON; }, @@ -165,9 +168,10 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { self->flutter_tizen_view_->OnPointerDown( button_event->x, button_event->y, button_event->timestamp, kFlutterPointerDeviceKindTouch, button_event->multi.device); + return ECORE_CALLBACK_DONE; } } - return ECORE_CALLBACK_DONE; + return ECORE_CALLBACK_PASS_ON; }, this)); @@ -182,9 +186,10 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { self->flutter_tizen_view_->OnPointerUp( button_event->x, button_event->y, button_event->timestamp, kFlutterPointerDeviceKindTouch, button_event->multi.device); + return ECORE_CALLBACK_DONE; } } - return ECORE_CALLBACK_DONE; + return ECORE_CALLBACK_PASS_ON; }, this)); @@ -198,9 +203,10 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { self->flutter_tizen_view_->OnPointerMove( move_event->x, move_event->y, move_event->timestamp, kFlutterPointerDeviceKindTouch, move_event->multi.device); + return ECORE_CALLBACK_DONE; } } - return ECORE_CALLBACK_DONE; + return ECORE_CALLBACK_PASS_ON; }, this)); @@ -224,9 +230,40 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { wheel_event->x, wheel_event->y, delta_x, delta_y, kScrollOffsetMultiplier, wheel_event->timestamp, kFlutterPointerDeviceKindTouch, 0); + return ECORE_CALLBACK_DONE; + } + } + return ECORE_CALLBACK_PASS_ON; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_KEY_DOWN, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* key_event = reinterpret_cast(event); + if (key_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnKey(key_event, true); + return ECORE_CALLBACK_DONE; } } - return ECORE_CALLBACK_DONE; + return ECORE_CALLBACK_PASS_ON; + }, + this)); + + ecore_event_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_KEY_UP, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* key_event = reinterpret_cast(event); + if (key_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnKey(key_event, false); + return ECORE_CALLBACK_DONE; + } + } + return ECORE_CALLBACK_PASS_ON; }, this)); } diff --git a/shell/platform/tizen/key_event_handler.cc b/shell/platform/tizen/key_event_handler.cc deleted file mode 100644 index a86a0da20dce6..0000000000000 --- a/shell/platform/tizen/key_event_handler.cc +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "key_event_handler.h" - -#include - -#include - -#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/logger.h" - -namespace flutter { - -namespace { - -constexpr char kBackKey[] = "XF86Back"; -constexpr char kExitKey[] = "XF86Exit"; - -// Keys that should always be handled by the app first but not by the system. -const std::vector kBindableSystemKeys = { - "XF86Menu", "XF86Back", "XF86AudioPlay", - "XF86AudioPause", "XF86AudioStop", "XF86AudioNext", - "XF86AudioPrev", "XF86AudioRewind", "XF86AudioForward", - "XF86AudioPlayPause", "XF86AudioRecord", "XF86LowerChannel", - "XF86RaiseChannel", "XF86ChannelList", "XF86PreviousChannel", - "XF86SysMenu", "XF86SimpleMenu", "XF86History", - "XF86Favorites", "XF86Info", "XF86Red", - "XF86Green", "XF86Yellow", "XF86Blue", - "XF86Subtitle", "XF86PlayBack", "XF86ChannelGuide", - "XF86Caption", "XF86Exit", -}; - -} // namespace - -KeyEventHandler::KeyEventHandler(FlutterTizenEngine* engine) : engine_(engine) { - if (!engine->renderer() || !engine->renderer()->IsValid()) { - return; - } - - // TODO - // engine->renderer()->BindKeys(kBindableSystemKeys); - - key_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, OnKey, this)); - key_event_handlers_.push_back( - ecore_event_handler_add(ECORE_EVENT_KEY_UP, OnKey, this)); -} - -KeyEventHandler::~KeyEventHandler() { - for (Ecore_Event_Handler* handler : key_event_handlers_) { - ecore_event_handler_del(handler); - } - key_event_handlers_.clear(); -} - -Eina_Bool KeyEventHandler::OnKey(void* data, int type, void* raw_event) { - auto* self = reinterpret_cast(data); - auto* event = reinterpret_cast(raw_event); - FlutterTizenEngine* engine = self->engine_; - bool is_down = type == ECORE_EVENT_KEY_DOWN; - - // TODO - // if (engine->renderer()->GetWindowId() != event->window) { - // return ECORE_CALLBACK_PASS_ON; - // } - - if (is_down) { - FT_LOG(Info) << "Key symbol: " << event->key << ", code: 0x" << std::setw(8) - << std::setfill('0') << std::right << std::hex - << event->keycode; - } - - if (engine->text_input_channel()) { - if (engine->text_input_channel()->SendKeyEvent(event, is_down)) { - return ECORE_CALLBACK_DONE; - } - } - - if (engine->platform_view_channel()) { - engine->platform_view_channel()->SendKeyEvent(event, is_down); - } - - if (engine->key_event_channel()) { - engine->key_event_channel()->SendKeyEvent( - event, is_down, - [engine, symbol = std::string(event->key), is_down](bool handled) { - if (handled) { - return; - } - if (symbol == kBackKey && !is_down) { - if (engine->navigation_channel()) { - engine->navigation_channel()->PopRoute(); - } - } else if (symbol == kExitKey && !is_down) { - ui_app_exit(); - } - }); - } - return ECORE_CALLBACK_DONE; -} - -} // namespace flutter diff --git a/shell/platform/tizen/key_event_handler.h b/shell/platform/tizen/key_event_handler.h deleted file mode 100644 index 07ce8b8615770..0000000000000 --- a/shell/platform/tizen/key_event_handler.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef EMBEDDER_KEY_EVENT_HANDLER_H_ -#define EMBEDDER_KEY_EVENT_HANDLER_H_ - -#include - -#include - -namespace flutter { - -class FlutterTizenEngine; - -class KeyEventHandler { - public: - explicit KeyEventHandler(FlutterTizenEngine* engine); - virtual ~KeyEventHandler(); - - private: - FlutterTizenEngine* engine_; - std::vector key_event_handlers_; - - static Eina_Bool OnKey(void* data, int type, void* event); -}; - -} // namespace flutter - -#endif // EMBEDDER_KEY_EVENT_HANDLER_H_ diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 9083dfa885965..df1f1504d40b4 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -4,7 +4,7 @@ #include "tizen_input_method_context.h" -#include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" #include "flutter/shell/platform/tizen/logger.h" namespace { @@ -103,9 +103,10 @@ T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { namespace flutter { -TizenInputMethodContext::TizenInputMethodContext(FlutterTizenEngine* engine) - : engine_(engine) { - FT_ASSERT(engine_); +TizenInputMethodContext::TizenInputMethodContext( + FlutterTizenWindow* flutter_tizen_window) + : flutter_tizen_window_(flutter_tizen_window) { + FT_ASSERT(flutter_tizen_window_); ecore_imf_init(); const char* imf_id = ecore_imf_context_default_id_get(); @@ -124,13 +125,9 @@ TizenInputMethodContext::TizenInputMethodContext(FlutterTizenEngine* engine) return; } - // TODO - // ecore_imf_context_client_window_set( - // imf_context_, - // reinterpret_cast(engine_->renderer()->GetWindowId())); - if (engine_) { - // - } + ecore_imf_context_client_window_set( + imf_context_, + reinterpret_cast(flutter_tizen_window_->GetWindowId())); SetContextOptions(); SetInputPanelOptions(); RegisterEventCallbacks(); diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 18febbeac1754..9374f42f8aeca 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -21,7 +21,7 @@ using OnPreeditStart = std::function; using OnPreeditEnd = std::function; using OnInputPanelStateChanged = std::function; -class FlutterTizenEngine; +class FlutterTizenWindow; struct InputPanelGeometry { int32_t x = 0, y = 0, w = 0, h = 0; @@ -29,7 +29,7 @@ struct InputPanelGeometry { class TizenInputMethodContext { public: - TizenInputMethodContext(FlutterTizenEngine* engine); + TizenInputMethodContext(FlutterTizenWindow* flutter_tizen_window); ~TizenInputMethodContext(); bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); @@ -69,8 +69,8 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); - FlutterTizenEngine* engine_{nullptr}; - Ecore_IMF_Context* imf_context_{nullptr}; + FlutterTizenWindow* flutter_tizen_window_ = nullptr; + Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; OnPreeditChanged on_preedit_changed_; OnPreeditStart on_preedit_start_; From b45925d3d07d3202ed9bf24462cc2cba4ad614a2 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 14:46:50 +0900 Subject: [PATCH 09/32] Update window related minor things Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen.cc | 6 +++--- shell/platform/tizen/flutter_tizen_ecore.cc | 2 -- shell/platform/tizen/flutter_tizen_engine.cc | 8 +++++--- shell/platform/tizen/flutter_tizen_view.cc | 1 - shell/platform/tizen/flutter_tizen_view.h | 9 ++++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 4f02acb3280c3..460ced0ef4123 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -73,9 +73,9 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { void* FlutterDesktopPluginRegistrarGetNativeWindow( FlutterDesktopPluginRegistrarRef registrar) { - // TODO - // return registrar->engine->renderer()->GetWindowHandle(); - return nullptr; + return registrar->engine->flutter_tizen_view() + ->flutter_tizen_window() + ->GetWindowHandle(); } void FlutterDesktopPluginRegistrarEnableInputBlocking( diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index fc5ea1c695343..d9ea63b93bc05 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -26,8 +26,6 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { - // Todo : Use view and window imple; - std::unique_ptr flutter_tizen_window = std::make_unique( flutter::FlutterTizenWindow::Geometry( diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index bc0231112d7d8..2e9c4bd7486a2 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -540,9 +540,11 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions( bridge->GetFlutterPlatformNodeDelegateFromID(0); std::shared_ptr window = FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock(); - // TODO - // auto geometry = engine->renderer_->GetWindowGeometry(); - // window->SetGeometry(geometry.x, geometry.y, geometry.w, geometry.h); + FlutterTizenWindow::Geometry geometry = + engine->flutter_tizen_view_->flutter_tizen_window() + ->GetWindowGeometry(); + window->SetGeometry(geometry.left, geometry.top, geometry.width, + geometry.height); window->SetRootNode(root); return; } diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index d2154f932af58..3bbfa217b2ce8 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -203,7 +203,6 @@ void FlutterTizenView::OnScroll(double x, } void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { - FT_LOG(Error) << "enter"; if (is_down) { FT_LOG(Info) << "Key symbol: " << event->key << ", code: 0x" << std::setw(8) << std::setfill('0') << std::right << std::hex diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index f2b2132d432dc..c787432702722 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -14,11 +14,10 @@ #include "flutter/shell/platform/tizen/channels/text_input_channel.h" #include "flutter/shell/platform/tizen/channels/window_channel.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/flutter_tizen_window.h" namespace flutter { -class FlutterTizenWindow; - class FlutterTizenView { public: FlutterTizenView(std::unique_ptr flutter_tizen_window); @@ -34,6 +33,10 @@ class FlutterTizenView { return flutter_tizen_engine_.get(); } + FlutterTizenWindow* flutter_tizen_window() { + return flutter_tizen_window_.get(); + } + // Creates rendering surface for Flutter engine to draw into. // Should be called before calling FlutterEngineRun using this view. void CreateRenderSurface(); @@ -117,7 +120,7 @@ class FlutterTizenView { // The engine associated with this view. std::unique_ptr flutter_tizen_engine_; - // TODO + // The window associated with this view. std::unique_ptr flutter_tizen_window_; // The plugin registrar managing internal plugins. From b5e3fad3d223daeab52ffe514bf8f727db5255d6 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 17:20:34 +0900 Subject: [PATCH 10/32] Fix a WindowChannel bug Signed-off-by: Boram Bae --- .../platform/tizen/channels/window_channel.cc | 6 +++-- shell/platform/tizen/flutter_tizen_window.h | 4 +++ .../tizen/flutter_tizen_window_ecore_wl2.cc | 26 +++++++------------ .../tizen/flutter_tizen_window_ecore_wl2.h | 4 +-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index d39f15d3b2c85..9445f2d47a9db 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -61,8 +61,10 @@ void WindowChannel::HandleMethodCall( FlutterTizenWindow::Geometry geometry = flutter_tizen_window_->GetWindowGeometry(); - - flutter_tizen_window_->SetWindowGeometry( + // FIXME: Use SetWindowGeometry() instead of OnGeometryChanged() + // After the SetWindowGeometry was successfully executed, I expected a + // handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't. + flutter_tizen_window_->OnGeometryChanged( {x ? *x : geometry.left, y ? *y : geometry.top, width ? *width : geometry.width, height ? *height : geometry.height}); result->Success(); diff --git a/shell/platform/tizen/flutter_tizen_window.h b/shell/platform/tizen/flutter_tizen_window.h index 53ada246f032e..c8b1f51c55dd4 100644 --- a/shell/platform/tizen/flutter_tizen_window.h +++ b/shell/platform/tizen/flutter_tizen_window.h @@ -63,6 +63,10 @@ class FlutterTizenWindow { virtual void Show() = 0; + // FIXME + // This is a temporary implementation that is only used by the window channel. + virtual void OnGeometryChanged(Geometry geometry) = 0; + protected: explicit FlutterTizenWindow(Geometry geometry, bool transparent, diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc index ceb7b538fc90a..d9ae354ca0feb 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc @@ -296,6 +296,10 @@ FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetWindowGeometry() { void FlutterTizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, geometry.top, geometry.width, geometry.height); + // FIXME : I refer to https://github.com/flutter-tizen/engine/pull/201, + // but I don't know why it doesn't work properly without calling + // ecore_wl2_window_position_set(). + ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, geometry.top); } FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetScreenGeometry() { @@ -348,22 +352,12 @@ void FlutterTizenWindowEcoreWl2::Show() { ecore_wl2_window_show(ecore_wl2_window_); } -Eina_Bool FlutterTizenWindowEcoreWl2::OnRotate(void* data, - int type, - void* event) { - auto* self = reinterpret_cast(data); - auto* rotation_event = - reinterpret_cast(event); - if (self->flutter_tizen_view_) { - int32_t degree = rotation_event->angle; - self->flutter_tizen_view_->OnRotate(degree); - auto geometry = self->GetWindowGeometry(); - ecore_wl2_window_rotation_change_done_send(self->ecore_wl2_window_, - rotation_event->rotation, - geometry.width, geometry.height); - } - FT_LOG(Error) << "done"; - return ECORE_CALLBACK_PASS_ON; +void FlutterTizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { + // This implementation mimics the situation in which the handler of + // ECORE_WL2_EVENT_WINDOW_CONFIGURE is called. + SetWindowGeometry(geometry); + flutter_tizen_view_->OnResize(geometry.left, geometry.top, geometry.width, + geometry.height); } void FlutterTizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h index ad51517bf3dda..3468c151f83eb 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h @@ -50,6 +50,8 @@ class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { void Show() override; + void OnGeometryChanged(Geometry geometry) override; + private: bool CreateWindow(); @@ -61,8 +63,6 @@ class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { void SetTizenPolicyNotificationLevel(int level); - static Eina_Bool OnRotate(void* data, int type, void* event); - Ecore_Wl2_Display* ecore_wl2_display_ = nullptr; Ecore_Wl2_Window* ecore_wl2_window_ = nullptr; From bd6632a47ce5c4323745cc962f4a598022fb8491 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 17:35:53 +0900 Subject: [PATCH 11/32] Rename TizenWindow * remove a prefix "Flutter" Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 2 +- .../tizen/channels/platform_channel.cc | 2 +- .../tizen/channels/platform_channel.h | 6 +- .../platform/tizen/channels/window_channel.cc | 11 ++-- .../platform/tizen/channels/window_channel.h | 6 +- shell/platform/tizen/flutter_tizen.cc | 3 +- shell/platform/tizen/flutter_tizen_ecore.cc | 12 ++-- .../tizen/flutter_tizen_elementary.cc | 2 +- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- shell/platform/tizen/flutter_tizen_view.cc | 4 +- shell/platform/tizen/flutter_tizen_view.h | 10 ++- .../tizen/tizen_input_method_context.cc | 4 +- .../tizen/tizen_input_method_context.h | 6 +- ...{flutter_tizen_window.h => tizen_window.h} | 14 ++-- ...ecore_wl2.cc => tizen_window_ecore_wl2.cc} | 66 +++++++++---------- ...w_ecore_wl2.h => tizen_window_ecore_wl2.h} | 14 ++-- 16 files changed, 76 insertions(+), 88 deletions(-) rename shell/platform/tizen/{flutter_tizen_window.h => tizen_window.h} (88%) rename shell/platform/tizen/{flutter_tizen_window_ecore_wl2.cc => tizen_window_ecore_wl2.cc} (85%) rename shell/platform/tizen/{flutter_tizen_window_ecore_wl2.h => tizen_window_ecore_wl2.h} (83%) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 00063466657ca..a7cfc2d2a0998 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -199,9 +199,9 @@ template("embedder") { } else { sources += [ "flutter_tizen_ecore.cc", - "flutter_tizen_window_ecore_wl2.cc", "tizen_renderer_ecore_wl2.cc", "tizen_vsync_waiter.cc", + "tizen_window_ecore_wl2.cc", ] libs += [ diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index c59ed9316d5e5..ce3d24096ae39 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -58,7 +58,7 @@ std::string text_clipboard = ""; } // namespace PlatformChannel::PlatformChannel(BinaryMessenger* messenger, - FlutterTizenWindow* flutter_tizen_window) + TizenWindow* flutter_tizen_window) : channel_(std::make_unique>( messenger, kChannelName, diff --git a/shell/platform/tizen/channels/platform_channel.h b/shell/platform/tizen/channels/platform_channel.h index b99c0c6c0e1aa..f344560fb61d0 100644 --- a/shell/platform/tizen/channels/platform_channel.h +++ b/shell/platform/tizen/channels/platform_channel.h @@ -11,7 +11,7 @@ #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" +#include "flutter/shell/platform/tizen/tizen_window.h" #include "rapidjson/document.h" namespace flutter { @@ -19,7 +19,7 @@ namespace flutter { class PlatformChannel { public: explicit PlatformChannel(BinaryMessenger* messenger, - FlutterTizenWindow* flutter_tizen_window); + TizenWindow* flutter_tizen_window); virtual ~PlatformChannel(); private: @@ -38,7 +38,7 @@ class PlatformChannel { // A reference to the window object managed by FlutterTizenView. // This can be nullptr if the engine is running in headless mode. - FlutterTizenWindow* flutter_tizen_window_; + TizenWindow* flutter_tizen_window_; }; } // namespace flutter diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index 9445f2d47a9db..1c7f41498c430 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -17,7 +17,7 @@ constexpr char kChannelName[] = "tizen/internal/window"; } // namespace WindowChannel::WindowChannel(BinaryMessenger* messenger, - FlutterTizenWindow* flutter_tizen_window) + TizenWindow* flutter_tizen_window) : flutter_tizen_window_(flutter_tizen_window) { channel_ = std::make_unique>( messenger, kChannelName, &StandardMethodCodec::GetInstance()); @@ -36,8 +36,7 @@ void WindowChannel::HandleMethodCall( const std::string& method_name = method_call.method_name(); if (method_name == "getWindowGeometry") { - FlutterTizenWindow::Geometry geometry = - flutter_tizen_window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = flutter_tizen_window_->GetWindowGeometry(); EncodableMap map; map[EncodableValue("x")] = EncodableValue(geometry.left); map[EncodableValue("y")] = EncodableValue(geometry.top); @@ -59,8 +58,7 @@ void WindowChannel::HandleMethodCall( EncodableValueHolder width(arguments, "width"); EncodableValueHolder height(arguments, "height"); - FlutterTizenWindow::Geometry geometry = - flutter_tizen_window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = flutter_tizen_window_->GetWindowGeometry(); // FIXME: Use SetWindowGeometry() instead of OnGeometryChanged() // After the SetWindowGeometry was successfully executed, I expected a // handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't. @@ -70,8 +68,7 @@ void WindowChannel::HandleMethodCall( result->Success(); #endif } else if (method_name == "getScreenGeometry") { - FlutterTizenWindow::Geometry geometry = - flutter_tizen_window_->GetScreenGeometry(); + TizenWindow::Geometry geometry = flutter_tizen_window_->GetScreenGeometry(); EncodableMap map; map[EncodableValue("width")] = EncodableValue(geometry.width); map[EncodableValue("height")] = EncodableValue(geometry.height); diff --git a/shell/platform/tizen/channels/window_channel.h b/shell/platform/tizen/channels/window_channel.h index 9b0c2c3e1f9fa..d91dd1ffafd4c 100644 --- a/shell/platform/tizen/channels/window_channel.h +++ b/shell/platform/tizen/channels/window_channel.h @@ -10,7 +10,7 @@ #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" +#include "flutter/shell/platform/tizen/tizen_window.h" namespace flutter { @@ -18,7 +18,7 @@ namespace flutter { class WindowChannel { public: explicit WindowChannel(BinaryMessenger* messenger, - FlutterTizenWindow* flutter_tizen_window); + TizenWindow* flutter_tizen_window); virtual ~WindowChannel(); private: @@ -28,7 +28,7 @@ class WindowChannel { std::unique_ptr> channel_; // A reference to the renderer object managed by FlutterTizenView. - FlutterTizenWindow* flutter_tizen_window_; + TizenWindow* flutter_tizen_window_; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 460ced0ef4123..33ee3efdb2800 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -13,8 +13,7 @@ #include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" - -#include "flutter/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h" +#include "flutter/shell/platform/tizen/tizen_window.h" namespace { diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index d9ea63b93bc05..72aed8df57f7e 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -7,8 +7,7 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/flutter_tizen_view.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h" -#include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_window_ecore_wl2.h" namespace { @@ -26,24 +25,21 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { - std::unique_ptr flutter_tizen_window = - std::make_unique( - flutter::FlutterTizenWindow::Geometry( + std::unique_ptr flutter_tizen_window = + std::make_unique( + flutter::TizenWindow::Geometry( {window_properties.x, window_properties.y, window_properties.width, window_properties.height}), window_properties.transparent, window_properties.focusable, window_properties.top_level); // Take ownership of the engine, starting it if necessary. - FT_LOG(Error) << "create view"; auto flutter_tizen_view = std::make_unique( std::move(flutter_tizen_window)); - FT_LOG(Error) << "Set engine to view"; flutter_tizen_view->SetFlutterTizenEngine( std::unique_ptr(EngineFromHandle(engine))); - FT_LOG(Error) << "Create render surface"; flutter_tizen_view->CreateRenderSurface(); if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index d4bc2275ea58e..ef85927d3ccaa 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -33,7 +33,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( // window_properties.focusable, window_properties.top_level); // auto flutter_tizen_view_ = std::make_unique(); - // flutter::FlutterTizenWindowEcoreWl2 window; + // flutter::TizenWindowEcoreWl2 window; flutter_tizen_view_->SetFlutterTizenEngine( std::unique_ptr(EngineFromHandle(engine))); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 2e9c4bd7486a2..9a9ca2414a0c6 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -540,7 +540,7 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions( bridge->GetFlutterPlatformNodeDelegateFromID(0); std::shared_ptr window = FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock(); - FlutterTizenWindow::Geometry geometry = + TizenWindow::Geometry geometry = engine->flutter_tizen_view_->flutter_tizen_window() ->GetWindowGeometry(); window->SetGeometry(geometry.left, geometry.top, geometry.width, diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 3bbfa217b2ce8..bf8a2ff7a0d59 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -5,8 +5,8 @@ #include "flutter_tizen_view.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" #include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_window.h" namespace { @@ -41,7 +41,7 @@ const std::vector kBindableSystemKeys = { namespace flutter { FlutterTizenView::FlutterTizenView( - std::unique_ptr flutter_tizen_window) + std::unique_ptr flutter_tizen_window) : flutter_tizen_window_(std::move(flutter_tizen_window)) { flutter_tizen_window_->SetFlutterTizenView(this); } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index c787432702722..9a6c23bdcd1e7 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -14,13 +14,13 @@ #include "flutter/shell/platform/tizen/channels/text_input_channel.h" #include "flutter/shell/platform/tizen/channels/window_channel.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" +#include "flutter/shell/platform/tizen/tizen_window.h" namespace flutter { class FlutterTizenView { public: - FlutterTizenView(std::unique_ptr flutter_tizen_window); + FlutterTizenView(std::unique_ptr flutter_tizen_window); ~FlutterTizenView(); @@ -33,9 +33,7 @@ class FlutterTizenView { return flutter_tizen_engine_.get(); } - FlutterTizenWindow* flutter_tizen_window() { - return flutter_tizen_window_.get(); - } + TizenWindow* flutter_tizen_window() { return flutter_tizen_window_.get(); } // Creates rendering surface for Flutter engine to draw into. // Should be called before calling FlutterEngineRun using this view. @@ -121,7 +119,7 @@ class FlutterTizenView { std::unique_ptr flutter_tizen_engine_; // The window associated with this view. - std::unique_ptr flutter_tizen_window_; + std::unique_ptr flutter_tizen_window_; // The plugin registrar managing internal plugins. std::unique_ptr internal_plugin_registrar_; diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index df1f1504d40b4..51352e5e1ac41 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -4,8 +4,8 @@ #include "tizen_input_method_context.h" -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" #include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_window.h" namespace { @@ -104,7 +104,7 @@ T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { namespace flutter { TizenInputMethodContext::TizenInputMethodContext( - FlutterTizenWindow* flutter_tizen_window) + TizenWindow* flutter_tizen_window) : flutter_tizen_window_(flutter_tizen_window) { FT_ASSERT(flutter_tizen_window_); ecore_imf_init(); diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 9374f42f8aeca..c2a3c09092cec 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -21,7 +21,7 @@ using OnPreeditStart = std::function; using OnPreeditEnd = std::function; using OnInputPanelStateChanged = std::function; -class FlutterTizenWindow; +class TizenWindow; struct InputPanelGeometry { int32_t x = 0, y = 0, w = 0, h = 0; @@ -29,7 +29,7 @@ struct InputPanelGeometry { class TizenInputMethodContext { public: - TizenInputMethodContext(FlutterTizenWindow* flutter_tizen_window); + TizenInputMethodContext(TizenWindow* flutter_tizen_window); ~TizenInputMethodContext(); bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); @@ -69,7 +69,7 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); - FlutterTizenWindow* flutter_tizen_window_ = nullptr; + TizenWindow* flutter_tizen_window_ = nullptr; Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; OnPreeditChanged on_preedit_changed_; diff --git a/shell/platform/tizen/flutter_tizen_window.h b/shell/platform/tizen/tizen_window.h similarity index 88% rename from shell/platform/tizen/flutter_tizen_window.h rename to shell/platform/tizen/tizen_window.h index c8b1f51c55dd4..830a1bd060648 100644 --- a/shell/platform/tizen/flutter_tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -14,15 +14,15 @@ namespace flutter { class FlutterTizenView; -class FlutterTizenWindow { +class TizenWindow { public: struct Geometry { int32_t left = 0, top = 0, width = 0, height = 0; }; - FlutterTizenWindow(); + TizenWindow(); - virtual ~FlutterTizenWindow() = default; + virtual ~TizenWindow() = default; // Sets the delegate used to communicate state changes from window to view // such as key presses, mouse position updates etc. @@ -68,10 +68,10 @@ class FlutterTizenWindow { virtual void OnGeometryChanged(Geometry geometry) = 0; protected: - explicit FlutterTizenWindow(Geometry geometry, - bool transparent, - bool focusable, - bool top_level) + explicit TizenWindow(Geometry geometry, + bool transparent, + bool focusable, + bool top_level) : initial_geometry_(geometry), transparent_(transparent), focusable_(focusable), diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc similarity index 85% rename from shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc rename to shell/platform/tizen/tizen_window_ecore_wl2.cc index d9ae354ca0feb..df98e9a0b19c2 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter_tizen_window_ecore_wl2.h" +#include "tizen_window_ecore_wl2.h" #include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" @@ -18,11 +18,11 @@ static const int kScrollOffsetMultiplier = 20; namespace flutter { -FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, - bool transparent, - bool focusable, - bool top_level) - : FlutterTizenWindow(geometry, transparent, focusable, top_level) { +TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, + bool transparent, + bool focusable, + bool top_level) + : TizenWindow(geometry, transparent, focusable, top_level) { if (!CreateWindow()) { FT_LOG(Error) << "Failed to create platform window"; return; @@ -33,11 +33,11 @@ FlutterTizenWindowEcoreWl2::FlutterTizenWindowEcoreWl2(Geometry geometry, Show(); } -FlutterTizenWindowEcoreWl2::~FlutterTizenWindowEcoreWl2() { +TizenWindowEcoreWl2::~TizenWindowEcoreWl2() { DestroyEcoreWl2(); } -bool FlutterTizenWindowEcoreWl2::CreateWindow() { +bool TizenWindowEcoreWl2::CreateWindow() { if (!ecore_wl2_init()) { FT_LOG(Error) << "Could not initialize Ecore Wl2."; return false; @@ -77,7 +77,7 @@ bool FlutterTizenWindowEcoreWl2::CreateWindow() { return ecore_wl2_egl_window_ && wl2_display_; } -void FlutterTizenWindowEcoreWl2::SetWindowOptions() { +void TizenWindowEcoreWl2::SetWindowOptions() { // Change the window type to use the tizen policy for notification window // according to top_level_. // Note: ECORE_WL2_WINDOW_TYPE_TOPLEVEL is similar to "ELM_WIN_BASIC" and it @@ -116,11 +116,11 @@ void FlutterTizenWindowEcoreWl2::SetWindowOptions() { sizeof(rotations) / sizeof(int)); } -void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { +void TizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* rotation_event = reinterpret_cast(event); @@ -141,7 +141,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* configure_event = reinterpret_cast(event); @@ -160,7 +160,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* button_event = reinterpret_cast(event); @@ -178,7 +178,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* button_event = reinterpret_cast(event); @@ -196,7 +196,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* move_event = reinterpret_cast(event); if (move_event->window == self->GetWindowId()) { @@ -213,7 +213,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* wheel_event = reinterpret_cast(event); if (wheel_event->window == self->GetWindowId()) { @@ -240,7 +240,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { @@ -255,7 +255,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { ecore_event_handlers_.push_back(ecore_event_handler_add( ECORE_EVENT_KEY_UP, [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); + auto* self = reinterpret_cast(data); if (self->flutter_tizen_view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { @@ -268,7 +268,7 @@ void FlutterTizenWindowEcoreWl2::RegisterEventHandlers() { this)); } -void FlutterTizenWindowEcoreWl2::DestroyEcoreWl2() { +void TizenWindowEcoreWl2::DestroyEcoreWl2() { if (ecore_wl2_egl_window_) { ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); ecore_wl2_egl_window_ = nullptr; @@ -286,14 +286,14 @@ void FlutterTizenWindowEcoreWl2::DestroyEcoreWl2() { ecore_wl2_shutdown(); } -FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetWindowGeometry() { +TizenWindow::Geometry TizenWindowEcoreWl2::GetWindowGeometry() { Geometry result; ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.left, &result.top, &result.width, &result.height); return result; } -void FlutterTizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { +void TizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, geometry.top, geometry.width, geometry.height); // FIXME : I refer to https://github.com/flutter-tizen/engine/pull/201, @@ -302,18 +302,18 @@ void FlutterTizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, geometry.top); } -FlutterTizenWindow::Geometry FlutterTizenWindowEcoreWl2::GetScreenGeometry() { +TizenWindow::Geometry TizenWindowEcoreWl2::GetScreenGeometry() { Geometry result = {}; ecore_wl2_display_screen_size_get(ecore_wl2_display_, &result.width, &result.height); return result; } -int32_t FlutterTizenWindowEcoreWl2::GetRotatoin() { +int32_t TizenWindowEcoreWl2::GetRotatoin() { return ecore_wl2_window_rotation_get(ecore_wl2_window_); } -int32_t FlutterTizenWindowEcoreWl2::GetDpi() { +int32_t TizenWindowEcoreWl2::GetDpi() { auto* output = ecore_wl2_window_output_find(ecore_wl2_window_); if (!output) { FT_LOG(Error) << "Could not find an output associated with the window."; @@ -322,37 +322,35 @@ int32_t FlutterTizenWindowEcoreWl2::GetDpi() { return ecore_wl2_output_dpi_get(output); } -uintptr_t FlutterTizenWindowEcoreWl2::GetWindowId() { +uintptr_t TizenWindowEcoreWl2::GetWindowId() { return ecore_wl2_window_id_get(ecore_wl2_window_); } -void FlutterTizenWindowEcoreWl2::ResizeRenderTargetWithRotation( - Geometry geometry, - int32_t angle) { +void TizenWindowEcoreWl2::ResizeRenderTargetWithRotation(Geometry geometry, + int32_t angle) { ecore_wl2_egl_window_resize_with_rotation( ecore_wl2_egl_window_, geometry.left, geometry.top, geometry.width, geometry.height, angle); } -void FlutterTizenWindowEcoreWl2::SetPreferredOrientations( +void TizenWindowEcoreWl2::SetPreferredOrientations( const std::vector& rotations) { ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations.data(), rotations.size()); } -void FlutterTizenWindowEcoreWl2::BindKeys( - const std::vector& keys) { +void TizenWindowEcoreWl2::BindKeys(const std::vector& keys) { for (const auto& key : keys) { ecore_wl2_window_keygrab_set(ecore_wl2_window_, key.c_str(), 0, 0, 0, ECORE_WL2_WINDOW_KEYGRAB_TOPMOST); } } -void FlutterTizenWindowEcoreWl2::Show() { +void TizenWindowEcoreWl2::Show() { ecore_wl2_window_show(ecore_wl2_window_); } -void FlutterTizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { +void TizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { // This implementation mimics the situation in which the handler of // ECORE_WL2_EVENT_WINDOW_CONFIGURE is called. SetWindowGeometry(geometry); @@ -360,7 +358,7 @@ void FlutterTizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { geometry.height); } -void FlutterTizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { +void TizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { Eina_Iterator* iter = ecore_wl2_display_globals_get(ecore_wl2_display_); struct wl_registry* registry = ecore_wl2_display_registry_get(ecore_wl2_display_); diff --git a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h similarity index 83% rename from shell/platform/tizen/flutter_tizen_window_ecore_wl2.h rename to shell/platform/tizen/tizen_window_ecore_wl2.h index 3468c151f83eb..93cff5f417469 100644 --- a/shell/platform/tizen/flutter_tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -6,7 +6,7 @@ #ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ #define EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ -#include "flutter/shell/platform/tizen/flutter_tizen_window.h" +#include "flutter/shell/platform/tizen/tizen_window.h" #define EFL_BETA_API_SUPPORT #include @@ -14,14 +14,14 @@ namespace flutter { -class FlutterTizenWindowEcoreWl2 : public FlutterTizenWindow { +class TizenWindowEcoreWl2 : public TizenWindow { public: - FlutterTizenWindowEcoreWl2(Geometry geometry, - bool transparent, - bool focusable, - bool top_level); + TizenWindowEcoreWl2(Geometry geometry, + bool transparent, + bool focusable, + bool top_level); - ~FlutterTizenWindowEcoreWl2(); + ~TizenWindowEcoreWl2(); Geometry GetWindowGeometry() override; From 745212ac5ae10293f634639d338c2b9acebfa003 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 20 Apr 2022 18:14:33 +0900 Subject: [PATCH 12/32] Cleanup minor things Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_view.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index bf8a2ff7a0d59..16f8509fbf49b 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -36,6 +36,7 @@ const std::vector kBindableSystemKeys = { "XF86Subtitle", "XF86PlayBack", "XF86ChannelGuide", "XF86Caption", "XF86Exit", }; + } // namespace namespace flutter { @@ -46,9 +47,7 @@ FlutterTizenView::FlutterTizenView( flutter_tizen_window_->SetFlutterTizenView(this); } -FlutterTizenView::~FlutterTizenView() { - FT_LOG(Info) << "enter"; -} +FlutterTizenView::~FlutterTizenView() {} void FlutterTizenView::SetFlutterTizenEngine( std::unique_ptr flutter_tizen_engine) { @@ -147,8 +146,6 @@ void FlutterTizenView::OnRotate(int32_t degree) { 0.0, 0.0, 1.0 // perspective }; - // touch_event_handler_->rotation = degree; - if (rotation_degree_ == 90 || rotation_degree_ == 270) { std::swap(width, height); } From 30746fa375b9acea22d2ca7c28a6a93e63fe6aad Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 21 Apr 2022 19:32:47 +0900 Subject: [PATCH 13/32] Implement TizenWindowElementary Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 7 +- shell/platform/tizen/flutter_tizen_ecore.cc | 2 +- .../tizen/flutter_tizen_elementary.cc | 34 +- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- shell/platform/tizen/flutter_tizen_engine.h | 2 +- shell/platform/tizen/flutter_tizen_view.cc | 4 +- shell/platform/tizen/tizen_event_loop.cc | 28 +- shell/platform/tizen/tizen_event_loop.h | 4 +- ...rer_ecore_wl2.cc => tizen_renderer_egl.cc} | 409 +++++++++--------- ...derer_ecore_wl2.h => tizen_renderer_egl.h} | 8 +- .../platform/tizen/tizen_renderer_evas_gl.cc | 352 ++++----------- shell/platform/tizen/tizen_renderer_evas_gl.h | 62 +-- shell/platform/tizen/tizen_window.h | 2 +- .../platform/tizen/tizen_window_ecore_wl2.cc | 10 +- shell/platform/tizen/tizen_window_ecore_wl2.h | 6 +- .../platform/tizen/tizen_window_elementary.cc | 348 +++++++++++++++ .../platform/tizen/tizen_window_elementary.h | 78 ++++ 17 files changed, 809 insertions(+), 549 deletions(-) rename shell/platform/tizen/{tizen_renderer_ecore_wl2.cc => tizen_renderer_egl.cc} (91%) rename shell/platform/tizen/{tizen_renderer_ecore_wl2.h => tizen_renderer_egl.h} (87%) create mode 100644 shell/platform/tizen/tizen_window_elementary.cc create mode 100644 shell/platform/tizen/tizen_window_elementary.h diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index a7cfc2d2a0998..6bd1b7055ad5b 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -186,7 +186,8 @@ template("embedder") { if (use_evas_gl_renderer) { sources += [ "flutter_tizen_elementary.cc", - "tizen_renderer_evas_gl.cc" + "tizen_renderer_evas_gl.cc", + "tizen_window_elementary.cc" ] libs += [ @@ -199,7 +200,7 @@ template("embedder") { } else { sources += [ "flutter_tizen_ecore.cc", - "tizen_renderer_ecore_wl2.cc", + "tizen_renderer_egl.cc", "tizen_vsync_waiter.cc", "tizen_window_ecore_wl2.cc", ] @@ -236,7 +237,7 @@ embedder("flutter_tizen_mobile") { embedder("flutter_tizen_wearable") { target_type = "shared_library" - use_evas_gl_renderer = false + use_evas_gl_renderer = true defines = [ "WEARABLE_PROFILE" ] } diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index 72aed8df57f7e..00a6a4d26ecc5 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -1,4 +1,4 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index ef85927d3ccaa..3fe7125d515fe 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -1,4 +1,4 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,7 +7,7 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/flutter_tizen_view.h" -#include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_window_elementary.h" namespace { @@ -25,18 +25,28 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { - // Todo : Use view and window imple; + std::unique_ptr flutter_tizen_window = + std::make_unique( + flutter::TizenWindow::Geometry( + {window_properties.x, window_properties.y, + window_properties.width, window_properties.height}), + window_properties.transparent, window_properties.focusable, + window_properties.top_level); + + // Take ownership of the engine, starting it if necessary. + auto flutter_tizen_view = std::make_unique( + std::move(flutter_tizen_window)); + + flutter_tizen_view->SetFlutterTizenEngine( + std::unique_ptr(EngineFromHandle(engine))); - // EngineFromHandle(engine)->InitializeRenderer( - // window_properties.x, window_properties.y, window_properties.width, - // window_properties.height, window_properties.transparent, - // window_properties.focusable, window_properties.top_level); - // auto flutter_tizen_view_ = std::make_unique(); + flutter_tizen_view->CreateRenderSurface(); - // flutter::TizenWindowEcoreWl2 window; + if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { + flutter_tizen_view->flutter_tizen_engine()->RunEngine(nullptr); + } - flutter_tizen_view_->SetFlutterTizenEngine( - std::unique_ptr(EngineFromHandle(engine))); + flutter_tizen_view->SendInitialGeometry(); - return HandleForView(flutter_tizen_view_.release()); + return HandleForView(flutter_tizen_view.release()); } diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 9a9ca2414a0c6..66c8bf316def9 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -79,7 +79,7 @@ FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) }, renderer_.get()); #else - renderer_ = std::make_unique(); + renderer_ = std::make_unique(); tizen_vsync_waiter_ = std::make_unique(this); #endif diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index cca99e88c622c..9a8e318dcdf61 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -30,7 +30,7 @@ #ifdef TIZEN_RENDERER_EVAS_GL #include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h" #else -#include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h" +#include "flutter/shell/platform/tizen/tizen_renderer_egl.h" #include "flutter/shell/platform/tizen/tizen_vsync_waiter.h" #endif diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 16f8509fbf49b..8da9c3b1cb1c6 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -66,7 +66,7 @@ void FlutterTizenView::SetFlutterTizenEngine( text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), std::make_unique(flutter_tizen_window_.get())); - OnRotate(flutter_tizen_window_->GetRotatoin()); + OnRotate(flutter_tizen_window_->GetRotation()); } void FlutterTizenView::CreateRenderSurface() { @@ -237,7 +237,7 @@ void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { } void FlutterTizenView::SendInitialGeometry() { - OnRotate(flutter_tizen_window_->GetRotatoin()); + OnRotate(flutter_tizen_window_->GetRotation()); } void FlutterTizenView::SendWindowMetrics(int32_t left, diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index 6502ecd9bff3d..45c0d90a73814 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -117,20 +117,16 @@ TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id, TizenRenderer* renderer) : TizenEventLoop(main_thread_id, get_current_time, on_task_expired), renderer_(renderer) { - evas_object_image_pixels_get_callback_set( - static_cast(renderer_)->GetImageHandle(), - [](void* data, Evas_Object* o) { // Render callback - auto* self = static_cast(data); - { - std::lock_guard lock(self->expired_tasks_mutex_); - for (const Task& task : self->expired_tasks_) { - self->on_task_expired_(&task.task); - } - self->expired_tasks_.clear(); - } - self->has_pending_renderer_callback_ = false; - }, - this); + static_cast(renderer_)->SetOnPixelsDirty([this]() { + { + std::lock_guard lock(expired_tasks_mutex_); + for (const auto& task : expired_tasks_) { + on_task_expired_(&task.task); + } + expired_tasks_.clear(); + } + has_pending_renderer_callback_ = false; + }); } TizenRenderEventLoop::~TizenRenderEventLoop() {} @@ -138,9 +134,7 @@ TizenRenderEventLoop::~TizenRenderEventLoop() {} void TizenRenderEventLoop::OnTaskExpired() { std::lock_guard lock(expired_tasks_mutex_); if (!has_pending_renderer_callback_ && !expired_tasks_.empty()) { - evas_object_image_pixels_dirty_set( - static_cast(renderer_)->GetImageHandle(), - EINA_TRUE); + static_cast(renderer_)->MarkPixelsDirty(); has_pending_renderer_callback_ = true; } } diff --git a/shell/platform/tizen/tizen_event_loop.h b/shell/platform/tizen/tizen_event_loop.h index 32aa1cd1668b8..dae7c3e2e3b53 100644 --- a/shell/platform/tizen/tizen_event_loop.h +++ b/shell/platform/tizen/tizen_event_loop.h @@ -22,8 +22,6 @@ namespace flutter { typedef uint64_t (*CurrentTimeProc)(); -class TizenRenderer; - class TizenEventLoop { public: using TaskExpiredCallback = std::function; @@ -91,6 +89,8 @@ class TizenPlatformEventLoop : public TizenEventLoop { }; #ifdef TIZEN_RENDERER_EVAS_GL +class TizenRenderer; + class TizenRenderEventLoop : public TizenEventLoop { public: TizenRenderEventLoop(std::thread::id main_thread_id, diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_egl.cc similarity index 91% rename from shell/platform/tizen/tizen_renderer_ecore_wl2.cc rename to shell/platform/tizen/tizen_renderer_egl.cc index 20934faf3fb49..d15849ea7acc9 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_egl.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "tizen_renderer_ecore_wl2.h" +#include "tizen_renderer_egl.h" +#include #include #include @@ -11,15 +12,173 @@ namespace flutter { -TizenRendererEcoreWl2::TizenRendererEcoreWl2() { - FT_LOG(Error) << "enter"; -} +TizenRendererEgl::TizenRendererEgl() {} -TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { +TizenRendererEgl::~TizenRendererEgl() { DestroySurface(); } -bool TizenRendererEcoreWl2::OnMakeCurrent() { +bool TizenRendererEgl::CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) { + egl_display_ = eglGetDisplay(static_cast(render_target_display)); + + if (EGL_NO_DISPLAY == egl_display_) { + PrintEGLError(); + FT_LOG(Error) << "Could not get EGL display."; + return false; + } + + if (!ChooseEGLConfiguration()) { + FT_LOG(Error) << "Could not choose an EGL configuration."; + return false; + } + + egl_extension_str_ = eglQueryString(egl_display_, EGL_EXTENSIONS); + + { + const EGLint attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + + egl_context_ = + eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, attribs); + if (egl_context_ == EGL_NO_CONTEXT) { + PrintEGLError(); + FT_LOG(Error) << "Could not create an onscreen context."; + return false; + } + + egl_resource_context_ = + eglCreateContext(egl_display_, egl_config_, egl_context_, attribs); + if (egl_resource_context_ == EGL_NO_CONTEXT) { + PrintEGLError(); + FT_LOG(Error) << "Could not create an offscreen context."; + return false; + } + } + + { + const EGLint attribs[] = {EGL_NONE}; + + auto* egl_window = + static_cast(ecore_wl2_egl_window_native_get( + static_cast(render_target))); + egl_surface_ = + eglCreateWindowSurface(egl_display_, egl_config_, egl_window, attribs); + if (egl_surface_ == EGL_NO_SURFACE) { + FT_LOG(Error) << "Could not create an onscreen window surface."; + return false; + } + } + + { + const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; + + egl_resource_surface_ = + eglCreatePbufferSurface(egl_display_, egl_config_, attribs); + if (egl_resource_surface_ == EGL_NO_SURFACE) { + FT_LOG(Error) << "Could not create an offscreen window surface."; + return false; + } + } + is_valid_ = true; + FT_LOG(Error) << "done"; + return true; +} + +void TizenRendererEgl::DestroySurface() { + if (egl_display_) { + eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT); + + if (EGL_NO_SURFACE != egl_surface_) { + eglDestroySurface(egl_display_, egl_surface_); + egl_surface_ = EGL_NO_SURFACE; + } + + if (EGL_NO_CONTEXT != egl_context_) { + eglDestroyContext(egl_display_, egl_context_); + egl_context_ = EGL_NO_CONTEXT; + } + + if (EGL_NO_SURFACE != egl_resource_surface_) { + eglDestroySurface(egl_display_, egl_resource_surface_); + egl_resource_surface_ = EGL_NO_SURFACE; + } + + if (EGL_NO_CONTEXT != egl_resource_context_) { + eglDestroyContext(egl_display_, egl_resource_context_); + egl_resource_context_ = EGL_NO_CONTEXT; + } + + eglTerminate(egl_display_); + egl_display_ = EGL_NO_DISPLAY; + } +} + +bool TizenRendererEgl::ChooseEGLConfiguration() { + EGLint config_attribs[] = { + // clang-format off + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, EGL_DONT_CARE, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, + EGL_SAMPLES, EGL_DONT_CARE, + EGL_NONE + // clang-format on + }; + + if (!eglInitialize(egl_display_, nullptr, nullptr)) { + PrintEGLError(); + FT_LOG(Error) << "Could not initialize the EGL display."; + return false; + } + + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + PrintEGLError(); + FT_LOG(Error) << "Could not bind the ES API."; + return false; + } + + EGLint config_size = 0; + if (!eglGetConfigs(egl_display_, nullptr, 0, &config_size)) { + PrintEGLError(); + FT_LOG(Error) << "Could not query framebuffer configurations."; + return false; + } + + EGLConfig* configs = (EGLConfig*)calloc(config_size, sizeof(EGLConfig)); + EGLint num_config; + if (!eglChooseConfig(egl_display_, config_attribs, configs, config_size, + &num_config)) { + free(configs); + PrintEGLError(); + FT_LOG(Error) << "No matching configurations found."; + return false; + } + + int buffer_size = 32; + EGLint size; + for (int i = 0; i < num_config; i++) { + eglGetConfigAttrib(egl_display_, configs[i], EGL_BUFFER_SIZE, &size); + if (buffer_size == size) { + egl_config_ = configs[i]; + break; + } + } + free(configs); + if (!egl_config_) { + FT_LOG(Error) << "No matching configuration found."; + return false; + } + + return true; +} + +bool TizenRendererEgl::OnMakeCurrent() { if (!IsValid()) { return false; } @@ -32,7 +191,7 @@ bool TizenRendererEcoreWl2::OnMakeCurrent() { return true; } -bool TizenRendererEcoreWl2::OnClearCurrent() { +bool TizenRendererEgl::OnClearCurrent() { if (!IsValid()) { return false; } @@ -45,7 +204,7 @@ bool TizenRendererEcoreWl2::OnClearCurrent() { return true; } -bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { +bool TizenRendererEgl::OnMakeResourceCurrent() { if (!IsValid()) { return false; } @@ -58,7 +217,7 @@ bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { return true; } -bool TizenRendererEcoreWl2::OnPresent() { +bool TizenRendererEgl::OnPresent() { if (!IsValid()) { return false; } @@ -71,14 +230,47 @@ bool TizenRendererEcoreWl2::OnPresent() { return true; } -uint32_t TizenRendererEcoreWl2::OnGetFBO() { +uint32_t TizenRendererEgl::OnGetFBO() { if (!IsValid()) { return 999; } return 0; } -void* TizenRendererEcoreWl2::OnProcResolver(const char* name) { +void TizenRendererEgl::PrintEGLError() { + EGLint error = eglGetError(); + switch (error) { +#define CASE_PRINT(value) \ + case value: { \ + FT_LOG(Error) << "EGL error: " << #value; \ + break; \ + } + CASE_PRINT(EGL_NOT_INITIALIZED) + CASE_PRINT(EGL_BAD_ACCESS) + CASE_PRINT(EGL_BAD_ALLOC) + CASE_PRINT(EGL_BAD_ATTRIBUTE) + CASE_PRINT(EGL_BAD_CONTEXT) + CASE_PRINT(EGL_BAD_CONFIG) + CASE_PRINT(EGL_BAD_CURRENT_SURFACE) + CASE_PRINT(EGL_BAD_DISPLAY) + CASE_PRINT(EGL_BAD_SURFACE) + CASE_PRINT(EGL_BAD_MATCH) + CASE_PRINT(EGL_BAD_PARAMETER) + CASE_PRINT(EGL_BAD_NATIVE_PIXMAP) + CASE_PRINT(EGL_BAD_NATIVE_WINDOW) + CASE_PRINT(EGL_CONTEXT_LOST) +#undef CASE_PRINT + default: { + FT_LOG(Error) << "Unknown EGL error: " << error; + } + } +} + +bool TizenRendererEgl::IsSupportedExtension(const char* name) { + return strstr(egl_extension_str_.c_str(), name); +} + +void* TizenRendererEgl::OnProcResolver(const char* name) { auto address = eglGetProcAddress(name); if (address != nullptr) { return reinterpret_cast(address); @@ -199,199 +391,4 @@ void* TizenRendererEcoreWl2::OnProcResolver(const char* name) { FT_LOG(Warn) << "Could not resolve: " << name; return nullptr; } - -bool TizenRendererEcoreWl2::CreateSurface(void* render_target, - void* render_target_display, - int32_t width, - int32_t height) { - FT_LOG(Error) << "enter"; - egl_display_ = eglGetDisplay(static_cast(render_target_display)); - - if (EGL_NO_DISPLAY == egl_display_) { - PrintEGLError(); - FT_LOG(Error) << "Could not get EGL display."; - return false; - } - - if (!ChooseEGLConfiguration()) { - FT_LOG(Error) << "Could not choose an EGL configuration."; - return false; - } - - egl_extension_str_ = eglQueryString(egl_display_, EGL_EXTENSIONS); - - { - const EGLint attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; - - egl_context_ = - eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, attribs); - if (egl_context_ == EGL_NO_CONTEXT) { - PrintEGLError(); - FT_LOG(Error) << "Could not create an onscreen context."; - return false; - } - - egl_resource_context_ = - eglCreateContext(egl_display_, egl_config_, egl_context_, attribs); - if (egl_resource_context_ == EGL_NO_CONTEXT) { - PrintEGLError(); - FT_LOG(Error) << "Could not create an offscreen context."; - return false; - } - } - - { - const EGLint attribs[] = {EGL_NONE}; - - auto* egl_window = - static_cast(ecore_wl2_egl_window_native_get( - static_cast(render_target))); - egl_surface_ = - eglCreateWindowSurface(egl_display_, egl_config_, egl_window, attribs); - if (egl_surface_ == EGL_NO_SURFACE) { - FT_LOG(Error) << "Could not create an onscreen window surface."; - return false; - } - } - - { - const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; - - egl_resource_surface_ = - eglCreatePbufferSurface(egl_display_, egl_config_, attribs); - if (egl_resource_surface_ == EGL_NO_SURFACE) { - FT_LOG(Error) << "Could not create an offscreen window surface."; - return false; - } - } - is_valid_ = true; - FT_LOG(Error) << "done"; - return true; -} - -bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { - EGLint config_attribs[] = { - // clang-format off - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, - EGL_SAMPLES, EGL_DONT_CARE, - EGL_NONE - // clang-format on - }; - - if (!eglInitialize(egl_display_, nullptr, nullptr)) { - PrintEGLError(); - FT_LOG(Error) << "Could not initialize the EGL display."; - return false; - } - - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - PrintEGLError(); - FT_LOG(Error) << "Could not bind the ES API."; - return false; - } - - EGLint config_size = 0; - if (!eglGetConfigs(egl_display_, nullptr, 0, &config_size)) { - PrintEGLError(); - FT_LOG(Error) << "Could not query framebuffer configurations."; - return false; - } - - EGLConfig* configs = (EGLConfig*)calloc(config_size, sizeof(EGLConfig)); - EGLint num_config; - if (!eglChooseConfig(egl_display_, config_attribs, configs, config_size, - &num_config)) { - free(configs); - PrintEGLError(); - FT_LOG(Error) << "No matching configurations found."; - return false; - } - - int buffer_size = 32; - EGLint size; - for (int i = 0; i < num_config; i++) { - eglGetConfigAttrib(egl_display_, configs[i], EGL_BUFFER_SIZE, &size); - if (buffer_size == size) { - egl_config_ = configs[i]; - break; - } - } - free(configs); - if (!egl_config_) { - FT_LOG(Error) << "No matching configuration found."; - return false; - } - - return true; -} - -void TizenRendererEcoreWl2::PrintEGLError() { - EGLint error = eglGetError(); - switch (error) { -#define CASE_PRINT(value) \ - case value: { \ - FT_LOG(Error) << "EGL error: " << #value; \ - break; \ - } - CASE_PRINT(EGL_NOT_INITIALIZED) - CASE_PRINT(EGL_BAD_ACCESS) - CASE_PRINT(EGL_BAD_ALLOC) - CASE_PRINT(EGL_BAD_ATTRIBUTE) - CASE_PRINT(EGL_BAD_CONTEXT) - CASE_PRINT(EGL_BAD_CONFIG) - CASE_PRINT(EGL_BAD_CURRENT_SURFACE) - CASE_PRINT(EGL_BAD_DISPLAY) - CASE_PRINT(EGL_BAD_SURFACE) - CASE_PRINT(EGL_BAD_MATCH) - CASE_PRINT(EGL_BAD_PARAMETER) - CASE_PRINT(EGL_BAD_NATIVE_PIXMAP) - CASE_PRINT(EGL_BAD_NATIVE_WINDOW) - CASE_PRINT(EGL_CONTEXT_LOST) -#undef CASE_PRINT - default: { - FT_LOG(Error) << "Unknown EGL error: " << error; - } - } -} - -void TizenRendererEcoreWl2::DestroySurface() { - if (egl_display_) { - eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - - if (EGL_NO_SURFACE != egl_surface_) { - eglDestroySurface(egl_display_, egl_surface_); - egl_surface_ = EGL_NO_SURFACE; - } - - if (EGL_NO_CONTEXT != egl_context_) { - eglDestroyContext(egl_display_, egl_context_); - egl_context_ = EGL_NO_CONTEXT; - } - - if (EGL_NO_SURFACE != egl_resource_surface_) { - eglDestroySurface(egl_display_, egl_resource_surface_); - egl_resource_surface_ = EGL_NO_SURFACE; - } - - if (EGL_NO_CONTEXT != egl_resource_context_) { - eglDestroyContext(egl_display_, egl_resource_context_); - egl_resource_context_ = EGL_NO_CONTEXT; - } - - eglTerminate(egl_display_); - egl_display_ = EGL_NO_DISPLAY; - } -} - -bool TizenRendererEcoreWl2::IsSupportedExtension(const char* name) { - return strstr(egl_extension_str_.c_str(), name); -} - } // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_egl.h similarity index 87% rename from shell/platform/tizen/tizen_renderer_ecore_wl2.h rename to shell/platform/tizen/tizen_renderer_egl.h index 5d30f5829efbf..281b39b0394e1 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_egl.h @@ -7,8 +7,6 @@ #define EFL_BETA_API_SUPPORT #include -#include -#include #include @@ -16,11 +14,11 @@ namespace flutter { -class TizenRendererEcoreWl2 : public TizenRenderer { +class TizenRendererEgl : public TizenRenderer { public: - explicit TizenRendererEcoreWl2(); + explicit TizenRendererEgl(); - virtual ~TizenRendererEcoreWl2(); + virtual ~TizenRendererEgl(); bool CreateSurface(void* render_target, void* render_target_display, diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index a4b218ee93575..c3a713a1f7c67 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -4,32 +4,79 @@ #include "tizen_renderer_evas_gl.h" -#include -#include - #include "tizen_evas_gl_helper.h" + +// g_evas_gl is shared with ExternalTexturePixelGL and ExternalTextureSurfaceGL Evas_GL* g_evas_gl = nullptr; + EVAS_GL_GLOBAL_GLES3_DEFINE(); #include "flutter/shell/platform/tizen/logger.h" namespace flutter { -TizenRendererEvasGL::TizenRendererEvasGL(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate) - : TizenRenderer(geometry, transparent, focusable, top_level, delegate) { - if (!SetupEvasWindow()) { - FT_LOG(Error) << "Could not set up Evas window."; - return; +TizenRendererEvasGL::TizenRendererEvasGL() {} + +TizenRendererEvasGL::~TizenRendererEvasGL() { + DestroySurface(); +} + +bool TizenRendererEvasGL::CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) { + evas_gl_ = evas_gl_new( + evas_object_evas_get(static_cast(render_target))); + if (!evas_gl_) { + FT_LOG(Error) << "Could not create an Evas GL object."; + return false; + } + + g_evas_gl = evas_gl_; + + gl_config_ = evas_gl_config_new(); + gl_config_->color_format = EVAS_GL_RGBA_8888; + gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; + gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; + + gl_context_ = + evas_gl_context_version_create(evas_gl_, nullptr, EVAS_GL_GLES_3_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); + if (!gl_context_) { + FT_LOG(Error) << "Failed to create an Evas GL context with " + "EVAS_GL_GLES_3_X; trying with EVAS_GL_GLES_2_X."; + gl_context_ = + evas_gl_context_version_create(evas_gl_, nullptr, EVAS_GL_GLES_2_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); } - if (!SetupEvasGL()) { - FT_LOG(Error) << "Could not set up Evas GL."; - return; + if (!gl_context_) { + FT_LOG(Fatal) << "Failed to create an Evas GL context."; + return false; } - Show(); + + EVAS_GL_GLOBAL_GLES3_USE(evas_gl_, gl_context_); + + gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, width, height); + gl_resource_surface_ = evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, + width, height, nullptr); + + Evas_Native_Surface native_surface; + evas_gl_native_surface_get(evas_gl_, gl_surface_, &native_surface); + + image_ = static_cast(render_target_display); + evas_object_image_native_surface_set(image_, &native_surface); + + evas_object_image_pixels_get_callback_set( + image_, + [](void* data, Evas_Object* o) { + TizenRendererEvasGL* self = static_cast(data); + if (self->on_pixels_dirty_) { + self->on_pixels_dirty_(); + } + }, + this); is_valid_ = true; @@ -38,11 +85,18 @@ TizenRendererEvasGL::TizenRendererEvasGL(Geometry geometry, glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); OnPresent(); + return true; } -TizenRendererEvasGL::~TizenRendererEvasGL() { - DestroyEvasGL(); - DestroyEvasWindow(); +void TizenRendererEvasGL::DestroySurface() { + evas_gl_surface_destroy(evas_gl_, gl_surface_); + evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); + + evas_gl_context_destroy(evas_gl_, gl_context_); + evas_gl_context_destroy(evas_gl_, gl_resource_context_); + + evas_gl_config_free(gl_config_); + evas_gl_free(evas_gl_); } bool TizenRendererEvasGL::OnMakeCurrent() { @@ -84,11 +138,6 @@ bool TizenRendererEvasGL::OnPresent() { return false; } - if (received_rotation_) { - SendRotationChangeDone(); - received_rotation_ = false; - } - return true; } @@ -99,6 +148,29 @@ uint32_t TizenRendererEvasGL::OnGetFBO() { return 0; } +bool TizenRendererEvasGL::IsSupportedExtension(const char* name) { + return strcmp(name, "EGL_TIZEN_image_native_surface") == 0; +} + +void TizenRendererEvasGL::MarkPixelsDirty() { + evas_object_image_pixels_dirty_set(image_, EINA_TRUE); +} + +void TizenRendererEvasGL::ResizeSurface(int32_t width, int32_t height) { + evas_gl_surface_destroy(evas_gl_, gl_surface_); + evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); + + evas_object_image_native_surface_set(image_, nullptr); + evas_object_image_size_set(image_, width, height); + gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, width, height); + gl_resource_surface_ = evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, + width, height, nullptr); + + Evas_Native_Surface native_surface; + evas_gl_native_surface_get(evas_gl_, gl_surface_, &native_surface); + evas_object_image_native_surface_set(image_, &native_surface); +} + void* TizenRendererEvasGL::OnProcResolver(const char* name) { auto address = evas_gl_proc_address_get(evas_gl_, name); if (address != nullptr) { @@ -554,236 +626,4 @@ void* TizenRendererEvasGL::OnProcResolver(const char* name) { return nullptr; } -TizenRenderer::Geometry TizenRendererEvasGL::GetWindowGeometry() { - Geometry result; - evas_object_geometry_get(evas_window_, &result.x, &result.y, &result.w, - &result.h); - return result; -} - -TizenRenderer::Geometry TizenRendererEvasGL::GetScreenGeometry() { - Geometry result = {}; - Ecore_Evas* ecore_evas = - ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)); - ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &result.w, - &result.h); - return result; -} - -int32_t TizenRendererEvasGL::GetDpi() { - Ecore_Evas* ecore_evas = - ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)); - int32_t xdpi, ydpi; - ecore_evas_screen_dpi_get(ecore_evas, &xdpi, &ydpi); - return xdpi; -} - -uintptr_t TizenRendererEvasGL::GetWindowId() { - return ecore_evas_window_get( - ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_))); -} - -void TizenRendererEvasGL::Show() { - evas_object_show(graphics_adapter_); - evas_object_show(evas_window_); -} - -bool TizenRendererEvasGL::SetupEvasGL() { - evas_gl_ = evas_gl_new(evas_object_evas_get(evas_window_)); - if (!evas_gl_) { - FT_LOG(Error) << "Could not create an Evas GL object."; - return false; - } - g_evas_gl = evas_gl_; - - gl_config_ = evas_gl_config_new(); - gl_config_->color_format = EVAS_GL_RGBA_8888; - gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; - gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; - - gl_context_ = - evas_gl_context_version_create(evas_gl_, nullptr, EVAS_GL_GLES_3_X); - gl_resource_context_ = - evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); - if (!gl_context_) { - FT_LOG(Error) << "Failed to create an Evas GL context with " - "EVAS_GL_GLES_3_X; trying with EVAS_GL_GLES_2_X."; - gl_context_ = - evas_gl_context_version_create(evas_gl_, nullptr, EVAS_GL_GLES_2_X); - gl_resource_context_ = - evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); - } - if (!gl_context_) { - FT_LOG(Fatal) << "Failed to create an Evas GL context."; - return false; - } - - EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); - - gl_surface_ = evas_gl_surface_create( - evas_gl_, gl_config_, initial_geometry_.w, initial_geometry_.h); - gl_resource_surface_ = evas_gl_pbuffer_surface_create( - evas_gl_, gl_config_, initial_geometry_.w, initial_geometry_.h, nullptr); - - Evas_Native_Surface native_surface; - evas_gl_native_surface_get(evas_gl_, gl_surface_, &native_surface); - evas_object_image_native_surface_set(graphics_adapter_, &native_surface); - - return true; -} - -bool TizenRendererEvasGL::SetupEvasWindow() { - elm_config_accel_preference_set("hw:opengl"); - - evas_window_ = elm_win_add(nullptr, nullptr, - top_level_ ? ELM_WIN_NOTIFICATION : ELM_WIN_BASIC); - if (!evas_window_) { - FT_LOG(Error) << "Could not create an Evas window."; - return false; - } - if (top_level_) { - efl_util_set_notification_window_level(evas_window_, - EFL_UTIL_NOTIFICATION_LEVEL_TOP); - } - // Please uncomment below and enable setWindowGeometry of window channel when - // Tizen 5.5 or later was chosen as default. - // elm_win_aux_hint_add(evas_window_, "wm.policy.win.user.geometry", "1"); - - Ecore_Evas* ecore_evas = - ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)); - - int32_t width, height; - ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &width, &height); - if (width == 0 || height == 0) { - FT_LOG(Error) << "Invalid screen size: " << width << " x " << height; - return false; - } - - if (initial_geometry_.w == 0) { - initial_geometry_.w = width; - } - if (initial_geometry_.h == 0) { - initial_geometry_.h = height; - } - - evas_object_move(evas_window_, initial_geometry_.x, initial_geometry_.y); - evas_object_resize(evas_window_, initial_geometry_.w, initial_geometry_.h); - evas_object_raise(evas_window_); - - elm_win_indicator_mode_set(evas_window_, ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(evas_window_, ELM_WIN_INDICATOR_OPAQUE); - - if (transparent_) { - elm_win_alpha_set(evas_window_, EINA_TRUE); - } else { - elm_win_alpha_set(evas_window_, EINA_FALSE); - - Evas_Object* bg = elm_bg_add(evas_window_); - evas_object_color_set(bg, 0, 0, 0, 0); - - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(evas_window_, bg); - } - - graphics_adapter_ = - evas_object_image_filled_add(evas_object_evas_get(evas_window_)); - evas_object_resize(graphics_adapter_, initial_geometry_.w, - initial_geometry_.h); - evas_object_move(graphics_adapter_, initial_geometry_.x, initial_geometry_.y); - evas_object_image_size_set(graphics_adapter_, initial_geometry_.w, - initial_geometry_.h); - evas_object_image_alpha_set(graphics_adapter_, EINA_TRUE); - elm_win_resize_object_add(evas_window_, graphics_adapter_); - - const int rotations[4] = {0, 90, 180, 270}; - elm_win_wm_rotation_available_rotations_set(evas_window_, &rotations[0], 4); - evas_object_smart_callback_add(evas_window_, "rotation,changed", - RotationEventCb, this); - - return true; -} - -void TizenRendererEvasGL::DestroyEvasWindow() { - evas_object_del(evas_window_); - evas_object_del(graphics_adapter_); -} - -void TizenRendererEvasGL::DestroyEvasGL() { - evas_gl_surface_destroy(evas_gl_, gl_surface_); - evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); - - evas_gl_context_destroy(evas_gl_, gl_context_); - evas_gl_context_destroy(evas_gl_, gl_resource_context_); - - evas_gl_config_free(gl_config_); - evas_gl_free(evas_gl_); -} - -void TizenRendererEvasGL::RotationEventCb(void* data, - Evas_Object* obj, - void* event_info) { - auto* self = reinterpret_cast(data); - FT_UNIMPLEMENTED(); - self->delegate_.OnOrientationChange(0); -} - -void TizenRendererEvasGL::SetRotate(int angle) { - elm_win_rotation_set(evas_window_, angle); - received_rotation_ = true; -} - -void TizenRendererEvasGL::SetGeometry(int32_t x, - int32_t y, - int32_t width, - int32_t height) { - evas_object_move(evas_window_, x, y); - evas_object_resize(evas_window_, width, height); - - evas_object_resize(graphics_adapter_, width, height); - evas_object_image_native_surface_set(graphics_adapter_, nullptr); - - evas_gl_surface_destroy(evas_gl_, gl_surface_); - evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); - - evas_object_image_size_set(graphics_adapter_, width, height); - gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, width, height); - gl_resource_surface_ = evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, - width, height, nullptr); - - Evas_Native_Surface native_surface; - evas_gl_native_surface_get(evas_gl_, gl_surface_, &native_surface); - evas_object_image_native_surface_set(graphics_adapter_, &native_surface); -} - -void TizenRendererEvasGL::ResizeWithRotation(int32_t x, - int32_t y, - int32_t width, - int32_t height, - int32_t angle) { - evas_object_move(evas_window_, x, y); - evas_object_resize(evas_window_, width, height); - SetRotate(angle); -} - -void TizenRendererEvasGL::SendRotationChangeDone() { - elm_win_wm_rotation_manual_rotation_done(evas_window_); -} - -void TizenRendererEvasGL::SetPreferredOrientations( - const std::vector& rotations) { - elm_win_wm_rotation_available_rotations_set( - evas_window_, static_cast(rotations.data()), - rotations.size()); -} - -bool TizenRendererEvasGL::IsSupportedExtension(const char* name) { - return strcmp(name, "EGL_TIZEN_image_native_surface") == 0; -} - -void TizenRendererEvasGL::BindKeys(const std::vector& keys) { - for (const std::string& key : keys) { - eext_win_keygrab_set(evas_window_, key.c_str()); - } -} - } // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index eb1525ecad76f..9a9e412fc9fd9 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -14,67 +14,51 @@ namespace flutter { +using OnPixelsDirty = std::function; + class TizenRendererEvasGL : public TizenRenderer { public: - explicit TizenRendererEvasGL(Geometry geometry, - bool transparent, - bool focusable, - bool top_level, - Delegate& delegate); + explicit TizenRendererEvasGL(); + virtual ~TizenRendererEvasGL(); + bool CreateSurface(void* render_target, + void* render_target_display, + int32_t width, + int32_t height) override; + + void DestroySurface() override; + bool OnMakeCurrent() override; + bool OnClearCurrent() override; - bool OnMakeResourceCurrent() override; - bool OnPresent() override; - uint32_t OnGetFBO() override; - void* OnProcResolver(const char* name) override; - Geometry GetWindowGeometry() override; - Geometry GetScreenGeometry() override; - int32_t GetDpi() override; - uintptr_t GetWindowId() override; + bool OnMakeResourceCurrent() override; - void* GetWindowHandle() override { return evas_window_; } + bool OnPresent() override; - Evas_Object* GetImageHandle() { return graphics_adapter_; } + uint32_t OnGetFBO() override; - void SetRotate(int angle) override; - void SetGeometry(int32_t x, - int32_t y, - int32_t width, - int32_t height) override; - void ResizeWithRotation(int32_t x, - int32_t y, - int32_t width, - int32_t height, - int32_t angle) override; - void SetPreferredOrientations(const std::vector& rotations) override; + void* OnProcResolver(const char* name) override; bool IsSupportedExtension(const char* name) override; - void BindKeys(const std::vector& keys) override; + void SetOnPixelsDirty(OnPixelsDirty callback) { on_pixels_dirty_ = callback; } - private: - void Show(); + void MarkPixelsDirty(); - bool SetupEvasWindow(); - bool SetupEvasGL(); - void DestroyEvasWindow(); - void DestroyEvasGL(); - - static void RotationEventCb(void* data, Evas_Object* obj, void* event_info); - void SendRotationChangeDone(); - - Evas_Object* evas_window_ = nullptr; - Evas_Object* graphics_adapter_ = nullptr; + void ResizeSurface(int32_t width, int32_t height); + private: Evas_GL* evas_gl_ = nullptr; Evas_GL_Config* gl_config_ = nullptr; Evas_GL_Context* gl_context_ = nullptr; Evas_GL_Context* gl_resource_context_ = nullptr; Evas_GL_Surface* gl_surface_ = nullptr; Evas_GL_Surface* gl_resource_surface_ = nullptr; + + Evas_Object* image_ = nullptr; + OnPixelsDirty on_pixels_dirty_; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index 830a1bd060648..aeeeac891ff8a 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -45,7 +45,7 @@ class TizenWindow { virtual void* GetRenderTargetDisplay() = 0; - virtual int32_t GetRotatoin() = 0; + virtual int32_t GetRotation() = 0; // Returns the scale factor for the backing window. virtual int32_t GetDpi() = 0; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index df98e9a0b19c2..d8a29b8bc93e6 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -34,6 +34,7 @@ TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, } TizenWindowEcoreWl2::~TizenWindowEcoreWl2() { + UnregisterEventCallbacks(); DestroyEcoreWl2(); } @@ -268,6 +269,13 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { this)); } +void TizenWindowEcoreWl2::UnregisterEventCallbacks() { + for (auto handler : ecore_event_handlers_) { + ecore_event_handler_del(handler); + } + ecore_event_handlers_.clear(); +} + void TizenWindowEcoreWl2::DestroyEcoreWl2() { if (ecore_wl2_egl_window_) { ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); @@ -309,7 +317,7 @@ TizenWindow::Geometry TizenWindowEcoreWl2::GetScreenGeometry() { return result; } -int32_t TizenWindowEcoreWl2::GetRotatoin() { +int32_t TizenWindowEcoreWl2::GetRotation() { return ecore_wl2_window_rotation_get(ecore_wl2_window_); } diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index 93cff5f417469..45498a6f9c1d1 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -33,7 +33,7 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetRenderTargetDisplay() override { return wl2_display_; } - int32_t GetRotatoin() override; + int32_t GetRotation() override; int32_t GetDpi() override; @@ -55,11 +55,13 @@ class TizenWindowEcoreWl2 : public TizenWindow { private: bool CreateWindow(); + void DestroyEcoreWl2(); + void SetWindowOptions(); void RegisterEventHandlers(); - void DestroyEcoreWl2(); + void UnregisterEventCallbacks(); void SetTizenPolicyNotificationLevel(int level); diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc new file mode 100644 index 0000000000000..e9a72e218d186 --- /dev/null +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -0,0 +1,348 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tizen_window_elementary.h" + +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/logger.h" + +#include +#include + +namespace { + +static const int kScrollDirectionVertical = 0; +static const int kScrollDirectionHorizontal = 1; +static const int kScrollOffsetMultiplier = 20; + +} // namespace + +namespace flutter { + +TizenWindowElementary::TizenWindowElementary(Geometry geometry, + bool transparent, + bool focusable, + bool top_level) + : TizenWindow(geometry, transparent, focusable, top_level) { + if (!CreateWindow()) { + FT_LOG(Error) << "Failed to create platform window"; + return; + } + + SetWindowOptions(); + RegisterEventHandlers(); + Show(); +} + +TizenWindowElementary::~TizenWindowElementary() { + UnregisterEventCallbacks(); + DestroyWindow(); +} + +bool TizenWindowElementary::CreateWindow() { + elm_config_accel_preference_set("hw:opengl"); + + elm_win_ = elm_win_add(nullptr, nullptr, + top_level_ ? ELM_WIN_NOTIFICATION : ELM_WIN_BASIC); + if (!elm_win_) { + FT_LOG(Error) << "Could not create an Evas window."; + return false; + } + + // Please uncomment below and enable setWindowGeometry of window channel when + // Tizen 5.5 or later was chosen as default. + // elm_win_aux_hint_add(elm_win_, "wm.policy.win.user.geometry", "1"); + + auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + + int32_t width, height; + ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &width, &height); + if (width == 0 || height == 0) { + FT_LOG(Error) << "Invalid screen size: " << width << " x " << height; + return false; + } + + if (initial_geometry_.width == 0) { + initial_geometry_.width = width; + } + if (initial_geometry_.height == 0) { + initial_geometry_.height = height; + } + + evas_object_move(elm_win_, initial_geometry_.left, initial_geometry_.top); + evas_object_resize(elm_win_, initial_geometry_.width, + initial_geometry_.height); + evas_object_raise(elm_win_); + + elm_win_indicator_mode_set(elm_win_, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(elm_win_, ELM_WIN_INDICATOR_OPAQUE); + + image_ = evas_object_image_filled_add(evas_object_evas_get(elm_win_)); + evas_object_resize(image_, initial_geometry_.width, initial_geometry_.height); + evas_object_move(image_, initial_geometry_.left, initial_geometry_.top); + evas_object_image_size_set(image_, initial_geometry_.width, + initial_geometry_.height); + evas_object_image_alpha_set(image_, EINA_TRUE); + elm_win_resize_object_add(elm_win_, image_); + + return elm_win_ && image_; +} + +void TizenWindowElementary::DestroyWindow() { + evas_object_del(elm_win_); + evas_object_del(image_); +} + +void TizenWindowElementary::SetWindowOptions() { + if (top_level_) { + efl_util_set_notification_window_level(elm_win_, + EFL_UTIL_NOTIFICATION_LEVEL_TOP); + } + + if (transparent_) { + elm_win_alpha_set(elm_win_, EINA_TRUE); + } else { + elm_win_alpha_set(elm_win_, EINA_FALSE); + + Evas_Object* bg = elm_bg_add(elm_win_); + evas_object_color_set(bg, 0, 0, 0, 0); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(elm_win_, bg); + } + + // TODO: focusable_ + // TOOD: indicator + + const int rotations[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(elm_win_, &rotations[0], 4); +} + +void TizenWindowElementary::RegisterEventHandlers() { + rotatoin_changed_callback_ = [](void* data, Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + if (self->elm_win_ == object) { + // FIXME + FT_UNIMPLEMENTED(); + self->flutter_tizen_view_->OnRotate(self->GetRotation()); + elm_win_wm_rotation_manual_rotation_done(self->elm_win_); + } + } + }; + evas_object_smart_callback_add(elm_win_, "rotation,changed", + rotatoin_changed_callback_, this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + if (self->elm_win_ == object) { + auto* mouse_event = + reinterpret_cast(event_info); + self->flutter_tizen_view_->OnPointerDown( + mouse_event->canvas.x, mouse_event->canvas.y, + mouse_event->timestamp, kFlutterPointerDeviceKindTouch, + mouse_event->button); + } + } + }; + evas_object_event_callback_add( + elm_win_, EVAS_CALLBACK_MOUSE_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN], this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + if (self->elm_win_ == object) { + auto* mouse_event = reinterpret_cast(event_info); + self->flutter_tizen_view_->OnPointerUp( + mouse_event->canvas.x, mouse_event->canvas.y, + mouse_event->timestamp, kFlutterPointerDeviceKindTouch, + mouse_event->button); + } + } + }; + evas_object_event_callback_add(elm_win_, EVAS_CALLBACK_MOUSE_UP, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP], + this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + if (self->elm_win_ == object) { + auto* mouse_event = + reinterpret_cast(event_info); + self->flutter_tizen_view_->OnPointerMove( + mouse_event->cur.canvas.x, mouse_event->cur.canvas.y, + mouse_event->timestamp, kFlutterPointerDeviceKindTouch, + mouse_event->buttons); + } + } + }; + evas_object_event_callback_add( + elm_win_, EVAS_CALLBACK_MOUSE_MOVE, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE], this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + if (self->elm_win_ == object) { + auto* wheel_event = + reinterpret_cast(event_info); + double delta_x = 0.0; + double delta_y = 0.0; + + if (wheel_event->direction == kScrollDirectionVertical) { + delta_y += wheel_event->z; + } else if (wheel_event->direction == kScrollDirectionHorizontal) { + delta_x += wheel_event->z; + } + + self->flutter_tizen_view_->OnScroll( + wheel_event->x, wheel_event->y, delta_x, delta_y, + kScrollOffsetMultiplier, wheel_event->timestamp, + kFlutterPointerDeviceKindTouch, 0); + } + } + }; + evas_object_event_callback_add( + elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL], this); + + // FIXME: ues EVAS_CALLBACK_KEY_DOWN, EVAS_CALLBACK_KEY_UP + ecore_event_key_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_KEY_DOWN, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* key_event = reinterpret_cast(event); + if (key_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnKey(key_event, false); + return ECORE_CALLBACK_DONE; + } + } + return ECORE_CALLBACK_PASS_ON; + }, + this)); + + ecore_event_key_handlers_.push_back(ecore_event_handler_add( + ECORE_EVENT_KEY_UP, + [](void* data, int type, void* event) -> Eina_Bool { + auto* self = reinterpret_cast(data); + if (self->flutter_tizen_view_) { + auto* key_event = reinterpret_cast(event); + if (key_event->window == self->GetWindowId()) { + self->flutter_tizen_view_->OnKey(key_event, true); + return ECORE_CALLBACK_DONE; + } + } + return ECORE_CALLBACK_PASS_ON; + }, + this)); +} + +void TizenWindowElementary::UnregisterEventCallbacks() { + evas_object_smart_callback_del(elm_win_, "rotation,changed", + rotatoin_changed_callback_); + + evas_object_event_callback_del( + elm_win_, EVAS_CALLBACK_MOUSE_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN]); + evas_object_event_callback_del( + elm_win_, EVAS_CALLBACK_MOUSE_UP, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP]); + evas_object_event_callback_del( + elm_win_, EVAS_CALLBACK_MOUSE_MOVE, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE]); + evas_object_event_callback_del( + elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL]); + + for (auto handler : ecore_event_key_handlers_) { + ecore_event_handler_del(handler); + } + ecore_event_key_handlers_.clear(); +} + +TizenWindow::Geometry TizenWindowElementary::GetWindowGeometry() { + // FIXME : evas_object_geometry_get() and ecore_wl2_window_geometry_get() are + // not equivalent. + Geometry result; + evas_object_geometry_get(elm_win_, &result.left, &result.top, &result.width, + &result.height); + return result; +} + +void TizenWindowElementary::SetWindowGeometry(Geometry geometry) { + evas_object_resize(elm_win_, geometry.width, geometry.height); + evas_object_move(elm_win_, geometry.left, geometry.top); + + evas_object_resize(image_, geometry.width, geometry.height); + evas_object_move(image_, geometry.left, geometry.top); +} + +TizenWindow::Geometry TizenWindowElementary::GetScreenGeometry() { + Geometry result; + auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &result.width, + &result.height); + return result; +} + +int32_t TizenWindowElementary::GetRotation() { + return elm_win_rotation_get(elm_win_); +} + +int32_t TizenWindowElementary::GetDpi() { + auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + int32_t xdpi, ydpi; + ecore_evas_screen_dpi_get(ecore_evas, &xdpi, &ydpi); + return xdpi; +} + +uintptr_t TizenWindowElementary::GetWindowId() { + return ecore_evas_window_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_))); +} + +void TizenWindowElementary::ResizeRenderTargetWithRotation(Geometry geometry, + int32_t angle) { + TizenRendererEvasGL* renderer_evas_gl = + reinterpret_cast( + flutter_tizen_view_->flutter_tizen_engine()->renderer()); + renderer_evas_gl->ResizeSurface(geometry.width, geometry.height); +} + +void TizenWindowElementary::SetPreferredOrientations( + const std::vector& rotations) { + elm_win_wm_rotation_available_rotations_set( + elm_win_, reinterpret_cast(rotations.data()), + rotations.size()); +} + +void TizenWindowElementary::BindKeys(const std::vector& keys) { + for (const auto& key : keys) { + eext_win_keygrab_set(elm_win_, key.c_str()); + } +} + +void TizenWindowElementary::Show() { + evas_object_show(image_); + evas_object_show(elm_win_); +} + +void TizenWindowElementary::OnGeometryChanged(Geometry geometry) { + SetWindowGeometry(geometry); + flutter_tizen_view_->OnResize(geometry.left, geometry.top, geometry.width, + geometry.height); +} + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h new file mode 100644 index 0000000000000..fe2b2f558c63f --- /dev/null +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -0,0 +1,78 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ +#define EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ + +#include "flutter/shell/platform/tizen/tizen_window.h" + +#define EFL_BETA_API_SUPPORT +#include +#include + +#include + +namespace flutter { + +class TizenWindowElementary : public TizenWindow { + public: + TizenWindowElementary(Geometry geometry, + bool transparent, + bool focusable, + bool top_level); + + ~TizenWindowElementary(); + + Geometry GetWindowGeometry() override; + + void SetWindowGeometry(Geometry geometry) override; + + Geometry GetScreenGeometry() override; + + void* GetRenderTarget() override { return elm_win_; } + + void* GetRenderTargetDisplay() override { return image_; } + + int32_t GetRotation() override; + + int32_t GetDpi() override; + + uintptr_t GetWindowId() override; + + void* GetWindowHandle() override { return elm_win_; } + + void ResizeRenderTargetWithRotation(Geometry geometry, + int32_t angle) override; + + void SetPreferredOrientations(const std::vector& rotations) override; + + void BindKeys(const std::vector& keys) override; + + void Show() override; + + void OnGeometryChanged(Geometry geometry) override; + + private: + bool CreateWindow(); + + void DestroyWindow(); + + void SetWindowOptions(); + + void RegisterEventHandlers(); + + void UnregisterEventCallbacks(); + + Evas_Object* elm_win_ = nullptr; + Evas_Object* image_ = nullptr; + + Evas_Smart_Cb rotatoin_changed_callback_; + std::unordered_map + evas_object_callbacks_; + std::vector ecore_event_key_handlers_; +}; + +} // namespace flutter +#endif From 11aaa65c5fcfbf4a642859f9969cc793306a3fa7 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 22 Apr 2022 10:19:26 +0900 Subject: [PATCH 14/32] Fix gn format error Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 6bd1b7055ad5b..44574e346ac56 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -187,7 +187,7 @@ template("embedder") { sources += [ "flutter_tizen_elementary.cc", "tizen_renderer_evas_gl.cc", - "tizen_window_elementary.cc" + "tizen_window_elementary.cc", ] libs += [ From 73ca452951a4c5ad438bfd5f19e40783700f7837 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 22 Apr 2022 11:24:02 +0900 Subject: [PATCH 15/32] Fix a bug on headless Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_engine.cc | 2 -- shell/platform/tizen/flutter_tizen_engine.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 66c8bf316def9..7e59a0072aa22 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -51,7 +51,6 @@ FlutterLocale CovertToFlutterLocale(const LanguageInfo& info) { FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) : project_(std::make_unique(project)), aot_data_(nullptr, nullptr) { - FT_LOG(Error) << "enter"; embedder_api_.struct_size = sizeof(FlutterEngineProcTable); FlutterEngineGetProcAddresses(&embedder_api_); @@ -98,7 +97,6 @@ FlutterTizenEngine::~FlutterTizenEngine() { } bool FlutterTizenEngine::RunEngine(const char* entrypoint) { - FT_LOG(Error) << "enter"; if (engine_ != nullptr) { FT_LOG(Error) << "The engine has already started."; return false; diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 9a8e318dcdf61..16b4c6d0e207b 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -183,7 +183,7 @@ class FlutterTizenEngine { friend class EngineModifier; // Whether the engine is running in headed or headless mode. - bool IsHeaded() { return renderer_ != nullptr; } + bool IsHeaded() { return flutter_tizen_view_ != nullptr; } // Converts a FlutterPlatformMessage to an equivalent FlutterDesktopMessage. FlutterDesktopMessage ConvertToDesktopMessage( From 8b379afed0800ed245c36186cd9e92e786e0cde5 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 22 Apr 2022 14:02:25 +0900 Subject: [PATCH 16/32] Fix a custom dart entrypoint bug Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_project_bundle.cc | 3 ++- shell/platform/tizen/flutter_project_bundle.h | 8 ++++++++ shell/platform/tizen/flutter_tizen.cc | 5 ++--- shell/platform/tizen/flutter_tizen_ecore.cc | 2 +- .../platform/tizen/flutter_tizen_elementary.cc | 2 +- shell/platform/tizen/flutter_tizen_engine.cc | 8 +++----- shell/platform/tizen/flutter_tizen_engine.h | 2 +- .../tizen/flutter_tizen_engine_unittest.cc | 2 +- shell/platform/tizen/public/flutter_tizen.h | 17 +++-------------- shell/platform/tizen/tizen_renderer_egl.cc | 1 - 10 files changed, 22 insertions(+), 28 deletions(-) diff --git a/shell/platform/tizen/flutter_project_bundle.cc b/shell/platform/tizen/flutter_project_bundle.cc index b81f5e21a6cfb..b8ee73f2efaeb 100644 --- a/shell/platform/tizen/flutter_project_bundle.cc +++ b/shell/platform/tizen/flutter_project_bundle.cc @@ -35,7 +35,8 @@ std::filesystem::path GetBinDirectory() { FlutterProjectBundle::FlutterProjectBundle( const FlutterDesktopEngineProperties& properties) : assets_path_(properties.assets_path), - icu_path_(properties.icu_data_path) { + icu_path_(properties.icu_data_path), + custom_dart_entrypoint_(properties.entrypoint) { if (properties.aot_library_path != nullptr) { aot_library_path_ = std::filesystem::path(properties.aot_library_path); } diff --git a/shell/platform/tizen/flutter_project_bundle.h b/shell/platform/tizen/flutter_project_bundle.h index 399b2aa14d171..b9f4c51ebe463 100644 --- a/shell/platform/tizen/flutter_project_bundle.h +++ b/shell/platform/tizen/flutter_project_bundle.h @@ -56,6 +56,11 @@ class FlutterProjectBundle { // Logs and returns nullptr on failure. UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs); + // Returns custom entrypoint in the Dart project + const std::string& custom_dart_entrypoint() { + return custom_dart_entrypoint_; + } + // Returns the command line arguments to be passed through to the Dart // entrypoint. const std::vector& dart_entrypoint_arguments() const { @@ -70,6 +75,9 @@ class FlutterProjectBundle { // Path to the AOT library file, if any. std::filesystem::path aot_library_path_; + // Custom entrypoint in the Dart project + std::string custom_dart_entrypoint_; + // Dart entrypoint arguments. std::vector dart_entrypoint_arguments_; }; diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 33ee3efdb2800..01828a5cbedac 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -57,9 +57,8 @@ FlutterDesktopEngineRef FlutterDesktopEngineCreate( return HandleForEngine(flutter_tizen_engine.release()); } -bool FlutterDesktopEngineRun(const FlutterDesktopEngineRef engine, - const char* entry_point) { - return EngineFromHandle(engine)->RunEngine(entry_point); +bool FlutterDesktopEngineRun(const FlutterDesktopEngineRef engine) { + return EngineFromHandle(engine)->RunEngine(); } void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index 00a6a4d26ecc5..e7eeea5d0df3b 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -43,7 +43,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( flutter_tizen_view->CreateRenderSurface(); if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { - flutter_tizen_view->flutter_tizen_engine()->RunEngine(nullptr); + flutter_tizen_view->flutter_tizen_engine()->RunEngine(); } flutter_tizen_view->SendInitialGeometry(); diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 3fe7125d515fe..5aafebc012832 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -43,7 +43,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( flutter_tizen_view->CreateRenderSurface(); if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { - flutter_tizen_view->flutter_tizen_engine()->RunEngine(nullptr); + flutter_tizen_view->flutter_tizen_engine()->RunEngine(); } flutter_tizen_view->SendInitialGeometry(); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 7e59a0072aa22..c57da159e9bce 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -89,14 +89,13 @@ FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) plugin_registrar_ = std::make_unique(); plugin_registrar_->engine = this; - FT_LOG(Error) << "done"; } FlutterTizenEngine::~FlutterTizenEngine() { renderer_ = nullptr; } -bool FlutterTizenEngine::RunEngine(const char* entrypoint) { +bool FlutterTizenEngine::RunEngine() { if (engine_ != nullptr) { FT_LOG(Error) << "The engine has already started."; return false; @@ -211,8 +210,8 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { if (aot_data_) { args.aot_data = aot_data_.get(); } - if (entrypoint) { - args.custom_dart_entrypoint = entrypoint; + if (!project_->custom_dart_entrypoint().empty()) { + args.custom_dart_entrypoint = project_->custom_dart_entrypoint().c_str(); } FlutterRendererConfig renderer_config = GetRendererConfig(); @@ -250,7 +249,6 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) { SetupLocales(); - FT_LOG(Error) << "done"; return true; } diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 16b4c6d0e207b..e54bbc30c56cb 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -66,7 +66,7 @@ class FlutterTizenEngine { // main(). // // Returns false if the engine couldn't be started. - bool RunEngine(const char* entrypoint); + bool RunEngine(); // Returns true if the engine is currently running. bool IsRunning() { return engine_ != nullptr; } diff --git a/shell/platform/tizen/flutter_tizen_engine_unittest.cc b/shell/platform/tizen/flutter_tizen_engine_unittest.cc index d129bdc837e36..bdaa2cfa56053 100644 --- a/shell/platform/tizen/flutter_tizen_engine_unittest.cc +++ b/shell/platform/tizen/flutter_tizen_engine_unittest.cc @@ -94,7 +94,7 @@ TEST_F(FlutterTizenEngineTest, RunDoesExpectedInitialization) { return kSuccess; })); - engine_->RunEngine(nullptr); + engine_->RunEngine(); EXPECT_TRUE(run_called); EXPECT_TRUE(update_locales_called); diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 7989d9e24ead7..4b113298103d3 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -74,25 +74,14 @@ typedef struct { // ========== Engine ========== // Creates a Flutter engine with the given properties. -// -// The caller owns the returned reference, and is responsible for calling -// FlutterDesktopEngineDestroy. The lifetime of |engine_properties| is required -// to extend only until the end of this call. FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineCreate( const FlutterDesktopEngineProperties& engine_properties); -// Starts running the given engine instance and optional entry point in the Dart -// project. If the entry point is null, defaults to main(). -// -// If provided, entry_point must be the name of a top-level function from the -// same Dart library that contains the app's main() function, and must be -// decorated with `@pragma(vm:entry-point)` to ensure the method is not -// tree-shaken by the Dart compiler. +// Runs an instance of a Flutter engine with the given properties. // -// Returns false if running the engine failed. +// If |headed| is false, the engine is run in headless mode. FLUTTER_EXPORT bool FlutterDesktopEngineRun( - const FlutterDesktopEngineRef engine, - const char* entry_point); + const FlutterDesktopEngineRef engine); // Shuts down the given engine instance. // diff --git a/shell/platform/tizen/tizen_renderer_egl.cc b/shell/platform/tizen/tizen_renderer_egl.cc index d15849ea7acc9..61b3212434455 100644 --- a/shell/platform/tizen/tizen_renderer_egl.cc +++ b/shell/platform/tizen/tizen_renderer_egl.cc @@ -82,7 +82,6 @@ bool TizenRendererEgl::CreateSurface(void* render_target, } } is_valid_ = true; - FT_LOG(Error) << "done"; return true; } From 36fecf5bec96e4e3b9de407d4c271d674eda8dcf Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 22 Apr 2022 14:14:45 +0900 Subject: [PATCH 17/32] Remove a headed property * If view is not specified, the engine is run in headless mode. Signed-off-by: Boram Bae --- shell/platform/tizen/public/flutter_tizen.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 4b113298103d3..11fb27138faff 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -27,9 +27,6 @@ typedef struct FlutterDesktopView* FlutterDesktopViewRef; // Properties for configuring the initial settings of a Flutter window. typedef struct { - // Whether the app is headed or headless. Other properties are ignored if - // this value is set to false. - bool headed; // The x-coordinate of the top left corner of the window. int32_t x; // The y-coordinate of the top left corner of the window. @@ -79,7 +76,7 @@ FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineCreate( // Runs an instance of a Flutter engine with the given properties. // -// If |headed| is false, the engine is run in headless mode. +// If view is not specified, the engine is run in headless mode. FLUTTER_EXPORT bool FlutterDesktopEngineRun( const FlutterDesktopEngineRef engine); From 8c26155c817e6996f5a00d746918e3b7275d007c Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 22 Apr 2022 18:52:15 +0900 Subject: [PATCH 18/32] Fix a crash on testing Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_project_bundle_unittests.cc | 8 ++++---- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- shell/platform/tizen/flutter_tizen_engine_unittest.cc | 1 + .../tizen/flutter_tizen_texture_registrar_unittests.cc | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/platform/tizen/flutter_project_bundle_unittests.cc b/shell/platform/tizen/flutter_project_bundle_unittests.cc index e52932cedaff8..3375f4deef073 100644 --- a/shell/platform/tizen/flutter_project_bundle_unittests.cc +++ b/shell/platform/tizen/flutter_project_bundle_unittests.cc @@ -12,7 +12,7 @@ TEST(FlutterProjectBundle, BasicPropertiesAbsolutePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "/foo/flutter_assets"; properties.icu_data_path = "/foo/icudtl.dat"; - + properties.entrypoint = ""; FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -24,7 +24,7 @@ TEST(FlutterProjectBundle, BasicPropertiesRelativePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - + properties.entrypoint = ""; FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -38,7 +38,7 @@ TEST(FlutterProjectBundle, EmptyEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - + properties.entrypoint = ""; std::vector switches; properties.switches = switches.data(); properties.switches_count = switches.size(); @@ -52,7 +52,7 @@ TEST(FlutterProjectBundle, HasEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - + properties.entrypoint = ""; std::vector switches; switches.push_back("--abc"); switches.push_back("--foo=\"bar, baz\""); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index c57da159e9bce..3eedf22dfe8a7 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -79,7 +79,6 @@ FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) renderer_.get()); #else renderer_ = std::make_unique(); - tizen_vsync_waiter_ = std::make_unique(this); #endif messenger_ = std::make_unique(); @@ -201,6 +200,7 @@ bool FlutterTizenEngine::RunEngine() { #endif #ifndef TIZEN_RENDERER_EVAS_GL if (IsHeaded()) { + tizen_vsync_waiter_ = std::make_unique(this); args.vsync_callback = [](void* user_data, intptr_t baton) -> void { reinterpret_cast(user_data) ->tizen_vsync_waiter_->AsyncWaitForVsync(baton); diff --git a/shell/platform/tizen/flutter_tizen_engine_unittest.cc b/shell/platform/tizen/flutter_tizen_engine_unittest.cc index bdaa2cfa56053..68a378f7beb87 100644 --- a/shell/platform/tizen/flutter_tizen_engine_unittest.cc +++ b/shell/platform/tizen/flutter_tizen_engine_unittest.cc @@ -23,6 +23,7 @@ class FlutterTizenEngineTest : public ::testing::Test { engine_prop.assets_path = "/foo/flutter_assets"; engine_prop.icu_data_path = "/foo/icudtl.dat"; engine_prop.aot_library_path = "/foo/libapp.so"; + engine_prop.entrypoint = ""; FlutterProjectBundle project(engine_prop); auto engine = std::make_unique(project); diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc b/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc index 2c72a93822529..a08375264c995 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc @@ -26,7 +26,7 @@ class FlutterTizenTextureRegistrarTest : public ::testing::Test { engine_prop.assets_path = "/foo/flutter_assets"; engine_prop.icu_data_path = "/foo/icudtl.dat"; engine_prop.aot_library_path = "/foo/libapp.so"; - + engine_prop.entrypoint = ""; FlutterProjectBundle project(engine_prop); auto engine = std::make_unique(project); engine_ = engine.release(); From 394fc640755d80d2716ba9fd3386343d5c8f6e9c Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 26 Apr 2022 15:23:25 +0900 Subject: [PATCH 19/32] Remove prefix "FlutterXXX" Signed-off-by: Boram Bae --- .../tizen/channels/platform_channel.cc | 16 ++-- .../tizen/channels/platform_channel.h | 5 +- .../platform/tizen/channels/window_channel.cc | 17 ++-- .../platform/tizen/channels/window_channel.h | 5 +- shell/platform/tizen/flutter_tizen.cc | 4 +- shell/platform/tizen/flutter_tizen_ecore.cc | 17 ++-- .../tizen/flutter_tizen_elementary.cc | 17 ++-- shell/platform/tizen/flutter_tizen_engine.cc | 35 ++++---- shell/platform/tizen/flutter_tizen_engine.h | 8 +- shell/platform/tizen/flutter_tizen_view.cc | 83 +++++++++---------- shell/platform/tizen/flutter_tizen_view.h | 15 ++-- .../tizen/tizen_input_method_context.cc | 10 +-- .../tizen/tizen_input_method_context.h | 4 +- shell/platform/tizen/tizen_window.h | 6 +- .../platform/tizen/tizen_window_ecore_wl2.cc | 44 +++++----- .../platform/tizen/tizen_window_elementary.cc | 80 +++++++++--------- 16 files changed, 171 insertions(+), 195 deletions(-) diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index ce3d24096ae39..5672bd73ef908 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -58,12 +58,12 @@ std::string text_clipboard = ""; } // namespace PlatformChannel::PlatformChannel(BinaryMessenger* messenger, - TizenWindow* flutter_tizen_window) + TizenWindow* window) : channel_(std::make_unique>( messenger, kChannelName, &JsonMethodCodec::GetInstance())), - flutter_tizen_window_(flutter_tizen_window) { + window_(window) { channel_->SetMethodCallHandler( [this](const MethodCall& call, std::unique_ptr> result) { @@ -164,13 +164,13 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) { } void PlatformChannel::RestoreSystemUiOverlays() { - if (!flutter_tizen_window_) { + if (!window_) { return; } #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - shell.InitializeSoftkey(flutter_tizen_window_->GetWindowId()); + shell.InitializeSoftkey(window_->GetWindowId()); if (shell.IsSoftkeyShown()) { shell.ShowSoftkey(); @@ -182,13 +182,13 @@ void PlatformChannel::RestoreSystemUiOverlays() { void PlatformChannel::SetEnabledSystemUiOverlays( const std::vector& overlays) { - if (!flutter_tizen_window_) { + if (!window_) { return; } #ifdef COMMON_PROFILE auto& shell = TizenShell::GetInstance(); - shell.InitializeSoftkey(flutter_tizen_window_->GetWindowId()); + shell.InitializeSoftkey(window_->GetWindowId()); if (std::find(overlays.begin(), overlays.end(), kSystemUiOverlayBottom) != overlays.end()) { @@ -201,7 +201,7 @@ void PlatformChannel::SetEnabledSystemUiOverlays( void PlatformChannel::SetPreferredOrientations( const std::vector& orientations) { - if (!flutter_tizen_window_) { + if (!window_) { return; } @@ -220,7 +220,7 @@ void PlatformChannel::SetPreferredOrientations( // default. rotations = {0, 90, 180, 270}; } - flutter_tizen_window_->SetPreferredOrientations(rotations); + window_->SetPreferredOrientations(rotations); } } // namespace flutter diff --git a/shell/platform/tizen/channels/platform_channel.h b/shell/platform/tizen/channels/platform_channel.h index f344560fb61d0..4e11fdd5ca7af 100644 --- a/shell/platform/tizen/channels/platform_channel.h +++ b/shell/platform/tizen/channels/platform_channel.h @@ -18,8 +18,7 @@ namespace flutter { class PlatformChannel { public: - explicit PlatformChannel(BinaryMessenger* messenger, - TizenWindow* flutter_tizen_window); + explicit PlatformChannel(BinaryMessenger* messenger, TizenWindow* window); virtual ~PlatformChannel(); private: @@ -38,7 +37,7 @@ class PlatformChannel { // A reference to the window object managed by FlutterTizenView. // This can be nullptr if the engine is running in headless mode. - TizenWindow* flutter_tizen_window_; + TizenWindow* window_; }; } // namespace flutter diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index 1c7f41498c430..eed1b07d9ce82 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -16,9 +16,8 @@ constexpr char kChannelName[] = "tizen/internal/window"; } // namespace -WindowChannel::WindowChannel(BinaryMessenger* messenger, - TizenWindow* flutter_tizen_window) - : flutter_tizen_window_(flutter_tizen_window) { +WindowChannel::WindowChannel(BinaryMessenger* messenger, TizenWindow* window) + : window_(window) { channel_ = std::make_unique>( messenger, kChannelName, &StandardMethodCodec::GetInstance()); channel_->SetMethodCallHandler( @@ -36,7 +35,7 @@ void WindowChannel::HandleMethodCall( const std::string& method_name = method_call.method_name(); if (method_name == "getWindowGeometry") { - TizenWindow::Geometry geometry = flutter_tizen_window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = window_->GetWindowGeometry(); EncodableMap map; map[EncodableValue("x")] = EncodableValue(geometry.left); map[EncodableValue("y")] = EncodableValue(geometry.top); @@ -58,17 +57,17 @@ void WindowChannel::HandleMethodCall( EncodableValueHolder width(arguments, "width"); EncodableValueHolder height(arguments, "height"); - TizenWindow::Geometry geometry = flutter_tizen_window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = window_->GetWindowGeometry(); // FIXME: Use SetWindowGeometry() instead of OnGeometryChanged() // After the SetWindowGeometry was successfully executed, I expected a // handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't. - flutter_tizen_window_->OnGeometryChanged( - {x ? *x : geometry.left, y ? *y : geometry.top, - width ? *width : geometry.width, height ? *height : geometry.height}); + window_->OnGeometryChanged({x ? *x : geometry.left, y ? *y : geometry.top, + width ? *width : geometry.width, + height ? *height : geometry.height}); result->Success(); #endif } else if (method_name == "getScreenGeometry") { - TizenWindow::Geometry geometry = flutter_tizen_window_->GetScreenGeometry(); + TizenWindow::Geometry geometry = window_->GetScreenGeometry(); EncodableMap map; map[EncodableValue("width")] = EncodableValue(geometry.width); map[EncodableValue("height")] = EncodableValue(geometry.height); diff --git a/shell/platform/tizen/channels/window_channel.h b/shell/platform/tizen/channels/window_channel.h index d91dd1ffafd4c..78c01ee2b94a1 100644 --- a/shell/platform/tizen/channels/window_channel.h +++ b/shell/platform/tizen/channels/window_channel.h @@ -17,8 +17,7 @@ namespace flutter { // Channel to get/set application's window size and device's screen size. class WindowChannel { public: - explicit WindowChannel(BinaryMessenger* messenger, - TizenWindow* flutter_tizen_window); + explicit WindowChannel(BinaryMessenger* messenger, TizenWindow* window); virtual ~WindowChannel(); private: @@ -28,7 +27,7 @@ class WindowChannel { std::unique_ptr> channel_; // A reference to the renderer object managed by FlutterTizenView. - TizenWindow* flutter_tizen_window_; + TizenWindow* window_; }; } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 01828a5cbedac..0a246dcc44f75 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -71,9 +71,7 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { void* FlutterDesktopPluginRegistrarGetNativeWindow( FlutterDesktopPluginRegistrarRef registrar) { - return registrar->engine->flutter_tizen_view() - ->flutter_tizen_window() - ->GetWindowHandle(); + return registrar->engine->view()->window()->GetWindowHandle(); } void FlutterDesktopPluginRegistrarEnableInputBlocking( diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index e7eeea5d0df3b..90a738572f74a 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -25,7 +25,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { - std::unique_ptr flutter_tizen_window = + std::unique_ptr window = std::make_unique( flutter::TizenWindow::Geometry( {window_properties.x, window_properties.y, @@ -34,19 +34,18 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( window_properties.top_level); // Take ownership of the engine, starting it if necessary. - auto flutter_tizen_view = std::make_unique( - std::move(flutter_tizen_window)); + auto view = std::make_unique(std::move(window)); - flutter_tizen_view->SetFlutterTizenEngine( + view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); - flutter_tizen_view->CreateRenderSurface(); + view->CreateRenderSurface(); - if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { - flutter_tizen_view->flutter_tizen_engine()->RunEngine(); + if (!view->engine()->IsRunning()) { + view->engine()->RunEngine(); } - flutter_tizen_view->SendInitialGeometry(); + view->SendInitialGeometry(); - return HandleForView(flutter_tizen_view.release()); + return HandleForView(view.release()); } diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 5aafebc012832..debc53a3d1d52 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -25,7 +25,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { - std::unique_ptr flutter_tizen_window = + std::unique_ptr window = std::make_unique( flutter::TizenWindow::Geometry( {window_properties.x, window_properties.y, @@ -34,19 +34,18 @@ FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( window_properties.top_level); // Take ownership of the engine, starting it if necessary. - auto flutter_tizen_view = std::make_unique( - std::move(flutter_tizen_window)); + auto view = std::make_unique(std::move(window)); - flutter_tizen_view->SetFlutterTizenEngine( + view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); - flutter_tizen_view->CreateRenderSurface(); + view->CreateRenderSurface(); - if (!flutter_tizen_view->flutter_tizen_engine()->IsRunning()) { - flutter_tizen_view->flutter_tizen_engine()->RunEngine(); + if (!view->engine()->IsRunning()) { + view->engine()->RunEngine(); } - flutter_tizen_view->SendInitialGeometry(); + view->SendInitialGeometry(); - return HandleForView(flutter_tizen_view.release()); + return HandleForView(view.release()); } diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 3eedf22dfe8a7..2ef9afb331fb6 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -270,8 +270,8 @@ bool FlutterTizenEngine::StopEngine() { return false; } -void FlutterTizenEngine::SetFlutterTizenView(FlutterTizenView* view) { - flutter_tizen_view_ = view; +void FlutterTizenEngine::SetView(FlutterTizenView* view) { + view_ = view; } void FlutterTizenEngine::SetPluginRegistrarDestructionCallback( @@ -411,54 +411,54 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { config.open_gl.struct_size = sizeof(config.open_gl); config.open_gl.make_current = [](void* user_data) -> bool { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return false; } - return engine->flutter_tizen_view()->OnMakeCurrent(); + return engine->view()->OnMakeCurrent(); }; config.open_gl.make_resource_current = [](void* user_data) -> bool { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return false; } - return engine->flutter_tizen_view()->OnMakeResourceCurrent(); + return engine->view()->OnMakeResourceCurrent(); }; config.open_gl.clear_current = [](void* user_data) -> bool { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return false; } - return engine->flutter_tizen_view()->OnClearCurrent(); + return engine->view()->OnClearCurrent(); }; config.open_gl.present = [](void* user_data) -> bool { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return false; } - return engine->flutter_tizen_view()->OnPresent(); + return engine->view()->OnPresent(); }; config.open_gl.fbo_callback = [](void* user_data) -> uint32_t { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return false; } - return engine->flutter_tizen_view()->OnGetFBO(); + return engine->view()->OnGetFBO(); }; config.open_gl.surface_transformation = [](void* user_data) -> FlutterTransformation { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return FlutterTransformation(); } - return engine->flutter_tizen_view()->GetFlutterTransformation(); + return engine->view()->GetFlutterTransformation(); }; config.open_gl.gl_proc_resolver = [](void* user_data, const char* name) -> void* { auto engine = reinterpret_cast(user_data); - if (!engine->flutter_tizen_view()) { + if (!engine->view()) { return nullptr; } - return engine->flutter_tizen_view()->OnProcResolver(name); + return engine->view()->OnProcResolver(name); }; config.open_gl.gl_external_texture_frame_callback = [](void* user_data, int64_t texture_id, size_t width, size_t height, @@ -537,8 +537,7 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions( std::shared_ptr window = FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock(); TizenWindow::Geometry geometry = - engine->flutter_tizen_view_->flutter_tizen_window() - ->GetWindowGeometry(); + engine->view_->window()->GetWindowGeometry(); window->SetGeometry(geometry.left, geometry.top, geometry.width, geometry.height); window->SetRootNode(root); diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index e54bbc30c56cb..a63fee393c759 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -75,11 +75,11 @@ class FlutterTizenEngine { bool StopEngine(); // Sets the view that is displaying this engine's content. - void SetFlutterTizenView(FlutterTizenView* view); + void SetView(FlutterTizenView* view); // The view displaying this engine's content, if any. This will be null for // headless engines. - FlutterTizenView* flutter_tizen_view() { return flutter_tizen_view_; } + FlutterTizenView* view() { return view_; } FlutterDesktopMessengerRef messenger() { return messenger_.get(); } @@ -183,7 +183,7 @@ class FlutterTizenEngine { friend class EngineModifier; // Whether the engine is running in headed or headless mode. - bool IsHeaded() { return flutter_tizen_view_ != nullptr; } + bool IsHeaded() { return view_ != nullptr; } // Converts a FlutterPlatformMessage to an equivalent FlutterDesktopMessage. FlutterDesktopMessage ConvertToDesktopMessage( @@ -219,7 +219,7 @@ class FlutterTizenEngine { UniqueAotDataPtr aot_data_; // The view displaying the content running in this engine, if any. - FlutterTizenView* flutter_tizen_view_ = nullptr; + FlutterTizenView* view_ = nullptr; // The plugin messenger handle given to API clients. std::unique_ptr messenger_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 8da9c3b1cb1c6..23a967facc164 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -41,71 +41,68 @@ const std::vector kBindableSystemKeys = { namespace flutter { -FlutterTizenView::FlutterTizenView( - std::unique_ptr flutter_tizen_window) - : flutter_tizen_window_(std::move(flutter_tizen_window)) { - flutter_tizen_window_->SetFlutterTizenView(this); +FlutterTizenView::FlutterTizenView(std::unique_ptr window) + : window_(std::move(window)) { + window_->SetView(this); } FlutterTizenView::~FlutterTizenView() {} -void FlutterTizenView::SetFlutterTizenEngine( +void FlutterTizenView::SetEngine( std::unique_ptr flutter_tizen_engine) { - flutter_tizen_engine_ = std::move(flutter_tizen_engine); - flutter_tizen_engine_->SetFlutterTizenView(this); + engine_ = std::move(flutter_tizen_engine); + engine_->SetView(this); - internal_plugin_registrar_ = std::make_unique( - flutter_tizen_engine_->plugin_registrar()); + internal_plugin_registrar_ = + std::make_unique(engine_->plugin_registrar()); // Setup window dependent channels. BinaryMessenger* messenger = internal_plugin_registrar_->messenger(); platform_channel_ = - std::make_unique(messenger, flutter_tizen_window_.get()); - window_channel_ = - std::make_unique(messenger, flutter_tizen_window_.get()); + std::make_unique(messenger, window_.get()); + window_channel_ = std::make_unique(messenger, window_.get()); text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), - std::make_unique(flutter_tizen_window_.get())); - OnRotate(flutter_tizen_window_->GetRotation()); + std::make_unique(window_.get())); + OnRotate(window_->GetRotation()); } void FlutterTizenView::CreateRenderSurface() { - if (flutter_tizen_engine_ && flutter_tizen_engine_->renderer()) { - auto geometry = flutter_tizen_window_->GetWindowGeometry(); - flutter_tizen_engine_->renderer()->CreateSurface( - flutter_tizen_window_->GetRenderTarget(), - flutter_tizen_window_->GetRenderTargetDisplay(), geometry.width, - geometry.height); + if (engine_ && engine_->renderer()) { + auto geometry = window_->GetWindowGeometry(); + engine_->renderer()->CreateSurface(window_->GetRenderTarget(), + window_->GetRenderTargetDisplay(), + geometry.width, geometry.height); } } void FlutterTizenView::DestroyRenderSurface() { - if (flutter_tizen_engine_ && flutter_tizen_engine_->renderer()) { - flutter_tizen_engine_->renderer()->DestroySurface(); + if (engine_ && engine_->renderer()) { + engine_->renderer()->DestroySurface(); } } bool FlutterTizenView::OnMakeCurrent() { - return flutter_tizen_engine_->renderer()->OnMakeCurrent(); + return engine_->renderer()->OnMakeCurrent(); } bool FlutterTizenView::OnClearCurrent() { - return flutter_tizen_engine_->renderer()->OnClearCurrent(); + return engine_->renderer()->OnClearCurrent(); } bool FlutterTizenView::OnMakeResourceCurrent() { - return flutter_tizen_engine_->renderer()->OnMakeResourceCurrent(); + return engine_->renderer()->OnMakeResourceCurrent(); } bool FlutterTizenView::OnPresent() { - return flutter_tizen_engine_->renderer()->OnPresent(); + return engine_->renderer()->OnPresent(); } uint32_t FlutterTizenView::OnGetFBO() { - return flutter_tizen_engine_->renderer()->OnGetFBO(); + return engine_->renderer()->OnGetFBO(); } void* FlutterTizenView::OnProcResolver(const char* name) { - return flutter_tizen_engine_->renderer()->OnProcResolver(name); + return engine_->renderer()->OnProcResolver(name); } void FlutterTizenView::OnResize(int32_t left, @@ -116,8 +113,8 @@ void FlutterTizenView::OnResize(int32_t left, std::swap(width, height); } - flutter_tizen_window_->ResizeRenderTargetWithRotation( - {left, top, width, height}, rotation_degree_); + window_->ResizeRenderTargetWithRotation({left, top, width, height}, + rotation_degree_); SendWindowMetrics(left, top, width, height, 0.0); } @@ -125,7 +122,7 @@ void FlutterTizenView::OnRotate(int32_t degree) { rotation_degree_ = degree; // Compute renderer transformation based on the angle of rotation. double rad = (360 - rotation_degree_) * M_PI / 180; - auto geometry = flutter_tizen_window_->GetWindowGeometry(); + auto geometry = window_->GetWindowGeometry(); int32_t width = geometry.width; int32_t height = geometry.height; @@ -150,7 +147,7 @@ void FlutterTizenView::OnRotate(int32_t degree) { std::swap(width, height); } - flutter_tizen_window_->ResizeRenderTargetWithRotation( + window_->ResizeRenderTargetWithRotation( {geometry.left, geometry.top, width, height}, rotation_degree_); // Window position does not change on rotation regardless of its orientation. @@ -212,15 +209,14 @@ void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { } } - if (flutter_tizen_engine_->platform_view_channel()) { - flutter_tizen_engine_->platform_view_channel()->SendKeyEvent(event, - is_down); + if (engine_->platform_view_channel()) { + engine_->platform_view_channel()->SendKeyEvent(event, is_down); } - if (flutter_tizen_engine_->key_event_channel()) { - flutter_tizen_engine_->key_event_channel()->SendKeyEvent( + if (engine_->key_event_channel()) { + engine_->key_event_channel()->SendKeyEvent( event, is_down, - [engine = flutter_tizen_engine_.get(), symbol = std::string(event->key), + [engine = engine_.get(), symbol = std::string(event->key), is_down](bool handled) { if (handled) { return; @@ -237,7 +233,7 @@ void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { } void FlutterTizenView::SendInitialGeometry() { - OnRotate(flutter_tizen_window_->GetRotation()); + OnRotate(window_->GetRotation()); } void FlutterTizenView::SendWindowMetrics(int32_t left, @@ -253,7 +249,7 @@ void FlutterTizenView::SendWindowMetrics(int32_t left, #ifdef TV_PROFILE double dpi = 72.0; #else - double dpi = static_cast(flutter_tizen_window_->GetDpi()); + double dpi = static_cast(window_->GetDpi()); #endif double scale_factor = dpi / 90.0 * kProfileFactor; computed_pixel_ratio = std::max(scale_factor, 1.0); @@ -261,8 +257,7 @@ void FlutterTizenView::SendWindowMetrics(int32_t left, computed_pixel_ratio = pixel_ratio; } - flutter_tizen_engine_->SendWindowMetrics(left, top, width, height, - computed_pixel_ratio); + engine_->SendWindowMetrics(left, top, width, height, computed_pixel_ratio); } void FlutterTizenView::SendFlutterPointerEvent( @@ -274,7 +269,7 @@ void FlutterTizenView::SendFlutterPointerEvent( size_t timestamp, FlutterPointerDeviceKind device_kind, int device_id) { - auto geometry = flutter_tizen_window_->GetWindowGeometry(); + auto geometry = window_->GetWindowGeometry(); double new_x = x, new_y = y; if (rotation_degree_ == 90) { @@ -302,7 +297,7 @@ void FlutterTizenView::SendFlutterPointerEvent( event.device = device_id; event.device_kind = kFlutterPointerDeviceKindTouch; - flutter_tizen_engine_->SendPointerEvent(event); + engine_->SendPointerEvent(event); } } // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 9a6c23bdcd1e7..862413c5254f0 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -20,20 +20,17 @@ namespace flutter { class FlutterTizenView { public: - FlutterTizenView(std::unique_ptr flutter_tizen_window); + FlutterTizenView(std::unique_ptr window); ~FlutterTizenView(); // Configures the window instance with an instance of a running Flutter // engine. - void SetFlutterTizenEngine( - std::unique_ptr flutter_tizen_engine); + void SetEngine(std::unique_ptr flutter_tizen_engine); - FlutterTizenEngine* flutter_tizen_engine() { - return flutter_tizen_engine_.get(); - } + FlutterTizenEngine* engine() { return engine_.get(); } - TizenWindow* flutter_tizen_window() { return flutter_tizen_window_.get(); } + TizenWindow* window() { return window_.get(); } // Creates rendering surface for Flutter engine to draw into. // Should be called before calling FlutterEngineRun using this view. @@ -116,10 +113,10 @@ class FlutterTizenView { int device_id); // The engine associated with this view. - std::unique_ptr flutter_tizen_engine_; + std::unique_ptr engine_; // The window associated with this view. - std::unique_ptr flutter_tizen_window_; + std::unique_ptr window_; // The plugin registrar managing internal plugins. std::unique_ptr internal_plugin_registrar_; diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 51352e5e1ac41..4b83d1b53dbf6 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -103,10 +103,9 @@ T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { namespace flutter { -TizenInputMethodContext::TizenInputMethodContext( - TizenWindow* flutter_tizen_window) - : flutter_tizen_window_(flutter_tizen_window) { - FT_ASSERT(flutter_tizen_window_); +TizenInputMethodContext::TizenInputMethodContext(TizenWindow* window) + : window_(window) { + FT_ASSERT(window_); ecore_imf_init(); const char* imf_id = ecore_imf_context_default_id_get(); @@ -126,8 +125,7 @@ TizenInputMethodContext::TizenInputMethodContext( } ecore_imf_context_client_window_set( - imf_context_, - reinterpret_cast(flutter_tizen_window_->GetWindowId())); + imf_context_, reinterpret_cast(window_->GetWindowId())); SetContextOptions(); SetInputPanelOptions(); RegisterEventCallbacks(); diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index c2a3c09092cec..dcc069c36791e 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -29,7 +29,7 @@ struct InputPanelGeometry { class TizenInputMethodContext { public: - TizenInputMethodContext(TizenWindow* flutter_tizen_window); + TizenInputMethodContext(TizenWindow* window); ~TizenInputMethodContext(); bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); @@ -69,7 +69,7 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); - TizenWindow* flutter_tizen_window_ = nullptr; + TizenWindow* window_ = nullptr; Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; OnPreeditChanged on_preedit_changed_; diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index aeeeac891ff8a..5ae30caa41cf5 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -26,9 +26,7 @@ class TizenWindow { // Sets the delegate used to communicate state changes from window to view // such as key presses, mouse position updates etc. - void SetFlutterTizenView(FlutterTizenView* view) { - flutter_tizen_view_ = view; - } + void SetView(FlutterTizenView* view) { view_ = view; } // Returns the geometry of the current window. virtual Geometry GetWindowGeometry() = 0; @@ -82,7 +80,7 @@ class TizenWindow { bool focusable_ = false; bool top_level_ = false; - FlutterTizenView* flutter_tizen_view_ = nullptr; + FlutterTizenView* view_ = nullptr; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index d8a29b8bc93e6..19e0f5bc0b9a2 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -122,12 +122,12 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_WL2_EVENT_WINDOW_ROTATE, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* rotation_event = reinterpret_cast(event); if (rotation_event->win == self->GetWindowId()) { int32_t degree = rotation_event->angle; - self->flutter_tizen_view_->OnRotate(degree); + self->view_->OnRotate(degree); auto geometry = self->GetWindowGeometry(); ecore_wl2_window_rotation_change_done_send( self->ecore_wl2_window_, rotation_event->rotation, @@ -143,13 +143,12 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_WL2_EVENT_WINDOW_CONFIGURE, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* configure_event = reinterpret_cast(event); if (configure_event->win == self->GetWindowId()) { - self->flutter_tizen_view_->OnResize( - configure_event->x, configure_event->y, configure_event->w, - configure_event->h); + self->view_->OnResize(configure_event->x, configure_event->y, + configure_event->w, configure_event->h); ecore_wl2_window_commit(self->ecore_wl2_window_, EINA_FALSE); return ECORE_CALLBACK_DONE; } @@ -162,11 +161,11 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_MOUSE_BUTTON_DOWN, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* button_event = reinterpret_cast(event); if (button_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnPointerDown( + self->view_->OnPointerDown( button_event->x, button_event->y, button_event->timestamp, kFlutterPointerDeviceKindTouch, button_event->multi.device); return ECORE_CALLBACK_DONE; @@ -180,11 +179,11 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_MOUSE_BUTTON_UP, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* button_event = reinterpret_cast(event); if (button_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnPointerUp( + self->view_->OnPointerUp( button_event->x, button_event->y, button_event->timestamp, kFlutterPointerDeviceKindTouch, button_event->multi.device); return ECORE_CALLBACK_DONE; @@ -198,10 +197,10 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_MOUSE_MOVE, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* move_event = reinterpret_cast(event); if (move_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnPointerMove( + self->view_->OnPointerMove( move_event->x, move_event->y, move_event->timestamp, kFlutterPointerDeviceKindTouch, move_event->multi.device); return ECORE_CALLBACK_DONE; @@ -215,7 +214,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_MOUSE_WHEEL, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* wheel_event = reinterpret_cast(event); if (wheel_event->window == self->GetWindowId()) { double delta_x = 0.0; @@ -227,10 +226,10 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { delta_x += wheel_event->z; } - self->flutter_tizen_view_->OnScroll( - wheel_event->x, wheel_event->y, delta_x, delta_y, - kScrollOffsetMultiplier, wheel_event->timestamp, - kFlutterPointerDeviceKindTouch, 0); + self->view_->OnScroll(wheel_event->x, wheel_event->y, delta_x, + delta_y, kScrollOffsetMultiplier, + wheel_event->timestamp, + kFlutterPointerDeviceKindTouch, 0); return ECORE_CALLBACK_DONE; } } @@ -242,10 +241,10 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_KEY_DOWN, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnKey(key_event, true); + self->view_->OnKey(key_event, true); return ECORE_CALLBACK_DONE; } } @@ -257,10 +256,10 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { ECORE_EVENT_KEY_UP, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnKey(key_event, false); + self->view_->OnKey(key_event, false); return ECORE_CALLBACK_DONE; } } @@ -362,8 +361,7 @@ void TizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { // This implementation mimics the situation in which the handler of // ECORE_WL2_EVENT_WINDOW_CONFIGURE is called. SetWindowGeometry(geometry); - flutter_tizen_view_->OnResize(geometry.left, geometry.top, geometry.width, - geometry.height); + view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); } void TizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index e9a72e218d186..c926369ca3d31 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -124,11 +124,11 @@ void TizenWindowElementary::RegisterEventHandlers() { rotatoin_changed_callback_ = [](void* data, Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { if (self->elm_win_ == object) { // FIXME FT_UNIMPLEMENTED(); - self->flutter_tizen_view_->OnRotate(self->GetRotation()); + self->view_->OnRotate(self->GetRotation()); elm_win_wm_rotation_manual_rotation_done(self->elm_win_); } } @@ -139,11 +139,11 @@ void TizenWindowElementary::RegisterEventHandlers() { evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN] = [](void* data, Evas* evas, Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { if (self->elm_win_ == object) { auto* mouse_event = reinterpret_cast(event_info); - self->flutter_tizen_view_->OnPointerDown( + self->view_->OnPointerDown( mouse_event->canvas.x, mouse_event->canvas.y, mouse_event->timestamp, kFlutterPointerDeviceKindTouch, mouse_event->button); @@ -158,13 +158,13 @@ void TizenWindowElementary::RegisterEventHandlers() { Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { if (self->elm_win_ == object) { auto* mouse_event = reinterpret_cast(event_info); - self->flutter_tizen_view_->OnPointerUp( - mouse_event->canvas.x, mouse_event->canvas.y, - mouse_event->timestamp, kFlutterPointerDeviceKindTouch, - mouse_event->button); + self->view_->OnPointerUp(mouse_event->canvas.x, mouse_event->canvas.y, + mouse_event->timestamp, + kFlutterPointerDeviceKindTouch, + mouse_event->button); } } }; @@ -175,11 +175,11 @@ void TizenWindowElementary::RegisterEventHandlers() { evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE] = [](void* data, Evas* evas, Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { if (self->elm_win_ == object) { auto* mouse_event = reinterpret_cast(event_info); - self->flutter_tizen_view_->OnPointerMove( + self->view_->OnPointerMove( mouse_event->cur.canvas.x, mouse_event->cur.canvas.y, mouse_event->timestamp, kFlutterPointerDeviceKindTouch, mouse_event->buttons); @@ -190,29 +190,29 @@ void TizenWindowElementary::RegisterEventHandlers() { elm_win_, EVAS_CALLBACK_MOUSE_MOVE, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE], this); - evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL] = - [](void* data, Evas* evas, Evas_Object* object, void* event_info) { - auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { - if (self->elm_win_ == object) { - auto* wheel_event = - reinterpret_cast(event_info); - double delta_x = 0.0; - double delta_y = 0.0; - - if (wheel_event->direction == kScrollDirectionVertical) { - delta_y += wheel_event->z; - } else if (wheel_event->direction == kScrollDirectionHorizontal) { - delta_x += wheel_event->z; - } - - self->flutter_tizen_view_->OnScroll( - wheel_event->x, wheel_event->y, delta_x, delta_y, - kScrollOffsetMultiplier, wheel_event->timestamp, - kFlutterPointerDeviceKindTouch, 0); - } + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->elm_win_ == object) { + auto* wheel_event = + reinterpret_cast(event_info); + double delta_x = 0.0; + double delta_y = 0.0; + + if (wheel_event->direction == kScrollDirectionVertical) { + delta_y += wheel_event->z; + } else if (wheel_event->direction == kScrollDirectionHorizontal) { + delta_x += wheel_event->z; } - }; + + self->view_->OnScroll(wheel_event->x, wheel_event->y, delta_x, delta_y, + kScrollOffsetMultiplier, wheel_event->timestamp, + kFlutterPointerDeviceKindTouch, 0); + } + } + }; evas_object_event_callback_add( elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL], this); @@ -222,10 +222,10 @@ void TizenWindowElementary::RegisterEventHandlers() { ECORE_EVENT_KEY_DOWN, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnKey(key_event, false); + self->view_->OnKey(key_event, false); return ECORE_CALLBACK_DONE; } } @@ -237,10 +237,10 @@ void TizenWindowElementary::RegisterEventHandlers() { ECORE_EVENT_KEY_UP, [](void* data, int type, void* event) -> Eina_Bool { auto* self = reinterpret_cast(data); - if (self->flutter_tizen_view_) { + if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->flutter_tizen_view_->OnKey(key_event, true); + self->view_->OnKey(key_event, true); return ECORE_CALLBACK_DONE; } } @@ -316,8 +316,7 @@ uintptr_t TizenWindowElementary::GetWindowId() { void TizenWindowElementary::ResizeRenderTargetWithRotation(Geometry geometry, int32_t angle) { TizenRendererEvasGL* renderer_evas_gl = - reinterpret_cast( - flutter_tizen_view_->flutter_tizen_engine()->renderer()); + reinterpret_cast(view_->engine()->renderer()); renderer_evas_gl->ResizeSurface(geometry.width, geometry.height); } @@ -341,8 +340,7 @@ void TizenWindowElementary::Show() { void TizenWindowElementary::OnGeometryChanged(Geometry geometry) { SetWindowGeometry(geometry); - flutter_tizen_view_->OnResize(geometry.left, geometry.top, geometry.width, - geometry.height); + view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); } } // namespace flutter From 2f3ae4cdea316e4d55cf2d266498cdb2c7b834fa Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 26 Apr 2022 15:26:01 +0900 Subject: [PATCH 20/32] Adding a trailing comma for readability Signed-off-by: Boram Bae --- shell/platform/tizen/channels/window_channel.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index eed1b07d9ce82..b7e246cb06946 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -61,9 +61,12 @@ void WindowChannel::HandleMethodCall( // FIXME: Use SetWindowGeometry() instead of OnGeometryChanged() // After the SetWindowGeometry was successfully executed, I expected a // handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't. - window_->OnGeometryChanged({x ? *x : geometry.left, y ? *y : geometry.top, - width ? *width : geometry.width, - height ? *height : geometry.height}); + window_->OnGeometryChanged({ + x ? *x : geometry.left, + y ? *y : geometry.top, + width ? *width : geometry.width, + height ? *height : geometry.height, + }); result->Success(); #endif } else if (method_name == "getScreenGeometry") { From 319e5c174ed74717f30e3bdd79e0753c61a4d9bf Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 26 Apr 2022 15:43:48 +0900 Subject: [PATCH 21/32] Add null check for custom entrypoint Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_project_bundle.cc | 7 +++++-- shell/platform/tizen/flutter_project_bundle.h | 2 +- shell/platform/tizen/flutter_project_bundle_unittests.cc | 4 ---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/flutter_project_bundle.cc b/shell/platform/tizen/flutter_project_bundle.cc index b8ee73f2efaeb..23ef6d2153b93 100644 --- a/shell/platform/tizen/flutter_project_bundle.cc +++ b/shell/platform/tizen/flutter_project_bundle.cc @@ -35,12 +35,15 @@ std::filesystem::path GetBinDirectory() { FlutterProjectBundle::FlutterProjectBundle( const FlutterDesktopEngineProperties& properties) : assets_path_(properties.assets_path), - icu_path_(properties.icu_data_path), - custom_dart_entrypoint_(properties.entrypoint) { + icu_path_(properties.icu_data_path) { if (properties.aot_library_path != nullptr) { aot_library_path_ = std::filesystem::path(properties.aot_library_path); } + if (properties.entrypoint != nullptr) { + custom_dart_entrypoint_ = std::string(properties.entrypoint); + } + for (int i = 0; i < properties.dart_entrypoint_argc; i++) { dart_entrypoint_arguments_.push_back( std::string(properties.dart_entrypoint_argv[i])); diff --git a/shell/platform/tizen/flutter_project_bundle.h b/shell/platform/tizen/flutter_project_bundle.h index b9f4c51ebe463..c167357af5768 100644 --- a/shell/platform/tizen/flutter_project_bundle.h +++ b/shell/platform/tizen/flutter_project_bundle.h @@ -56,7 +56,7 @@ class FlutterProjectBundle { // Logs and returns nullptr on failure. UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs); - // Returns custom entrypoint in the Dart project + // Returns custom entrypoint in the Dart project. const std::string& custom_dart_entrypoint() { return custom_dart_entrypoint_; } diff --git a/shell/platform/tizen/flutter_project_bundle_unittests.cc b/shell/platform/tizen/flutter_project_bundle_unittests.cc index 3375f4deef073..27b05139f1ad3 100644 --- a/shell/platform/tizen/flutter_project_bundle_unittests.cc +++ b/shell/platform/tizen/flutter_project_bundle_unittests.cc @@ -12,7 +12,6 @@ TEST(FlutterProjectBundle, BasicPropertiesAbsolutePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "/foo/flutter_assets"; properties.icu_data_path = "/foo/icudtl.dat"; - properties.entrypoint = ""; FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -24,7 +23,6 @@ TEST(FlutterProjectBundle, BasicPropertiesRelativePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - properties.entrypoint = ""; FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -38,7 +36,6 @@ TEST(FlutterProjectBundle, EmptyEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - properties.entrypoint = ""; std::vector switches; properties.switches = switches.data(); properties.switches_count = switches.size(); @@ -52,7 +49,6 @@ TEST(FlutterProjectBundle, HasEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; - properties.entrypoint = ""; std::vector switches; switches.push_back("--abc"); switches.push_back("--foo=\"bar, baz\""); From 7030839b99f84399348df74af2f6420895e9a17e Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 26 Apr 2022 15:55:46 +0900 Subject: [PATCH 22/32] Update based on review Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen.cc | 1 + shell/platform/tizen/flutter_tizen_ecore.cc | 19 ++++++++++--------- .../tizen/flutter_tizen_elementary.cc | 19 ++++++++++--------- shell/platform/tizen/flutter_tizen_engine.cc | 14 +++++++------- shell/platform/tizen/flutter_tizen_view.cc | 7 ++++--- shell/platform/tizen/flutter_tizen_view.h | 16 +++++++--------- 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 0a246dcc44f75..b3c1821d37fac 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -52,6 +52,7 @@ FlutterDesktopEngineRef FlutterDesktopEngineCreate( flutter::Logger::SetLoggingPort(std::stoi(logging_port)); } flutter::Logger::Start(); + auto flutter_tizen_engine = std::make_unique(project); return HandleForEngine(flutter_tizen_engine.release()); diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index 90a738572f74a..9638d46c09f6a 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -1,7 +1,4 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. #include "public/flutter_tizen.h" @@ -25,17 +22,21 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { + flutter::TizenWindow::Geometry window_geometry = { + window_properties.x, + window_properties.y, + window_properties.width, + window_properties.height, + }; + std::unique_ptr window = std::make_unique( - flutter::TizenWindow::Geometry( - {window_properties.x, window_properties.y, - window_properties.width, window_properties.height}), - window_properties.transparent, window_properties.focusable, - window_properties.top_level); + window_geometry, window_properties.transparent, + window_properties.focusable, window_properties.top_level); - // Take ownership of the engine, starting it if necessary. auto view = std::make_unique(std::move(window)); + // Take ownership of the engine, starting it if necessary. view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index debc53a3d1d52..72fe6e8854ea5 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -1,7 +1,4 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. #include "public/flutter_tizen.h" @@ -25,17 +22,21 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { + flutter::TizenWindow::Geometry window_geometry = { + window_properties.x, + window_properties.y, + window_properties.width, + window_properties.height, + }; + std::unique_ptr window = std::make_unique( - flutter::TizenWindow::Geometry( - {window_properties.x, window_properties.y, - window_properties.width, window_properties.height}), - window_properties.transparent, window_properties.focusable, - window_properties.top_level); + window_geometry, window_properties.transparent, + window_properties.focusable, window_properties.top_level); - // Take ownership of the engine, starting it if necessary. auto view = std::make_unique(std::move(window)); + // Take ownership of the engine, starting it if necessary. view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 2ef9afb331fb6..d28a5b5549a96 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -410,35 +410,35 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { config.type = kOpenGL; config.open_gl.struct_size = sizeof(config.open_gl); config.open_gl.make_current = [](void* user_data) -> bool { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return false; } return engine->view()->OnMakeCurrent(); }; config.open_gl.make_resource_current = [](void* user_data) -> bool { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return false; } return engine->view()->OnMakeResourceCurrent(); }; config.open_gl.clear_current = [](void* user_data) -> bool { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return false; } return engine->view()->OnClearCurrent(); }; config.open_gl.present = [](void* user_data) -> bool { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return false; } return engine->view()->OnPresent(); }; config.open_gl.fbo_callback = [](void* user_data) -> uint32_t { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return false; } @@ -446,7 +446,7 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { }; config.open_gl.surface_transformation = [](void* user_data) -> FlutterTransformation { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return FlutterTransformation(); } @@ -454,7 +454,7 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { }; config.open_gl.gl_proc_resolver = [](void* user_data, const char* name) -> void* { - auto engine = reinterpret_cast(user_data); + auto* engine = reinterpret_cast(user_data); if (!engine->view()) { return nullptr; } diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 23a967facc164..b905865b31e16 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -56,7 +56,7 @@ void FlutterTizenView::SetEngine( internal_plugin_registrar_ = std::make_unique(engine_->plugin_registrar()); - // Setup window dependent channels. + // Set up window dependent channels. BinaryMessenger* messenger = internal_plugin_registrar_->messenger(); platform_channel_ = std::make_unique(messenger, window_.get()); @@ -64,12 +64,13 @@ void FlutterTizenView::SetEngine( text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), std::make_unique(window_.get())); + OnRotate(window_->GetRotation()); } void FlutterTizenView::CreateRenderSurface() { if (engine_ && engine_->renderer()) { - auto geometry = window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = window_->GetWindowGeometry(); engine_->renderer()->CreateSurface(window_->GetRenderTarget(), window_->GetRenderTargetDisplay(), geometry.width, geometry.height); @@ -137,7 +138,7 @@ void FlutterTizenView::OnRotate(int32_t degree) { } // view settransform - flutter_trans_formation_ = { + flutter_transformation_ = { cos(rad), -sin(rad), trans_x, // x sin(rad), cos(rad), trans_y, // y 0.0, 0.0, 1.0 // perspective diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 862413c5254f0..0e94bd2788073 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -42,11 +42,8 @@ class FlutterTizenView { // Callbacks for clearing context, settings context and swapping buffers, // these are typically called on an engine-controlled (non-platform) thread. bool OnMakeCurrent(); - bool OnClearCurrent(); - bool OnMakeResourceCurrent(); - bool OnPresent(); uint32_t OnGetFBO(); @@ -88,21 +85,21 @@ class FlutterTizenView { void OnKey(Ecore_Event_Key* event, bool is_down); FlutterTransformation GetFlutterTransformation() { - return flutter_trans_formation_; + return flutter_transformation_; } void SendInitialGeometry(); private: // Sends a window metrics update to the Flutter engine using current window - // dimensions in physical + // dimensions in physical. void SendWindowMetrics(int32_t left, int32_t top, int32_t width, int32_t height, double pixel_ratio); - // Reports pointer event to Flutter engine + // Reports pointer event to Flutter engine. void SendFlutterPointerEvent(FlutterPointerPhase phase, double x, double y, @@ -137,9 +134,10 @@ class FlutterTizenView { bool pointer_state_ = false; // The current view transformation. - FlutterTransformation flutter_trans_formation_ = {1.0, 0.0, 0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, 1.0}; + FlutterTransformation flutter_transformation_ = {1.0, 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 0.0, 1.0}; }; } // namespace flutter -#endif + +#endif // EMBEDDER_FLUTTER_TIZEN_VIEW_H_ From 0fd880d3d854b15069e1f26b5c956153608978ae Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 26 Apr 2022 16:37:00 +0900 Subject: [PATCH 23/32] Change API name based on review Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_ecore.cc | 2 +- shell/platform/tizen/flutter_tizen_elementary.cc | 2 +- shell/platform/tizen/public/flutter_tizen.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index 9638d46c09f6a..dce3f34887a47 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -19,7 +19,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { } // namespace -FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( +FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { flutter::TizenWindow::Geometry window_geometry = { diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 72fe6e8854ea5..22e4f14642288 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -19,7 +19,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) { } // namespace -FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( +FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine) { flutter::TizenWindow::Geometry window_geometry = { diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 11fb27138faff..aeba4ec9e42b9 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -131,7 +131,7 @@ FLUTTER_EXPORT void FlutterDesktopEngineNotifyAppIsDetached( // ========== View ========== // Creates a view that hosts and displays the given engine instance. -FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateUsingNewWindow( +FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine); From 3c913a301112ddb570a66724dd1d7121f23c2190 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 28 Apr 2022 11:36:24 +0900 Subject: [PATCH 24/32] Update based on review Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen.cc | 5 ++--- shell/platform/tizen/flutter_tizen_ecore.cc | 4 ++-- shell/platform/tizen/flutter_tizen_elementary.cc | 4 ++-- shell/platform/tizen/flutter_tizen_view.cc | 9 ++++----- shell/platform/tizen/flutter_tizen_view.h | 2 +- shell/platform/tizen/tizen_window_ecore_wl2.cc | 4 ++-- shell/platform/tizen/tizen_window_elementary.cc | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index b3c1821d37fac..2f58bc48074a1 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -53,9 +53,8 @@ FlutterDesktopEngineRef FlutterDesktopEngineCreate( } flutter::Logger::Start(); - auto flutter_tizen_engine = - std::make_unique(project); - return HandleForEngine(flutter_tizen_engine.release()); + auto engine = std::make_unique(project); + return HandleForEngine(engine.release()); } bool FlutterDesktopEngineRun(const FlutterDesktopEngineRef engine) { diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index dce3f34887a47..a8ba934721c2c 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -1,4 +1,6 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "public/flutter_tizen.h" @@ -39,9 +41,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( // Take ownership of the engine, starting it if necessary. view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); - view->CreateRenderSurface(); - if (!view->engine()->IsRunning()) { view->engine()->RunEngine(); } diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 22e4f14642288..aade8e8f0a888 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -1,4 +1,6 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "public/flutter_tizen.h" @@ -39,9 +41,7 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( // Take ownership of the engine, starting it if necessary. view->SetEngine( std::unique_ptr(EngineFromHandle(engine))); - view->CreateRenderSurface(); - if (!view->engine()->IsRunning()) { view->engine()->RunEngine(); } diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index b905865b31e16..c489352ac116e 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -48,9 +48,8 @@ FlutterTizenView::FlutterTizenView(std::unique_ptr window) FlutterTizenView::~FlutterTizenView() {} -void FlutterTizenView::SetEngine( - std::unique_ptr flutter_tizen_engine) { - engine_ = std::move(flutter_tizen_engine); +void FlutterTizenView::SetEngine(std::unique_ptr engine) { + engine_ = std::move(engine); engine_->SetView(this); internal_plugin_registrar_ = @@ -123,7 +122,7 @@ void FlutterTizenView::OnRotate(int32_t degree) { rotation_degree_ = degree; // Compute renderer transformation based on the angle of rotation. double rad = (360 - rotation_degree_) * M_PI / 180; - auto geometry = window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = window_->GetWindowGeometry(); int32_t width = geometry.width; int32_t height = geometry.height; @@ -270,7 +269,7 @@ void FlutterTizenView::SendFlutterPointerEvent( size_t timestamp, FlutterPointerDeviceKind device_kind, int device_id) { - auto geometry = window_->GetWindowGeometry(); + TizenWindow::Geometry geometry = window_->GetWindowGeometry(); double new_x = x, new_y = y; if (rotation_degree_ == 90) { diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 0e94bd2788073..a18e233c51cce 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -26,7 +26,7 @@ class FlutterTizenView { // Configures the window instance with an instance of a running Flutter // engine. - void SetEngine(std::unique_ptr flutter_tizen_engine); + void SetEngine(std::unique_ptr engine); FlutterTizenEngine* engine() { return engine_.get(); } diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 19e0f5bc0b9a2..66859275855b5 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -128,7 +128,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (rotation_event->win == self->GetWindowId()) { int32_t degree = rotation_event->angle; self->view_->OnRotate(degree); - auto geometry = self->GetWindowGeometry(); + Geometry geometry = self->GetWindowGeometry(); ecore_wl2_window_rotation_change_done_send( self->ecore_wl2_window_, rotation_event->rotation, geometry.width, geometry.height); @@ -269,7 +269,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { } void TizenWindowEcoreWl2::UnregisterEventCallbacks() { - for (auto handler : ecore_event_handlers_) { + for (auto* handler : ecore_event_handlers_) { ecore_event_handler_del(handler); } ecore_event_handlers_.clear(); diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index c926369ca3d31..56ad55307cdbf 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -266,7 +266,7 @@ void TizenWindowElementary::UnregisterEventCallbacks() { elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL]); - for (auto handler : ecore_event_key_handlers_) { + for (auto* handler : ecore_event_key_handlers_) { ecore_event_handler_del(handler); } ecore_event_key_handlers_.clear(); From 4fb03438339643243fafd902bd39999336d51a9e Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 28 Apr 2022 11:41:53 +0900 Subject: [PATCH 25/32] Clean up minor things Signed-off-by: Boram Bae --- .../platform/tizen/flutter_tizen_texture_registrar_unittests.cc | 2 +- shell/platform/tizen/flutter_tizen_view.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc b/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc index a08375264c995..2c72a93822529 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar_unittests.cc @@ -26,7 +26,7 @@ class FlutterTizenTextureRegistrarTest : public ::testing::Test { engine_prop.assets_path = "/foo/flutter_assets"; engine_prop.icu_data_path = "/foo/icudtl.dat"; engine_prop.aot_library_path = "/foo/libapp.so"; - engine_prop.entrypoint = ""; + FlutterProjectBundle project(engine_prop); auto engine = std::make_unique(project); engine_ = engine.release(); diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index c489352ac116e..6d43497d2f962 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -97,6 +97,7 @@ bool FlutterTizenView::OnMakeResourceCurrent() { bool FlutterTizenView::OnPresent() { return engine_->renderer()->OnPresent(); } + uint32_t FlutterTizenView::OnGetFBO() { return engine_->renderer()->OnGetFBO(); } From 6cca9bfa70ed2e35335c7d50909e455965e9490b Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 29 Apr 2022 13:17:54 +0900 Subject: [PATCH 26/32] Update based on review Signed-off-by: Boram Bae --- .../tizen/flutter_project_bundle_unittests.cc | 4 ++++ .../platform/tizen/flutter_tizen_engine_unittest.cc | 1 - shell/platform/tizen/flutter_tizen_view.cc | 1 - shell/platform/tizen/flutter_tizen_view.h | 1 - shell/platform/tizen/tizen_renderer.h | 1 - shell/platform/tizen/tizen_renderer_egl.cc | 1 + shell/platform/tizen/tizen_renderer_egl.h | 6 +++--- shell/platform/tizen/tizen_renderer_evas_gl.cc | 2 +- shell/platform/tizen/tizen_renderer_evas_gl.h | 2 ++ shell/platform/tizen/tizen_window.h | 2 +- shell/platform/tizen/tizen_window_ecore_wl2.cc | 13 ++++++------- shell/platform/tizen/tizen_window_ecore_wl2.h | 11 ++++++----- shell/platform/tizen/tizen_window_elementary.cc | 13 ++++++------- shell/platform/tizen/tizen_window_elementary.h | 2 +- 14 files changed, 31 insertions(+), 29 deletions(-) diff --git a/shell/platform/tizen/flutter_project_bundle_unittests.cc b/shell/platform/tizen/flutter_project_bundle_unittests.cc index 27b05139f1ad3..e52932cedaff8 100644 --- a/shell/platform/tizen/flutter_project_bundle_unittests.cc +++ b/shell/platform/tizen/flutter_project_bundle_unittests.cc @@ -12,6 +12,7 @@ TEST(FlutterProjectBundle, BasicPropertiesAbsolutePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "/foo/flutter_assets"; properties.icu_data_path = "/foo/icudtl.dat"; + FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -23,6 +24,7 @@ TEST(FlutterProjectBundle, BasicPropertiesRelativePaths) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; + FlutterProjectBundle project(properties); EXPECT_TRUE(project.HasValidPaths()); @@ -36,6 +38,7 @@ TEST(FlutterProjectBundle, EmptyEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; + std::vector switches; properties.switches = switches.data(); properties.switches_count = switches.size(); @@ -49,6 +52,7 @@ TEST(FlutterProjectBundle, HasEngineArguments) { FlutterDesktopEngineProperties properties = {}; properties.assets_path = "foo/flutter_assets"; properties.icu_data_path = "foo/icudtl.dat"; + std::vector switches; switches.push_back("--abc"); switches.push_back("--foo=\"bar, baz\""); diff --git a/shell/platform/tizen/flutter_tizen_engine_unittest.cc b/shell/platform/tizen/flutter_tizen_engine_unittest.cc index 68a378f7beb87..bdaa2cfa56053 100644 --- a/shell/platform/tizen/flutter_tizen_engine_unittest.cc +++ b/shell/platform/tizen/flutter_tizen_engine_unittest.cc @@ -23,7 +23,6 @@ class FlutterTizenEngineTest : public ::testing::Test { engine_prop.assets_path = "/foo/flutter_assets"; engine_prop.icu_data_path = "/foo/icudtl.dat"; engine_prop.aot_library_path = "/foo/libapp.so"; - engine_prop.entrypoint = ""; FlutterProjectBundle project(engine_prop); auto engine = std::make_unique(project); diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 6d43497d2f962..dd0838963f960 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -137,7 +137,6 @@ void FlutterTizenView::OnRotate(int32_t degree) { trans_x = width; } - // view settransform flutter_transformation_ = { cos(rad), -sin(rad), trans_x, // x sin(rad), cos(rad), trans_y, // y diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index a18e233c51cce..28c7f8635a0fa 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -50,7 +50,6 @@ class FlutterTizenView { void* OnProcResolver(const char* name); - // ========== Window Event Delegate ========== void OnResize(int32_t left, int32_t top, int32_t width, int32_t height); void OnRotate(int32_t degree); diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 9de5bf21fff40..c5f600a251641 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -6,7 +6,6 @@ #define EMBEDDER_TIZEN_RENDERER_H_ #include -#include namespace flutter { diff --git a/shell/platform/tizen/tizen_renderer_egl.cc b/shell/platform/tizen/tizen_renderer_egl.cc index 61b3212434455..0b88fc2212235 100644 --- a/shell/platform/tizen/tizen_renderer_egl.cc +++ b/shell/platform/tizen/tizen_renderer_egl.cc @@ -81,6 +81,7 @@ bool TizenRendererEgl::CreateSurface(void* render_target, return false; } } + is_valid_ = true; return true; } diff --git a/shell/platform/tizen/tizen_renderer_egl.h b/shell/platform/tizen/tizen_renderer_egl.h index 281b39b0394e1..74708e3b65fc6 100644 --- a/shell/platform/tizen/tizen_renderer_egl.h +++ b/shell/platform/tizen/tizen_renderer_egl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H_ -#define EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H_ +#ifndef EMBEDDER_TIZEN_RENDERER_EGL_H_ +#define EMBEDDER_TIZEN_RENDERER_EGL_H_ #define EFL_BETA_API_SUPPORT #include @@ -58,4 +58,4 @@ class TizenRendererEgl : public TizenRenderer { } // namespace flutter -#endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H_ +#endif // EMBEDDER_TIZEN_RENDERER_EGL_H_ diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index c3a713a1f7c67..5994cd0b4d54c 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -6,7 +6,7 @@ #include "tizen_evas_gl_helper.h" -// g_evas_gl is shared with ExternalTexturePixelGL and ExternalTextureSurfaceGL +// g_evas_gl is shared with ExternalTexturePixelGL and ExternalTextureSurfaceGL. Evas_GL* g_evas_gl = nullptr; EVAS_GL_GLOBAL_GLES3_DEFINE(); diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 9a9e412fc9fd9..3e961df8f6ba7 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -5,6 +5,8 @@ #ifndef EMBEDDER_TIZEN_RENDERER_EVAS_GL_H_ #define EMBEDDER_TIZEN_RENDERER_EVAS_GL_H_ +#include + #undef EFL_BETA_API_SUPPORT #include #include diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index 5ae30caa41cf5..0fb2d0a17f9de 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -45,7 +45,7 @@ class TizenWindow { virtual int32_t GetRotation() = 0; - // Returns the scale factor for the backing window. + // Returns the dpi of the screen. virtual int32_t GetDpi() = 0; virtual uintptr_t GetWindowId() = 0; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 66859275855b5..024599921c16c 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -24,7 +24,7 @@ TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, bool top_level) : TizenWindow(geometry, transparent, focusable, top_level) { if (!CreateWindow()) { - FT_LOG(Error) << "Failed to create platform window"; + FT_LOG(Error) << "Failed to create a platform window."; return; } @@ -34,8 +34,8 @@ TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, } TizenWindowEcoreWl2::~TizenWindowEcoreWl2() { - UnregisterEventCallbacks(); - DestroyEcoreWl2(); + UnregisterEventHandlers(); + DestroyWindow(); } bool TizenWindowEcoreWl2::CreateWindow() { @@ -63,7 +63,6 @@ bool TizenWindowEcoreWl2::CreateWindow() { if (initial_geometry_.width == 0) { initial_geometry_.width = width; } - if (initial_geometry_.height == 0) { initial_geometry_.height = height; } @@ -268,14 +267,14 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { this)); } -void TizenWindowEcoreWl2::UnregisterEventCallbacks() { +void TizenWindowEcoreWl2::UnregisterEventHandlers() { for (auto* handler : ecore_event_handlers_) { ecore_event_handler_del(handler); } ecore_event_handlers_.clear(); } -void TizenWindowEcoreWl2::DestroyEcoreWl2() { +void TizenWindowEcoreWl2::DestroyWindow() { if (ecore_wl2_egl_window_) { ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); ecore_wl2_egl_window_ = nullptr; @@ -347,7 +346,7 @@ void TizenWindowEcoreWl2::SetPreferredOrientations( } void TizenWindowEcoreWl2::BindKeys(const std::vector& keys) { - for (const auto& key : keys) { + for (const std::string& key : keys) { ecore_wl2_window_keygrab_set(ecore_wl2_window_, key.c_str(), 0, 0, 0, ECORE_WL2_WINDOW_KEYGRAB_TOPMOST); } diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index 45498a6f9c1d1..25dc1f56f9287 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -3,8 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ -#define EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ +#ifndef EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ +#define EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ #include "flutter/shell/platform/tizen/tizen_window.h" @@ -55,13 +55,13 @@ class TizenWindowEcoreWl2 : public TizenWindow { private: bool CreateWindow(); - void DestroyEcoreWl2(); + void DestroyWindow(); void SetWindowOptions(); void RegisterEventHandlers(); - void UnregisterEventCallbacks(); + void UnregisterEventHandlers(); void SetTizenPolicyNotificationLevel(int level); @@ -76,4 +76,5 @@ class TizenWindowEcoreWl2 : public TizenWindow { }; } // namespace flutter -#endif + +#endif // EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index 56ad55307cdbf..7c77bc057b7b6 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -27,7 +27,7 @@ TizenWindowElementary::TizenWindowElementary(Geometry geometry, bool top_level) : TizenWindow(geometry, transparent, focusable, top_level) { if (!CreateWindow()) { - FT_LOG(Error) << "Failed to create platform window"; + FT_LOG(Error) << "Failed to create a platform window."; return; } @@ -37,7 +37,7 @@ TizenWindowElementary::TizenWindowElementary(Geometry geometry, } TizenWindowElementary::~TizenWindowElementary() { - UnregisterEventCallbacks(); + UnregisterEventHandlers(); DestroyWindow(); } @@ -76,9 +76,6 @@ bool TizenWindowElementary::CreateWindow() { initial_geometry_.height); evas_object_raise(elm_win_); - elm_win_indicator_mode_set(elm_win_, ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(elm_win_, ELM_WIN_INDICATOR_OPAQUE); - image_ = evas_object_image_filled_add(evas_object_evas_get(elm_win_)); evas_object_resize(image_, initial_geometry_.width, initial_geometry_.height); evas_object_move(image_, initial_geometry_.left, initial_geometry_.top); @@ -113,8 +110,10 @@ void TizenWindowElementary::SetWindowOptions() { elm_win_resize_object_add(elm_win_, bg); } + elm_win_indicator_mode_set(elm_win_, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(elm_win_, ELM_WIN_INDICATOR_OPAQUE); + // TODO: focusable_ - // TOOD: indicator const int rotations[4] = {0, 90, 180, 270}; elm_win_wm_rotation_available_rotations_set(elm_win_, &rotations[0], 4); @@ -249,7 +248,7 @@ void TizenWindowElementary::RegisterEventHandlers() { this)); } -void TizenWindowElementary::UnregisterEventCallbacks() { +void TizenWindowElementary::UnregisterEventHandlers() { evas_object_smart_callback_del(elm_win_, "rotation,changed", rotatoin_changed_callback_); diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index fe2b2f558c63f..5fd9cf5686ca0 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -63,7 +63,7 @@ class TizenWindowElementary : public TizenWindow { void RegisterEventHandlers(); - void UnregisterEventCallbacks(); + void UnregisterEventHandlers(); Evas_Object* elm_win_ = nullptr; Evas_Object* image_ = nullptr; From e7781a9579d0ef3805fa0cf4dd277787cccf0dc1 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 2 May 2022 10:45:00 +0900 Subject: [PATCH 27/32] Remove prefix "FLUTTER" from protection macro Signed-off-by: Boram Bae --- shell/platform/tizen/tizen_window.h | 7 ++++--- shell/platform/tizen/tizen_window_elementary.h | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index 0fb2d0a17f9de..b4a6ed94d5d2b 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -3,8 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_H_ -#define EMBEDDER_FLUTTER_TIZEN_WINDOW_H_ +#ifndef EMBEDDER_TIZEN_WINDOW_H_ +#define EMBEDDER_TIZEN_WINDOW_H_ #include #include @@ -84,4 +84,5 @@ class TizenWindow { }; } // namespace flutter -#endif + +#endif // EMBEDDER_TIZEN_WINDOW_H_ diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 5fd9cf5686ca0..4b9e1c2e2d770 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -3,8 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ -#define EMBEDDER_FLUTTER_TIZEN_WINDOW_ECORE_WL2_H_ +#ifndef EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ +#define EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ #include "flutter/shell/platform/tizen/tizen_window.h" @@ -75,4 +75,5 @@ class TizenWindowElementary : public TizenWindow { }; } // namespace flutter -#endif + +#endif // EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ From b989ba3f4c8c29c6e057f3897606361d96cf1ee7 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 2 May 2022 15:15:46 +0900 Subject: [PATCH 28/32] Fix a typo Signed-off-by: Boram Bae --- shell/platform/tizen/tizen_window_elementary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 4b9e1c2e2d770..930cdc5c2f0ec 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -3,8 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ -#define EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ +#ifndef EMBEDDER_TIZEN_WINDOW_ELEMENTARY_H_ +#define EMBEDDER_TIZEN_WINDOW_ELEMENTARY_H_ #include "flutter/shell/platform/tizen/tizen_window.h" @@ -76,4 +76,4 @@ class TizenWindowElementary : public TizenWindow { } // namespace flutter -#endif // EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ +#endif // EMBEDDER_TIZEN_WINDOW_ELEMENTARY_H_ From 2910892678dd02d8b69b27bc32ac359427743788 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 2 May 2022 15:59:59 +0900 Subject: [PATCH 29/32] Fix regression changes Signed-off-by: Boram Bae --- shell/platform/tizen/tizen_event_loop.cc | 2 +- shell/platform/tizen/tizen_window_ecore_wl2.cc | 4 ++-- shell/platform/tizen/tizen_window_elementary.cc | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index 45c0d90a73814..8faba58b34ee3 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -120,7 +120,7 @@ TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id, static_cast(renderer_)->SetOnPixelsDirty([this]() { { std::lock_guard lock(expired_tasks_mutex_); - for (const auto& task : expired_tasks_) { + for (const Task& task : expired_tasks_) { on_task_expired_(&task.task); } expired_tasks_.clear(); diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 024599921c16c..fefb0d13da933 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -268,7 +268,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { } void TizenWindowEcoreWl2::UnregisterEventHandlers() { - for (auto* handler : ecore_event_handlers_) { + for (Ecore_Event_Handler* handler : ecore_event_handlers_) { ecore_event_handler_del(handler); } ecore_event_handlers_.clear(); @@ -320,7 +320,7 @@ int32_t TizenWindowEcoreWl2::GetRotation() { } int32_t TizenWindowEcoreWl2::GetDpi() { - auto* output = ecore_wl2_window_output_find(ecore_wl2_window_); + Ecore_Wl2_Output* output = ecore_wl2_window_output_find(ecore_wl2_window_); if (!output) { FT_LOG(Error) << "Could not find an output associated with the window."; return 0; diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index 7c77bc057b7b6..49725fe0d6fc9 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -55,7 +55,8 @@ bool TizenWindowElementary::CreateWindow() { // Tizen 5.5 or later was chosen as default. // elm_win_aux_hint_add(elm_win_, "wm.policy.win.user.geometry", "1"); - auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + Ecore_Evas* ecore_evas = + ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); int32_t width, height; ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &width, &height); @@ -265,7 +266,7 @@ void TizenWindowElementary::UnregisterEventHandlers() { elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL]); - for (auto* handler : ecore_event_key_handlers_) { + for (Ecore_Event_Handler* handler : ecore_event_key_handlers_) { ecore_event_handler_del(handler); } ecore_event_key_handlers_.clear(); @@ -290,7 +291,8 @@ void TizenWindowElementary::SetWindowGeometry(Geometry geometry) { TizenWindow::Geometry TizenWindowElementary::GetScreenGeometry() { Geometry result; - auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + Ecore_Evas* ecore_evas = + ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &result.width, &result.height); return result; @@ -301,7 +303,8 @@ int32_t TizenWindowElementary::GetRotation() { } int32_t TizenWindowElementary::GetDpi() { - auto* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); + Ecore_Evas* ecore_evas = + ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); int32_t xdpi, ydpi; ecore_evas_screen_dpi_get(ecore_evas, &xdpi, &ydpi); return xdpi; @@ -327,7 +330,7 @@ void TizenWindowElementary::SetPreferredOrientations( } void TizenWindowElementary::BindKeys(const std::vector& keys) { - for (const auto& key : keys) { + for (const std::string& key : keys) { eext_win_keygrab_set(elm_win_, key.c_str()); } } From 6d136c40bb270a5ed594c99c8c3c1cce1be4ffab Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 3 May 2022 14:18:09 +0900 Subject: [PATCH 30/32] Call bindKeys when Creating the view Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_view.cc | 1 + shell/platform/tizen/tizen_window_ecore_wl2.cc | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index dd0838963f960..a73169d5f9ac7 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -44,6 +44,7 @@ namespace flutter { FlutterTizenView::FlutterTizenView(std::unique_ptr window) : window_(std::move(window)) { window_->SetView(this); + window->BindKeys(kBindableSystemKeys); } FlutterTizenView::~FlutterTizenView() {} diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index fefb0d13da933..4353f4d30c256 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -302,9 +302,9 @@ TizenWindow::Geometry TizenWindowEcoreWl2::GetWindowGeometry() { void TizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, geometry.top, geometry.width, geometry.height); - // FIXME : I refer to https://github.com/flutter-tizen/engine/pull/201, - // but I don't know why it doesn't work properly without calling - // ecore_wl2_window_position_set(). + // FIXME: The changes set in `ecore_wl2_window_geometry_set` seems to apply + // only after calling `ecore_wl2_window_position_set`. Call a more appropriate + // API that flushes geometry settings to the compositor. ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, geometry.top); } From 5fef421b562af6c92bea6fda80c4ff1b89dce88f Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 3 May 2022 14:55:32 +0900 Subject: [PATCH 31/32] Updated based on review Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_view.cc | 1 - shell/platform/tizen/flutter_tizen_view.h | 2 ++ shell/platform/tizen/tizen_renderer_evas_gl.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index a73169d5f9ac7..b9391a0d03275 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -6,7 +6,6 @@ #include "flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" -#include "flutter/shell/platform/tizen/tizen_window.h" namespace { diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 28c7f8635a0fa..b59fa6d7d0606 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -8,6 +8,8 @@ #include +#include + #include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/tizen/channels/platform_channel.h" diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 3e961df8f6ba7..badba04499004 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -8,7 +8,6 @@ #include #undef EFL_BETA_API_SUPPORT -#include #include #include From 67324df0f4748b02c49d578e3921f3b0ef9bdf58 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 3 May 2022 15:05:16 +0900 Subject: [PATCH 32/32] Fix a typo Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_view.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index b9391a0d03275..d6db6bf5851d8 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -43,7 +43,7 @@ namespace flutter { FlutterTizenView::FlutterTizenView(std::unique_ptr window) : window_(std::move(window)) { window_->SetView(this); - window->BindKeys(kBindableSystemKeys); + window_->BindKeys(kBindableSystemKeys); } FlutterTizenView::~FlutterTizenView() {}