video_shell: Add name of role to video shell objects 88/314888/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 22 Jul 2024 09:09:14 +0000 (18:09 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 22 Jul 2024 22:57:26 +0000 (07:57 +0900)
This names role of video shell objects for debugging purpose.

Change-Id: I5df36e4f4d82282c59a80a62983f8aa4ca564af8

src/bin/server/e_video_shell.c

index d5eb3ed..f5bebef 100644 (file)
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <math.h>
 #include <stdlib.h>
+#include <string.h>
 #include <uuid.h>
 #include <wtz-video-shell-server-protocol.h>
 #include <Eina.h>
@@ -520,6 +521,17 @@ _viewport_export_handle_generate(E_Video_Viewport *viewport)
 }
 
 static void
+_viewport_name_init(E_Video_Viewport *viewport)
+{
+   E_Surface *parent_surface = e_subsurface_parent_get(viewport->subsurface);
+   E_Client *parent_ec = e_surface_ec_get(parent_surface);
+   char name[256];
+
+   snprintf(name, sizeof(name), "VS::Viewport(Parent 0x%08zx)", e_log_client_util_win_get(parent_ec));
+   e_surface_name_set(e_subsurface_surface_get(viewport->subsurface), name);
+}
+
+static void
 _video_shell_cb_export_viewport(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *subsurface_resource)
 {
    E_Video_Viewport *viewport;
@@ -572,6 +584,7 @@ _video_shell_cb_export_viewport(struct wl_client *client, struct wl_resource *re
    e_object_ref(E_OBJECT(viewport->shell));
 
    _viewport_export_handle_generate(viewport);
+   _viewport_name_init(viewport);
 
    VS_INF("VIEWPORT %p| Created with E_Subsurface(%p)", viewport, viewport->subsurface);
 }
@@ -1133,6 +1146,46 @@ _video_surface_role_to_str(E_Video_Surface_Role role)
 }
 
 static void
+_video_surface_name_update(E_Video_Surface *surface)
+{
+   char name[256];
+   char suffix[256];
+   E_Client *ec;
+
+   if (surface->role == E_VIDEO_SURFACE_ROLE_SUBSURFACE)
+     {
+        ec = e_surface_ec_get(e_subsurface_parent_get(surface->subsurface));
+        snprintf(suffix, sizeof(suffix), "VS::Subsurface(Parent 0x%08zx)", e_log_client_util_win_get(ec));
+     }
+   else if (surface->role == E_VIDEO_SURFACE_ROLE_VIEWPORT_SOURCE)
+     {
+        if (surface->source->viewport)
+          {
+             ec = e_surface_ec_get(e_subsurface_surface_get(surface->source->viewport->subsurface));
+             snprintf(suffix, sizeof(suffix), "VS::Source(Viewport 0x%08zx)", e_log_client_util_win_get(ec));
+          }
+        else
+          {
+             snprintf(suffix, sizeof(suffix), "VS::Source(Viewport null)");
+          }
+     }
+   else
+     {
+        snprintf(suffix, sizeof(suffix), "VS::Surface");
+     }
+
+   if (surface->name)
+     {
+        snprintf(name, sizeof(name), "%s [%s]", surface->name, suffix);
+        e_surface_name_set(surface->surface, name);
+     }
+   else
+     {
+        e_surface_name_set(surface->surface, suffix);
+     }
+}
+
+static void
 _video_surface_cb_source_destroy(struct wl_listener *listener, void *data)
 {
    E_Video_Surface *surface = wl_container_of(listener, surface, source_destroy);
@@ -1142,6 +1195,8 @@ _video_surface_cb_source_destroy(struct wl_listener *listener, void *data)
    wl_list_remove(&surface->source_destroy.link);
    surface->source = NULL;
    surface->role = E_VIDEO_SURFACE_ROLE_NONE;
+
+   _video_surface_name_update(surface);
 }
 
 static void
@@ -1315,6 +1370,8 @@ _video_surface_cb_get_viewport_source(struct wl_client *client, struct wl_resour
         return;
      }
 
+   _video_surface_name_update(surface);
+
    VS_INF("SOURCE %p| Created with E_Video_Surface(%p), Viewport(%p)", source, surface, viewport);
 }
 
@@ -1329,6 +1386,8 @@ _video_surface_cb_subsurface_destroy(struct wl_listener *listener, void *data)
    surface->subsurface = NULL;
    surface->role = E_VIDEO_SURFACE_ROLE_NONE;
 
+   _video_surface_name_update(surface);
+
    // HACK
    // Restore surface role to prevent it from being used as another role
    e_surface_role_unset(surface->surface);
@@ -1378,6 +1437,8 @@ _video_surface_cb_get_subsurface(struct wl_client *client, struct wl_resource *r
 
    surface->role = E_VIDEO_SURFACE_ROLE_SUBSURFACE;
 
+   _video_surface_name_update(surface);
+
    VS_INF("SURFACE %p| Subsurface(%p) created with Parent E_Surface(%p)",
           surface, surface->subsurface, parent_surface);
 }
@@ -1407,7 +1468,7 @@ _video_surface_cb_set_name(struct wl_client *client, struct wl_resource *resourc
    free(surface->name);
    surface->name = tmp;
 
-   e_surface_name_set(surface->surface, tmp);
+   _video_surface_name_update(surface);
 }
 
 static void