Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: gpu/ipc/service/direct_composition_surface_win.cc

Issue 2813103004: Do additional blit and Present on first draw to overlay. (Closed)
Patch Set: improve Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/ipc/service/direct_composition_surface_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..73b00e6dfd2aed2e71bfa4da52bd7567cef158ff 100644
--- a/gpu/ipc/service/direct_composition_surface_win.cc
+++ b/gpu/ipc/service/direct_composition_surface_win.cc
@@ -413,7 +413,28 @@ 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
+ // 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;
+ HRESULT hr =
+ swap_chain_->GetBuffer(0, IID_PPV_ARGS(dest_texture.Receive()));
+ DCHECK(SUCCEEDED(hr));
+ base::win::ScopedComPtr<ID3D11Texture2D> src_texture;
+ hr = swap_chain_->GetBuffer(1, IID_PPV_ARGS(src_texture.Receive()));
+ DCHECK(SUCCEEDED(hr));
+ 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()))) {
« no previous file with comments | « no previous file | gpu/ipc/service/direct_composition_surface_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698