From 37b4d45f563b717919bfd6256aa37629badccdcf Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Thu, 29 Apr 2021 15:51:42 +0900 Subject: [PATCH] ecore_wl2: add ecore_wl2_subsurface_rotation_set 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 | 33 ++++++++++++++++++ src/lib/ecore_wl2/ecore_wl2_subsurf.c | 64 ++++++++++++++++++++++++++++++++--- 2 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 14c0b9f..0a1e9a9 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -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 diff --git a/src/lib/ecore_wl2/ecore_wl2_subsurf.c b/src/lib/ecore_wl2/ecore_wl2_subsurf.c index 8ce492e..f13bafa 100644 --- a/src/lib/ecore_wl2/ecore_wl2_subsurf.c +++ b/src/lib/ecore_wl2/ecore_wl2_subsurf.c @@ -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) { -- 2.7.4