| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; | 582 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; |
| 583 HRESULT hr = | 583 HRESULT hr = |
| 584 swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.Receive())); | 584 swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.Receive())); |
| 585 DCHECK(SUCCEEDED(hr)); | 585 DCHECK(SUCCEEDED(hr)); |
| 586 base::win::ScopedComPtr<ID3D11Texture2D> src_texture; | 586 base::win::ScopedComPtr<ID3D11Texture2D> src_texture; |
| 587 hr = swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.Receive())); | 587 hr = swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.Receive())); |
| 588 DCHECK(SUCCEEDED(hr)); | 588 DCHECK(SUCCEEDED(hr)); |
| 589 base::win::ScopedComPtr<ID3D11DeviceContext> context; | 589 base::win::ScopedComPtr<ID3D11DeviceContext> context; |
| 590 d3d11_device_->GetImmediateContext(context.Receive()); | 590 d3d11_device_->GetImmediateContext(context.Receive()); |
| 591 context->CopyResource(dest_texture.get(), src_texture.get()); | 591 context->CopyResource(dest_texture.get(), src_texture.get()); |
| 592 |
| 593 // Additionally wait for the GPU to finish executing its commands, or |
| 594 // there still may be a black flicker when presenting expensive content |
| 595 // (e.g. 4k video). |
| 596 base::win::ScopedComPtr<IDXGIDevice2> dxgi_device2; |
| 597 hr = d3d11_device_.QueryInterface(dxgi_device2.Receive()); |
| 598 DCHECK(SUCCEEDED(hr)); |
| 599 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 600 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 601 dxgi_device2->EnqueueSetEvent(event.handle()); |
| 602 event.Wait(); |
| 592 } | 603 } |
| 593 | 604 |
| 594 swap_chain_->Present(1, 0); | 605 swap_chain_->Present(1, 0); |
| 595 | 606 |
| 596 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.SwapchainFormat", | 607 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.SwapchainFormat", |
| 597 is_yuy2_swapchain_); | 608 is_yuy2_swapchain_); |
| 598 frames_since_color_space_change_++; | 609 frames_since_color_space_change_++; |
| 599 | 610 |
| 600 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; | 611 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; |
| 601 if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { | 612 if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1231 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
| 1221 return child_window_.GetTaskRunnerForTesting(); | 1232 return child_window_.GetTaskRunnerForTesting(); |
| 1222 } | 1233 } |
| 1223 | 1234 |
| 1224 base::win::ScopedComPtr<IDXGISwapChain1> | 1235 base::win::ScopedComPtr<IDXGISwapChain1> |
| 1225 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1236 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
| 1226 return layer_tree_->GetLayerSwapChainForTesting(index); | 1237 return layer_tree_->GetLayerSwapChainForTesting(index); |
| 1227 } | 1238 } |
| 1228 | 1239 |
| 1229 } // namespace gpu | 1240 } // namespace gpu |
| OLD | NEW |