OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/ipc/service/child_window_surface_win.h" | 5 #include "gpu/ipc/service/child_window_surface_win.h" |
6 | 6 |
| 7 #include <d3d11_1.h> |
7 #include <memory> | 8 #include <memory> |
8 | 9 |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/win/scoped_comptr.h" |
11 #include "gpu/ipc/common/gpu_messages.h" | 14 #include "gpu/ipc/common/gpu_messages.h" |
12 #include "gpu/ipc/service/gpu_channel_manager.h" | 15 #include "gpu/ipc/service/gpu_channel_manager.h" |
13 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 16 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
14 #include "ui/display/display_switches.h" | 17 #include "ui/display/display_switches.h" |
15 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
16 #include "ui/gl/egl_util.h" | 19 #include "ui/gl/egl_util.h" |
| 20 #include "ui/gl/gl_angle_util_win.h" |
17 #include "ui/gl/gl_context.h" | 21 #include "ui/gl/gl_context.h" |
18 #include "ui/gl/gl_surface_egl.h" | 22 #include "ui/gl/gl_surface_egl.h" |
19 #include "ui/gl/scoped_make_current.h" | 23 #include "ui/gl/scoped_make_current.h" |
20 | 24 |
| 25 #if defined(NTDDI_WIN10_RS2) |
| 26 #define ENABLE_HDR_DETECTION |
| 27 #include <dxgi1_6.h> |
| 28 #endif |
| 29 |
21 namespace gpu { | 30 namespace gpu { |
22 | 31 |
23 ChildWindowSurfaceWin::ChildWindowSurfaceWin( | 32 ChildWindowSurfaceWin::ChildWindowSurfaceWin( |
24 std::unique_ptr<gfx::VSyncProvider> vsync_provider, | 33 std::unique_ptr<gfx::VSyncProvider> vsync_provider, |
25 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 34 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
26 HWND parent_window) | 35 HWND parent_window) |
27 : gl::NativeViewGLSurfaceEGL(0, std::move(vsync_provider)), | 36 : gl::NativeViewGLSurfaceEGL(0, std::move(vsync_provider)), |
28 child_window_(delegate, parent_window), | 37 child_window_(delegate, parent_window), |
29 alpha_(true), | 38 alpha_(true), |
30 first_swap_(true) { | 39 first_swap_(true) { |
31 // Don't use EGL_ANGLE_window_fixed_size so that we can avoid recreating the | 40 // Don't use EGL_ANGLE_window_fixed_size so that we can avoid recreating the |
32 // window surface, which can cause flicker on DirectComposition. | 41 // window surface, which can cause flicker on DirectComposition. |
33 enable_fixed_size_angle_ = false; | 42 enable_fixed_size_angle_ = false; |
34 } | 43 } |
35 | 44 |
| 45 bool ChildWindowSurfaceWin::IsHDRSupported() { |
| 46 #if defined(ENABLE_HDR_DETECTION) |
| 47 base::win::ScopedComPtr<ID3D11Device> d3d11_device = |
| 48 gl::QueryD3D11DeviceObjectFromANGLE(); |
| 49 if (!d3d11_device) { |
| 50 DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 " |
| 51 << "device from ANGLE."; |
| 52 return false; |
| 53 } |
| 54 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; |
| 55 d3d11_device.CopyTo(dxgi_device.GetAddressOf()); |
| 56 base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter; |
| 57 dxgi_device->GetAdapter(dxgi_adapter.GetAddressOf()); |
| 58 |
| 59 unsigned int i = 0; |
| 60 while (true) { |
| 61 base::win::ScopedComPtr<IDXGIOutput> output; |
| 62 if (FAILED(dxgi_adapter->EnumOutputs(i++, output.GetAddressOf()))) |
| 63 break; |
| 64 base::win::ScopedComPtr<IDXGIOutput6> output6; |
| 65 if (FAILED(output.CopyTo(output6.GetAddressOf()))) |
| 66 continue; |
| 67 |
| 68 DXGI_OUTPUT_DESC1 desc; |
| 69 if (FAILED(output6->GetDesc1(&desc))) |
| 70 continue; |
| 71 |
| 72 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.ColorSpace", desc.ColorSpace); |
| 73 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.MaxLuminance", desc.MaxLuminance); |
| 74 |
| 75 if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) { |
| 76 UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", true); |
| 77 return true; |
| 78 } |
| 79 } |
| 80 UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", false); |
| 81 #endif |
| 82 return false; |
| 83 } |
| 84 |
36 EGLConfig ChildWindowSurfaceWin::GetConfig() { | 85 EGLConfig ChildWindowSurfaceWin::GetConfig() { |
37 if (!config_) { | 86 if (!config_) { |
38 int alpha_size = alpha_ ? 8 : EGL_DONT_CARE; | 87 int alpha_size = alpha_ ? 8 : EGL_DONT_CARE; |
39 int bits_per_channel = | 88 int bits_per_channel = |
40 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) | 89 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) |
41 ? 16 | 90 ? 16 |
42 : 8; | 91 : 8; |
43 | 92 |
44 EGLint config_attribs[] = {EGL_ALPHA_SIZE, | 93 EGLint config_attribs[] = {EGL_ALPHA_SIZE, |
45 alpha_size, | 94 alpha_size, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 216 |
168 void ChildWindowSurfaceWin::WaitForSnapshotRendering() { | 217 void ChildWindowSurfaceWin::WaitForSnapshotRendering() { |
169 DCHECK(gl::GLContext::GetCurrent()->IsCurrent(this)); | 218 DCHECK(gl::GLContext::GetCurrent()->IsCurrent(this)); |
170 glFinish(); | 219 glFinish(); |
171 } | 220 } |
172 | 221 |
173 ChildWindowSurfaceWin::~ChildWindowSurfaceWin() { | 222 ChildWindowSurfaceWin::~ChildWindowSurfaceWin() { |
174 } | 223 } |
175 | 224 |
176 } // namespace gpu | 225 } // namespace gpu |
OLD | NEW |