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 <windows.h> | 8 #include <windows.h> |
8 #include <algorithm> | 9 #include <algorithm> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
15 #include "base/file_path.h" | 16 #include "base/file_path.h" |
16 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 void AcceleratedPresenter::DoSuspend() { | 827 void AcceleratedPresenter::DoSuspend() { |
827 base::AutoLock locked(lock_); | 828 base::AutoLock locked(lock_); |
828 swap_chain_ = NULL; | 829 swap_chain_ = NULL; |
829 } | 830 } |
830 | 831 |
831 void AcceleratedPresenter::DoReleaseSurface() { | 832 void AcceleratedPresenter::DoReleaseSurface() { |
832 base::AutoLock locked(lock_); | 833 base::AutoLock locked(lock_); |
833 source_texture_.Release(); | 834 source_texture_.Release(); |
834 } | 835 } |
835 | 836 |
837 void AcceleratedPresenter::GetPresentationStats(base::TimeTicks *timebase, | |
838 uint32 *interval_n, | |
839 uint32 *interval_d) { | |
840 lock_.AssertAcquired(); | |
841 | |
842 DWM_TIMING_INFO timingInfo; | |
843 timingInfo.cbSize = sizeof(timingInfo); | |
844 HRESULT gctiResult = DwmGetCompositionTimingInfo(window_, &timingInfo); | |
845 if (gctiResult != S_OK) | |
846 return; | |
jbates
2012/07/28 01:35:30
2 space indent
| |
847 | |
848 // TODO: For scheduling purposes we can choose to synchronize to the | |
849 // vblank or composition time. If the composition time jitters, it may | |
850 // be better to rely on the vblank only. It may be even better to have | |
851 // animations depend on the vblank, but touch events and rendering to | |
852 // depend on composition time eventually. | |
853 *timebase = base::TimeTicks::FromQPCValue( | |
854 static_cast<LONGLONG>(timingInfo.qpcCompose)); | |
855 *interval_n = timingInfo.rateCompose.uiNumerator; | |
856 *interval_d = timingInfo.rateCompose.uiDenominator; | |
857 } | |
858 | |
836 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) | 859 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) |
837 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( | 860 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( |
838 window)) { | 861 window)) { |
839 } | 862 } |
840 | 863 |
841 AcceleratedSurface::~AcceleratedSurface() { | 864 AcceleratedSurface::~AcceleratedSurface() { |
842 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_); | 865 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_); |
843 presenter_->Invalidate(); | 866 presenter_->Invalidate(); |
844 } | 867 } |
845 | 868 |
846 bool AcceleratedSurface::Present(HDC dc) { | 869 bool AcceleratedSurface::Present(HDC dc) { |
847 return presenter_->Present(dc); | 870 return presenter_->Present(dc); |
848 } | 871 } |
849 | 872 |
850 bool AcceleratedSurface::CopyTo(const gfx::Size& size, void* buf) { | 873 bool AcceleratedSurface::CopyTo(const gfx::Size& size, void* buf) { |
851 return presenter_->CopyTo(size, buf); | 874 return presenter_->CopyTo(size, buf); |
852 } | 875 } |
853 | 876 |
854 void AcceleratedSurface::Suspend() { | 877 void AcceleratedSurface::Suspend() { |
855 presenter_->Suspend(); | 878 presenter_->Suspend(); |
856 } | 879 } |
857 | 880 |
858 void AcceleratedSurface::WasHidden() { | 881 void AcceleratedSurface::WasHidden() { |
859 presenter_->WasHidden(); | 882 presenter_->WasHidden(); |
860 } | 883 } |
OLD | NEW |