ecore_wl2: add ecore_wl2_subsurface_rotation_set 67/257667/2 submit/ags=submit/tizen/20210430.105132/20210504.123650 submit/tizen/20210504.083345
authorShinwoo Kim <cinoo.kim@samsung.com>
Thu, 29 Apr 2021 06:51:42 +0000 (15:51 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 4 May 2021 08:17:17 +0000 (17:17 +0900)
This patch is adding ecore_wl2_subsurface_rotation_set to support
downloadable application which is using allowed API only.

*tizen_only

Change-Id: Icaea559788fd9ef0830bca4915cff459ecf6c5dc

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_subsurf.c

index 14c0b9f..0a1e9a9 100644 (file)
@@ -3268,6 +3268,39 @@ EAPI Eina_Bool ecore_wl2_subsurface_video_surface_prepare(Ecore_Wl2_Subsurface *
 EAPI Eina_Bool ecore_wl2_subsurface_video_surface_destination_set(Ecore_Wl2_Subsurface *subsurface, int x, int y, int w, int h);
 
 /**
+ * @brief Defines the rotation types of video surface
+ *
+ * @see ecore_wl2_subsurface_video_surface_rotation_set
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.0
+ */
+typedef enum _Ecore_Wl2_Subsurface_Rotation
+{
+   ECORE_WL2_SUBSURFACE_ROTATION_NORMAL,
+   ECORE_WL2_SUBSURFACE_ROTATION_90,
+   ECORE_WL2_SUBSURFACE_ROTATION_180,
+   ECORE_WL2_SUBSURFACE_ROTATION_270,
+   ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED,
+   ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_90,
+   ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_180,
+   ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_270
+} Ecore_Wl2_Subsurface_Rotation;
+
+/**
+ * @brief Set video surface rotation for a given subsurface
+ *
+ * @param subsurface The subsurface to set video surface rotation
+ * @param rotation  The rotation type to set video surface rotation
+ *
+ * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
+ *
+ * @ingroup Ecore_Wl2_Subsurface_Group
+ * @since_tizen 6.0
+ */
+EAPI Eina_Bool ecore_wl2_subsurface_video_surface_rotation_set(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface_Rotation rotation);
+
+/**
  * @brief Set an auxiliary hint on a given subsurface
  *
  * @param subsurface The subsurface to set an auxiliary hint
index 8ce492e..f13bafa 100644 (file)
@@ -296,16 +296,13 @@ ecore_wl2_subsurface_window_get(Ecore_Wl2_Subsurface *subsurface)
    return subsurface->parent;
 }
 
-EAPI Eina_Bool
-ecore_wl2_subsurface_video_surface_destination_set(Ecore_Wl2_Subsurface *subsurface, int x, int y, int w, int h)
+static Eina_Bool _tizen_video_viewport_get(Ecore_Wl2_Subsurface *subsurface)
 {
    Ecore_Wl2_Display *display;
    struct wl_registry *registry;
    Eina_Iterator *globals;
    Ecore_Wl2_Global *global;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, EINA_FALSE);
-
    if (!subsurface->video)
      {
         ERR("prepare subsurface(%p) first", subsurface);
@@ -352,12 +349,71 @@ ecore_wl2_subsurface_video_surface_destination_set(Ecore_Wl2_Subsurface *subsurf
           }
      }
 
+   return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+ecore_wl2_subsurface_video_surface_destination_set(Ecore_Wl2_Subsurface *subsurface, int x, int y, int w, int h)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, EINA_FALSE);
+   if (!_tizen_video_viewport_get(subsurface)) return EINA_FALSE;
+
    tizen_viewport_set_destination(subsurface->wl.viewport, x, y, w, h);
    wl_surface_commit(subsurface->wl.surface);
 
    return EINA_TRUE;
 }
 
+EAPI Eina_Bool
+ecore_wl2_subsurface_video_surface_rotation_set(Ecore_Wl2_Subsurface *subsurface, Ecore_Wl2_Subsurface_Rotation rotation)
+{
+   int transform;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, EINA_FALSE);
+
+   if (rotation < ECORE_WL2_SUBSURFACE_ROTATION_NORMAL ||
+       rotation > ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_270)
+     {
+        ERR("Not supported: %d", rotation);
+        return EINA_FALSE;
+     }
+
+   if (!_tizen_video_viewport_get(subsurface)) return EINA_FALSE;
+
+   switch (rotation)
+     {
+      case ECORE_WL2_SUBSURFACE_ROTATION_NORMAL:
+        transform = WL_OUTPUT_TRANSFORM_NORMAL;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_90:
+        transform = WL_OUTPUT_TRANSFORM_90;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_180:
+        transform = WL_OUTPUT_TRANSFORM_180;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_270:
+        transform = WL_OUTPUT_TRANSFORM_270;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED:
+        transform = WL_OUTPUT_TRANSFORM_FLIPPED;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_90:
+        transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_180:
+        transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
+        break;
+      case ECORE_WL2_SUBSURFACE_ROTATION_FLIPPED_270:
+        transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
+        break;
+     }
+
+   tizen_viewport_set_transform(subsurface->wl.viewport, transform);
+   wl_surface_commit(subsurface->wl.surface);
+
+   return EINA_TRUE;
+}
+
 void
 _ecore_wl2_subsurfae_place_surface_stack(Ecore_Wl2_Subsurface *subsurf, Ecore_Wl2_Subsurface *other, Eina_Bool above)
 {