diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-03 02:40:32 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-03 02:40:32 +0000 |
commit | abc374f771f2d810b284c2d714a16510c63d9070 (patch) | |
tree | 4ed37d9189df90ad3abdb8b5e537c6d7a0eccce8 /ui/surface/accelerated_surface_win.cc | |
parent | 25cb8c4503a4caa3e737215c22b0a84a372f7c24 (diff) | |
download | chromium_src-abc374f771f2d810b284c2d714a16510c63d9070.zip chromium_src-abc374f771f2d810b284c2d714a16510c63d9070.tar.gz chromium_src-abc374f771f2d810b284c2d714a16510c63d9070.tar.bz2 |
Reland 174257 with fix for win_aura
win: AcceleratedPresenter replies to the GPU process as soon as shared texture is copied.
This means the GPU does not deschedule for as long waiting until it can render to the back buffer safely.
TBR=apatrick@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11642051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/surface/accelerated_surface_win.cc')
-rw-r--r-- | ui/surface/accelerated_surface_win.cc | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc index acd8c64..0fa247d7 100644 --- a/ui/surface/accelerated_surface_win.cc +++ b/ui/surface/accelerated_surface_win.cc @@ -390,11 +390,13 @@ scoped_refptr<AcceleratedPresenter> AcceleratedPresenter::GetForWindow( void AcceleratedPresenter::AsyncPresentAndAcknowledge( const gfx::Size& size, int64 surface_handle, - const CompletionTask& completion_task) { + const CopyCompletionTask& copy_completion_task, + const PresentCompletionTask& present_completion_task) { if (!surface_handle) { TRACE_EVENT1("gpu", "EarlyOut_ZeroSurfaceHandle", "surface_handle", surface_handle); - completion_task.Run(true, base::TimeTicks(), base::TimeDelta()); + copy_completion_task.Run(true); + present_completion_task.Run(base::TimeTicks(), base::TimeDelta()); return; } @@ -404,7 +406,8 @@ void AcceleratedPresenter::AsyncPresentAndAcknowledge( this, size, surface_handle, - completion_task)); + copy_completion_task, + present_completion_task)); } void AcceleratedPresenter::Present(HDC dc) { @@ -629,7 +632,8 @@ static base::TimeDelta GetSwapDelay() { void AcceleratedPresenter::DoPresentAndAcknowledge( const gfx::Size& size, int64 surface_handle, - const CompletionTask& completion_task) { + const CopyCompletionTask& copy_completion_task, + const PresentCompletionTask& present_completion_task) { TRACE_EVENT2( "gpu", "DoPresentAndAcknowledge", "width", size.width(), @@ -643,15 +647,21 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( present_thread_->InitDevice(); if (!present_thread_->device()) { - if (!completion_task.is_null()) - completion_task.Run(false, base::TimeTicks(), base::TimeDelta()); + if (!copy_completion_task.is_null()) + copy_completion_task.Run(false); + if (!present_completion_task.is_null()) + present_completion_task.Run(base::TimeTicks(), base::TimeDelta()); TRACE_EVENT0("gpu", "EarlyOut_NoDevice"); return; } // Ensure the task is always run and while the lock is taken. - base::ScopedClosureRunner scoped_completion_runner( - base::Bind(completion_task, true, base::TimeTicks(), base::TimeDelta())); + base::ScopedClosureRunner scoped_copy_completion_runner( + base::Bind(copy_completion_task, true)); + base::ScopedClosureRunner scoped_present_completion_runner( + base::Bind(present_completion_task, + base::TimeTicks(), + base::TimeDelta())); // If invalidated, do nothing, the window is gone. if (!window_) { @@ -788,6 +798,23 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( if (FAILED(hr)) return; + // Wait for the StretchRect to complete before notifying the GPU process + // that it is safe to write to its backing store again. + { + TRACE_EVENT0("gpu", "spin"); + do { + hr = present_thread_->query()->GetData(NULL, 0, D3DGETDATA_FLUSH); + + if (hr == S_FALSE) + Sleep(1); + } while (hr == S_FALSE); + } + + // Acknowledge that the copy is complete and it is safe to modify the shared + // texture. + scoped_copy_completion_runner.Release(); + copy_completion_task.Run(true); + present_size_ = size; static const base::TimeDelta swap_delay = GetSwapDelay(); @@ -853,20 +880,8 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( 1000000 / display_mode.RefreshRate); } - // Wait for the StretchRect to complete before notifying the GPU process - // that it is safe to write to its backing store again. - { - TRACE_EVENT0("gpu", "spin"); - do { - hr = present_thread_->query()->GetData(NULL, 0, D3DGETDATA_FLUSH); - - if (hr == S_FALSE) - Sleep(1); - } while (hr == S_FALSE); - } - - scoped_completion_runner.Release(); - completion_task.Run(true, last_vsync_time, refresh_period); + scoped_present_completion_runner.Release(); + present_completion_task.Run(last_vsync_time, refresh_period); } void AcceleratedPresenter::DoSuspend() { |