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

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: Rebase on top of commited base/time changes 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
« no previous file with comments | « ui/surface/accelerated_surface_win.h ('k') | ui/ui.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 void AcceleratedPresenter::DoSuspend() { 855 void AcceleratedPresenter::DoSuspend() {
855 base::AutoLock locked(lock_); 856 base::AutoLock locked(lock_);
856 swap_chain_ = NULL; 857 swap_chain_ = NULL;
857 } 858 }
858 859
859 void AcceleratedPresenter::DoReleaseSurface() { 860 void AcceleratedPresenter::DoReleaseSurface() {
860 base::AutoLock locked(lock_); 861 base::AutoLock locked(lock_);
861 source_texture_.Release(); 862 source_texture_.Release();
862 } 863 }
863 864
865 void AcceleratedPresenter::GetPresentationStats(base::TimeTicks* timebase,
866 uint32* interval_numerator,
867 uint32* interval_denominator) {
868 lock_.AssertAcquired();
869
870 DWM_TIMING_INFO timing_info;
871 timing_info.cbSize = sizeof(timing_info);
872 HRESULT result = DwmGetCompositionTimingInfo(window_, &timing_info);
873 if (result != S_OK)
874 return;
875
876 *timebase = base::TimeTicks::FromQPCValue(
877 static_cast<LONGLONG>(timing_info.qpcVBlank));
878 // Swap the numerator/denominator to convert frequency to period.
879 *interval_numerator = timing_info.rateRefresh.uiDenominator;
880 *interval_denominator = timing_info.rateRefresh.uiNumerator;
881 }
882
864 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) 883 AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window)
865 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( 884 : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter(
866 window)) { 885 window)) {
867 } 886 }
868 887
869 AcceleratedSurface::~AcceleratedSurface() { 888 AcceleratedSurface::~AcceleratedSurface() {
870 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_); 889 g_accelerated_presenter_map.Pointer()->RemovePresenter(presenter_);
871 presenter_->Invalidate(); 890 presenter_->Invalidate();
872 } 891 }
873 892
874 bool AcceleratedSurface::Present(HDC dc) { 893 bool AcceleratedSurface::Present(HDC dc) {
875 return presenter_->Present(dc); 894 return presenter_->Present(dc);
876 } 895 }
877 896
878 bool AcceleratedSurface::CopyTo(const gfx::Rect& src_subrect, 897 bool AcceleratedSurface::CopyTo(const gfx::Rect& src_subrect,
879 const gfx::Size& dst_size, 898 const gfx::Size& dst_size,
880 void* buf) { 899 void* buf) {
881 return presenter_->CopyTo(src_subrect, dst_size, buf); 900 return presenter_->CopyTo(src_subrect, dst_size, buf);
882 } 901 }
883 902
884 void AcceleratedSurface::Suspend() { 903 void AcceleratedSurface::Suspend() {
885 presenter_->Suspend(); 904 presenter_->Suspend();
886 } 905 }
887 906
888 void AcceleratedSurface::WasHidden() { 907 void AcceleratedSurface::WasHidden() {
889 presenter_->WasHidden(); 908 presenter_->WasHidden();
890 } 909 }
OLDNEW
« no previous file with comments | « 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