Skip to content

Commit

Permalink
[Multimedia] Add a new constructor of Display to remove dependency of…
Browse files Browse the repository at this point in the history
… UI frameworks (Samsung#5738)

* Add a new constructor of Display to remove depenendcy of UI frameworks

* Rename property

* Apply review comment

---------

Co-authored-by: Jay Cho <[email protected]>
  • Loading branch information
myroot and JoonghyunCho authored Jan 29, 2024
1 parent 5c82a6b commit 0ec95f9
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Tizen.Multimedia/Common/Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,41 @@ public Display(NUI.Window window, bool uiSync)
UiSync = uiSync;
}

/// <summary>
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="IWindowProvider"/> interface.
/// </summary>
/// <param name="window">An <see cref="IWindowProvider"/> object that provides a handle to a window.</param>
/// <since_tizen> 12 </since_tizen>
public Display(IWindowProvider window)
: this(window, false)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="IWindowProvider"/> interface.
/// </summary>
/// <param name="window">An <see cref="IWindowProvider"/> object that provides a handle to a window.</param>
/// <param name="uiSync">A value indicating whether video and UI are in sync or not.</param>
/// <remarks>
/// UI sync is only for <see cref="T:Tizen.Multimedia.Player"/> and
/// <see cref="T:Tizen.Multimedia.Player.DisplaySettings"/> will not work in UI sync mode.
/// </remarks>
/// <since_tizen> 12 </since_tizen>
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; }
Expand Down Expand Up @@ -222,5 +257,24 @@ internal static Tizen.Multimedia.Rotation ToMmRotation(this NUI.Window.WindowOri

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;
}
}
}
43 changes: 43 additions & 0 deletions src/Tizen.Multimedia/Common/IWindowProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;

namespace Tizen.Multimedia
{
/// <summary>
/// The IWindowProvider interface provides the window handle and information about the window's position, size, and rotation.
/// </summary>
/// <since_tizen> 12 </since_tizen>
public interface IWindowProvider
{
/// <summary>
/// Gets the window handle
/// </summary>
/// <remarks>
/// This handle represents Ecore_Wl2_Window on native.
/// </remarks>
IntPtr WindowHandle { get; }

/// <summary>
/// Gets the x-coordinate of the window's position.
/// </summary>
float X { get; }
/// <summary>
/// Gets the y-coordinate of the window's position.
/// </summary>
float Y { get; }

/// <summary>
/// Gets the width of the window.
/// </summary>
float Width { get; }

/// <summary>
/// Gets the height of the window.
/// </summary>
float Height { get; }

/// <summary>
/// Gets the rotation of the window in degrees. The value can only be 0, 90, 180, or 270.
/// </summary>
int Rotation { get; }
}
}

0 comments on commit 0ec95f9

Please sign in to comment.