Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: gpu/ipc/service/direct_composition_surface_win.cc

Issue 2938543002: Detect HDR capability (Closed)
Patch Set: histograms updated Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.h ('k') | gpu/ipc/service/gpu_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/direct_composition_surface_win.h" 5 #include "gpu/ipc/service/direct_composition_surface_win.h"
6 6
7 #include <d3d11_1.h> 7 #include <d3d11_1.h>
8 #include <dcomptypes.h> 8 #include <dcomptypes.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 17 matching lines...) Expand all
28 #include "ui/gfx/transform.h" 28 #include "ui/gfx/transform.h"
29 #include "ui/gl/dc_renderer_layer_params.h" 29 #include "ui/gl/dc_renderer_layer_params.h"
30 #include "ui/gl/egl_util.h" 30 #include "ui/gl/egl_util.h"
31 #include "ui/gl/gl_angle_util_win.h" 31 #include "ui/gl/gl_angle_util_win.h"
32 #include "ui/gl/gl_context.h" 32 #include "ui/gl/gl_context.h"
33 #include "ui/gl/gl_image_dxgi.h" 33 #include "ui/gl/gl_image_dxgi.h"
34 #include "ui/gl/gl_image_memory.h" 34 #include "ui/gl/gl_image_memory.h"
35 #include "ui/gl/gl_surface_egl.h" 35 #include "ui/gl/gl_surface_egl.h"
36 #include "ui/gl/scoped_make_current.h" 36 #include "ui/gl/scoped_make_current.h"
37 37
38 #if defined(NTDDI_WIN10_RS2)
39 #define ENABLE_HDR_DETECTION
40 #include <dxgi1_6.h>
41 #endif
42
38 #ifndef EGL_ANGLE_flexible_surface_compatibility 43 #ifndef EGL_ANGLE_flexible_surface_compatibility
39 #define EGL_ANGLE_flexible_surface_compatibility 1 44 #define EGL_ANGLE_flexible_surface_compatibility 1
40 #define EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE 0x33A6 45 #define EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE 0x33A6
41 #endif /* EGL_ANGLE_flexible_surface_compatibility */ 46 #endif /* EGL_ANGLE_flexible_surface_compatibility */
42 47
43 namespace gpu { 48 namespace gpu {
44 namespace { 49 namespace {
45 50
46 // Some drivers fail to correctly handle BT.709 video in overlays. This flag 51 // Some drivers fail to correctly handle BT.709 video in overlays. This flag
47 // converts them to BT.601 in the video processor. 52 // converts them to BT.601 in the video processor.
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } 990 }
986 991
987 // static 992 // static
988 bool DirectCompositionSurfaceWin::AreOverlaysSupported() { 993 bool DirectCompositionSurfaceWin::AreOverlaysSupported() {
989 if (!HardwareSupportsOverlays()) 994 if (!HardwareSupportsOverlays())
990 return false; 995 return false;
991 996
992 return base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays); 997 return base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays);
993 } 998 }
994 999
1000 // static
1001 bool DirectCompositionSurfaceWin::IsHDRSupported() {
1002 bool hdr_monitor_found = true;
1003 #if defined(ENABLE_HDR_DETECTION)
1004 base::win::ScopedComPtr<ID3D11Device> d3d11_device =
1005 gl::QueryD3D11DeviceObjectFromANGLE();
1006 if (!d3d11_device) {
1007 DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 "
1008 << "device from ANGLE.";
1009 return false;
1010 }
1011 base::win::ScopedComPtr<IDXGIDevice> dxgi_device;
1012 d3d11_device.CopyTo(dxgi_device.GetAddressOf());
1013 base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter;
1014 dxgi_device->GetAdapter(dxgi_adapter.GetAddressOf());
1015
1016 unsigned int i = 0;
1017 while (true) {
1018 base::win::ScopedComPtr<IDXGIOutput> output;
1019 if (FAILED(dxgi_adapter->EnumOutputs(i++, output.GetAddressOf())))
1020 break;
1021 base::win::ScopedComPtr<IDXGIOutput6> output6;
1022 if (FAILED(output.CopyTo(output6.GetAddressOf())))
1023 continue;
1024
1025 DXGI_OUTPUT_DESC1 desc;
1026 if (FAILED(output6->GetDesc1(&desc)))
1027 continue;
1028
1029 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.ColorSpace", desc.ColorSpace);
1030 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.MaxLuminance", desc.MaxLuminance);
1031
1032 if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) {
1033 hdr_monitor_found = true;
1034 return true;
1035 }
1036 }
1037 UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", hdr_monitor_found);
1038 return hdr_monitor_found;
1039 #else
1040 return false;
1041 #endif
1042 }
1043
995 bool DirectCompositionSurfaceWin::InitializeNativeWindow() { 1044 bool DirectCompositionSurfaceWin::InitializeNativeWindow() {
996 if (window_) 1045 if (window_)
997 return true; 1046 return true;
998 1047
999 bool result = child_window_.Initialize(); 1048 bool result = child_window_.Initialize();
1000 window_ = child_window_.window(); 1049 window_ = child_window_.window();
1001 return result; 1050 return result;
1002 } 1051 }
1003 1052
1004 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) { 1053 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { 1218 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() {
1170 return child_window_.GetTaskRunnerForTesting(); 1219 return child_window_.GetTaskRunnerForTesting();
1171 } 1220 }
1172 1221
1173 base::win::ScopedComPtr<IDXGISwapChain1> 1222 base::win::ScopedComPtr<IDXGISwapChain1>
1174 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { 1223 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const {
1175 return layer_tree_->GetLayerSwapChainForTesting(index); 1224 return layer_tree_->GetLayerSwapChainForTesting(index);
1176 } 1225 }
1177 1226
1178 } // namespace gpu 1227 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.h ('k') | gpu/ipc/service/gpu_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698