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 <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 return; | 405 return; |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 NOTREACHED(); | 409 NOTREACHED(); |
410 } | 410 } |
411 | 411 |
412 scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter( | 412 scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter( |
413 gfx::PluginWindowHandle window) { | 413 gfx::PluginWindowHandle window) { |
414 base::AutoLock locked(lock_); | 414 base::AutoLock locked(lock_); |
| 415 |
| 416 if (!window) { |
| 417 return presenters_.begin()->second; |
| 418 } |
| 419 |
415 PresenterMap::iterator it = presenters_.find(window); | 420 PresenterMap::iterator it = presenters_.find(window); |
416 if (it == presenters_.end()) | 421 if (it == presenters_.end()) |
417 return scoped_refptr<AcceleratedPresenter>(); | 422 return scoped_refptr<AcceleratedPresenter>(); |
418 | 423 |
419 return it->second; | 424 return it->second; |
420 } | 425 } |
421 | 426 |
422 AcceleratedPresenter::AcceleratedPresenter(gfx::PluginWindowHandle window) | 427 AcceleratedPresenter::AcceleratedPresenter(gfx::PluginWindowHandle window) |
423 : present_thread_(g_present_thread_pool.Pointer()->NextThread()), | 428 : present_thread_(g_present_thread_pool.Pointer()->NextThread()), |
424 window_(window), | 429 window_(window), |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 659 |
655 void AcceleratedPresenter::Invalidate() { | 660 void AcceleratedPresenter::Invalidate() { |
656 // Make any pending or future presentation tasks do nothing. Once the last | 661 // Make any pending or future presentation tasks do nothing. Once the last |
657 // last pending task has been ignored, the reference count on the presenter | 662 // last pending task has been ignored, the reference count on the presenter |
658 // will go to zero and the presenter, and potentially also the present thread | 663 // will go to zero and the presenter, and potentially also the present thread |
659 // it has a reference count on, will be destroyed. | 664 // it has a reference count on, will be destroyed. |
660 base::AutoLock locked(lock_); | 665 base::AutoLock locked(lock_); |
661 window_ = NULL; | 666 window_ = NULL; |
662 } | 667 } |
663 | 668 |
| 669 void AcceleratedPresenter::SetNewTargetWindow(gfx::PluginWindowHandle window) { |
| 670 window_ = window; |
| 671 } |
| 672 |
664 AcceleratedPresenter::~AcceleratedPresenter() { | 673 AcceleratedPresenter::~AcceleratedPresenter() { |
665 } | 674 } |
666 | 675 |
667 static base::TimeDelta GetSwapDelay() { | 676 static base::TimeDelta GetSwapDelay() { |
668 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 677 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
669 int delay = 0; | 678 int delay = 0; |
670 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { | 679 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { |
671 base::StringToInt(cmd_line->GetSwitchValueNative( | 680 base::StringToInt(cmd_line->GetSwitchValueNative( |
672 switches::kGpuSwapDelay).c_str(), &delay); | 681 switches::kGpuSwapDelay).c_str(), &delay); |
673 } | 682 } |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 return presenter_->CopyTo(src_subrect, dst_size, buf); | 945 return presenter_->CopyTo(src_subrect, dst_size, buf); |
937 } | 946 } |
938 | 947 |
939 void AcceleratedSurface::Suspend() { | 948 void AcceleratedSurface::Suspend() { |
940 presenter_->Suspend(); | 949 presenter_->Suspend(); |
941 } | 950 } |
942 | 951 |
943 void AcceleratedSurface::WasHidden() { | 952 void AcceleratedSurface::WasHidden() { |
944 presenter_->WasHidden(); | 953 presenter_->WasHidden(); |
945 } | 954 } |
OLD | NEW |