Repository: xbmc/xbmc
File: xbmc/platform/win32/WIN32Util.cpp (C++)

Code before:
  }

  if (!advancedColorSupported)
  {
    status = HDR_STATUS::HDR_UNSUPPORTED;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is not HDR capable or cannot be detected");
  }
  else
  {
    status = advancedColorEnabled ? HDR_STATUS::HDR_ON : HDR_STATUS::HDR_OFF;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is HDR capable and current HDR status is {}",
                 advancedColorEnabled ? "ON" : "OFF");
  }

  return status;
}
#endif // TARGET_WINDOWS_DESKTOP

HDR_STATUS CWIN32Util::GetWindowsHDRStatus()
{
  HDR_STATUS status = HDR_STATUS::HDR_UNKNOWN;

#ifdef TARGET_WINDOWS_STORE

  if (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::Xbox &&
      HDR_STATUS::HDR_UNKNOWN != (status = CWinRtUtil::GetWindowsHDRStatus()))
    return status;

  // detection failure: fallback to traditional UWP method
  status = CWinRtUtil::GetWindowsHDRStatusUWP();
  return status == HDR_STATUS::HDR_UNKNOWN ? HDR_STATUS::HDR_UNSUPPORTED : status;

#else
  // WinRT detection available for Win 11 22621 and up.
  if (CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionWin11_22H2) &&
      HDR_STATUS::HDR_UNKNOWN != (status = CWinRtUtil::GetWindowsHDRStatus()))
  {
    return status;
  }

  // Not Win11 or detection failure: fallback to traditional Win32 method
  return GetWindowsHDRStatusWin32();

#endif
}

/*!
 * \brief Retrieve from the system the max luminance of SDR content in HDR.
 *

Review comment (suggestion):
It's only a personal preference but since Visual Studio editor grey out not used code path (desktop/UWP) I prefer no extra blank lines inside `#ifdef` code blocks.

i.e. this instead of current:

![after](https://github.com/xbmc/xbmc/assets/58434170/bf5f7cd8-982a-467a-bc97-fc4cf7db3015)
 
here and similar others

Code after:
  }

  if (!advancedColorSupported)
  {
    status = HDR_STATUS::HDR_UNSUPPORTED;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is not HDR capable or cannot be detected");
  }
  else
  {
    status = advancedColorEnabled ? HDR_STATUS::HDR_ON : HDR_STATUS::HDR_OFF;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is HDR capable and current HDR status is {}",
                 advancedColorEnabled ? "ON" : "OFF");
  }
#endif // TARGET_WINDOWS_DESKTOP

  return status;
}

HDR_STATUS CWIN32Util::GetWindowsHDRStatus()
{
  HDR_STATUS status = HDR_STATUS::HDR_UNKNOWN;

#ifdef TARGET_WINDOWS_STORE
  if (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::Xbox &&
      HDR_STATUS::HDR_UNKNOWN != (status = CWinRtUtil::GetWindowsHDRStatus()))
    return status;

  // Not Xbox or detection failure: fallback to traditional UWP method
  status = CWinRtUtil::GetWindowsHDRStatusUWP();
  return status == HDR_STATUS::HDR_UNKNOWN ? HDR_STATUS::HDR_UNSUPPORTED : status;
#else
  // WinRT detection available for Win 11 22621 and above.
  if (CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionWin11_22H2) &&
      HDR_STATUS::HDR_UNKNOWN != (status = CWinRtUtil::GetWindowsHDRStatus()))
    return status;

  // Not Win11 or detection failure: fallback to traditional Win32 method
  status = GetWindowsHDRStatusWin32();
  return status == HDR_STATUS::HDR_UNKNOWN ? HDR_STATUS::HDR_UNSUPPORTED : status;
#endif
}

/*!
 * \brief Retrieve from the system the max luminance of SDR content in HDR.
 *
 * Retrieve from the system the max luminance of SDR content in HDR.
 * Note: always returns 80 nits when the screen is in SDR mode.
 *
 * \param gdiDeviceName The screen to retrieve the information for