Chromium Code Reviews| Index: gpu/ipc/service/direct_composition_surface_win.cc |
| diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc |
| index ac184e96e62625f2d9ebf3fb886cc2998e6d0867..e047d7650f34c0dbd82c9dcff32d7f242e8b0968 100644 |
| --- a/gpu/ipc/service/direct_composition_surface_win.cc |
| +++ b/gpu/ipc/service/direct_composition_surface_win.cc |
| @@ -413,7 +413,25 @@ void DCLayerTree::SwapChainPresenter::PresentToSwapChain( |
| swap_chain_scale_x_ = bounds_rect.width() * 1.0f / swap_chain_size.width(); |
| swap_chain_scale_y_ = bounds_rect.height() * 1.0f / swap_chain_size.height(); |
| - swap_chain_->Present(first_present ? 0 : 1, 0); |
| + if (first_present) { |
| + swap_chain_->Present(0, 0); |
| + |
| + // DirectComposition can display black for a swapchain between the first |
| + // and second time it's presented to - maybe the first Present can get |
| + // lost somehow and it shows the wrong buffer.In that case copy the |
|
sunnyps
2017/04/13 21:03:13
nit: space after period
|
| + // buffers so both have the correct contents, which seems to help. The |
| + // first Present() after this needs to have SyncInterval > 0, or else the |
| + // workaround doesn't help. |
| + base::win::ScopedComPtr<ID3D11Texture2D> dest_texture; |
| + swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.Receive())); |
|
sunnyps
2017/04/13 21:03:12
nit: CHECK if these calls succeeded?
|
| + base::win::ScopedComPtr<ID3D11Texture2D> src_texture; |
| + swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.Receive())); |
| + base::win::ScopedComPtr<ID3D11DeviceContext> context; |
| + d3d11_device_->GetImmediateContext(context.Receive()); |
| + context->CopyResource(dest_texture.get(), src_texture.get()); |
| + } |
| + |
| + swap_chain_->Present(1, 0); |
| base::win::ScopedComPtr<IDXGISwapChainMedia> swap_chain_media; |
| if (SUCCEEDED(swap_chain_.QueryInterface(swap_chain_media.Receive()))) { |