summaryrefslogtreecommitdiffstats
path: root/cc/input
diff options
context:
space:
mode:
authorbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-25 19:46:46 +0000
committerbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-25 19:46:46 +0000
commitde2cf8caf24f9dff41462b4ed164d18c553b30e3 (patch)
tree9b7833a432e15c49b8217d529e17cc474c0e47af /cc/input
parent406e93caa0d00078548cbbb830767f5cc976e32d (diff)
downloadchromium_src-de2cf8caf24f9dff41462b4ed164d18c553b30e3.zip
chromium_src-de2cf8caf24f9dff41462b4ed164d18c553b30e3.tar.gz
chromium_src-de2cf8caf24f9dff41462b4ed164d18c553b30e3.tar.bz2
cc: Use HighResNow as timebase if it is fast and reliable
If base::TimeTicks::HighResNow is fast and reliable, we use it for frame times, animations, and scheduling. Otherwise, we use base::TimeTicks::Now and use a timebase of zero to avoid an incorrect or jittery timebase. This adds a gfx::FrameTime::Now() function, so the same timebase is used across the ui and cc directories. Additionally, the OutputSurface now uses a HighRes version of the DelayBasedTimesource if gfx::FrameTime::Now() is HighRes. BUG=303356 Review URL: https://codereview.chromium.org/27710005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/input')
-rw-r--r--cc/input/top_controls_manager.cc5
-rw-r--r--cc/input/top_controls_manager_unittest.cc13
2 files changed, 10 insertions, 8 deletions
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc
index 1d1b1a2..871d9e6 100644
--- a/cc/input/top_controls_manager.cc
+++ b/cc/input/top_controls_manager.cc
@@ -7,11 +7,12 @@
#include <algorithm>
#include "base/logging.h"
-#include "base/time/time.h"
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/timing_function.h"
#include "cc/input/top_controls_manager_client.h"
+#include "cc/output/begin_frame_args.h"
#include "cc/trees/layer_tree_impl.h"
+#include "ui/gfx/frame_time.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d_f.h"
@@ -194,7 +195,7 @@ void TopControlsManager::SetupAnimation(AnimationDirection direction) {
top_controls_animation_ = KeyframedFloatAnimationCurve::Create();
double start_time =
- (base::TimeTicks::Now() - base::TimeTicks()).InMillisecondsF();
+ (gfx::FrameTime::Now() - base::TimeTicks()).InMillisecondsF();
top_controls_animation_->AddKeyframe(
FloatKeyframe::Create(start_time, controls_top_offset_,
scoped_ptr<TimingFunction>()));
diff --git a/cc/input/top_controls_manager_unittest.cc b/cc/input/top_controls_manager_unittest.cc
index 799f018..74687ad 100644
--- a/cc/input/top_controls_manager_unittest.cc
+++ b/cc/input/top_controls_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/frame_time.h"
#include "ui/gfx/vector2d_f.h"
namespace cc {
@@ -131,7 +132,7 @@ TEST(TopControlsManagerTest, PartialShownHideAnimation) {
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;
@@ -161,7 +162,7 @@ TEST(TopControlsManagerTest, PartialShownShowAnimation) {
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;
@@ -187,7 +188,7 @@ TEST(TopControlsManagerTest, PartialHiddenWithAmbiguousThresholdShows) {
manager->ScrollEnd();
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;
@@ -213,7 +214,7 @@ TEST(TopControlsManagerTest, PartialHiddenWithAmbiguousThresholdHides) {
manager->ScrollEnd();
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;
@@ -243,7 +244,7 @@ TEST(TopControlsManagerTest, PartialShownWithAmbiguousThresholdHides) {
manager->ScrollEnd();
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;
@@ -273,7 +274,7 @@ TEST(TopControlsManagerTest, PartialShownWithAmbiguousThresholdShows) {
manager->ScrollEnd();
EXPECT_TRUE(manager->animation());
- base::TimeTicks time = base::TimeTicks::Now();
+ base::TimeTicks time = gfx::FrameTime::Now();
float previous_offset = manager->controls_top_offset();
while (manager->animation()) {
time = base::TimeDelta::FromMicroseconds(100) + time;