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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; | 682 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; |
683 HRESULT hr = | 683 HRESULT hr = |
684 swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.GetAddressOf())); | 684 swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.GetAddressOf())); |
685 DCHECK(SUCCEEDED(hr)); | 685 DCHECK(SUCCEEDED(hr)); |
686 base::win::ScopedComPtr<ID3D11Texture2D> src_texture; | 686 base::win::ScopedComPtr<ID3D11Texture2D> src_texture; |
687 hr = swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.GetAddressOf())); | 687 hr = swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.GetAddressOf())); |
688 DCHECK(SUCCEEDED(hr)); | 688 DCHECK(SUCCEEDED(hr)); |
689 base::win::ScopedComPtr<ID3D11DeviceContext> context; | 689 base::win::ScopedComPtr<ID3D11DeviceContext> context; |
690 d3d11_device_->GetImmediateContext(context.GetAddressOf()); | 690 d3d11_device_->GetImmediateContext(context.GetAddressOf()); |
691 context->CopyResource(dest_texture.Get(), src_texture.Get()); | 691 context->CopyResource(dest_texture.Get(), src_texture.Get()); |
| 692 |
| 693 // Additionally wait for the GPU to finish executing its commands, or |
| 694 // there still may be a black flicker when presenting expensive content |
| 695 // (e.g. 4k video). |
| 696 base::win::ScopedComPtr<IDXGIDevice2> dxgi_device2; |
| 697 hr = d3d11_device_.CopyTo(dxgi_device2.GetAddressOf()); |
| 698 DCHECK(SUCCEEDED(hr)); |
| 699 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 700 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 701 dxgi_device2->EnqueueSetEvent(event.handle()); |
| 702 event.Wait(); |
692 } | 703 } |
693 | 704 |
694 swap_chain_->Present(1, 0); | 705 swap_chain_->Present(1, 0); |
695 | 706 |
696 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.SwapchainFormat", | 707 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.SwapchainFormat", |
697 is_yuy2_swapchain_); | 708 is_yuy2_swapchain_); |
698 frames_since_color_space_change_++; | 709 frames_since_color_space_change_++; |
699 | 710 |
700 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; | 711 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; |
701 if (SUCCEEDED(swap_chain_.CopyTo(swap_chain_media.GetAddressOf()))) { | 712 if (SUCCEEDED(swap_chain_.CopyTo(swap_chain_media.GetAddressOf()))) { |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1336 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
1326 return child_window_.GetTaskRunnerForTesting(); | 1337 return child_window_.GetTaskRunnerForTesting(); |
1327 } | 1338 } |
1328 | 1339 |
1329 base::win::ScopedComPtr<IDXGISwapChain1> | 1340 base::win::ScopedComPtr<IDXGISwapChain1> |
1330 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1341 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
1331 return layer_tree_->GetLayerSwapChainForTesting(index); | 1342 return layer_tree_->GetLayerSwapChainForTesting(index); |
1332 } | 1343 } |
1333 | 1344 |
1334 } // namespace gpu | 1345 } // namespace gpu |
OLD | NEW |