Chromium Code Reviews| 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 "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 video_processor_.get(), 0, FALSE); | 406 video_processor_.get(), 0, FALSE); |
| 407 | 407 |
| 408 hr = video_context_->VideoProcessorBlt(video_processor_.get(), | 408 hr = video_context_->VideoProcessorBlt(video_processor_.get(), |
| 409 out_view_.get(), 0, 1, &stream); | 409 out_view_.get(), 0, 1, &stream); |
| 410 CHECK(SUCCEEDED(hr)); | 410 CHECK(SUCCEEDED(hr)); |
| 411 } | 411 } |
| 412 | 412 |
| 413 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width(); | 413 swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width(); |
| 414 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height(); | 414 swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height(); |
| 415 | 415 |
| 416 swap_chain_->Present(first_present ? 0 : 1, 0); | 416 if (first_present) { |
| 417 swap_chain_->Present(0, 0); | |
| 418 | |
| 419 // DirectComposition can display black for a swapchain between the first | |
| 420 // and second time it's presented to - maybe the first Present can get | |
| 421 // lost somehow and it shows the wrong buffer.In that case copy the | |
|
sunnyps
2017/04/13 21:03:13
nit: space after period
| |
| 422 // buffers so both have the correct contents, which seems to help. The | |
| 423 // first Present() after this needs to have SyncInterval > 0, or else the | |
| 424 // workaround doesn't help. | |
| 425 base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; | |
| 426 swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.Receive())); | |
|
sunnyps
2017/04/13 21:03:12
nit: CHECK if these calls succeeded?
| |
| 427 base::win::ScopedComPtr<ID3D11Texture2D> src_texture; | |
| 428 swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.Receive())); | |
| 429 base::win::ScopedComPtr<ID3D11DeviceContext> context; | |
| 430 d3d11_device_->GetImmediateContext(context.Receive()); | |
| 431 context->CopyResource(dest_texture.get(), src_texture.get()); | |
| 432 } | |
| 433 | |
| 434 swap_chain_->Present(1, 0); | |
| 417 | 435 |
| 418 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; | 436 base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; |
| 419 if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { | 437 if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { |
| 420 DXGI_FRAME_STATISTICS_MEDIA stats = {}; | 438 DXGI_FRAME_STATISTICS_MEDIA stats = {}; |
| 421 if (SUCCEEDED(swap_chain_media->GetFrameStatisticsMedia(&stats))) { | 439 if (SUCCEEDED(swap_chain_media->GetFrameStatisticsMedia(&stats))) { |
| 422 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.DirectComposition.CompositionMode", | 440 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.DirectComposition.CompositionMode", |
| 423 stats.CompositionMode); | 441 stats.CompositionMode); |
| 424 } | 442 } |
| 425 } | 443 } |
| 426 } | 444 } |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 1079 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
| 1062 return child_window_.GetTaskRunnerForTesting(); | 1080 return child_window_.GetTaskRunnerForTesting(); |
| 1063 } | 1081 } |
| 1064 | 1082 |
| 1065 base::win::ScopedComPtr<IDXGISwapChain1> | 1083 base::win::ScopedComPtr<IDXGISwapChain1> |
| 1066 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { | 1084 DirectCompositionSurfaceWin::GetLayerSwapChainForTesting(size_t index) const { |
| 1067 return layer_tree_->GetLayerSwapChainForTesting(index); | 1085 return layer_tree_->GetLayerSwapChainForTesting(index); |
| 1068 } | 1086 } |
| 1069 | 1087 |
| 1070 } // namespace gpu | 1088 } // namespace gpu |
| OLD | NEW |