ecore-evas-drm: Implement support for hardware output rotations
authorChris Michael <cp.michael@samsung.com>
Wed, 4 Oct 2017 15:41:59 +0000 (11:41 -0400)
committerChris Michael <cp.michael@samsung.com>
Wed, 4 Oct 2017 15:41:59 +0000 (11:41 -0400)
This patch adds support for doing output rotations via hardware. This
is implemented inside the Ecore_Evas engine so that it is transparent
to the caller of ecore_evas_rotation_set.

ref T5999

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

index bd569dd..521e05b 100644 (file)
@@ -221,13 +221,64 @@ static void
 _drm_rotation_do(Ecore_Evas *ee, int rotation, int resize)
 {
    Evas_Engine_Info_Drm *einfo;
-   int diff;
+   Ecore_Evas_Engine_Drm_Data *edata;
+   Eina_Bool use_hw = EINA_FALSE;
+   int diff, rotations = 0, orient = 0;
 
    if (ee->rotation == rotation) return;
 
    einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(ee->evas);
    if (!einfo) return;
 
+   edata = ee->engine.data;
+
+   rotations = ecore_drm2_output_supported_rotations_get(edata->output);
+   if (rotations >= 0)
+     {
+        if (rotations & ECORE_DRM2_ROTATION_NORMAL)
+          {
+             if (rotation == 0)
+               {
+                  use_hw = EINA_TRUE;
+                  orient = ECORE_DRM2_ROTATION_NORMAL;
+               }
+          }
+
+        if (rotations & ECORE_DRM2_ROTATION_90)
+          {
+             if (rotation == 90)
+               {
+                  use_hw = EINA_TRUE;
+                  orient = ECORE_DRM2_ROTATION_90;
+               }
+          }
+
+        if (rotations & ECORE_DRM2_ROTATION_180)
+          {
+             if (rotation == 180)
+               {
+                  use_hw = EINA_TRUE;
+                  orient = ECORE_DRM2_ROTATION_180;
+               }
+          }
+
+        if (rotations & ECORE_DRM2_ROTATION_270)
+          {
+             if (rotation == 270)
+               {
+                  use_hw = EINA_TRUE;
+                  orient = ECORE_DRM2_ROTATION_270;
+               }
+          }
+     }
+
+   if (use_hw)
+     {
+        ecore_drm2_output_rotation_set(edata->output, orient);
+        ee->rotation = rotation;
+        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);