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

Side by Side Diff: ui/surface/accelerated_surface_win.cc

Issue 10825053: Use DwmGetCompositionTimingInfo to get vsync info on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix whitespace Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_numerator,
839 uint32 *interval_denominator) {
840 lock_.AssertAcquired();
841
842 DWM_TIMING_INFO timingInfo;
apatrick_chromium 2012/07/30 19:43:31 timing_info
843 timingInfo.cbSize = sizeof(timingInfo);
844 HRESULT gctiResult = DwmGetCompositionTimingInfo(window_, &timingInfo);
apatrick_chromium 2012/07/30 19:43:31 I'd just call this result. otherwise gcti_result.
brianderson 2012/07/30 20:16:39 Artifact of previous code that had multiple result
845 if (gctiResult != S_OK)
846 return;
847
848 *timebase = base::TimeTicks::FromQPCValue(
849 static_cast<LONGLONG>(timingInfo.qpcVBlank));
850 // Swap the numerator/denominator to convert frequency to period.
851 *interval_numerator = timingInfo.rateRefresh.uiDenominator;
852 *interval_denominator = timingInfo.rateRefresh.uiNumerator;
853 }
854
836 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) 855 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window)
837 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( 856 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter(
838 window)) { 857 window)) {
839 } 858 }
840 859
841 AcceleratedSurface::~AcceleratedSurface() { 860 AcceleratedSurface::~AcceleratedSurface() {
842 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_); 861 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_);
843 presenter_->Invalidate(); 862 presenter_->Invalidate();
844 } 863 }
845 864
846 bool AcceleratedSurface::Present(HDC dc) { 865 bool AcceleratedSurface::Present(HDC dc) {
847 return presenter_->Present(dc); 866 return presenter_->Present(dc);
848 } 867 }
849 868
850 bool AcceleratedSurface::CopyTo(const gfx::Size& size, void* buf) { 869 bool AcceleratedSurface::CopyTo(const gfx::Size& size, void* buf) {
851 return presenter_->CopyTo(size, buf); 870 return presenter_->CopyTo(size, buf);
852 } 871 }
853 872
854 void AcceleratedSurface::Suspend() { 873 void AcceleratedSurface::Suspend() {
855 presenter_->Suspend(); 874 presenter_->Suspend();
856 } 875 }
857 876
858 void AcceleratedSurface::WasHidden() { 877 void AcceleratedSurface::WasHidden() {
859 presenter_->WasHidden(); 878 presenter_->WasHidden();
860 } 879 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698