ecore_evas_wayland: consider output_rotation to manage evas. 12/127312/1
authorBoram Park <boram1288.park@samsung.com>
Fri, 17 Mar 2017 04:55:34 +0000 (13:55 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 27 Apr 2017 04:42:41 +0000 (13:42 +0900)
Change-Id: I38885a7e507d8f7480fafaa458401262d622eaae

src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c

index ee43d1c..e7e6146 100755 (executable)
@@ -45,7 +45,7 @@ static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
 /* local function prototypes */
 static int _ecore_evas_wl_common_render_updates_process(Ecore_Evas *ee, Eina_List *updates);
 void _ecore_evas_wl_common_render_updates(void *data, Evas *evas EINA_UNUSED, void *event);
-static void _rotation_do(Ecore_Evas *ee, int rotation, int resize);
+static void _rotation_do(Ecore_Evas *ee, int rotation, int output_rotation, int resize);
 static void _ecore_evas_wayland_alpha_do(Ecore_Evas *ee, int alpha);
 static void _ecore_evas_wayland_transparent_do(Ecore_Evas *ee, int transparent);
 static void _ecore_evas_wl_common_border_update(Ecore_Evas *ee);
@@ -61,6 +61,70 @@ _ecore_evas_wl_common_state_update(Ecore_Evas *ee)
    if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
 }
 
+static int
+_ecore_evas_wl_common_engine_rotation_get(Ecore_Evas *ee)
+{
+   if (!strncmp(ee->driver, "wayland_shm", 11))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
+        Evas_Engine_Info_Wayland_Shm *einfo;
+        einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
+        return einfo->info.rotation;
+#endif
+     }
+   else if (!strncmp(ee->driver, "wayland_egl", 11))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
+        Evas_Engine_Info_Wayland_Egl *einfo;
+        einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
+        return einfo->info.rotation;
+#endif
+     }
+   return 0;
+}
+
+void
+_ecore_evas_wl_common_engine_info_rotation_set(Ecore_Evas *ee, Evas_Engine_Info *info)
+{
+   Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
+
+   if (!strncmp(ee->driver, "wayland_shm", 11))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
+        Evas_Engine_Info_Wayland_Shm *einfo = (Evas_Engine_Info_Wayland_Shm *)info;
+        einfo->info.rotation = (ee->rotation + wdata->output_rotation) % 360;
+        ecore_wl_window_buffer_transform_set(wdata->win, wdata->output_rotation / 90);
+        WRN("evas engine rotate: %d", einfo->info.rotation);
+#endif
+     }
+   else if (!strncmp(ee->driver, "wayland_egl", 11))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
+        Evas_Engine_Info_Wayland_Egl *einfo = (Evas_Engine_Info_Wayland_Egl *)info;
+        einfo->info.rotation = (ee->rotation + wdata->output_rotation) % 360;
+        ecore_wl_window_buffer_transform_set(wdata->win, wdata->output_rotation / 90);
+        WRN("evas engine rotate: %d", einfo->info.rotation);
+#endif
+     }
+}
+
+static void
+_ecore_evas_wl_common_rotate_update(Ecore_Evas *ee)
+{
+   Ecore_Evas_Engine_Wl_Data *wdata;
+   Ecore_Wl_Output *output;
+   int rotation;
+
+   wdata = ee->engine.data;
+   output = ecore_wl_window_output_find(wdata->win);
+   rotation = ecore_wl_output_transform_get(output) * 90;
+
+   if (_ecore_evas_wl_common_engine_rotation_get(ee) == ((rotation + ee->rotation) % 360))
+     return;
+
+   _rotation_do(ee, ee->rotation, rotation, 0);
+}
+
 static int 
 _ecore_evas_wl_common_render_updates_process(Ecore_Evas *ee, Eina_List *updates)
 {
@@ -199,6 +263,8 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
         _ecore_evas_wl_common_move(ee, nx, ny);
         _ecore_evas_wl_common_resize(ee, nw, nh);
 
+        _ecore_evas_wl_common_rotate_update(ee);
+
         if (prev_full != ee->prop.fullscreen)
           _ecore_evas_wl_common_state_update(ee);
 
@@ -211,6 +277,8 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
    if ((ee->req.w != nw) || (ee->req.h != nh))
      _ecore_evas_wl_common_resize(ee, nw, nh);
 
+   _ecore_evas_wl_common_rotate_update(ee);
+
    if ((prev_max != ee->prop.maximized) ||
        (prev_full != ee->prop.fullscreen))
      _ecore_evas_wl_common_state_update(ee);
@@ -436,13 +504,16 @@ _ecore_evas_wl_common_cb_output_transform(void *data, int type EINA_UNUSED, void
    output = ecore_wl_window_output_find(wdata->win);
    if (output != ev->output) return ECORE_CALLBACK_PASS_ON;
 
-   /* do something */
+   _ecore_evas_wl_common_rotate_update(ee);
 
    return ECORE_CALLBACK_PASS_ON;
 }
 
+/* ee->rotation shouldn't include the output rotation value. Therefore, we
+ * SHOULD handle the window rotation and output transform seperately.
+ */
 static void
-_rotation_do(Ecore_Evas *ee, int rotation, int resize)
+_rotation_do(Ecore_Evas *ee, int rotation, int output_rotation, int resize)
 {
    Ecore_Evas_Engine_Wl_Data *wdata;
    int rot_dif;
@@ -457,7 +528,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
    ecore_wl_window_rotation_set(wdata->win, rotation);
 
    /* check if rotation is just a flip */
-   if (rot_dif != 180)
+   if (rot_dif % 180)
      {
         int minw, minh, maxw, maxh;
         int basew, baseh, stepw, steph;
@@ -472,7 +543,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
              evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
 
              /* check for fullscreen */
-             if (!ee->prop.fullscreen)
+             if (!ee->prop.fullscreen && !ee->prop.maximized)
                {
                   /* resize the ecore_wayland window */
                   ecore_wl_window_resize(wdata->win,
@@ -549,6 +620,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
 
         /* record the current rotation of the ecore_evas */
         ee->rotation = rotation;
+        wdata->output_rotation = output_rotation;
 
         /* reset min, max, base, & step sizes */
         ecore_evas_size_min_set(ee, minh, minw);
@@ -572,6 +644,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
 
         /* record the current rotation of the ecore_evas */
         ee->rotation = rotation;
+        wdata->output_rotation = output_rotation;
 
         /* send a mouse_move process
          *
@@ -597,7 +670,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
         einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
         if (!einfo) return;
 
-        einfo->info.rotation = rotation;
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
 
         if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
           ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
@@ -610,7 +683,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize)
         einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
         if (!einfo) return;
 
-        einfo->info.rotation = rotation;
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
 
         /* TIZEN_ONLY(20160728):
              wayland spec is not define whether wl_egl_window_create() can use null surface or not.
@@ -668,6 +741,8 @@ _ecore_evas_wl_common_app_rotation_set(Ecore_Evas *ee, int rotation, int resize)
 void
 _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize)
 {
+   Ecore_Evas_Engine_Wl_Data *wdata;
+
 // TIZEN_ONLY(20170212): pend rotation until app set rotation
    if (ecore_evas_data_get(ee, "pending_rotation"))
      {
@@ -681,7 +756,9 @@ _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize)
         ee->delayed.rotation_changed = EINA_TRUE;
         return;
      }
-   _rotation_do(ee, rotation, resize);
+
+   wdata = ee->engine.data;
+   _rotation_do(ee, rotation, wdata->output_rotation, resize);
 }
 
 int
@@ -937,6 +1014,8 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
           }
      }
 
+   _ecore_evas_wl_common_rotate_update(ee);
+
    evas_output_size_get(ee->evas, &ow, &oh);
 
    if (ECORE_EVAS_PORTRAIT(ee) && ((ow != w) || (oh != h)))
@@ -1486,7 +1565,7 @@ _ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl_Window *win, int rot, Ein
         einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
         if (!einfo) return;
 
-        einfo->info.rotation = rot;
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
 
         if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
           ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
@@ -1499,7 +1578,7 @@ _ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl_Window *win, int rot, Ein
         einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
         if (!einfo) return;
 
-        einfo->info.rotation = rot;
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
 
         /* TIZEN_ONLY(20160728):
            wayland spec is not define whether wl_egl_window_create() can use null surface or not.
@@ -1996,7 +2075,8 @@ _ecore_evas_wl_common_render_updates(void *data, Evas *evas EINA_UNUSED, void *e
      }
    if (ee->delayed.rotation_changed)
      {
-        _rotation_do(ee, ee->delayed.rotation, ee->delayed.rotation_resize);
+        Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
+        _rotation_do(ee, ee->delayed.rotation, wdata->output_rotation, ee->delayed.rotation_resize);
         ee->delayed.rotation_changed = EINA_FALSE;
      }
 }
@@ -2125,11 +2205,15 @@ void
 _ecore_evas_wl_common_output_transform_register(Ecore_Evas *ee)
 {
    Ecore_Evas_Engine_Wl_Data *wdata;
+   Ecore_Wl_Output *output;
 
    if (!ee) return;
    if (!(wdata = ee->engine.data)) return;
    if (wdata->output_transform_hdl) return;
 
+   output = ecore_wl_window_output_find(wdata->win);
+   wdata->output_rotation = ecore_wl_output_transform_get(output) * 90;
+
    wdata->output_transform_hdl =
      ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM,
                              _ecore_evas_wl_common_cb_output_transform, ee);
index 18a4a33..0653054 100644 (file)
@@ -302,6 +302,7 @@ ecore_evas_wayland_egl_options_new_internal(const char *disp_name, unsigned int
         einfo->info.rotation = ee->rotation;
         einfo->info.depth = 32;
         einfo->info.surface = ecore_wl_window_surface_create(wdata->win);
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
         if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
           {
              ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
index 0897133..4b238e0 100755 (executable)
@@ -115,6 +115,7 @@ void _ecore_evas_wl_common_wm_rot_manual_rotation_done(Ecore_Evas *ee);
 void _ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl_Window *win, int rot, Eina_Bool resize, int w, int h, void *data);
 
 int _ecore_evas_common_init_count_get(void);
+void _ecore_evas_wl_common_engine_info_rotation_set(Ecore_Evas *ee, Evas_Engine_Info *info);
 
 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
 void _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location);
index bd40a33..386d213 100644 (file)
@@ -270,6 +270,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
         if (_ecore_evas_common_init_count_get() == 1)
               tbm_client = wayland_tbm_client_init(einfo->info.wl_disp);
         einfo->info.tbm_client = tbm_client;
+        _ecore_evas_wl_common_engine_info_rotation_set(ee, (Evas_Engine_Info *)einfo);
         if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
           {
              ERR("Failed to set Evas Engine Info for '%s'", ee->driver);