Skip to content

Commit

Permalink
Revert "Merge pull request ppy#6268 from Susko3/dont-overload-Display…
Browse files Browse the repository at this point in the history
…Handle"

This reverts commit d73af6c, reversing
changes made to f7718ea.
  • Loading branch information
peppy committed May 21, 2024
1 parent e6d363a commit e2f5b3d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Android/AndroidGameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace osu.Framework.Android
{
internal class AndroidGameWindow : SDL3MobileWindow
{
public override IntPtr SurfaceHandle => AndroidGameActivity.Surface.NativeSurface?.Handle ?? IntPtr.Zero;
public override IntPtr DisplayHandle => AndroidGameActivity.Surface.NativeSurface?.Handle ?? IntPtr.Zero;

public AndroidGameWindow(GraphicsSurfaceType surfaceType, string appName)
: base(surfaceType, appName)
Expand Down
6 changes: 3 additions & 3 deletions osu.Framework/Graphics/Veldrid/VeldridDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ public VeldridDevice(IGraphicsSurface graphicsSurface)
{
var linuxGraphics = (ILinuxGraphicsSurface)this.graphicsSurface;
swapchain.Source = linuxGraphics.IsWayland
? SwapchainSource.CreateWayland(linuxGraphics.DisplayHandle, this.graphicsSurface.WindowHandle)
: SwapchainSource.CreateXlib(linuxGraphics.DisplayHandle, this.graphicsSurface.WindowHandle);
? SwapchainSource.CreateWayland(this.graphicsSurface.DisplayHandle, this.graphicsSurface.WindowHandle)
: SwapchainSource.CreateXlib(this.graphicsSurface.DisplayHandle, this.graphicsSurface.WindowHandle);
break;
}

case RuntimeInfo.Platform.Android:
{
var androidGraphics = (IAndroidGraphicsSurface)this.graphicsSurface;
swapchain.Source = SwapchainSource.CreateAndroidSurface(androidGraphics.SurfaceHandle, androidGraphics.JniEnvHandle);
swapchain.Source = SwapchainSource.CreateAndroidSurface(this.graphicsSurface.DisplayHandle, androidGraphics.JniEnvHandle);
break;
}
}
Expand Down
6 changes: 0 additions & 6 deletions osu.Framework/Platform/IAndroidGraphicsSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@ public interface IAndroidGraphicsSurface
/// Returns JNI environment handle.
/// </summary>
IntPtr JniEnvHandle { get; }

/// <summary>
/// Android Surface handle.
/// </summary>
/// <remarks>https://developer.android.com/reference/android/view/Surface.html</remarks>
IntPtr SurfaceHandle { get; }
}
}
6 changes: 6 additions & 0 deletions osu.Framework/Platform/IGraphicsSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public interface IGraphicsSurface
/// </summary>
IntPtr WindowHandle { get; }

/// <summary>
/// A pointer representing a handle to the display containing this window, provided by the operating system.
/// This is specific to X11/Wayland subsystems.
/// </summary>
IntPtr DisplayHandle { get; }

/// <summary>
/// The type of surface.
/// </summary>
Expand Down
8 changes: 0 additions & 8 deletions osu.Framework/Platform/ILinuxGraphicsSurface.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;

namespace osu.Framework.Platform
{
public interface ILinuxGraphicsSurface
Expand All @@ -11,11 +9,5 @@ public interface ILinuxGraphicsSurface
/// Whether the current display server is Wayland.
/// </summary>
bool IsWayland { get; }

/// <summary>
/// A pointer representing a handle to the display containing this window, provided by the operating system.
/// This is specific to X11/Wayland subsystems.
/// </summary>
IntPtr DisplayHandle { get; }
}
}
7 changes: 1 addition & 6 deletions osu.Framework/Platform/SDL/SDL3GraphicsSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal unsafe class SDL3GraphicsSurface : IGraphicsSurface, IOpenGLGraphicsSur
private IntPtr context;

public IntPtr WindowHandle => window.WindowHandle;
public IntPtr DisplayHandle => window.DisplayHandle;

public GraphicsSurfaceType Type { get; }

Expand Down Expand Up @@ -215,19 +216,13 @@ bool IOpenGLGraphicsSurface.VerticalSync

bool ILinuxGraphicsSurface.IsWayland => window.IsWayland;

[SupportedOSPlatform("linux")]
IntPtr ILinuxGraphicsSurface.DisplayHandle => window.DisplayHandle;

#endregion

#region Android-specific implementation

[SupportedOSPlatform("android")]
IntPtr IAndroidGraphicsSurface.JniEnvHandle => SDL3.SDL_AndroidGetJNIEnv();

[SupportedOSPlatform("android")]
IntPtr IAndroidGraphicsSurface.SurfaceHandle => window.SurfaceHandle;

#endregion
}
}
7 changes: 1 addition & 6 deletions osu.Framework/Platform/SDL3Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
Expand Down Expand Up @@ -120,8 +119,7 @@ public IntPtr WindowHandle
}
}

[SupportedOSPlatform("linux")]
public IntPtr DisplayHandle
public virtual IntPtr DisplayHandle
{
get
{
Expand All @@ -140,9 +138,6 @@ public IntPtr DisplayHandle
}
}

[SupportedOSPlatform("android")]
public virtual IntPtr SurfaceHandle => throw new PlatformNotSupportedException();

public bool CapsLockPressed => SDL3.SDL_GetModState().HasFlagFast(SDL_Keymod.SDL_KMOD_CAPS);

/// <summary>
Expand Down

0 comments on commit e2f5b3d

Please sign in to comment.