using System.Linq; using NvAPIWrapper.Native; using NvAPIWrapper.Native.Display; using NvAPIWrapper.Native.Display.Structures; using NvAPIWrapper.Native.General.Structures; using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; namespace NvAPIWrapper.Display { /// /// Contains information regarding the scan-out buffer settings of a display device /// public class ScanOutInformation { internal ScanOutInformation(DisplayDevice displayDevice) { DisplayDevice = displayDevice; } /// /// Gets the clone importance assigned to the target if the target is a cloned view of the SourceDesktopRectangle /// (0:primary,1 secondary,...). /// public uint CloneImportance { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).CloneImportance; } /// /// Gets the display device that this instance describes /// public DisplayDevice DisplayDevice { get; } /// /// Gets a boolean value indicating if the display device scan out output is warped /// public bool IsDisplayWarped { get => DisplayApi.GetScanOutWarpingState(DisplayDevice.DisplayId).IsEnabled; } /// /// Gets a boolean value indicating if the display device intensity is modified /// public bool IsIntensityModified { get => DisplayApi.GetScanOutIntensityState(DisplayDevice.DisplayId).IsEnabled; } /// /// Gets the operating system display device rectangle in desktop coordinates displayId is scanning out from. /// public Rectangle SourceDesktopRectangle { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceDesktopRectangle; } /// /// Gets the rotation performed between the SourceViewPortRectangle and the TargetViewPortRectangle. /// public Rotate SourceToTargetRotation { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceToTargetRotation; } /// /// Gets the area inside the SourceDesktopRectangle which is scanned out to the display. /// public Rectangle SourceViewPortRectangle { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceViewPortRectangle; } /// /// Gets the vertical size of the active resolution scanned out to the display. /// public uint TargetDisplayHeight { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetDisplayHeight; } /// /// Gets the horizontal size of the active resolution scanned out to the display. /// public uint TargetDisplayWidth { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetDisplayWidth; } /// /// Gets the area inside the rectangle described by targetDisplayWidth/Height SourceViewPortRectangle is scanned out /// to. /// public Rectangle TargetViewPortRectangle { get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetViewPortRectangle; } /// /// Disables the intensity modification on the display device scan-out buffer. /// /// A boolean value that indicates whether the settings will be kept over a reboot. public void DisableIntensityModifications(out bool isSticky) { DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, null, out isSticky); } /// /// Disables the warping of display device scan-out buffer. /// /// A boolean value that indicates whether the settings will be kept over a reboot. public void DisableWarping(out bool isSticky) { var vorticesCount = 0; DisplayApi.SetScanOutWarping(DisplayDevice.DisplayId, null, ref vorticesCount, out isSticky); } /// /// Enables the intensity modification on the display device scan-out buffer. /// /// The intensity texture to apply to the scan-out buffer. /// A boolean value that indicates whether the settings will be kept over a reboot. public void EnableIntensityModifications(IntensityTexture intensityTexture, out bool isSticky) { using ( var intensity = new ScanOutIntensityV1( (uint) intensityTexture.Width, (uint) intensityTexture.Height, intensityTexture.ToFloatArray() ) ) { DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, intensity, out isSticky); } } /// /// Enables the intensity modification on the display device scan-out buffer. /// /// The intensity texture to apply to the scan-out buffer. /// The offset texture to apply to the scan-out buffer. /// A boolean value that indicates whether the settings will be kept over a reboot. public void EnableIntensityModifications( IntensityTexture intensityTexture, FloatTexture offsetTexture, out bool isSticky) { using ( var intensity = new ScanOutIntensityV2( (uint) intensityTexture.Width, (uint) intensityTexture.Height, intensityTexture.ToFloatArray(), (uint) offsetTexture.Channels, offsetTexture.ToFloatArray() ) ) { DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, intensity, out isSticky); } } /// /// Enables the warping of display device scan-out buffer /// /// The type of warping vortexes. /// An array of warping vortexes. /// The rectangle in desktop coordinates describing the source area for the warping. /// A boolean value that indicates whether the settings will be kept over a reboot. // ReSharper disable once TooManyArguments public void EnableWarping( WarpingVerticeFormat warpingVerticeFormat, XYUVRQVortex[] vortices, Rectangle textureRectangle, out bool isSticky) { using ( var warping = new ScanOutWarpingV1( warpingVerticeFormat, vortices.SelectMany(vortex => vortex.AsFloatArray()).ToArray(), textureRectangle ) ) { var vorticesCount = vortices.Length; DisplayApi.SetScanOutWarping(DisplayDevice.DisplayId, warping, ref vorticesCount, out isSticky); } } /// /// Queries the current state of one of the various scan-out composition parameters. /// /// The scan-out composition parameter. /// The additional value included with the parameter value. /// The scan-out composition parameter value. public ScanOutCompositionParameterValue GetCompositionParameterValue( ScanOutCompositionParameter parameter, out float additionalValue) { return DisplayApi.GetScanOutCompositionParameter(DisplayDevice.DisplayId, parameter, out additionalValue); } /// /// Sets the current state of one of the various scan-out composition parameters. /// /// The scan-out composition parameter. /// The scan-out composition parameter value. /// The additional value included with the parameter value. public void SetCompositionParameterValue( ScanOutCompositionParameter parameter, ScanOutCompositionParameterValue parameterValue, float additionalValue) { DisplayApi.SetScanOutCompositionParameter(DisplayDevice.DisplayId, parameter, parameterValue, ref additionalValue); } } }