From 19166cd093b66b8adc3a3cb506d29c28093e41f7 Mon Sep 17 00:00:00 2001 From: "swan.seo" Date: Wed, 13 Jul 2022 18:05:02 +1100 Subject: [PATCH 1/4] Add FlutterDesktopViewGetContainer * Makes all tizen view types be able to get target container handle. Signed-off-by: swan.seo --- shell/platform/tizen/flutter_tizen.cc | 7 +++++++ shell/platform/tizen/flutter_tizen_elementary.cc | 10 ---------- shell/platform/tizen/public/flutter_tizen.h | 10 ++++++---- shell/platform/tizen/tizen_view.h | 2 -- shell/platform/tizen/tizen_view_base.h | 2 ++ shell/platform/tizen/tizen_window_ecore_wl2.h | 2 ++ shell/platform/tizen/tizen_window_elementary.h | 2 ++ 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index c1778f79df54a..0110ef460b43c 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -233,6 +233,13 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( return HandleForView(view.release()); } +void* FlutterDesktopViewGetContainer(FlutterDesktopViewRef view_ref) { + flutter::FlutterTizenView* view = ViewFromHandle(view_ref); + auto* tizen_view = + reinterpret_cast(view->tizen_view()); + return tizen_view->GetRenderTargetContainer(); +} + void FlutterDesktopViewResize(FlutterDesktopViewRef view, int32_t width, int32_t height) { diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 187e1e7a4c665..9123930233164 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -47,13 +47,3 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( return HandleForView(view.release()); } - -void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) { - auto* view = reinterpret_cast(view_ref); - if (view->tizen_view()->GetType() == flutter::TizenViewType::kView) { - auto* tizen_view = - reinterpret_cast(view->tizen_view()); - return tizen_view->GetRenderTargetContainer(); - } - return nullptr; -} diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index a00138439e5ba..a1154b6de9922 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -167,12 +167,14 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( // @warning This API is a work-in-progress and may change. FLUTTER_EXPORT void FlutterDesktopViewDestroy(FlutterDesktopViewRef view); -// Returns a handle to evas object that the FlutterView is drawn to. +// Returns a handle to target container that FlutterView is drawn to. // -// Cast the returned void* to Evas_Object*. +// Cast the returned void* +// - view elementary : to Evas_Object*. +// - window elementary : to Evas_Object* +// - window ecore wl2 : to Ecore_Wl2_Window* // @warning This API is a work-in-progress and may change. -FLUTTER_EXPORT void* FlutterDesktopViewGetEvasObject( - FlutterDesktopViewRef view); +FLUTTER_EXPORT void* FlutterDesktopViewGetContainer(FlutterDesktopViewRef view); // Resizes the view. // @warning This API is a work-in-progress and may change. diff --git a/shell/platform/tizen/tizen_view.h b/shell/platform/tizen/tizen_view.h index 6fb8696ea2dda..f39447c2edaff 100644 --- a/shell/platform/tizen/tizen_view.h +++ b/shell/platform/tizen/tizen_view.h @@ -18,8 +18,6 @@ class TizenView : public TizenViewBase { TizenView() = default; virtual ~TizenView() = default; - virtual void* GetRenderTargetContainer() = 0; - TizenViewType GetType() override { return TizenViewType::kView; }; protected: diff --git a/shell/platform/tizen/tizen_view_base.h b/shell/platform/tizen/tizen_view_base.h index 113121a6c7f68..7c3c29478de06 100644 --- a/shell/platform/tizen/tizen_view_base.h +++ b/shell/platform/tizen/tizen_view_base.h @@ -30,6 +30,8 @@ class TizenViewBase { // by the rendering backend. virtual void* GetRenderTarget() = 0; + virtual void* GetRenderTargetContainer() = 0; + virtual uintptr_t GetWindowId() = 0; // Returns the geometry of the view. diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index ecf77a52fc8e7..bdb14ad3682ad 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -34,6 +34,8 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetRenderTarget() override { return ecore_wl2_egl_window_; } + void* GetRenderTargetContainer() override { return ecore_wl2_window_; } + void* GetRenderTargetDisplay() override { return wl2_display_; } int32_t GetRotation() override; diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index ceb5f1fb05892..5410611f1bb2f 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -33,6 +33,8 @@ class TizenWindowElementary : public TizenWindow { void* GetRenderTarget() override { return image_; } + void* GetRenderTargetContainer() override { return elm_win_; } + void* GetRenderTargetDisplay() override { return nullptr; } int32_t GetRotation() override; From 2c5b06448234d431dcbefc026a20ab2ba1632d0b Mon Sep 17 00:00:00 2001 From: "swan.seo" Date: Thu, 14 Jul 2022 13:00:40 +1100 Subject: [PATCH 2/4] Apply reviewer's comment --- shell/platform/tizen/flutter_tizen.cc | 12 ++++-------- shell/platform/tizen/public/flutter_tizen.h | 7 ++++--- shell/platform/tizen/tizen_view_base.h | 2 +- shell/platform/tizen/tizen_view_elementary.h | 2 +- shell/platform/tizen/tizen_window_ecore_wl2.h | 4 +--- shell/platform/tizen/tizen_window_elementary.h | 4 +--- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 0110ef460b43c..4efaef2962589 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -82,14 +82,10 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { delete engine; } -void* FlutterDesktopPluginRegistrarGetNativeWindow( +void* FlutterDesktopPluginRegistrarGetNativeHandle( FlutterDesktopPluginRegistrarRef registrar) { flutter::TizenViewBase* tizen_view = registrar->engine->view()->tizen_view(); - if (tizen_view->GetType() == flutter::TizenViewType::kWindow) { - auto* window = reinterpret_cast(tizen_view); - return window->GetWindowHandle(); - } - return nullptr; + return tizen_view->GetNativeHandle(); } void FlutterDesktopPluginRegistrarEnableInputBlocking( @@ -233,11 +229,11 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( return HandleForView(view.release()); } -void* FlutterDesktopViewGetContainer(FlutterDesktopViewRef view_ref) { +void* FlutterDesktopViewGetNativeHandle(FlutterDesktopViewRef view_ref) { flutter::FlutterTizenView* view = ViewFromHandle(view_ref); auto* tizen_view = reinterpret_cast(view->tizen_view()); - return tizen_view->GetRenderTargetContainer(); + return tizen_view->GetNativeHandle(); } void FlutterDesktopViewResize(FlutterDesktopViewRef view, diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index a1154b6de9922..e17dcfd7f39cb 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -167,14 +167,15 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( // @warning This API is a work-in-progress and may change. FLUTTER_EXPORT void FlutterDesktopViewDestroy(FlutterDesktopViewRef view); -// Returns a handle to target container that FlutterView is drawn to. +// Returns a native UI toolkit handle for manipulation in host application. // // Cast the returned void* // - view elementary : to Evas_Object*. // - window elementary : to Evas_Object* // - window ecore wl2 : to Ecore_Wl2_Window* // @warning This API is a work-in-progress and may change. -FLUTTER_EXPORT void* FlutterDesktopViewGetContainer(FlutterDesktopViewRef view); +FLUTTER_EXPORT void* FlutterDesktopViewGetNativeHandle( + FlutterDesktopViewRef view); // Resizes the view. // @warning This API is a work-in-progress and may change. @@ -188,7 +189,7 @@ FLUTTER_EXPORT void FlutterDesktopViewResize(FlutterDesktopViewRef view, // // If the app runs on a wearable device, cast void* to Evas_Object*, // otherwise cast it to Ecore_Wl2_Window*. -FLUTTER_EXPORT void* FlutterDesktopPluginRegistrarGetNativeWindow( +FLUTTER_EXPORT void* FlutterDesktopPluginRegistrarGetNativeHandle( FlutterDesktopPluginRegistrarRef registrar); #if defined(__cplusplus) diff --git a/shell/platform/tizen/tizen_view_base.h b/shell/platform/tizen/tizen_view_base.h index 7c3c29478de06..3f3f6190ac6cb 100644 --- a/shell/platform/tizen/tizen_view_base.h +++ b/shell/platform/tizen/tizen_view_base.h @@ -30,7 +30,7 @@ class TizenViewBase { // by the rendering backend. virtual void* GetRenderTarget() = 0; - virtual void* GetRenderTargetContainer() = 0; + virtual void* GetNativeHandle() = 0; virtual uintptr_t GetWindowId() = 0; diff --git a/shell/platform/tizen/tizen_view_elementary.h b/shell/platform/tizen/tizen_view_elementary.h index 74e58cb994313..5304d9b8c5dd4 100644 --- a/shell/platform/tizen/tizen_view_elementary.h +++ b/shell/platform/tizen/tizen_view_elementary.h @@ -30,7 +30,7 @@ class TizenViewElementary : public TizenView { void* GetRenderTarget() override { return image_; } - void* GetRenderTargetContainer() override { return container_; } + void* GetNativeHandle() override { return container_; } int32_t GetDpi() override; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index bdb14ad3682ad..ca9e88063b735 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -34,7 +34,7 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetRenderTarget() override { return ecore_wl2_egl_window_; } - void* GetRenderTargetContainer() override { return ecore_wl2_window_; } + void* GetNativeHandle() override { return ecore_wl2_window_; } void* GetRenderTargetDisplay() override { return wl2_display_; } @@ -44,8 +44,6 @@ class TizenWindowEcoreWl2 : public TizenWindow { uintptr_t GetWindowId() override; - void* GetWindowHandle() override { return ecore_wl2_window_; } - void SetPreferredOrientations(const std::vector& rotations) override; void BindKeys(const std::vector& keys) override; diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 5410611f1bb2f..1065fac615a13 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -33,7 +33,7 @@ class TizenWindowElementary : public TizenWindow { void* GetRenderTarget() override { return image_; } - void* GetRenderTargetContainer() override { return elm_win_; } + void* GetNativeHandle() override { return elm_win_; } void* GetRenderTargetDisplay() override { return nullptr; } @@ -43,8 +43,6 @@ class TizenWindowElementary : public TizenWindow { uintptr_t GetWindowId() override; - void* GetWindowHandle() override { return elm_win_; } - void SetPreferredOrientations(const std::vector& rotations) override; void BindKeys(const std::vector& keys) override; From a539b0267f4564f93e62b939766999079e3d086c Mon Sep 17 00:00:00 2001 From: "swan.seo" Date: Mon, 1 Aug 2022 18:52:11 +1100 Subject: [PATCH 3/4] Apply reviewer's comment - Remove FlutterDesktopPluginRegistrarGetNativeHandle - Add FlutterDesktopPluginRegistrarGetView --- shell/platform/tizen/flutter_tizen.cc | 5 ++--- shell/platform/tizen/public/flutter_tizen.h | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 4efaef2962589..af6266c456b1b 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -82,10 +82,9 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { delete engine; } -void* FlutterDesktopPluginRegistrarGetNativeHandle( +FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView( FlutterDesktopPluginRegistrarRef registrar) { - flutter::TizenViewBase* tizen_view = registrar->engine->view()->tizen_view(); - return tizen_view->GetNativeHandle(); + return HandleForView(registrar->engine->view()); } void FlutterDesktopPluginRegistrarEnableInputBlocking( diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index e17dcfd7f39cb..53ae6d3faa714 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -185,11 +185,8 @@ FLUTTER_EXPORT void FlutterDesktopViewResize(FlutterDesktopViewRef view, // ========== 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* FlutterDesktopPluginRegistrarGetNativeHandle( +// Returns the view associated with this registrar's engine instance. +FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView( FlutterDesktopPluginRegistrarRef registrar); #if defined(__cplusplus) From a13966d3f356b4e51cfb4e83cd06116ec2b933fe Mon Sep 17 00:00:00 2001 From: "swan.seo" Date: Mon, 1 Aug 2022 19:38:55 +1100 Subject: [PATCH 4/4] Apply reviewer's comment - Change the order of the declaration of GetRenderTargetDisplay and GetNativeHandle --- shell/platform/tizen/tizen_window.h | 2 -- shell/platform/tizen/tizen_window_ecore_wl2.h | 4 ++-- shell/platform/tizen/tizen_window_elementary.h | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index 2b78edb3c1a7b..a78793f062b20 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -19,8 +19,6 @@ class TizenWindow : public TizenViewBase { TizenWindow() = default; virtual ~TizenWindow() = default; - virtual void* GetWindowHandle() = 0; - virtual int32_t GetRotation() = 0; virtual void SetPreferredOrientations(const std::vector& rotations) = 0; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index ca9e88063b735..7ad6c716e0ea1 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -34,10 +34,10 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetRenderTarget() override { return ecore_wl2_egl_window_; } - void* GetNativeHandle() override { return ecore_wl2_window_; } - void* GetRenderTargetDisplay() override { return wl2_display_; } + void* GetNativeHandle() override { return ecore_wl2_window_; } + int32_t GetRotation() override; int32_t GetDpi() override; diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 1065fac615a13..aabb02cf8935b 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -33,10 +33,10 @@ class TizenWindowElementary : public TizenWindow { void* GetRenderTarget() override { return image_; } - void* GetNativeHandle() override { return elm_win_; } - void* GetRenderTargetDisplay() override { return nullptr; } + void* GetNativeHandle() override { return elm_win_; } + int32_t GetRotation() override; int32_t GetDpi() override;