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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 private: | 102 private: |
103 std::deque<DXGI_FRAME_PRESENTATION_MODE> presents_; | 103 std::deque<DXGI_FRAME_PRESENTATION_MODE> presents_; |
104 int composed_count_ = 0; | 104 int composed_count_ = 0; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(PresentationHistory); | 106 DISALLOW_COPY_AND_ASSIGN(PresentationHistory); |
107 }; | 107 }; |
108 | 108 |
109 gfx::Size g_overlay_monitor_size; | 109 gfx::Size g_overlay_monitor_size; |
110 | 110 |
| 111 bool g_supports_scaled_overlays = true; |
| 112 |
111 // This is the raw support info, which shouldn't depend on field trial state. | 113 // This is the raw support info, which shouldn't depend on field trial state. |
112 bool HardwareSupportsOverlays() { | 114 bool HardwareSupportsOverlays() { |
113 if (!gl::GLSurfaceEGL::IsDirectCompositionSupported()) | 115 if (!gl::GLSurfaceEGL::IsDirectCompositionSupported()) |
114 return false; | 116 return false; |
115 | 117 |
116 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 118 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
117 if (command_line->HasSwitch(switches::kEnableDirectCompositionLayers)) | 119 if (command_line->HasSwitch(switches::kEnableDirectCompositionLayers)) |
118 return true; | 120 return true; |
119 if (command_line->HasSwitch(switches::kDisableDirectCompositionLayers)) | 121 if (command_line->HasSwitch(switches::kDisableDirectCompositionLayers)) |
120 return false; | 122 return false; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // scaled overlays still work. Even when scaled overlays aren't actually | 160 // scaled overlays still work. Even when scaled overlays aren't actually |
159 // supported, presentation using the overlay path should be relatively | 161 // supported, presentation using the overlay path should be relatively |
160 // efficient. | 162 // efficient. |
161 if (flags & (DXGI_OVERLAY_SUPPORT_FLAG_SCALING | | 163 if (flags & (DXGI_OVERLAY_SUPPORT_FLAG_SCALING | |
162 DXGI_OVERLAY_SUPPORT_FLAG_DIRECT)) { | 164 DXGI_OVERLAY_SUPPORT_FLAG_DIRECT)) { |
163 DXGI_OUTPUT_DESC monitor_desc = {}; | 165 DXGI_OUTPUT_DESC monitor_desc = {}; |
164 if (FAILED(output3->GetDesc(&monitor_desc))) | 166 if (FAILED(output3->GetDesc(&monitor_desc))) |
165 continue; | 167 continue; |
166 g_overlay_monitor_size = | 168 g_overlay_monitor_size = |
167 gfx::Rect(monitor_desc.DesktopCoordinates).size(); | 169 gfx::Rect(monitor_desc.DesktopCoordinates).size(); |
| 170 g_supports_scaled_overlays = |
| 171 !!(flags & DXGI_OVERLAY_SUPPORT_FLAG_SCALING); |
168 return true; | 172 return true; |
169 } | 173 } |
170 } | 174 } |
171 return false; | 175 return false; |
172 } | 176 } |
173 | 177 |
174 // Only one DirectComposition surface can be rendered into at a time. Track | 178 // Only one DirectComposition surface can be rendered into at a time. Track |
175 // here which IDCompositionSurface is being rendered into. If another context | 179 // here which IDCompositionSurface is being rendered into. If another context |
176 // is made current, then this surface will be suspended. | 180 // is made current, then this surface will be suspended. |
177 IDCompositionSurface* g_current_surface; | 181 IDCompositionSurface* g_current_surface; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 509 } |
506 | 510 |
507 // Swap chain size is the minimum of the on-screen size and the source | 511 // Swap chain size is the minimum of the on-screen size and the source |
508 // size so the video processor can do the minimal amount of work and | 512 // size so the video processor can do the minimal amount of work and |
509 // the overlay has to read the minimal amount of data. | 513 // the overlay has to read the minimal amount of data. |
510 // DWM is also less likely to promote a surface to an overlay if it's | 514 // DWM is also less likely to promote a surface to an overlay if it's |
511 // much larger than its area on-screen. | 515 // much larger than its area on-screen. |
512 gfx::Rect bounds_rect = params.rect; | 516 gfx::Rect bounds_rect = params.rect; |
513 gfx::Size ceiled_input_size = gfx::ToCeiledSize(params.contents_rect.size()); | 517 gfx::Size ceiled_input_size = gfx::ToCeiledSize(params.contents_rect.size()); |
514 gfx::Size swap_chain_size = bounds_rect.size(); | 518 gfx::Size swap_chain_size = bounds_rect.size(); |
515 swap_chain_size.SetToMin(ceiled_input_size); | 519 |
| 520 if (g_supports_scaled_overlays) |
| 521 swap_chain_size.SetToMin(ceiled_input_size); |
516 | 522 |
517 // YUY2 surfaces must have an even width. | 523 // YUY2 surfaces must have an even width. |
518 if (swap_chain_size.width() % 2 == 1) | 524 if (swap_chain_size.width() % 2 == 1) |
519 swap_chain_size.set_width(swap_chain_size.width() + 1); | 525 swap_chain_size.set_width(swap_chain_size.width() + 1); |
520 | 526 |
521 InitializeVideoProcessor(ceiled_input_size, swap_chain_size); | 527 InitializeVideoProcessor(ceiled_input_size, swap_chain_size); |
522 | 528 |
523 if (surface_->workarounds().disable_larger_than_screen_overlays) { | 529 if (surface_->workarounds().disable_larger_than_screen_overlays) { |
524 // Because of the rounding when converting between pixels and DIPs, a | 530 // Because of the rounding when converting between pixels and DIPs, a |
525 // fullscreen video can become slightly larger than the monitor - e.g. on | 531 // fullscreen video can become slightly larger than the monitor - e.g. on |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1342 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
1337 return child_window_.GetTaskRunnerForTesting(); | 1343 return child_window_.GetTaskRunnerForTesting(); |
1338 } | 1344 } |
1339 | 1345 |
1340 base::win::ScopedComPtr<IDXGISwapChain1> | 1346 base::win::ScopedComPtr<IDXGISwapChain1> |
1341 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1347 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
1342 return layer_tree_->GetLayerSwapChainForTesting(index); | 1348 return layer_tree_->GetLayerSwapChainForTesting(index); |
1343 } | 1349 } |
1344 | 1350 |
1345 } // namespace gpu | 1351 } // namespace gpu |
OLD | NEW |