< Summary

Class:GDX.Display
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Display.cs
Covered lines:0
Uncovered lines:12
Coverable lines:12
Total lines:85
Line coverage:0% (0 of 12)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:4
Method coverage:0% (0 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetScreenHeight()0%2100%
GetScreenWidth()0%2100%
IsHDRSupported()0%2100%
IsHDREnabled()0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Display.cs

#LineLine coverage
 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
 5using System.Runtime.CompilerServices;
 6using UnityEngine;
 7
 8namespace 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()
 025        {
 026            return Screen.currentResolution.height;
 027        }
 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()
 037        {
 038            return Screen.currentResolution.width;
 039        }
 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
 051        {
 52#if UNITY_PS4
 53            return ((UnityEngine.PS4.Utility.GetVideoOutDeviceCapability(UnityEngine.PS4.Utility.videoOutPortHandle) &
 54                    UnityEngine.PS4.Utility.VideoOutDeviceCapability.BT2020_PQ) != 0);
 55#else
 056            return SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.DefaultHDR);
 57#endif // UNITY_PS4
 058        }
 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
 070        {
 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
 079            return SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.DefaultHDR);
 80#endif // UNITY_PS4
 081        }
 82
 83#endif // !UNITY_DOTSRUNTIME
 84    }
 85}