Use DwmGetCompositionTimingInfo to get vsync info on Windows


BUG=


Review URL: https://chromiumcodereview.appspot.com/10825053

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150395 0039d316-1c4b-4281-b951-d872f2087c98
parent b6c832d9
......@@ -4,6 +4,7 @@
#include "ui/surface/accelerated_surface_win.h"
#include <dwmapi.h>
#include <windows.h>
#include <algorithm>
......@@ -861,6 +862,24 @@ void AcceleratedPresenter::DoReleaseSurface() {
source_texture_.Release();
}
void AcceleratedPresenter::GetPresentationStats(base::TimeTicks* timebase,
uint32* interval_numerator,
uint32* interval_denominator) {
lock_.AssertAcquired();
DWM_TIMING_INFO timing_info;
timing_info.cbSize = sizeof(timing_info);
HRESULT result = DwmGetCompositionTimingInfo(window_, &timing_info);
if (result != S_OK)
return;
*timebase = base::TimeTicks::FromQPCValue(
static_cast<LONGLONG>(timing_info.qpcVBlank));
// Swap the numerator/denominator to convert frequency to period.
*interval_numerator = timing_info.rateRefresh.uiDenominator;
*interval_denominator = timing_info.rateRefresh.uiNumerator;
}
AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window)
: presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter(
window)) {
......
......@@ -77,6 +77,18 @@ class SURFACE_EXPORT AcceleratedPresenter
bool DoRealPresent(HDC dc);
void DoReleaseSurface();
// This gets the timestamp and period of the display's last vsync.
// The period is represented as a ratio which, when divided, will give you
// the interval in seconds. i.e.:
// inteval_in_seconds = interval_numerator / interval_denominator;
// For example, some machines will return an interval_numerator of 1001
// and an interval_denominator of 60000, resulting in an interval of
// 1001/60000 ~= .016683 seconds
// Note: This function assumes lock_ is acquired.
void GetPresentationStats(base::TimeTicks* timebase,
uint32* interval_numerator,
uint32* interval_denominator);
// The thread with which this presenter has affinity.
PresentThread* const present_thread_;
......
......@@ -636,10 +636,12 @@
'DelayLoadDLLs': [
'd2d1.dll',
'd3d10_1.dll',
'dwmapi.dll',
],
'AdditionalDependencies': [
'd2d1.lib',
'd3d10_1.lib',
'dwmapi.lib',
],
},
},
......@@ -647,6 +649,7 @@
'libraries': [
'-limm32.lib',
'-ld2d1.lib',
'-ldwmapi.lib',
'-loleacc.lib',
],
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment