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

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: Elaborate comments and fix pointer formatting 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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 void AcceleratedPresenter::DoSuspend() { 837 void AcceleratedPresenter::DoSuspend() {
837 base::AutoLock locked(lock_); 838 base::AutoLock locked(lock_);
838 swap_chain_ = NULL; 839 swap_chain_ = NULL;
839 } 840 }
840 841
841 void AcceleratedPresenter::DoReleaseSurface() { 842 void AcceleratedPresenter::DoReleaseSurface() {
842 base::AutoLock locked(lock_); 843 base::AutoLock locked(lock_);
843 source_texture_.Release(); 844 source_texture_.Release();
844 } 845 }
845 846
847 void AcceleratedPresenter::GetPresentationStats(base::TimeTicks* timebase,
848 uint32* interval_numerator,
849 uint32* interval_denominator) {
850 lock_.AssertAcquired();
851
852 DWM_TIMING_INFO timingInfo;
853 timingInfo.cbSize = sizeof(timingInfo);
854 HRESULT gctiResult = DwmGetCompositionTimingInfo(window_, &timingInfo);
855 if (gctiResult != S_OK)
856 return;
857
858 *timebase = base::TimeTicks::FromQPCValue(
859 static_cast<LONGLONG>(timingInfo.qpcVBlank));
860 // Swap the numerator/denominator to convert frequency to period.
861 *interval_numerator = timingInfo.rateRefresh.uiDenominator;
862 *interval_denominator = timingInfo.rateRefresh.uiNumerator;
863 }
864
846 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) 865 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window)
847 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( 866 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter(
848 window)) { 867 window)) {
849 } 868 }
850 869
851 AcceleratedSurface::~AcceleratedSurface() { 870 AcceleratedSurface::~AcceleratedSurface() {
852 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_); 871 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_);
853 presenter_->Invalidate(); 872 presenter_->Invalidate();
854 } 873 }
855 874
856 bool AcceleratedSurface::Present(HDC dc) { 875 bool AcceleratedSurface::Present(HDC dc) {
857 return presenter_->Present(dc); 876 return presenter_->Present(dc);
858 } 877 }
859 878
860 bool AcceleratedSurface::CopyTo(const gfx::Rect& src_subrect, 879 bool AcceleratedSurface::CopyTo(const gfx::Rect& src_subrect,
861 const gfx::Size& dst_size, 880 const gfx::Size& dst_size,
862 void* buf) { 881 void* buf) {
863 return presenter_->CopyTo(src_subrect, dst_size, buf); 882 return presenter_->CopyTo(src_subrect, dst_size, buf);
864 } 883 }
865 884
866 void AcceleratedSurface::Suspend() { 885 void AcceleratedSurface::Suspend() {
867 presenter_->Suspend(); 886 presenter_->Suspend();
868 } 887 }
869 888
870 void AcceleratedSurface::WasHidden() { 889 void AcceleratedSurface::WasHidden() {
871 presenter_->WasHidden(); 890 presenter_->WasHidden();
872 } 891 }
OLDNEW
« base/time_win.cc ('K') | « ui/surface/accelerated_surface_win.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698