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

Unified Diff: ui/surface/accelerated_surface_win.cc

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_surface_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/surface/accelerated_surface_win.cc
diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc
index f346dbeadd6bd83750afd0d462c434c349a124ce..a8b57c5a450fa02e20df2505dcc2bbdc279da3ab 100644
--- a/ui/surface/accelerated_surface_win.cc
+++ b/ui/surface/accelerated_surface_win.cc
@@ -28,6 +28,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/win/shell.h"
#include "ui/events/latency_info.h"
+#include "ui/gfx/frame_time.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/win/dpi.h"
#include "ui/gfx/win/hwnd_util.h"
@@ -877,18 +878,22 @@ void AcceleratedPresenter::DoPresentAndAcknowledge(
if (raster_status.InVBlank)
clamped_scanline = display_mode.Height;
- base::TimeTicks current_time = base::TimeTicks::HighResNow();
-
// Figure out approximately how far back in time the last vsync was based on
// the ratio of the raster scanline to the display height.
base::TimeTicks last_vsync_time;
base::TimeDelta refresh_period;
+
if (display_mode.Height) {
+ refresh_period = base::TimeDelta::FromMicroseconds(
+ 1000000 / display_mode.RefreshRate);
+ // If FrameTime is not high resolution, we use a timebase of zero to avoid
+ // introducing jitter into our frame start times.
+ if (gfx::FrameTime::TimestampsAreHighRes()) {
+ base::TimeTicks current_time = gfx::FrameTime::Now();
last_vsync_time = current_time -
base::TimeDelta::FromMilliseconds((clamped_scanline * 1000) /
(display_mode.RefreshRate * display_mode.Height));
- refresh_period = base::TimeDelta::FromMicroseconds(
- 1000000 / display_mode.RefreshRate);
+ }
}
// Wait for the StretchRect to complete before notifying the GPU process
« no previous file with comments | « ui/gl/gl_surface_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698