e_info: Add 'transform' command for video_shell 86/317586/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 11 Sep 2024 02:30:17 +0000 (11:30 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 12 Sep 2024 03:32:43 +0000 (12:32 +0900)
winfo -video_shell transform [HANDLE] [0|90|180|270] [OPTIONS]

  --help      Show this help message and exit
  --geometry  Geometry to be transformed. X and Y values are translated by surface-local coordination. Format: [X,Y,WIDTH,HEIGHT]
  --ratio     Set aspect ratio. If both WIDTH and HEIGHT are set to -1, aspect ratio will be disabled. Format: [WIDTH,HEIGHT]

  NOTE: The HANDLE is a viewport handle you can find with `winfo -video_shell info`

Change-Id: I04010091e632d78e782259166733502958cc2a55

src/bin/debug/e_info_client.c
src/bin/debug/e_info_server.c
src/bin/server/e_video_shell.c
src/bin/server/e_video_shell_intern.h
src/include/e_info_shared_types.h

index dada26b733f8d3a66a6e4be99d2d23550a596aae..b72c7038262062a820ce5c13232330cd684a7bfc 100644 (file)
@@ -6730,6 +6730,70 @@ show_help:
    printf("%s", USAGE_VIDEO_SHELL_INFO);
 }
 
+static void
+_e_info_client_video_shell_transform(int argc, char **args)
+{
+   const char *export_handle = NULL;
+   E_Info_Video_Shell_Transform transform = E_INFO_VIDEO_SHELL_TRANSFORM_UNKNOWN;
+   int x = -1, y = -1, width = -1, height = -1;
+   int ratio_width = -2, ratio_height = -2;
+
+   for (size_t i = 0; i < argc; i++)
+     {
+        if (strcmp(args[i], "--help") == 0)
+          {
+             goto show_help;
+          }
+        else if (strcmp(args[i], "--geometry") == 0)
+          {
+             if (argc < ++i)
+               goto err;
+
+             if (sscanf(args[i], "%d,%d,%d,%d", &x, &y, &width, &height) <= 0)
+               goto err;
+          }
+        else if (strcmp(args[i], "--ratio") == 0)
+          {
+             if (argc < ++i)
+               goto err;
+
+             if (sscanf(args[i], "%d,%d", &ratio_width, &ratio_height) <= 0)
+               goto err;
+          }
+        else
+          {
+             if (!export_handle)
+               {
+                  export_handle = args[i];
+                  continue;
+               }
+
+             if (strcmp(args[i], "0") == 0)
+               transform = E_INFO_VIDEO_SHELL_TRANSFORM_NORMAL;
+             else if (strcmp(args[i], "90") == 0)
+               transform = E_INFO_VIDEO_SHELL_TRANSFORM_90;
+             else if (strcmp(args[i], "180") == 0)
+               transform = E_INFO_VIDEO_SHELL_TRANSFORM_180;
+             else if (strcmp(args[i], "270") == 0)
+               transform = E_INFO_VIDEO_SHELL_TRANSFORM_270;
+             else
+               goto err;
+          }
+     }
+
+   if (export_handle == NULL || transform == E_INFO_VIDEO_SHELL_TRANSFORM_UNKNOWN)
+     goto err;
+
+   _e_info_client_eldbus_message_with_args(VIDEO_SHELL_TRANSFORM_METHOD_NAME, NULL, "siiiiiii",
+                                           export_handle, transform, x, y, width, height, ratio_width, ratio_height);
+
+   return;
+err:
+   printf("video_shell: transform: error: invalid argument\n\n");
+show_help:
+   printf("%s", USAGE_VIDEO_SHELL_TRANSFORM);
+}
+
 static void
 _e_info_client_proc_video_shell(int argc, char **argv)
 {
@@ -6743,6 +6807,8 @@ _e_info_client_proc_video_shell(int argc, char **argv)
      _e_info_client_video_shell_border(argc - 1, &args[1]);
    else if (strcmp(args[0], "info") == 0)
      _e_info_client_video_shell_info(argc - 1, &args[1]);
+   else if (strcmp(args[0], "transform") == 0)
+     _e_info_client_video_shell_transform(argc - 1, &args[1]);
    else
      goto err;
 
index 57d7143d002816e871a223ce4eb5b79e0f2e42a6..68eba010543246df962a5701091caf211c96cc6d 100644 (file)
@@ -7377,6 +7377,48 @@ end:
    return reply;
 }
 
+static E_Video_Shell_Transform
+_e_info_video_shell_transform_to_video_shell(E_Info_Video_Shell_Transform transform)
+{
+   E_Video_Shell_Transform shell_transform;
+
+   switch (transform)
+     {
+   default:
+   case E_INFO_VIDEO_SHELL_TRANSFORM_NORMAL:
+      shell_transform = E_VIDEO_SHELL_TRANSFORM_NORMAL;
+      break;
+   case E_INFO_VIDEO_SHELL_TRANSFORM_90:
+      shell_transform = E_VIDEO_SHELL_TRANSFORM_90;
+      break;
+   case E_INFO_VIDEO_SHELL_TRANSFORM_180:
+      shell_transform = E_VIDEO_SHELL_TRANSFORM_180;
+      break;
+   case E_INFO_VIDEO_SHELL_TRANSFORM_270:
+      shell_transform = E_VIDEO_SHELL_TRANSFORM_270;
+      break;
+     }
+
+   return shell_transform;
+}
+
+static Eldbus_Message *
+_e_info_server_cb_video_shell_transform(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *export_handle;
+   E_Info_Video_Shell_Transform transform;
+   int x, y, width, height;
+   int ratio_width, ratio_height;
+
+   if (!eldbus_message_arguments_get(msg, "siiiiiii", &export_handle, &transform, &x, &y, &width, &height, &ratio_width, &ratio_height))
+     goto end;
+
+   e_video_shell_viewport_transform(export_handle, _e_info_video_shell_transform_to_video_shell(transform), x, y, width, height, ratio_width, ratio_height);
+end:
+   return reply;
+}
+
 static Eldbus_Message *
 _e_info_server_cb_key_elapsed_time(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -7523,6 +7565,7 @@ static const Eldbus_Method methods[] = {
    { "log_control", ELDBUS_ARGS({"s","log type" }, {"i", "enable"}), NULL, _e_info_server_cb_log_control, 0},
    { VIDEO_SHELL_BORDER_METHOD_NAME, ELDBUS_ARGS({"b", "The command for border of video viewport"}), NULL, _e_info_server_cb_video_shell_border, 0},
    { VIDEO_SHELL_INFO_METHOD_NAME, ELDBUS_ARGS({"s", "Print video shell information"}), NULL, _e_info_server_cb_video_shell_info, 0},
+   { VIDEO_SHELL_TRANSFORM_METHOD_NAME, ELDBUS_ARGS({"siiiiiii", "Transform video viewport"}), NULL, _e_info_server_cb_video_shell_transform, 0},
    { "key_elapsed_time", ELDBUS_ARGS({"i", "key elapsed time"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_key_elapsed_time, 0},
    { "pointer_thread_mode", ELDBUS_ARGS({"i", "set pointer_thread_mode"}), NULL, _e_info_server_cb_pointer_thread_mode, 0 },
    { NULL, NULL, NULL, NULL, 0 }
index 5f398d8450270637a2f5cb03b744b328d527df61..8747672bf19c2bd9d6dc97b212b9135befbc2645 100644 (file)
@@ -10,6 +10,7 @@
 #include "e_comp_wl_buffer_intern.h"
 #include "e_desk_intern.h"
 #include "e_comp_wl_subsurface_intern.h"
+#include "e_video_shell_intern.h"
 #include "e_view_intern.h"
 #include "e_view_client_intern.h"
 
 
 typedef struct _E_Video_Viewport_Source E_Video_Viewport_Source;
 
-typedef struct
+struct _E_Video_Shell
 {
    struct wl_display *display;
    struct wl_global *global;
    Eina_Hash *viewports;
    struct wl_listener display_destroy;
    struct wl_list link;
-} E_Video_Shell;
+};
 
 typedef enum
 {
@@ -1027,8 +1028,7 @@ _source_viewport_transform_update(E_Video_Viewport_Source *source)
    cx = ((double)x + (double)w/2);
    cy = ((double)y + (double)h/2);
 
-   if ((transform == WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_90) ||
-       (transform == WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_270))
+   if (transform & WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_90)
      {
         sx = (double)h / w;
         sy = (double)w / h;
@@ -1048,7 +1048,7 @@ _source_viewport_transform_update(E_Video_Viewport_Source *source)
                               0.0);
         e_util_transform_scale(source->transform, sx, sy, 1.0);
      }
-   else if (transform == WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_180)
+   else
      {
         e_util_transform_rotation_axis_set(source->transform, cx, cy, -1);
         e_util_transform_scale(source->transform, 1.0, 1.0, 1.0);
@@ -1967,6 +1967,93 @@ e_video_shell_info_print(void)
    return ret;
 }
 
+static enum wtz_video_exported_viewport_transform
+_e_video_shell_transform_to_wtz(E_Video_Shell_Transform e_transform)
+{
+   enum wtz_video_exported_viewport_transform wtz_transform;
+
+   switch (e_transform)
+     {
+   default:
+   case E_VIDEO_SHELL_TRANSFORM_NORMAL:
+      wtz_transform = WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_NORMAL;
+      break;
+   case E_VIDEO_SHELL_TRANSFORM_90:
+      wtz_transform = WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_90;
+      break;
+   case E_VIDEO_SHELL_TRANSFORM_180:
+      wtz_transform = WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_180;
+      break;
+   case E_VIDEO_SHELL_TRANSFORM_270:
+      wtz_transform = WTZ_VIDEO_EXPORTED_VIEWPORT_TRANSFORM_270;
+      break;
+     }
+
+   return wtz_transform;
+}
+
+EINTERN void
+e_video_shell_viewport_transform(const char *handle, E_Video_Shell_Transform transform, int x, int y, int width, int height, int ratio_width, int ratio_height)
+{
+   E_Video_Shell *shell;
+   E_Video_Viewport *viewport;
+   enum wtz_video_exported_viewport_transform wtz_transform;
+
+   wl_list_for_each(shell, &shells, link)
+     {
+        viewport = eina_hash_find(shell->viewports, handle);
+        if (!viewport)
+          continue;
+
+        if (viewport->source && ratio_width != -2 && ratio_height != -2)
+          {
+             if ((ratio_width == -1 && ratio_height == -1) ||
+                 (ratio_width > 0 && ratio_height > 0))
+               {
+                  if (ratio_width == -1 && ratio_height == -1)
+                    {
+                       viewport->source->pending.has_aspect_ratio = EINA_FALSE;
+                    }
+                  else
+                    {
+                       viewport->source->pending.has_aspect_ratio = EINA_TRUE;
+                       viewport->source->pending.aspect_ratio.width = ratio_width;
+                       viewport->source->pending.aspect_ratio.height = ratio_height;
+                    }
+                  viewport->source->pending.committed |= E_VIDEO_VIEWPORT_SOURCE_STATE_ASPECT_RATIO;
+
+                  viewport->source->current = viewport->source->pending;
+                  viewport->source->pending.committed = E_VIDEO_VIEWPORT_SOURCE_STATE_CLEAN;
+
+                  _source_viewport_destination_update(viewport->source);
+                  _source_viewport_apply(viewport->source);
+                  _source_viewport_transform_update(viewport->source);
+               }
+          }
+
+        wtz_transform = _e_video_shell_transform_to_wtz(transform);
+        if (viewport->pending.transform != wtz_transform)
+          {
+             viewport->pending.committed |= E_VIDEO_VIEWPORT_STATE_TRANSFORM;
+             viewport->pending.transform = _e_video_shell_transform_to_wtz(transform);
+          }
+
+        if (width != -1 && height != -1)
+          {
+             e_subsurface_position_set(viewport->subsurface, x, y);
+
+             viewport->pending.committed |= E_VIDEO_VIEWPORT_STATE_DESTINATION;
+             viewport->pending.width = width;
+             viewport->pending.height = height;
+          }
+
+        if (viewport->pending.committed != E_VIDEO_VIEWPORT_STATE_CLEAN)
+          _viewport_state_commit(viewport, &viewport->pending);
+
+        break;
+     }
+}
+
 typedef enum
 {
    TOP = 0,
index cb38197276abda7ef5f6dc8f6ea6710210694fdd..dd7fa2378de7e1ae9dad7b689e6441de1acf5bf8 100644 (file)
@@ -3,11 +3,19 @@
 
 #include <Eina.h>
 
-struct E_Video_Shell;
-typedef struct E_Video_Shell E_Video_Shell;
+typedef struct _E_Video_Shell E_Video_Shell;
+
+typedef enum
+{
+   E_VIDEO_SHELL_TRANSFORM_NORMAL,
+   E_VIDEO_SHELL_TRANSFORM_90,
+   E_VIDEO_SHELL_TRANSFORM_180,
+   E_VIDEO_SHELL_TRANSFORM_270,
+} E_Video_Shell_Transform;
 
 E_Video_Shell *e_video_shell_create(struct wl_display *display);
 void e_video_shell_border_enabled_set(Eina_Bool enabled);
 char *e_video_shell_info_print(void);
+void e_video_shell_viewport_transform(const char *handle, E_Video_Shell_Transform transform, int x, int y, int width, int height, int ratio_width, int ratio_height);
 
 #endif
index b3e1dfbe5243913bb0569ce0f4deafeab3849f5b..4e213176c1b576544d0fa68053c2c5c3af58daf8 100644 (file)
@@ -373,6 +373,7 @@ typedef enum
 /* -------------------------------------------------------------------------- */
 #define VIDEO_SHELL_BORDER_METHOD_NAME "video_shell_border"
 #define VIDEO_SHELL_INFO_METHOD_NAME "video_shell_info"
+#define VIDEO_SHELL_TRANSFORM_METHOD_NAME "video_shell_transform"
 #define USAGE_VIDEO_SHELL \
    "[GLOBAL-OPTS] SUBCOMMAND [OPTS]\n\n" \
    "Global Options:\n" \
@@ -380,7 +381,8 @@ typedef enum
    "\n" \
    "Subcommands:\n" \
    "  border\tManipulate border of video viewport\n" \
-   "  info\t\tPrint video shell information\n"
+   "  info\t\tPrint video shell information\n" \
+   "  transform\tTransform video viewport"
 #define USAGE_VIDEO_SHELL_BORDER \
    "winfo -video_shell border [OPTS]\n\n" \
    "  --help\tShow this help message and exit\n" \
@@ -389,5 +391,21 @@ typedef enum
    "winfo -video_shell info [OPTS]\n\n" \
    "  --help\tShow this help message and exit\n" \
    "  --file\tLog to file. Default to stdout.\n"
+#define USAGE_VIDEO_SHELL_TRANSFORM \
+   "winfo -video_shell transform [HANDLE] [0|90|180|270] [OPTIONS]\n\n" \
+   "  --help\tShow this help message and exit\n" \
+   "  --geometry\tGeometry to be transformed. X and Y values are translated by surface-local coordination. Format: [X,Y,WIDTH,HEIGHT]\n" \
+   "  --ratio\tSet aspect ratio. If both WIDTH and HEIGHT are set to -1, aspect ratio will be disabled. Format: [WIDTH,HEIGHT]\n" \
+   "\n" \
+   "  NOTE: The HANDLE is a viewport handle you can find with `winfo -video_shell info`\n"
+
+typedef enum
+{
+   E_INFO_VIDEO_SHELL_TRANSFORM_NORMAL,
+   E_INFO_VIDEO_SHELL_TRANSFORM_90,
+   E_INFO_VIDEO_SHELL_TRANSFORM_180,
+   E_INFO_VIDEO_SHELL_TRANSFORM_270,
+   E_INFO_VIDEO_SHELL_TRANSFORM_UNKNOWN,
+} E_Info_Video_Shell_Transform;
 
 #endif /* end of _E_INFO_SHARED_TYPES_ */