e_comp_screen: Add e_comp_screen_rotation_pre_set() API 53/202153/3 accepted/tizen/unified/20190327.025224 submit/tizen/20190326.072819
authorYoungJun Cho <yj44.cho@samsung.com>
Mon, 25 Mar 2019 09:04:26 +0000 (18:04 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 26 Mar 2019 06:27:24 +0000 (06:27 +0000)
This patch adds e_comp_screen_rotation_pre_set() API.

Change-Id: I663e69408605deaa8813cc657d38fc26c6a729eb
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
src/bin/e_comp_screen.c
src/bin/e_comp_screen.h
src/bin/e_info_client.c
src/bin/e_info_server.c

index ffcd12a180a4c4658395c02163ffcd6624972720..725ff0ec5f9c4c128276b262f4da6c9ac8340101 100644 (file)
@@ -888,6 +888,8 @@ _e_comp_screen_engine_init(void)
    TRACE_DS_END();
 
    e_comp->e_comp_screen = e_comp_screen;
+   e_comp_screen->rotation_pre = e_config->screen_rotation_pre;
+   e_comp_screen->rotation_setting = e_config->screen_rotation_setting;
    e_comp_screen->rotation = screen_rotation;
 
    TRACE_DS_BEGIN(E_COMP_SCREEN:OUTPUTS INIT);
@@ -1249,21 +1251,11 @@ e_comp_screen_shutdown()
    e_comp->e_comp_screen = NULL;
 }
 
-E_API Eina_Bool
-e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
+static E_Output *
+_e_comp_screen_output_find_primary(E_Comp_Screen *e_comp_screen)
 {
    E_Output *output = NULL, *o;
    const Eina_List *l;
-   int w, h;
-   int screen_rotation;
-   E_Input_Device *dev;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
-
-   if (e_config->screen_rotation_setting == rotation) return EINA_TRUE;
 
    EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
      {
@@ -1281,17 +1273,31 @@ e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
    if (!output)
      {
         ERR("couldn't find the primary output");
-        return EINA_FALSE;
+        return NULL;
      }
 
-   screen_rotation = (e_config->screen_rotation_pre + rotation) % 360;
+   return output;
+}
+
+static Eina_Bool
+_e_comp_screen_rotation_set(E_Comp_Screen *e_comp_screen, int screen_rotation,
+  void (*setter)(E_Comp_Screen *e_comp_screen, int data), int data)
+{
+   E_Output *output = NULL;
+   E_Input_Device *dev;
+   const Eina_List *l;
+   int w, h;
+
+   output = _e_comp_screen_output_find_primary(e_comp_screen);
+   if (!output)
+     return EINA_FALSE;
 
    if (!e_output_rotate(output, screen_rotation))
      return EINA_FALSE;
 
-   /* TODO: need to save e_config->screen_rotation_setting to e_config data file */
-   e_config->screen_rotation_setting = rotation;
    e_comp_screen->rotation = screen_rotation;
+   if (setter)
+      setter(e_comp_screen, data);
 
    ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
    ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
@@ -1319,6 +1325,56 @@ e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
    return EINA_TRUE;
 }
 
+static void
+_e_comp_screen_rotation_pre_setter(E_Comp_Screen *e_comp_screen, int rotation_pre)
+{
+   e_comp_screen->rotation_pre = rotation_pre;
+   INF("EE RotationPre: %d", rotation_pre);
+}
+
+E_API Eina_Bool
+e_comp_screen_rotation_pre_set(E_Comp_Screen *e_comp_screen, int rotation_pre)
+{
+   int screen_rotation;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre % 90, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre < 0, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre > 270, EINA_FALSE);
+
+   if (e_comp_screen->rotation_pre == rotation_pre) return EINA_TRUE;
+
+   screen_rotation = (rotation_pre + e_comp_screen->rotation_setting) % 360;
+
+   return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
+     _e_comp_screen_rotation_pre_setter, rotation_pre);
+}
+
+static void
+_e_comp_screen_rotation_setting_setter(E_Comp_Screen *e_comp_screen, int rotation)
+{
+   e_comp_screen->rotation_setting = rotation;
+   INF("EE RotationSetting: %d", rotation);
+}
+
+E_API Eina_Bool
+e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
+{
+   int screen_rotation;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
+
+   if (e_comp_screen->rotation_setting == rotation) return EINA_TRUE;
+
+   screen_rotation = (e_comp_screen->rotation_pre + rotation) % 360;
+
+   return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
+     _e_comp_screen_rotation_setting_setter, rotation);
+}
+
 E_API void
 e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
 {
index 9e0711fdfa99d4ca693bdc3e23b8f2d7240fa498..3d74afb73180265c393ad32f56d04cdb0d7b6146 100644 (file)
@@ -25,6 +25,8 @@ struct _E_Comp_Screen
    const Eina_List *devices;
 
    /* for screen_rotation */
+   int rotation_pre;
+   int rotation_setting;
    int rotation;
 
    /* pp support */
@@ -53,6 +55,7 @@ EINTERN void              e_comp_screen_hwc_info_debug(void);
 
 EINTERN void              e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh);
 EINTERN const Eina_List * e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen);
+E_API   Eina_Bool         e_comp_screen_rotation_pre_set(E_Comp_Screen *e_comp_screen, int rotation_pre);
 E_API   Eina_Bool         e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation);
 
 E_API   void              e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore);
index d47758379e9fdcf6d535c8bc23d83c2de40d5a8a..d3d5e504db6bc419c2fee14c4d67a26c7e990394 100644 (file)
@@ -3550,6 +3550,28 @@ arg_err:
   "\tenlightenment_info -kill -all\n" \
   "\tenlightenment_info -kill -help\n" \
 
+static void
+_e_info_client_proc_screen_rotation_pre(int argc, char **argv)
+{
+   int rotation_pre;
+
+   if (argc < 3)
+     {
+        printf("Error Check Args: enlightenment_info -screen_rotation [0|90|180|270]\n");
+        return;
+     }
+
+   rotation_pre = atoi(argv[2]);
+   if (rotation_pre < 0 || rotation_pre > 360 || rotation_pre % 90)
+     {
+        printf("Error Check Args: enlightenment_info -screen_rotation_pre [0|90|180|270]\n");
+        return;
+     }
+
+   if (!_e_info_client_eldbus_message_with_args("screen_rotation_pre", NULL, "i", rotation_pre))
+     printf("_e_info_client_eldbus_message_with_args error");
+}
+
 static void
 _e_info_client_proc_screen_rotation(int argc, char **argv)
 {
@@ -5294,6 +5316,12 @@ static ProcInfo procs_to_execute[] =
       "Force render according to parameters",
       _e_info_client_proc_force_render
    },
+   {
+      "screen_rotation_pre",
+      "[0|90|180|270]",
+      "To rotate screen (pre)",
+      _e_info_client_proc_screen_rotation_pre
+   },
    {
       "screen_rotation",
       "[0|90|180|270]",
index a41467adb3157d7a26e857ca843ace4dae8a86f9..e74ff58744e2f9c08175e8837203b2b75ddf679f 100644 (file)
@@ -4802,6 +4802,29 @@ _e_info_server_cb_force_render(const Eldbus_Service_Interface *iface EINA_UNUSED
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_screen_rotation_pre(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   int rotation_pre;
+
+   if (!eldbus_message_arguments_get(msg, "i", &rotation_pre))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (!e_comp || !e_comp->e_comp_screen)
+     {
+        ERR("Error no screen.");
+        return reply;
+     }
+
+   e_comp_screen_rotation_pre_set(e_comp->e_comp_screen, rotation_pre);
+
+   return reply;
+}
+
 static Eldbus_Message *
 _e_info_server_cb_screen_rotation(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -6060,6 +6083,7 @@ static const Eldbus_Method methods[] = {
    { "desktop_geometry_set", ELDBUS_ARGS({"iiii", "Geometry"}), NULL, _e_info_server_cb_desktop_geometry_set, 0},
    { "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_pre", ELDBUS_ARGS({"i", "value"}), NULL, _e_info_server_cb_screen_rotation_pre, 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},
    { "get_win_under_touch", NULL, ELDBUS_ARGS({"i", "result"}), _e_info_server_cb_get_win_under_touch, 0 },