OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/surface/accelerated_surface_win.h" | 5 #include "ui/surface/accelerated_surface_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 // static | 371 // static |
372 scoped_refptr<AcceleratedPresenter> AcceleratedPresenter::GetForWindow( | 372 scoped_refptr<AcceleratedPresenter> AcceleratedPresenter::GetForWindow( |
373 gfx::PluginWindowHandle window) { | 373 gfx::PluginWindowHandle window) { |
374 return g_accelerated_presenter_map.Pointer()->GetPresenter(window); | 374 return g_accelerated_presenter_map.Pointer()->GetPresenter(window); |
375 } | 375 } |
376 | 376 |
377 void AcceleratedPresenter::AsyncPresentAndAcknowledge( | 377 void AcceleratedPresenter::AsyncPresentAndAcknowledge( |
378 const gfx::Size& size, | 378 const gfx::Size& size, |
379 int64 surface_handle, | 379 int64 surface_handle, |
380 const ui::LatencyInfo& latency_info, | 380 const std::vector<ui::LatencyInfo>& latency_info, |
381 const CompletionTask& completion_task) { | 381 const CompletionTask& completion_task) { |
382 if (!surface_handle) { | 382 if (!surface_handle) { |
383 TRACE_EVENT1("gpu", "EarlyOut_ZeroSurfaceHandle", | 383 TRACE_EVENT1("gpu", "EarlyOut_ZeroSurfaceHandle", |
384 "surface_handle", surface_handle); | 384 "surface_handle", surface_handle); |
385 completion_task.Run( | 385 completion_task.Run(true, base::TimeTicks(), base::TimeDelta(), |
386 true, base::TimeTicks(), base::TimeDelta(), ui::LatencyInfo()); | 386 std::vector<ui::LatencyInfo>()); |
387 return; | 387 return; |
388 } | 388 } |
389 | 389 |
390 present_thread_->message_loop()->PostTask( | 390 present_thread_->message_loop()->PostTask( |
391 FROM_HERE, | 391 FROM_HERE, |
392 base::Bind(&AcceleratedPresenter::DoPresentAndAcknowledge, | 392 base::Bind(&AcceleratedPresenter::DoPresentAndAcknowledge, |
393 this, | 393 this, |
394 size, | 394 size, |
395 surface_handle, | 395 surface_handle, |
396 latency_info, | 396 latency_info, |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 672 |
673 bool AcceleratedPresenter::IsSwapChainInitialized() const { | 673 bool AcceleratedPresenter::IsSwapChainInitialized() const { |
674 base::AutoLock locked(*present_thread_->lock()); | 674 base::AutoLock locked(*present_thread_->lock()); |
675 | 675 |
676 return !!swap_chain_; | 676 return !!swap_chain_; |
677 } | 677 } |
678 | 678 |
679 void AcceleratedPresenter::DoPresentAndAcknowledge( | 679 void AcceleratedPresenter::DoPresentAndAcknowledge( |
680 const gfx::Size& size, | 680 const gfx::Size& size, |
681 int64 surface_handle, | 681 int64 surface_handle, |
682 const ui::LatencyInfo& latency_info, | 682 const std::vector<ui::LatencyInfo>& latency_info, |
683 const CompletionTask& completion_task) { | 683 const CompletionTask& completion_task) { |
684 TRACE_EVENT2( | 684 TRACE_EVENT2( |
685 "gpu", "DoPresentAndAcknowledge", | 685 "gpu", "DoPresentAndAcknowledge", |
686 "width", size.width(), | 686 "width", size.width(), |
687 "height", size.height()); | 687 "height", size.height()); |
688 | 688 |
689 HRESULT hr; | 689 HRESULT hr; |
690 | 690 |
691 base::AutoLock locked(*present_thread_->lock()); | 691 base::AutoLock locked(*present_thread_->lock()); |
692 | 692 |
693 latency_info_.MergeWith(latency_info); | 693 for (size_t i = 0; i < latency_info.size(); i++) |
| 694 latency_info_.push_back(latency_info[i]); |
694 | 695 |
695 // Initialize the device lazily since calling Direct3D can crash bots. | 696 // Initialize the device lazily since calling Direct3D can crash bots. |
696 present_thread_->InitDevice(); | 697 present_thread_->InitDevice(); |
697 | 698 |
698 if (!present_thread_->device()) { | 699 if (!present_thread_->device()) { |
699 completion_task.Run( | 700 completion_task.Run(false, base::TimeTicks(), base::TimeDelta(), |
700 false, base::TimeTicks(), base::TimeDelta(), ui::LatencyInfo()); | 701 std::vector<ui::LatencyInfo>()); |
701 TRACE_EVENT0("gpu", "EarlyOut_NoDevice"); | 702 TRACE_EVENT0("gpu", "EarlyOut_NoDevice"); |
702 return; | 703 return; |
703 } | 704 } |
704 | 705 |
705 // Ensure the task is acknowledged on early out after this point. | 706 // Ensure the task is acknowledged on early out after this point. |
706 base::ScopedClosureRunner scoped_completion_runner( | 707 base::ScopedClosureRunner scoped_completion_runner( |
707 base::Bind(completion_task, | 708 base::Bind(completion_task, |
708 true, | 709 true, |
709 base::TimeTicks(), | 710 base::TimeTicks(), |
710 base::TimeDelta(), | 711 base::TimeDelta(), |
711 ui::LatencyInfo())); | 712 std::vector<ui::LatencyInfo>())); |
712 | 713 |
713 // If invalidated, do nothing, the window is gone. | 714 // If invalidated, do nothing, the window is gone. |
714 if (!window_) { | 715 if (!window_) { |
715 TRACE_EVENT0("gpu", "EarlyOut_NoWindow"); | 716 TRACE_EVENT0("gpu", "EarlyOut_NoWindow"); |
716 return; | 717 return; |
717 } | 718 } |
718 | 719 |
719 #if !defined(USE_AURA) | 720 #if !defined(USE_AURA) |
720 // If the window is a different size than the swap chain that is being | 721 // If the window is a different size than the swap chain that is being |
721 // presented then drop the frame. | 722 // presented then drop the frame. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 if (present_thread_->IsDeviceLost()) | 841 if (present_thread_->IsDeviceLost()) |
841 present_thread_->ResetDevice(); | 842 present_thread_->ResetDevice(); |
842 return; | 843 return; |
843 } | 844 } |
844 } else { | 845 } else { |
845 HDC dc = GetDC(window_); | 846 HDC dc = GetDC(window_); |
846 PresentWithGDI(dc); | 847 PresentWithGDI(dc); |
847 ReleaseDC(window_, dc); | 848 ReleaseDC(window_, dc); |
848 } | 849 } |
849 | 850 |
850 latency_info_.AddLatencyNumber( | 851 for (size_t i = 0; i < latency_info_.size(); i++) { |
851 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 852 latency_info_[i].AddLatencyNumber( |
| 853 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); |
| 854 } |
852 | 855 |
853 hidden_ = false; | 856 hidden_ = false; |
854 | 857 |
855 D3DDISPLAYMODE display_mode; | 858 D3DDISPLAYMODE display_mode; |
856 hr = present_thread_->device()->GetDisplayMode(0, &display_mode); | 859 hr = present_thread_->device()->GetDisplayMode(0, &display_mode); |
857 if (FAILED(hr)) { | 860 if (FAILED(hr)) { |
858 LOG(ERROR) << "Failed to get display mode"; | 861 LOG(ERROR) << "Failed to get display mode"; |
859 return; | 862 return; |
860 } | 863 } |
861 | 864 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 if (present_thread_->IsDeviceLost()) { | 912 if (present_thread_->IsDeviceLost()) { |
910 present_thread_->ResetDevice(); | 913 present_thread_->ResetDevice(); |
911 return; | 914 return; |
912 } | 915 } |
913 } | 916 } |
914 } while (hr == S_FALSE); | 917 } while (hr == S_FALSE); |
915 } | 918 } |
916 | 919 |
917 scoped_completion_runner.Release(); | 920 scoped_completion_runner.Release(); |
918 completion_task.Run(true, last_vsync_time, refresh_period, latency_info_); | 921 completion_task.Run(true, last_vsync_time, refresh_period, latency_info_); |
919 latency_info_.Clear(); | 922 latency_info_.clear(); |
920 } | 923 } |
921 | 924 |
922 void AcceleratedPresenter::DoSuspend() { | 925 void AcceleratedPresenter::DoSuspend() { |
923 base::AutoLock locked(*present_thread_->lock()); | 926 base::AutoLock locked(*present_thread_->lock()); |
924 swap_chain_ = NULL; | 927 swap_chain_ = NULL; |
925 } | 928 } |
926 | 929 |
927 void AcceleratedPresenter::DoReleaseSurface() { | 930 void AcceleratedPresenter::DoReleaseSurface() { |
928 base::AutoLock locked(*present_thread_->lock()); | 931 base::AutoLock locked(*present_thread_->lock()); |
929 present_thread_->InitDevice(); | 932 present_thread_->InitDevice(); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 presenter_->Suspend(); | 1102 presenter_->Suspend(); |
1100 } | 1103 } |
1101 | 1104 |
1102 void AcceleratedSurface::WasHidden() { | 1105 void AcceleratedSurface::WasHidden() { |
1103 presenter_->WasHidden(); | 1106 presenter_->WasHidden(); |
1104 } | 1107 } |
1105 | 1108 |
1106 void AcceleratedSurface::SetIsSessionLocked(bool locked) { | 1109 void AcceleratedSurface::SetIsSessionLocked(bool locked) { |
1107 presenter_->SetIsSessionLocked(locked); | 1110 presenter_->SetIsSessionLocked(locked); |
1108 } | 1111 } |
OLD | NEW |