remote_surface: added remote surface option to enlightenment_info 33/131033/3
authorMinJeong Kim <minjjj.kim@samsung.com>
Thu, 18 May 2017 11:20:36 +0000 (20:20 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Fri, 26 May 2017 05:22:03 +0000 (05:22 +0000)
Change-Id: I9e128a5beb68393570e0c88d3773d4192426bfbd
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/bin/e_comp_wl_rsm.c
src/bin/e_comp_wl_rsm.h
src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_info_shared_types.h

index bee8ae3a6317b376c3cd6d1a838e72565bb51f11..a236b7bec42e56ba634e9d1467d60fcc77203c30 100644 (file)
@@ -2398,6 +2398,165 @@ e_comp_wl_remote_surface_commit(E_Client *ec)
 #endif /* HAVE_REMOTE_SURFACE */
 }
 
+EINTERN void
+e_comp_wl_remote_surface_debug_info_get(Eldbus_Message_Iter *iter)
+{
+#ifdef HAVE_REMOTE_SURFACE
+   Eldbus_Message_Iter *line_array;
+   Eina_Iterator *hash_iter;
+   E_Comp_Wl_Remote_Provider *provider;
+   E_Comp_Wl_Remote_Source *source;
+   int idx = 0;
+   char info_str[1024];
+
+   eldbus_message_iter_arguments_append(iter, "as", &line_array);
+   if (!_rsm)
+     {
+        eldbus_message_iter_basic_append(line_array,
+                                         's',
+                                         "Remote Surface not initialized..");
+        eldbus_message_iter_container_close(iter, line_array);
+        return;
+     }
+
+   /* PROVIDER */
+   hash_iter = eina_hash_iterator_data_new(_rsm->provider_hash);
+   EINA_ITERATOR_FOREACH(hash_iter, provider)
+     {
+        E_Client *ec = provider->ec;
+        E_Comp_Wl_Remote_Surface *remote_surface;
+        Eina_List *l;
+
+        if (!ec) continue;
+
+        snprintf(info_str, sizeof(info_str),
+                 "%10s [%d] 0x%08x win(0x%08x) res(%d) pid(%d) vis(%d) name(%s)",
+                 "PROVIDER", idx++, (unsigned int)provider,
+                 e_client_util_win_get(ec),
+                 e_pixmap_res_id_get(ec->pixmap),
+                 ec->netwm.pid,
+                 provider->vis_ref,
+                 e_client_util_name_get(ec)?:ec->icccm.class?:"NO NAME");
+        eldbus_message_iter_basic_append(line_array, 's', info_str);
+
+        if (provider->surfaces)
+          {
+             snprintf(info_str, sizeof(info_str), "%7s", "│");
+             eldbus_message_iter_basic_append(line_array, 's', info_str);
+          }
+
+        EINA_LIST_FOREACH(provider->surfaces, l, remote_surface)
+          {
+             struct wl_client *wc = NULL;
+             E_Client *owner = NULL;
+             pid_t pid = -1;
+             int s_idx = 0;
+             Eina_Bool is_last = 0;
+
+             if (!remote_surface->resource) continue;
+
+             owner = remote_surface->owner;
+             if (!owner)
+               owner = remote_surface->bind_ec;
+
+             wc = wl_resource_get_client(remote_surface->resource);
+             if (wc)
+               wl_client_get_credentials(wc, &pid, NULL, NULL);
+
+             if ((eina_list_last(provider->surfaces) == l))
+                 is_last = EINA_TRUE;
+
+             snprintf(info_str, sizeof(info_str),
+                      "%10s CONSUMER [%d] 0x%08x ec(0x%08x) win(0x%08x) pid(%d) vis(%d) redirected(%d) name(%s)",
+                      is_last? "└─" : "├─", s_idx++, (unsigned int)remote_surface,
+                      (unsigned int)owner?:0,
+                      owner?e_client_util_win_get(owner):0,
+                      pid,
+                      remote_surface->visible,
+                      remote_surface->redirect,
+                      owner? e_client_util_name_get(owner)?:owner->icccm.class?:"NO NAME":"NO OWNER"
+                      );
+             eldbus_message_iter_basic_append(line_array, 's', info_str);
+          }
+        eldbus_message_iter_basic_append(line_array, 's', "");
+     }
+   eina_iterator_free(hash_iter);
+
+   /* SOURCE */
+   idx = 0;
+   hash_iter = eina_hash_iterator_data_new(_rsm->source_hash);
+   EINA_ITERATOR_FOREACH(hash_iter, source)
+     {
+        E_Client *ec = source->ec;
+        E_Comp_Wl_Remote_Surface *remote_surface;
+        Eina_List *l;
+
+        if (!ec) continue;
+        snprintf(info_str, sizeof(info_str),
+                 "%10s [%d] 0x%08x win(0x%08x) res(%d) pid(%d) offscreen(%d) name(%s)",
+                 "SOURCE", idx++, (unsigned int)source,
+                 e_client_util_win_get(ec),
+                 e_pixmap_res_id_get(ec->pixmap),
+                 ec->netwm.pid,
+                 source->offscreen_ref,
+                 e_client_util_name_get(ec)?:ec->icccm.class?:"NO NAME");
+        eldbus_message_iter_basic_append(line_array, 's', info_str);
+
+        if (source->surfaces)
+          {
+             snprintf(info_str, sizeof(info_str), "%7s", "│");
+             eldbus_message_iter_basic_append(line_array, 's', info_str);
+          }
+
+        EINA_LIST_FOREACH(source->surfaces, l, remote_surface)
+          {
+             struct wl_client *wc = NULL;
+             E_Client *owner = NULL;
+             pid_t pid = -1;
+             int s_idx = 0;
+             Eina_Bool is_last = 0;
+
+             if (!remote_surface->resource) continue;
+
+             owner = remote_surface->owner;
+             if (!owner)
+               owner = remote_surface->bind_ec;
+
+             wc = wl_resource_get_client(remote_surface->resource);
+             if (wc)
+               wl_client_get_credentials(wc, &pid, NULL, NULL);
+
+             if ((eina_list_last(source->surfaces) == l))
+               is_last = EINA_TRUE;
+
+             snprintf(info_str, sizeof(info_str),
+                      "%10s CONSUMER [%d] 0x%08x ec(0x%08x) win(0x%08x) pid(%d) vis(%d) redirected(%d) name(%s)",
+                      is_last? "└─" : "├─", s_idx++, (unsigned int)remote_surface,
+                      (unsigned int)owner?:0,
+                      owner?e_client_util_win_get(owner):0,
+                      pid,
+                      remote_surface->visible,
+                      remote_surface->redirect,
+                      owner? e_client_util_name_get(owner)?:owner->icccm.class?:"NO NAME":"NO OWNER"
+                     );
+             eldbus_message_iter_basic_append(line_array, 's', info_str);
+          }
+        eldbus_message_iter_basic_append(line_array, 's', "");
+     }
+   eina_iterator_free(hash_iter);
+
+   eldbus_message_iter_container_close(iter, line_array);
+#else
+   Eldbus_Message_Iter *line_array;
+
+   eldbus_message_iter_arguments_append(iter, "as", &line_array);
+   eldbus_message_iter_basic_append(line_array,
+                                    's',
+                                    "Enlightenment doesn't support remote surface");
+   eldbus_message_iter_container_close(iter, line_array);
+#endif
+}
+
 #undef E_CLIENT_HOOK_APPEND
 #define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
   do                                      \
index 10a0770a873137e323762bf08e464cac3a09e895..782a9533999760e0a1b5b1f3c7c1de944e4b2af0 100644 (file)
@@ -7,6 +7,7 @@ typedef struct _E_Event_Remote_Surface_Provider E_Event_Remote_Surface_Provider;
 EINTERN void      e_comp_wl_remote_surface_init(void);
 EINTERN void      e_comp_wl_remote_surface_shutdown(void);
 EINTERN Eina_Bool e_comp_wl_remote_surface_commit(E_Client *ec);
+EINTERN void      e_comp_wl_remote_surface_debug_info_get(Eldbus_Message_Iter *iter);
 
 E_API extern int E_EVENT_REMOTE_SURFACE_PROVIDER_VISIBILITY_CHANGE;
 
index 08e432d0d0c810af0a29d66f555477b096ed78a7..70b2b0e9903b9b79cb9124b8327f463f77ffbffc 100644 (file)
@@ -2561,6 +2561,69 @@ _e_info_client_proc_screen_rotation(int argc, char **argv)
      printf("_e_info_client_eldbus_message_with_args error");
 }
 
+static void
+_e_info_client_cb_remote_surface(const Eldbus_Message *msg)
+{
+   const char *name = NULL, *text = NULL;
+   Eina_Bool res;
+   Eldbus_Message_Iter *lines;
+   char *result = NULL;
+
+   res = eldbus_message_error_get(msg, &name, &text);
+   if (res) goto finish;
+
+   res = eldbus_message_arguments_get(msg, "as", &lines);
+   if (!res) goto finish;
+
+   while (eldbus_message_iter_get_and_next(lines, 's', &result))
+     printf("%s\n", result);
+
+   return;
+finish:
+   if ((name) || (text))
+     {
+        printf("errname:%s errmsg:%s\n", name, text);
+     }
+}
+
+static void
+_e_info_client_proc_remote_surface(int argc, char **argv)
+{
+   Eina_Bool res;
+   int i;
+   int dump = -1, query = 0;
+
+   if (argc < 3) goto arg_err;
+   for (i = 2; i < argc; i++)
+     {
+        if (eina_streq(argv[i], "dump"))
+          {
+             if (argc == i + 1)
+               goto arg_err;
+
+             dump = atoi(argv[i+1]);
+             i = i + 1;
+          }
+
+        if (eina_streq(argv[i], "info"))
+          {
+             query = 1;
+          }
+     }
+
+   if (dump == -1 && query == 0)
+     goto arg_err;
+
+   res = _e_info_client_eldbus_message_with_args("remote_surface",
+                                                 _e_info_client_cb_remote_surface,
+                                                 "ii",
+                                                 dump, query);
+   EINA_SAFETY_ON_FALSE_RETURN(res);
+   return;
+arg_err:
+   printf("%s\n", USAGE_REMOTE_SURFACE);
+}
+
 static struct
 {
    const char *option;
@@ -2754,6 +2817,12 @@ static struct
       "to rotate screen",
       _e_info_client_proc_screen_rotation
    },
+   {
+      "remote_surface",
+      USAGE_REMOTE_SURFACE,
+      "for remote surface debugging",
+      _e_info_client_proc_remote_surface
+   }
 };
 
 static void
index 4a2f7ea5f043b1ad63ac07019ccbf9eed75c76ae..28c362978f1475ac21a7da33218843eab68a6aa8 100755 (executable)
@@ -63,6 +63,7 @@ static Eina_List    *e_info_dump_hdlrs;
 static char         *e_info_dump_path;
 static int           e_info_dump_running;
 static int           e_info_dump_count;
+static int           e_info_dump_remote_surface = 0;
 
 //FILE pointer for protocol_trace
 static FILE *log_fp_ptrace = NULL;
@@ -2389,8 +2390,11 @@ _e_info_server_cb_buffer_change(void *data, int type, void *event)
      }
    if (e_client_util_ignored_get(ec))
      {
-        ERR("%s: e_client_util_ignored_get(ec) true. return\n", __func__);
-        return ECORE_CALLBACK_PASS_ON;
+        if (!e_info_dump_remote_surface || !ec->remote_surface.provider)
+          {
+             ERR("%s: e_client_util_ignored_get(ec) true. return\n", __func__);
+             return ECORE_CALLBACK_PASS_ON;
+          }
      }
 
    buffer = e_pixmap_resource_get(ec->pixmap);
@@ -2969,6 +2973,41 @@ _e_info_server_cb_screen_rotation(const Eldbus_Service_Interface *iface EINA_UNU
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_remote_surface(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   int dump_request, info_query;
+   Eina_Bool res;
+   Eldbus_Message_Iter *iter, *line_array;
+
+   res = eldbus_message_arguments_get(msg,
+                                      "ii", &dump_request, &info_query);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(res, reply);
+
+   if (info_query)
+     {
+        e_comp_wl_remote_surface_debug_info_get(eldbus_message_iter_get(reply));
+     }
+   else if (dump_request != -1)
+     {
+        char reply_msg[1024] = "";
+
+        e_info_dump_remote_surface = dump_request;
+
+        snprintf(reply_msg, sizeof(reply_msg), "Switch %s remote surface dump",
+                 dump_request? "ON":"OFF");
+
+        iter = eldbus_message_iter_get(reply);
+        eldbus_message_iter_arguments_append(iter, "as", &line_array);
+        eldbus_message_iter_basic_append(line_array, 's', reply_msg);
+        eldbus_message_iter_container_close(iter, line_array);
+     }
+
+   return reply;
+}
+
+//{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
    { "compobjs", NULL, ELDBUS_ARGS({"a("SIGNATURE_COMPOBJS_CLIENT")", "array of comp objs"}), _e_info_server_cb_compobjs, 0 },
@@ -3009,6 +3048,7 @@ static const Eldbus_Method methods[] = {
    { "desk_zoom", ELDBUS_ARGS({"ddii", "Zoom"}), NULL, _e_info_server_cb_desk_zoom, 0},
    { "frender", ELDBUS_ARGS({"i", "frender"}), ELDBUS_ARGS({"s", "force_render_result"}), _e_info_server_cb_force_render, 0},
    { "screen_rotation", ELDBUS_ARGS({"i", "value"}), NULL, _e_info_server_cb_screen_rotation, 0},
+   { "remote_surface", ELDBUS_ARGS({"ii", "remote surface query"}), ELDBUS_ARGS({"as", "remote surfac information"}), _e_info_server_cb_remote_surface, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index b2089c0ecdc965da60ee0c3aa2f0bcb8ee68b3b4..d13dcc25fdff7d4465131b32b58763483922cd85 100644 (file)
@@ -180,4 +180,17 @@ typedef enum
 #define SIGNATURE_SUBSURFACE "uuuiiiiuuuuuuuus"
 #define WAYLAND_SERVER_RESOURCE_ID_MASK 0xff000000
 
+/* -------------------------------------------------------------------------- */
+/* REMOTE SURFACE                                                             */
+/* -------------------------------------------------------------------------- */
+#define USAGE_REMOTE_SURFACE                                                   \
+   "enlightenment_info -remote_surface (info | dump)\n"                                                           \
+   "Commands:\n"                                                               \
+   "\tinfo : print current remote surface info\n"                              \
+   "\tdump : on/off to dump provider's buffer by -dump_buffers [0:off, 1:on]\n"\
+   "Example:\n"                                                                \
+   "\tenlightenment_info -remote_surface info\n"                              \
+   "\tenlightenment_info -remote_surface dump 0\n"                            \
+   "\tenlightenment_info -remote_surface dump 1\n"
+
 #endif /* end of _E_INFO_SHARED_TYPES_ */