ecore_wl2_subsurface: support foreign shell 23/257823/3
authorShinwoo Kim <cinoo.kim@samsung.com>
Mon, 3 May 2021 11:46:11 +0000 (20:46 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 25 May 2021 10:43:01 +0000 (19:43 +0900)
Please refer to following enlightenment commit message,
for more well defined information about the foreign shell.

  commit b213f873bc279d7957d407aec5f6157713bbf0b2
  Author: Seunghun Lee <shiin.lee@samsung.com>
  Date:   Fri Apr 9 14:41:03 2021 +0900

    Support wtz-foreign protocol
    This is an initial commit to support wtz-foreign protocol.

    This is to support out-of-process video playing surface.
    wtz-foreign protocol is to enable one client to share its resources to
    another client.
    The client which exported a reference of foreign shell then can change
    attributes - such as size, orientation, and map state - of foreign shell.
    So, the client which import a foreign shell can draw its contents onto a
    surface without concerning about attributes such as size like as
    mentioned.

    The e_foreign contains implementation of wtz_exporter and wtz_importer.
    And e_foreign_shell contains implementation of wtz_exported_shell and
    wtz_foreign_shell.

Change-Id: Ie9b5bd5cea33263673f9d551b0486f08f84cb4a7

packaging/efl.spec
src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_subsurf.c
src/lib/ecore_wl2/meson.build

index e284729..d6465cb 100644 (file)
@@ -46,6 +46,7 @@ BuildRequires:  pkgconfig(tizen-extension-client)
 BuildRequires:  pkgconfig(tizen-launch-client)
 BuildRequires:  pkgconfig(tizen-remote-surface-client)
 BuildRequires:  pkgconfig(tizen-policy-ext-client)
+BuildRequires:  pkgconfig(wtz-foreign-client)
 BuildRequires:  wayland-protocols
 Requires:       libwayland-extension-client
 Requires:       libwayland-egl-tizen
index c67763e..32ec5d9 100644 (file)
@@ -3312,6 +3312,133 @@ EAPI Eina_Bool ecore_wl2_subsurface_video_surface_rotation_set(Ecore_Wl2_Subsurf
  */
 EAPI void ecore_wl2_subsurface_aux_hint_set(Ecore_Wl2_Subsurface *subsurface, const char *hint, const char *val);
 //
+
+
+//TIZEN_ONLY(20210503): support foreign shell
+/**
+ * @brief Export given subsurface
+ *
+ * @param subsurface The subsurface to export
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI Eina_Bool ecore_wl2_subsurface_export(Ecore_Wl2_Subsurface *subsurface);
+
+/**
+ * @brief Get exported surface handle for a given subsurface
+ *
+ * @param subsurface The subsurface to get exported surface handle
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI const char* ecore_wl2_subsurface_exported_surface_handle_get(Ecore_Wl2_Subsurface *subsurface);
+
+/**
+ * @brief Show exported surface for a given subsurface
+ *
+ * @param subsurface The subsurface to show exported surface
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_show(Ecore_Wl2_Subsurface *subsurface);
+
+/**
+ * @brief Hide exported surface for a given subsurface
+ *
+ * @param subsurface The subsurface to hide exported surface
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_hide(Ecore_Wl2_Subsurface *subsurface);
+
+/**
+ * @brief Place exported surface for a given subsurface on layer above a reference subsurface
+ *
+ * @param subsurface the subsurface
+ * @param other the sibling reference subsurface, or NULL for parent surface
+ * @see ecore_wl2_subsurface_place_surface_above
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_place_above(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface *other);
+
+/**
+ * @brief Place exported surface for a given subsurface on layer below a reference subsurface
+ *
+ * @param subsurface the subsurface
+ * @param other the sibling reference subsurface, or NULL for parent surface
+ * @see ecore_wl2_subsurface_place_surface_above
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_place_below(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface *other);
+
+/**
+ * @brief Set position of exported surface for a given subsurface
+ *
+ * @param subsurface the subsurface
+ * @param x X position of exported surface
+ * @param y Y position of exported surface
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_move(Ecore_Wl2_Subsurface *subsurface, int x, int y);
+
+/**
+ * @brief Set size of exported surface for a given subsurface
+ *
+ * @param subsurface the subsurface
+ * @param w Width of exported surface
+ * @param h Height of exported surface
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_resize(Ecore_Wl2_Subsurface *subsurface, int w, int h);
+
+/**
+ * @brief Set transform of exported surface for a given subsurface
+ *
+ * @param subsurface the subsurface
+ * @param transform The exported surface transform being requested
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_transform_set(Ecore_Wl2_Subsurface *subsurface, int transform);
+
+/**
+ * @brief Enables or disables exported surface synchronization for a given subsurface
+ *
+ * @param subsurface the subsurface
+ * @param sync true to enable synchronization, false to desynchronize
+ *
+ * @see ecore_wl2_subsurface_sync_set
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_surface_sync_set(Ecore_Wl2_Subsurface *subsurface, Eina_Bool sync);
+
+/**
+ * @brief Commit exported surface for a given subsurface
+ *
+ * This generates a wl_surface_commit() immediately
+ *
+ * @param subsurface the subsurface
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.5
+ */
+EAPI void ecore_wl2_subsurface_exported_shell_commit(Ecore_Wl2_Subsurface *subsurface);
+//
 # undef EAPI
 # define EAPI
 
index 2c5e7f4..a1a9c80 100644 (file)
@@ -141,6 +141,9 @@ struct _Ecore_Wl2_Display
         // TIZEN_ONLY(20200601): support tizen_renderer
         struct tizen_renderer *tz_renderer;
         //
+        //TIZEN_ONLY(20210503): support foreign shell
+        struct wtz_exporter *fs_exporter;
+        //
 
         int compositor_version;
      } wl;
@@ -195,6 +198,11 @@ struct _Ecore_Wl2_Subsurface
         tbm_surface_h tbm_surface;
         struct wl_buffer *wl_buffer;
         //
+
+        //TIZEN_ONLY(20210503): support foreign shell
+        struct wtz_exported_shell *fs;
+        char *fs_handle;
+        //
      } wl;
 
    // TIZEN_ONLY(20201022): support restack video
index f13bafa..37bf58f 100644 (file)
@@ -4,6 +4,10 @@
 
 #include "ecore_wl2_private.h"
 
+//TIZEN_ONLY(20210503): support foreign shell
+#include <wtz-foreign-client-protocol.h>
+//
+
 // TIZEN_ONLY(20201022): support restack video
 #include <wayland-tbm-client.h>
 
@@ -51,6 +55,11 @@ _ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf)
      _ecore_wl2_subsurface_video_surface_del(subsurf);
    //
 
+   //TIZEN_ONLY(20210503): support foreign shell
+   if (subsurf->wl.fs) wtz_exported_shell_destroy(subsurf->wl.fs);
+   if (subsurf->wl.fs_handle) free((char *)subsurf->wl.fs_handle);
+   //
+
    _ecore_wl2_subsurf_unmap(subsurf);
 
    parent = subsurf->parent;
@@ -221,6 +230,179 @@ ecore_wl2_subsurface_opaque_region_set(Ecore_Wl2_Subsurface *subsurface, int x,
 }
 
 
+//TIZEN_ONLY(20210503): support foreign shell
+static void
+_exported_shell_cb_handle(void *data,
+                          struct wtz_exported_shell *sh EINA_UNUSED,
+                          const char *handle)
+{
+   Ecore_Wl2_Subsurface *subsurface = data;
+
+   subsurface->wl.fs_handle = strdup(handle);
+}
+
+static const struct wtz_exported_shell_listener _exported_shell_listener =
+{
+   _exported_shell_cb_handle
+};
+
+EAPI Eina_Bool
+ecore_wl2_subsurface_export(Ecore_Wl2_Subsurface *subsurface)
+{
+   Ecore_Wl2_Display *display;
+   struct wl_registry *registry;
+   Eina_Iterator *globals;
+   Ecore_Wl2_Global *global;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, EINA_FALSE);
+
+   if (subsurface->wl.fs_handle) return EINA_TRUE;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface->parent, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface->parent->display, EINA_FALSE);
+
+   display = subsurface->parent->display;
+   if (!display->wl.fs_exporter)
+     {
+        registry = ecore_wl2_display_registry_get(display);
+        if (!registry) return EINA_FALSE;
+
+        globals = ecore_wl2_display_globals_get(display);
+        if (!globals) return EINA_FALSE;
+
+        EINA_ITERATOR_FOREACH(globals, global)
+          {
+             if (strcmp(global->interface, "wtz_exporter") == 0)
+               {
+                  display->wl.fs_exporter = wl_registry_bind(registry,
+                            global->id, &wtz_exporter_interface, 1);
+                  break;
+               }
+          }
+     }
+
+   if (!subsurface->wl.fs)
+     {
+        subsurface->wl.fs = wtz_exporter_export_shell(display->wl.fs_exporter,
+                                                       subsurface->wl.surface);
+     }
+
+   wtz_exported_shell_add_listener(subsurface->wl.fs,
+                        &_exported_shell_listener, subsurface);
+   wl_display_roundtrip(display->wl.display);
+
+   return EINA_TRUE;
+}
+
+EAPI const char*
+ecore_wl2_subsurface_exported_surface_handle_get(Ecore_Wl2_Subsurface *subsurface)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, NULL);
+
+   return subsurface->wl.fs_handle;
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_show(Ecore_Wl2_Subsurface *subsurface)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   EINA_SAFETY_ON_NULL_RETURN(subsurface->wl.fs);
+
+   wtz_exported_shell_map(subsurface->wl.fs);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_hide(Ecore_Wl2_Subsurface *subsurface)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   EINA_SAFETY_ON_NULL_RETURN(subsurface->wl.fs);
+
+   wtz_exported_shell_unmap(subsurface->wl.fs);
+}
+
+void
+_ecore_wl2_subsurfae_place_surface_stack(Ecore_Wl2_Subsurface *subsurf, Ecore_Wl2_Subsurface *other, Eina_Bool above)
+{
+   struct wl_surface *psurface;
+
+   EINA_SAFETY_ON_NULL_RETURN(subsurf);
+
+   /* every subsurface is created by window base now,
+      someday we could use another subsurface as a parent */
+   if (other)
+     {
+        if (subsurf->parent != other->parent)
+          {
+             ERR("Check parent of subsurf(%p) and other(%p)", subsurf, other);
+             return;
+          }
+        if (above)
+          wl_subsurface_place_above(subsurf->wl.subsurface, other->wl.surface);
+        else
+          wl_subsurface_place_below(subsurf->wl.subsurface, other->wl.surface);
+     }
+   else
+     {
+        psurface = ecore_wl2_window_surface_get(subsurf->parent);
+        if (above)
+          wl_subsurface_place_above(subsurf->wl.subsurface, psurface);
+        else
+          wl_subsurface_place_below(subsurf->wl.subsurface, psurface);
+     }
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_place_above(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface *other)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   _ecore_wl2_subsurfae_place_surface_stack(subsurface, other, EINA_TRUE);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_place_below(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface *other)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   _ecore_wl2_subsurfae_place_surface_stack(subsurface, other, EINA_FALSE);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_move(Ecore_Wl2_Subsurface *subsurface, int x, int y)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   wl_subsurface_set_position(subsurface->wl.subsurface, x, y);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_resize(Ecore_Wl2_Subsurface *subsurface, int w, int h)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   EINA_SAFETY_ON_NULL_RETURN(subsurface->wl.fs);
+   wtz_exported_shell_set_destination(subsurface->wl.fs, w, h);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_transform_set(Ecore_Wl2_Subsurface *subsurface, int transform)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   EINA_SAFETY_ON_NULL_RETURN(subsurface->wl.fs);
+   wtz_exported_shell_set_transform(subsurface->wl.fs, transform);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_sync_set(Ecore_Wl2_Subsurface *subsurface, Eina_Bool sync)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   ecore_wl2_subsurface_sync_set(subsurface, sync);
+}
+
+EAPI void
+ecore_wl2_subsurface_exported_surface_commit(Ecore_Wl2_Subsurface *subsurface)
+{
+   EINA_SAFETY_ON_NULL_RETURN(subsurface);
+   wl_surface_commit(subsurface->wl.surface);
+}
+//
+
 // TIZEN_ONLY(20201022): support restack video
 EAPI Eina_Bool
 ecore_wl2_subsurface_video_surface_prepare(Ecore_Wl2_Subsurface *subsurface)
@@ -414,37 +596,6 @@ ecore_wl2_subsurface_video_surface_rotation_set(Ecore_Wl2_Subsurface *subsurface
    return EINA_TRUE;
 }
 
-void
-_ecore_wl2_subsurfae_place_surface_stack(Ecore_Wl2_Subsurface *subsurf, Ecore_Wl2_Subsurface *other, Eina_Bool above)
-{
-   struct wl_surface *psurface;
-
-   EINA_SAFETY_ON_NULL_RETURN(subsurf);
-
-   /* every subsurface is created by window base now,
-      someday we could use another subsurface as a parent */
-   if (other)
-     {
-        if (subsurf->parent != other->parent)
-          {
-             ERR("Check parent of subsurf(%p) and other(%p)", subsurf, other);
-             return;
-          }
-        if (above)
-          wl_subsurface_place_above(subsurf->wl.subsurface, other->wl.surface);
-        else
-          wl_subsurface_place_below(subsurf->wl.subsurface, other->wl.surface);
-     }
-   else
-     {
-        psurface = ecore_wl2_window_surface_get(subsurf->parent);
-        if (above)
-          wl_subsurface_place_above(subsurf->wl.subsurface, psurface);
-        else
-          wl_subsurface_place_below(subsurf->wl.subsurface, psurface);
-     }
-}
-
 EAPI void
 ecore_wl2_subsurface_place_surface_above(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface *other)
 {
index 5453344..e347015 100644 (file)
@@ -30,6 +30,7 @@ ecore_wl2_ext_deps += [
   dependency('wayland-egl'),
   dependency('wayland-egl-tizen'),
   dependency('tizen-policy-ext-client'),
+  dependency('wtz-foreign-client'),
 ]
 ecore_wl2_src += files([
   'ecore_wl2_tbmsurface.c',