Reduced the displayid calls for profile comparison

This commit is contained in:
Terry MacDonald 2022-05-29 21:01:08 +12:00
parent f6b1eed990
commit 567c9b7af2
4 changed files with 21 additions and 18 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.3.1.79")]
[assembly: AssemblyFileVersion("2.3.1.79")]
[assembly: AssemblyVersion("2.3.2.1")]
[assembly: AssemblyFileVersion("2.3.2.1")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -167,6 +167,7 @@ namespace DisplayMagicianShared.AMD
private IntPtr _adlContextHandle = IntPtr.Zero;
private AMD_DISPLAY_CONFIG _activeDisplayConfig;
public List<ADL_DISPLAY_CONNECTION_TYPE> SkippedColorConnectionTypes;
public List<string> _allConnectedDisplayIdentifiers;
static AMDLibrary() { }
public AMDLibrary()
@ -205,6 +206,7 @@ namespace DisplayMagicianShared.AMD
SharedLogger.logger.Trace($"AMDLibrary/AMDLibrary: AMD ADL2 library was initialised successfully");
SharedLogger.logger.Trace($"AMDLibrary/AMDLibrary: Running UpdateActiveConfig to ensure there is a config to use later");
_activeDisplayConfig = GetActiveConfig();
_allConnectedDisplayIdentifiers = GetAllConnectedDisplayIdentifiers();
}
else
{
@ -1604,11 +1606,8 @@ namespace DisplayMagicianShared.AMD
// We want to check the AMD profile can be used now
SharedLogger.logger.Trace($"AMDLibrary/IsPossibleConfig: Testing whether the AMD display configuration is possible to be used now");
// Check the currently available displays (include the ones not active)
List<string> currentAllIds = GetAllConnectedDisplayIdentifiers();
// Check that we have all the displayConfig DisplayIdentifiers we need available now
if (displayConfig.DisplayIdentifiers.All(value => currentAllIds.Contains(value)))
if (displayConfig.DisplayIdentifiers.All(value => _allConnectedDisplayIdentifiers.Contains(value)))
{
SharedLogger.logger.Trace($"AMDLibrary/IsPossibleConfig: Success! The AMD display configuration is possible to be used now");
return true;
@ -1631,7 +1630,9 @@ namespace DisplayMagicianShared.AMD
{
SharedLogger.logger.Trace($"AMDLibrary/GetAllConnectedDisplayIdentifiers: Getting all the display identifiers that can possibly be used");
bool allDisplays = true;
return GetSomeDisplayIdentifiers(allDisplays);
_allConnectedDisplayIdentifiers = GetSomeDisplayIdentifiers(allDisplays);
return _allConnectedDisplayIdentifiers;
}
private List<string> GetSomeDisplayIdentifiers(bool allDisplays = false)

View File

@ -195,6 +195,7 @@ namespace DisplayMagicianShared.NVIDIA
private bool _initialised = false;
private NVIDIA_DISPLAY_CONFIG _activeDisplayConfig;
public List<NV_MONITOR_CONN_TYPE> SkippedColorConnectionTypes;
public List<string> _allConnectedDisplayIdentifiers;
// To detect redundant calls
private bool _disposed = false;
@ -233,6 +234,7 @@ namespace DisplayMagicianShared.NVIDIA
SharedLogger.logger.Trace($"NVIDIALibrary/NVIDIALibrary: NVIDIA NVAPI library was initialised successfully");
SharedLogger.logger.Trace($"NVIDIALibrary/NVIDIALibrary: Running UpdateActiveConfig to ensure there is a config to use later");
_activeDisplayConfig = GetActiveConfig();
_allConnectedDisplayIdentifiers = GetAllConnectedDisplayIdentifiers();
}
else
{
@ -1072,7 +1074,7 @@ namespace DisplayMagicianShared.NVIDIA
NVStatus = NVImport.NvAPI_Disp_ColorControl(displayIds[displayIndex].DisplayId, ref colorData);
if (NVStatus == NVAPI_STATUS.NVAPI_OK)
{
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Your monitor {displayIds[displayIndex].DisplayId} has the following color settings set. BPC = {colorData.Bpc.ToString("G")}. Color Format = {colorData.ColorFormat.ToString("G")}. Colorimetry = {colorData.Colorimetry.ToString("G")}. Color Selection Policy = {colorData.ColorSelectionPolicy.ToString("G")}. Color Depth = {colorData.Depth.ToString("G")}. Dynamic Range = {colorData.DynamicRange.ToString("G")}. NvAPI_Disp_ColorControl() returned error code {NVStatus}");
SharedLogger.logger.Trace($"NVIDIALibrary/GetNVIDIADisplayConfig: Your monitor {displayIds[displayIndex].DisplayId} has the following color settings set. BPC = {colorData.Bpc.ToString("G")}. Color Format = {colorData.ColorFormat.ToString("G")}. Colorimetry = {colorData.Colorimetry.ToString("G")}. Color Selection Policy = {colorData.ColorSelectionPolicy.ToString("G")}. Color Depth = {colorData.Depth.ToString("G")}. Dynamic Range = {colorData.DynamicRange.ToString("G")}. NvAPI_Disp_ColorControl() returned error code {NVStatus}");
myDisplay.ColorData = colorData;
myDisplay.HasColorData = true;
}
@ -2700,11 +2702,8 @@ namespace DisplayMagicianShared.NVIDIA
// We want to check the NVIDIA profile can be used now
SharedLogger.logger.Trace($"NVIDIALibrary/IsPossibleConfig: Testing whether the NVIDIA display configuration is possible to be used now");
// check what the currently available displays are (include the ones not active)
List<string> currentAllIds = GetAllConnectedDisplayIdentifiers();
// CHeck that we have all the displayConfig DisplayIdentifiers we need available now
if (displayConfig.DisplayIdentifiers.All(value => currentAllIds.Contains(value)))
if (displayConfig.DisplayIdentifiers.All(value => _allConnectedDisplayIdentifiers.Contains(value)))
//if (currentAllIds.Intersect(displayConfig.DisplayIdentifiers).Count() == displayConfig.DisplayIdentifiers.Count)
{
SharedLogger.logger.Trace($"NVIDIALibrary/IsPossibleConfig: Success! The NVIDIA display configuration is possible to be used now");
@ -2830,7 +2829,9 @@ namespace DisplayMagicianShared.NVIDIA
public List<string> GetAllConnectedDisplayIdentifiers()
{
SharedLogger.logger.Trace($"NVIDIALibrary/GetAllConnectedDisplayIdentifiers: Getting all the display identifiers that can possibly be used");
return GetSomeDisplayIdentifiers(true);
_allConnectedDisplayIdentifiers = GetSomeDisplayIdentifiers(true);
return _allConnectedDisplayIdentifiers;
}
private List<string> GetSomeDisplayIdentifiers(bool allDisplays = true)

View File

@ -114,6 +114,7 @@ namespace DisplayMagicianShared.Windows
private bool _initialised = false;
private WINDOWS_DISPLAY_CONFIG _activeDisplayConfig;
public List<DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY> SkippedColorConnectionTypes;
public List<string> _allConnectedDisplayIdentifiers;
// To detect redundant calls
private bool _disposed = false;
@ -136,6 +137,7 @@ namespace DisplayMagicianShared.Windows
SharedLogger.logger.Trace("WinLibrary/WinLibrary: Intialising Windows CCD library interface");
_initialised = true;
_activeDisplayConfig = GetActiveConfig();
_allConnectedDisplayIdentifiers = GetAllConnectedDisplayIdentifiers();
}
~WinLibrary()
@ -1670,12 +1672,9 @@ namespace DisplayMagicianShared.Windows
// We want to check the Windows Display profile can be used now
SharedLogger.logger.Trace($"WinLibrary/IsPossibleConfig: Testing whether the Windows display configuration is possible to be used now");
// check what the currently available displays are (include the ones not active)
List<string> currentAllIds = GetAllConnectedDisplayIdentifiers();
// CHeck that we have all the displayConfig DisplayIdentifiers we need available now
//if (currentAllIds.Intersect(displayConfig.DisplayIdentifiers).Count() == displayConfig.DisplayIdentifiers.Count)
if (displayConfig.DisplayIdentifiers.All(value => currentAllIds.Contains(value)))
if (displayConfig.DisplayIdentifiers.All(value => _allConnectedDisplayIdentifiers.Contains(value)))
{
SharedLogger.logger.Trace($"WinLibrary/IsPossibleConfig: Success! THe Windows display configuration is possible to be used now");
return true;
@ -1697,7 +1696,9 @@ namespace DisplayMagicianShared.Windows
public List<string> GetAllConnectedDisplayIdentifiers()
{
SharedLogger.logger.Trace($"WinLibrary/GetAllConnectedDisplayIdentifiers: Getting all the display identifiers that can possibly be used");
return GetSomeDisplayIdentifiers(QDC.QDC_ALL_PATHS | QDC.QDC_INCLUDE_HMD);
_allConnectedDisplayIdentifiers = GetSomeDisplayIdentifiers(QDC.QDC_ALL_PATHS | QDC.QDC_INCLUDE_HMD);
return _allConnectedDisplayIdentifiers;
}
private List<string> GetSomeDisplayIdentifiers(QDC selector = QDC.QDC_ONLY_ACTIVE_PATHS | QDC.QDC_INCLUDE_HMD)