From 0ec95f97deae35cda0a6d1350ff6bc18af8f3f36 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 29 Jan 2024 15:52:04 +0900 Subject: [PATCH] [Multimedia] Add a new constructor of Display to remove dependency of UI frameworks (#5738) * Add a new constructor of Display to remove depenendcy of UI frameworks * Rename property * Apply review comment --------- Co-authored-by: Jay Cho --- src/Tizen.Multimedia/Common/Display.cs | 54 ++++++++++++++++++++++++++ src/Tizen.Multimedia/Common/IWindowProvider.cs | 43 ++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/Tizen.Multimedia/Common/IWindowProvider.cs diff --git a/src/Tizen.Multimedia/Common/Display.cs b/src/Tizen.Multimedia/Common/Display.cs index 1082110..8415951 100644 --- a/src/Tizen.Multimedia/Common/Display.cs +++ b/src/Tizen.Multimedia/Common/Display.cs @@ -174,6 +174,41 @@ namespace Tizen.Multimedia UiSync = uiSync; } + /// + /// Initializes a new instance of the class with an interface. + /// + /// An object that provides a handle to a window. + /// 12 + public Display(IWindowProvider window) + : this(window, false) + { + } + + /// + /// Initializes a new instance of the class with an interface. + /// + /// An object that provides a handle to a window. + /// A value indicating whether video and UI are in sync or not. + /// + /// UI sync is only for and + /// will not work in UI sync mode. + /// + /// 12 + public Display(IWindowProvider window, bool uiSync) + { + if (window == null) + { + throw new ArgumentNullException(nameof(window)); + } + + _setter = new EcoreDisplaySetter(window.WindowHandle, + new Rectangle((int)window.X, (int)window.Y, (int)window.Width, (int)window.Height), + window.Rotation.ToMmRotation()); + + UiSync = uiSync; + } + + private EvasObject EvasObject { get; } private DisplayType Type { get; } @@ -222,5 +257,24 @@ namespace Tizen.Multimedia return Tizen.Multimedia.Rotation.Rotate90; } + + internal static Rotation ToMmRotation(this int rotation) + { + switch (rotation) + { + case 0: + return Rotation.Rotate0; + case 90: + return Rotation.Rotate90; + case 180: + return Rotation.Rotate180; + case 270: + return Rotation.Rotate270; + default: + break; + } + + return Rotation.Rotate90; + } } } diff --git a/src/Tizen.Multimedia/Common/IWindowProvider.cs b/src/Tizen.Multimedia/Common/IWindowProvider.cs new file mode 100644 index 0000000..0a86da5 --- /dev/null +++ b/src/Tizen.Multimedia/Common/IWindowProvider.cs @@ -0,0 +1,43 @@ +using System; + +namespace Tizen.Multimedia +{ + /// + /// The IWindowProvider interface provides the window handle and information about the window's position, size, and rotation. + /// + /// 12 + public interface IWindowProvider + { + /// + /// Gets the window handle + /// + /// + /// This handle represents Ecore_Wl2_Window on native. + /// + IntPtr WindowHandle { get; } + + /// + /// Gets the x-coordinate of the window's position. + /// + float X { get; } + /// + /// Gets the y-coordinate of the window's position. + /// + float Y { get; } + + /// + /// Gets the width of the window. + /// + float Width { get; } + + /// + /// Gets the height of the window. + /// + float Height { get; } + + /// + /// Gets the rotation of the window in degrees. The value can only be 0, 90, 180, or 270. + /// + int Rotation { get; } + } +} -- 2.7.4