OLD | NEW |
---|---|
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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 child_window_(delegate, parent_window), | 984 child_window_(delegate, parent_window), |
985 workarounds_(delegate->GetFeatureInfo()->workarounds()), | 985 workarounds_(delegate->GetFeatureInfo()->workarounds()), |
986 vsync_provider_(std::move(vsync_provider)) {} | 986 vsync_provider_(std::move(vsync_provider)) {} |
987 | 987 |
988 DirectCompositionSurfaceWin::~DirectCompositionSurfaceWin() { | 988 DirectCompositionSurfaceWin::~DirectCompositionSurfaceWin() { |
989 Destroy(); | 989 Destroy(); |
990 } | 990 } |
991 | 991 |
992 // static | 992 // static |
993 bool DirectCompositionSurfaceWin::AreOverlaysSupported() { | 993 bool DirectCompositionSurfaceWin::AreOverlaysSupported() { |
994 if (!HardwareSupportsOverlays()) | 994 static bool initialized; |
995 return false; | 995 static bool overlays_supported; |
996 if (initialized) | |
997 return overlays_supported; | |
996 | 998 |
997 return base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays); | 999 initialized = true; |
1000 | |
1001 if (HardwareSupportsOverlays()) { | |
1002 overlays_supported = | |
sunnyps
2017/07/24 22:03:47
nit: overlays_supported = base::FeatureList::IsEna
| |
1003 base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays); | |
1004 } else { | |
1005 overlays_supported = false; | |
1006 } | |
1007 | |
1008 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.OverlaysSupported", | |
1009 overlays_supported); | |
1010 return overlays_supported; | |
998 } | 1011 } |
999 | 1012 |
1000 // static | 1013 // static |
1001 bool DirectCompositionSurfaceWin::IsHDRSupported() { | 1014 bool DirectCompositionSurfaceWin::IsHDRSupported() { |
1002 bool hdr_monitor_found = false; | 1015 bool hdr_monitor_found = false; |
1003 #if defined(ENABLE_HDR_DETECTION) | 1016 #if defined(ENABLE_HDR_DETECTION) |
1004 base::win::ScopedComPtr<ID3D11Device> d3d11_device = | 1017 base::win::ScopedComPtr<ID3D11Device> d3d11_device = |
1005 gl::QueryD3D11DeviceObjectFromANGLE(); | 1018 gl::QueryD3D11DeviceObjectFromANGLE(); |
1006 if (!d3d11_device) { | 1019 if (!d3d11_device) { |
1007 DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 " | 1020 DLOG(ERROR) << "Failing to detect HDR, couldn't retrieve D3D11 " |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 bool DirectCompositionSurfaceWin::OnMakeCurrent(gl::GLContext* context) { | 1184 bool DirectCompositionSurfaceWin::OnMakeCurrent(gl::GLContext* context) { |
1172 if (root_surface_) | 1185 if (root_surface_) |
1173 return root_surface_->OnMakeCurrent(context); | 1186 return root_surface_->OnMakeCurrent(context); |
1174 return true; | 1187 return true; |
1175 } | 1188 } |
1176 | 1189 |
1177 bool DirectCompositionSurfaceWin::SupportsDCLayers() const { | 1190 bool DirectCompositionSurfaceWin::SupportsDCLayers() const { |
1178 return true; | 1191 return true; |
1179 } | 1192 } |
1180 | 1193 |
1194 bool DirectCompositionSurfaceWin::UseOverlaysForVideo() const { | |
1195 return AreOverlaysSupported(); | |
1196 } | |
1197 | |
1181 bool DirectCompositionSurfaceWin::SetDrawRectangle(const gfx::Rect& rectangle) { | 1198 bool DirectCompositionSurfaceWin::SetDrawRectangle(const gfx::Rect& rectangle) { |
1182 if (root_surface_) | 1199 if (root_surface_) |
1183 return root_surface_->SetDrawRectangle(rectangle); | 1200 return root_surface_->SetDrawRectangle(rectangle); |
1184 return false; | 1201 return false; |
1185 } | 1202 } |
1186 | 1203 |
1187 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { | 1204 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { |
1188 if (root_surface_) | 1205 if (root_surface_) |
1189 return root_surface_->GetDrawOffset(); | 1206 return root_surface_->GetDrawOffset(); |
1190 return gfx::Vector2d(); | 1207 return gfx::Vector2d(); |
(...skipping 24 matching lines...) Expand all Loading... | |
1215 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1232 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
1216 return child_window_.GetTaskRunnerForTesting(); | 1233 return child_window_.GetTaskRunnerForTesting(); |
1217 } | 1234 } |
1218 | 1235 |
1219 base::win::ScopedComPtr<IDXGISwapChain1> | 1236 base::win::ScopedComPtr<IDXGISwapChain1> |
1220 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1237 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
1221 return layer_tree_->GetLayerSwapChainForTesting(index); | 1238 return layer_tree_->GetLayerSwapChainForTesting(index); |
1222 } | 1239 } |
1223 | 1240 |
1224 } // namespace gpu | 1241 } // namespace gpu |
OLD | NEW |