e_info: replace -dump_topvwins to -dump topvwins | ns 48/145848/1
authorJuyeon Lee <juyeonne.lee@samsung.com>
Thu, 24 Aug 2017 05:28:48 +0000 (14:28 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Thu, 24 Aug 2017 05:29:03 +0000 (14:29 +0900)
-dump topvwins: enables to dump top visible surfaces on commit
-dump ns : enables to dump native surface on evas object

Change-Id: I0ea6c174d52ef5cfdb7f7158f4380883bdc2ed2c

src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_info_shared_types.h

index 85d2b23e38a2f1d6e3cd06c6262a2de233303950..d3c80b6dceb638c8033bae0a008c87ecf0317709 100644 (file)
@@ -1225,7 +1225,7 @@ _e_info_client_proc_keygrab_status(int argc, char **argv)
 }
 
 static char *
-_directory_make(char *path)
+_directory_make(char *type, char *path)
 {
    char dir[PATH_MAX], curdir[PATH_MAX], stamp[PATH_MAX];
    time_t timer;
@@ -1290,9 +1290,9 @@ _directory_make(char *path)
    snprintf(stamp, PATH_MAX, "%04d%02d%02d.%02d%02d%02d", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
 
    if (strlen(dir) == 1 && dir[0] == '/')
-     snprintf(fullpath, PATH_MAX, "/topvwins-%s", stamp);
+     snprintf(fullpath, PATH_MAX, "/%s-%s", type, stamp);
    else
-     snprintf(fullpath, PATH_MAX, "%s/topvwins-%s", dir, stamp);
+     snprintf(fullpath, PATH_MAX, "%s/%s-%s", dir, type, stamp);
 
    free (buf);
 
@@ -1309,18 +1309,32 @@ _directory_make(char *path)
 }
 
 static void
-_e_info_client_proc_topvwins_shot(int argc, char **argv)
+_e_info_client_proc_wins_shot(int argc, char **argv)
 {
-   char *directory = _directory_make(argv[2]);
-   EINA_SAFETY_ON_NULL_RETURN(directory);
+   char *directory = NULL;
+   char *type = NULL;
 
-   if (!_e_info_client_eldbus_message_with_args("dump_topvwins", NULL, "s", directory))
+   if (argc == 3)
+     directory = _directory_make(argv[2], NULL);
+   else if (argc == 4)
+     directory = _directory_make(argv[2], argv[3]);
+   else
+     goto arg_err;
+
+   if (!directory) goto arg_err;
+
+   type = argv[2];
+   if (!_e_info_client_eldbus_message_with_args("dump_wins", NULL, SIGNATURE_DUMP_WINS, type, directory))
      {
         free(directory);
         return;
      }
 
    free(directory);
+
+   return;
+arg_err:
+   printf("Usage: enlightenment_info -dump %s\n", USAGE_DUMPIMAGE);
 }
 
 static void
@@ -4180,9 +4194,10 @@ static struct
       _e_info_client_proc_subsurface
    },
    {
-      "dump_topvwins", "[directory_path]",
-      "Dump top-level visible windows (default directory_path : current working directory)",
-      _e_info_client_proc_topvwins_shot
+      "dump",
+      USAGE_DUMPIMAGE,
+      "Dump window images with options",
+      _e_info_client_proc_wins_shot
    },
    {
       "eina_log_levels", "[mymodule1:5,mymodule2:2]",
index eafc591c7c9996363ff3543869e5c06f6ac3ad89..b55770b1de54a3af7bc5d181a6c0d90d1640a6fb 100644 (file)
@@ -2360,19 +2360,10 @@ _e_info_server_cb_window_prop_get(const Eldbus_Service_Interface *iface EINA_UNU
    return _msg_window_prop_append(msg, mode, value, property_name, property_value);
 }
 
-static Eldbus_Message *
-_e_info_server_cb_topvwins_dump(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+static void _e_info_server_cb_wins_dump_topvwins(const char *dir)
 {
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-   const char *dir;
    Evas_Object *o;
 
-   if (!eldbus_message_arguments_get(msg, "s", &dir))
-     {
-        ERR("Error getting arguments.");
-        return reply;
-     }
-
    for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
      {
         E_Client *ec = evas_object_data_get(o, "E_Client");
@@ -2390,6 +2381,96 @@ _e_info_server_cb_topvwins_dump(const Eldbus_Service_Interface *iface EINA_UNUSE
 
         e_info_server_dump_client(ec, fname);
      }
+}
+
+static void _e_info_server_cb_wins_dump_ns(const char *dir)
+{
+   Evas_Object *o;
+
+   for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+     {
+        Ecore_Window win;
+        E_Client *ec;
+        Evas_Native_Surface *ns = NULL;
+        Evas_Object *co = NULL; // native surface set
+        tbm_surface_h tbm_surface = NULL;
+        char fname[PATH_MAX];
+        const char *bltin_t = NULL;
+
+        ec = evas_object_data_get(o, "E_Client");
+        win = e_client_util_win_get(ec);
+
+        // find obj which have native surface set
+        bltin_t = evas_object_type_get(o);
+        if (!e_util_strcmp(bltin_t, "image"))
+          {
+             // builtin types "image" could have cw->obj
+             ns = evas_object_image_native_surface_get(o);
+             if (ns) co = o;
+          }
+
+        if (!ns)
+          {
+             if (!co) co = evas_object_name_child_find(o, "cw->obj", -1);
+             if (co) ns = evas_object_image_native_surface_get(co);
+          }
+
+        if (!ns)
+          {
+             Eina_List *ll;
+             Evas_Object *c = NULL;
+
+             if (evas_object_smart_data_get(o))
+               {
+                  //find smart obj members
+                  EINA_LIST_REVERSE_FOREACH(evas_object_smart_members_get(o), ll, c)
+                    {
+                       if (!co) co = evas_object_name_child_find(c, "cw->obj", -1);
+                       if (co) ns = evas_object_image_native_surface_get(co);
+                       if (ns) break;
+                    }
+               }
+          }
+
+        if (!ns) continue;
+
+        switch (ns->type)
+          {
+           case EVAS_NATIVE_SURFACE_WL:
+              snprintf(fname, sizeof(fname), "%s/0x%08x_wl_%p.png", dir, win, co);
+              if (ns->data.wl.legacy_buffer)
+                tbm_surface = wayland_tbm_server_get_surface(NULL, ns->data.wl.legacy_buffer);
+              if (tbm_surface)
+                tdm_helper_dump_buffer(tbm_surface, fname);
+              break;
+           case EVAS_NATIVE_SURFACE_TBM:
+              snprintf(fname, sizeof(fname), "%s/0x%08x_tbm_%p.png", dir, win, co);
+              if (ns->data.tbm.buffer)
+                tdm_helper_dump_buffer(ns->data.tbm.buffer, fname);
+              break;
+           default:
+              break;
+          }
+     }
+}
+
+static Eldbus_Message *
+_e_info_server_cb_wins_dump(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *type;
+   const char *dir;
+
+   if (!eldbus_message_arguments_get(msg, SIGNATURE_DUMP_WINS, &type, &dir))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (!e_util_strcmp(type, "topvwins"))
+     _e_info_server_cb_wins_dump_topvwins(dir);
+   else if (!e_util_strcmp(type, "ns"))
+     _e_info_server_cb_wins_dump_ns(dir);
 
    return reply;
 }
@@ -5021,7 +5102,7 @@ static const Eldbus_Method methods[] = {
    { "get_all_window_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_all_window_info_get, 0 },
    { "compobjs", NULL, ELDBUS_ARGS({"a("SIGNATURE_COMPOBJS_CLIENT")", "array of comp objs"}), _e_info_server_cb_compobjs, 0 },
    { "subsurface", NULL, ELDBUS_ARGS({"a("SIGNATURE_SUBSURFACE")", "array of ec"}), _e_info_server_cb_subsurface, 0 },
-   { "dump_topvwins", ELDBUS_ARGS({"s", "directory"}), NULL, _e_info_server_cb_topvwins_dump, 0 },
+   { "dump_wins", ELDBUS_ARGS({SIGNATURE_DUMP_WINS, "directory"}), NULL, _e_info_server_cb_wins_dump, 0 },
    { "eina_log_levels", ELDBUS_ARGS({"s", "eina log levels"}), NULL, _e_info_server_cb_eina_log_levels, 0 },
    { "eina_log_path", ELDBUS_ARGS({"s", "eina log path"}), NULL, _e_info_server_cb_eina_log_path, 0 },
 #ifdef HAVE_DLOG
index d95734f3f97dc9b8586dafeebbf25d5a547c0fee..896155793f9826e24530a36a6a9a78d08ef2f58a 100644 (file)
@@ -201,4 +201,14 @@ typedef enum
    "\tenlightenment_info -remote_surface dump 0\n"                            \
    "\tenlightenment_info -remote_surface dump 1\n"
 
+/* -------------------------------------------------------------------------- */
+/* DUMP WINS                                                                  */
+/* -------------------------------------------------------------------------- */
+#define SIGNATURE_DUMP_WINS "ss"
+#define USAGE_DUMPIMAGE                                                  \
+   "[Option..] [DIR]\n"                                                  \
+   "\ttopvwins     : Dump buffer commit on top visible clients\n"        \
+   "\tns           : Dump native surfaces set on clients\n"
+
+
 #endif /* end of _E_INFO_SHARED_TYPES_ */