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

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

Issue 2938543002: Detect HDR capability (Closed)
Patch Set: moved to dc surface Created 3 years, 6 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
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 #if defined(ENABLE_HDR_DETECTION)
1003 base::win::ScopedComPtr<ID3D11Device> d3d11_device =
1004 gl::QueryD3D11DeviceObjectFromANGLE();
1005 if (!d3d11_device) {
1006 DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 "
1007 << "device from ANGLE.";
1008 return false;
1009 }
1010 base::win::ScopedComPtr<IDXGIDevice> dxgi_device;
1011 d3d11_device.CopyTo(dxgi_device.GetAddressOf());
1012 base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter;
1013 dxgi_device->GetAdapter(dxgi_adapter.GetAddressOf());
1014
1015 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
1016 while (true) {
1017 base::win::ScopedComPtr<IDXGIOutput> output;
1018 if (FAILED(dxgi_adapter->EnumOutputs(i++, output.GetAddressOf())))
1019 break;
1020 base::win::ScopedComPtr<IDXGIOutput6> output6;
1021 if (FAILED(output.CopyTo(output6.GetAddressOf())))
1022 continue;
1023
1024 DXGI_OUTPUT_DESC1 desc;
1025 if (FAILED(output6->GetDesc1(&desc)))
1026 continue;
1027
1028 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.ColorSpace", desc.ColorSpace);
1029 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.Output.MaxLuminance", desc.MaxLuminance);
1030
1031 if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) {
1032 UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", true);
1033 return true;
1034 }
1035 }
1036 UMA_HISTOGRAM_BOOLEAN("GPU.Output.HDR", false);
1037 #endif
1038 return false;
1039 }
1040
995 bool DirectCompositionSurfaceWin::InitializeNativeWindow() { 1041 bool DirectCompositionSurfaceWin::InitializeNativeWindow() {
996 if (window_) 1042 if (window_)
997 return true; 1043 return true;
998 1044
999 bool result = child_window_.Initialize(); 1045 bool result = child_window_.Initialize();
1000 window_ = child_window_.window(); 1046 window_ = child_window_.window();
1001 return result; 1047 return result;
1002 } 1048 }
1003 1049
1004 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) { 1050 bool DirectCompositionSurfaceWin::Initialize(gl::GLSurfaceFormat format) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { 1215 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() {
1170 return child_window_.GetTaskRunnerForTesting(); 1216 return child_window_.GetTaskRunnerForTesting();
1171 } 1217 }
1172 1218
1173 base::win::ScopedComPtr<IDXGISwapChain1> 1219 base::win::ScopedComPtr<IDXGISwapChain1>
1174 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { 1220 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const {
1175 return layer_tree_->GetLayerSwapChainForTesting(index); 1221 return layer_tree_->GetLayerSwapChainForTesting(index);
1176 } 1222 }
1177 1223
1178 } // namespace gpu 1224 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698