| | | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | using System.Runtime.CompilerServices; |
| | | 6 | | using UnityEngine; |
| | | 7 | | |
| | | 8 | | namespace GDX |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// A collection of display related helper utilities. |
| | | 12 | | /// </summary> |
| | | 13 | | [VisualScriptingCompatible(8)] |
| | | 14 | | public static class Display |
| | | 15 | | { |
| | | 16 | | #if !UNITY_DOTSRUNTIME |
| | | 17 | | /// <summary> |
| | | 18 | | /// <para>Returns the actual screen height being rendered on the current platform.</para> |
| | | 19 | | /// </summary> |
| | | 20 | | /// <remarks>This resolves issues with scaled rendering.</remarks> |
| | | 21 | | /// <returns>The pixel height of the screen resolution.</returns> |
| | | 22 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | | 23 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 24 | | public static int GetScreenHeight() |
| | 0 | 25 | | { |
| | 0 | 26 | | return Screen.currentResolution.height; |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// <para>Returns the actual screen width being rendered on the current platform.</para> |
| | | 31 | | /// </summary> |
| | | 32 | | /// <remarks>This resolves issues with scaled rendering.</remarks> |
| | | 33 | | /// <returns>The pixel width of the screen resolution.</returns> |
| | | 34 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | | 35 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 36 | | public static int GetScreenWidth() |
| | 0 | 37 | | { |
| | 0 | 38 | | return Screen.currentResolution.width; |
| | 0 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Does the current display device support HDR output? |
| | | 43 | | /// </summary> |
| | | 44 | | /// <returns>true/false</returns> |
| | | 45 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | | 46 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 47 | | #pragma warning disable IDE1006 |
| | | 48 | | // ReSharper disable once InconsistentNaming |
| | | 49 | | public static bool IsHDRSupported() |
| | | 50 | | #pragma warning restore IDE1006 |
| | 0 | 51 | | { |
| | | 52 | | #if UNITY_PS4 |
| | | 53 | | return ((UnityEngine.PS4.Utility.GetVideoOutDeviceCapability(UnityEngine.PS4.Utility.videoOutPortHandle) & |
| | | 54 | | UnityEngine.PS4.Utility.VideoOutDeviceCapability.BT2020_PQ) != 0); |
| | | 55 | | #else |
| | 0 | 56 | | return SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.DefaultHDR); |
| | | 57 | | #endif // UNITY_PS4 |
| | 0 | 58 | | } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Is HDR output currently enabled (and actively being used)? |
| | | 62 | | /// </summary> |
| | | 63 | | /// <returns>true/false</returns> |
| | | 64 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | | 65 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 66 | | #pragma warning disable IDE1006 |
| | | 67 | | // ReSharper disable once InconsistentNaming |
| | | 68 | | public static bool IsHDREnabled() |
| | | 69 | | #pragma warning restore IDE1006 |
| | 0 | 70 | | { |
| | | 71 | | #if UNITY_PS4 |
| | | 72 | | UnityEngine.PS4.Utility.GetRequestedVideoOutMode(out videoMode) |
| | | 73 | | return ((videoMode.colorimetry == UnityEngine.PS4.Utility.VideoOutColorimetry.BT2020_PQ)|| |
| | | 74 | | (videoMode.colorimetry == UnityEngine.PS4.Utility.VideoOutColorimetry.RGB2020_PQ) || |
| | | 75 | | (videoMode.colorimetry == UnityEngine.PS4.Utility.VideoOutColorimetry.YCBCR2020_PQ)); |
| | | 76 | | #elif UNITY_XBOXONE |
| | | 77 | | return UnityEngine.XboxOne.Graphics.displayInHDR; |
| | | 78 | | #else |
| | 0 | 79 | | return SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.DefaultHDR); |
| | | 80 | | #endif // UNITY_PS4 |
| | 0 | 81 | | } |
| | | 82 | | |
| | | 83 | | #endif // !UNITY_DOTSRUNTIME |
| | | 84 | | } |
| | | 85 | | } |