ecore-evas-drm: Implement actual evas engine rotations in drm
authorChris Michael <cp.michael@samsung.com>
Tue, 19 Sep 2017 15:58:55 +0000 (11:58 -0400)
committerChris Michael <cp.michael@samsung.com>
Tue, 19 Sep 2017 17:10:33 +0000 (13:10 -0400)
This patch implements handling of evas output rotation for the
ecore_evas drm engine.

ref T5999

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/modules/ecore_evas/engines/drm/ecore_evas_drm.c

index 561dd3092c43052938cc04567e29eaa26c794989..bd569ddbd5badebdfc797383536fc029c4e7e34c 100644 (file)
@@ -218,17 +218,75 @@ _drm_free(Ecore_Evas *ee)
 }
 
 static void
-_drm_rotation_do(Ecore_Evas *ee, int rotation, int resize EINA_UNUSED)
+_drm_rotation_do(Ecore_Evas *ee, int rotation, int resize)
 {
    Evas_Engine_Info_Drm *einfo;
+   int diff;
 
    if (ee->rotation == rotation) return;
-   ee->rotation = rotation;
+
    einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(ee->evas);
    if (!einfo) return;
+
    einfo->info.rotation = rotation;
    if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
      ERR("evas_engine_info_set() for engine '%s' failed", ee->driver);
+
+   diff = ee->rotation - rotation;
+   if (diff < 0) diff = -diff;
+
+   if (diff != 180)
+     {
+        if (!resize)
+          {
+             int ww, hh;
+
+             if (ECORE_EVAS_PORTRAIT(ee))
+               evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
+             else
+               evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.h, ee->req.w);
+
+             ww = ee->h;
+             hh = ee->w;
+             ee->w = ww;
+             ee->h = hh;
+             ee->req.w = ww;
+             ee->req.h = hh;
+          }
+        else
+          {
+             if ((rotation == 0) || (rotation == 180))
+               {
+                  evas_output_size_set(ee->evas, ee->w, ee->h);
+                  evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+               }
+             else
+               {
+                  evas_output_size_set(ee->evas, ee->h, ee->w);
+                  evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
+               }
+
+             if (ee->func.fn_resize) ee->func.fn_resize(ee);
+
+             if (ECORE_EVAS_PORTRAIT(ee))
+               evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+             else
+               evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
+          }
+
+        ee->rotation = rotation;
+     }
+   else
+     {
+        ee->rotation = rotation;
+
+        if (ee->func.fn_resize) ee->func.fn_resize(ee);
+
+        if (ECORE_EVAS_PORTRAIT(ee))
+          evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+        else
+          evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
+     }
 }
 
 static void