Chromium Code Reviews| Index: gpu/ipc/service/direct_composition_surface_win.cc |
| diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc |
| index 5fdf8fcc9fd74955eeabe30b8d1149812211a773..44b59725a4e9cf7f2b818636660c5fd444cd0d9e 100644 |
| --- a/gpu/ipc/service/direct_composition_surface_win.cc |
| +++ b/gpu/ipc/service/direct_composition_surface_win.cc |
| @@ -35,6 +35,11 @@ |
| #include "ui/gl/gl_surface_egl.h" |
| #include "ui/gl/scoped_make_current.h" |
| +#if defined(NTDDI_WIN10_RS2) |
| +#define ENABLE_HDR_DETECTION |
| +#include <dxgi1_6.h> |
| +#endif |
| + |
| #ifndef EGL_ANGLE_flexible_surface_compatibility |
| #define EGL_ANGLE_flexible_surface_compatibility 1 |
| #define EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE 0x33A6 |
| @@ -992,6 +997,47 @@ bool DirectCompositionSurfaceWin::AreOverlaysSupported() { |
| return base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays); |
| } |
| +// static |
| +bool DirectCompositionSurfaceWin::IsHDRSupported() { |
| +#if defined(ENABLE_HDR_DETECTION) |
| + base::win::ScopedComPtr<ID3D11Device> d3d11_device = |
| + gl::QueryD3D11DeviceObjectFromANGLE(); |
| + if (!d3d11_device) { |
| + DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 " |
| + << "device from ANGLE."; |
| + return false; |
| + } |
| + base::win::ScopedComPtr<IDXGIDevice> dxgi_device; |
| + d3d11_device.CopyTo(dxgi_device.GetAddressOf()); |
| + base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter; |
| + dxgi_device->GetAdapter(dxgi_adapter.GetAddressOf()); |
| + |
| + unsigned int i = 0; |
|
palmer
2017/06/26 19:16:41
The style guide says not to use unsigned as a way
hubbe
2017/06/26 19:20:42
EnumOutputs is a microsoft API, so changing it see
|
| + while (true) { |
| + base::win::ScopedComPtr<IDXGIOutput> output; |
| + if (FAILED(dxgi_adapter->EnumOutputs(i++, output.GetAddressOf()))) |
| + break; |
| + base::win::ScopedComPtr<IDXGIOutput6> output6; |
| + if (FAILED(output.CopyTo(output6.GetAddressOf()))) |
| + continue; |
| + |
| + DXGI_OUTPUT_DESC1 desc; |
| + if (FAILED(output6->GetDesc1(&desc))) |
| + continue; |
| + |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.ColorSpace", desc.ColorSpace); |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.MaxLuminance", desc.MaxLuminance); |
| + |
| + if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) { |
| + UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", true); |
| + return true; |
| + } |
| + } |
| + UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", false); |
| +#endif |
| + return false; |
| +} |
| + |
| bool DirectCompositionSurfaceWin::InitializeNativeWindow() { |
| if (window_) |
| return true; |