summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 20:56:32 +0000
committerskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 20:56:32 +0000
commitef915f53eaff99da21a38ae0575ce50e099ddf4e (patch)
treeb176d60d3f81e8d4727466c46704c89fbee656bd
parenta53e5ed5ad7fefaec62abea5b721b992476673bc (diff)
downloadchromium_src-ef915f53eaff99da21a38ae0575ce50e099ddf4e.zip
chromium_src-ef915f53eaff99da21a38ae0575ce50e099ddf4e.tar.gz
chromium_src-ef915f53eaff99da21a38ae0575ce50e099ddf4e.tar.bz2
cc: Use input events to trigger vsync
When we know that an input event is the last one to be delivered for the current vsync interval, trigger the vsync event immediately instead of waiting for one to be delivered over IPC. On Android devices this lets us start rendering about 1 ms earlier than otherwise. BUG=230336 Review URL: https://chromiumcodereview.appspot.com/13863006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195581 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/input/input_handler.h3
-rw-r--r--cc/test/fake_layer_tree_host_impl_client.h2
-rw-r--r--cc/trees/layer_tree_host_impl.cc5
-rw-r--r--cc/trees/layer_tree_host_impl.h3
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc2
-rw-r--r--cc/trees/layer_tree_host_unittest.cc41
-rw-r--r--cc/trees/single_thread_proxy.h2
-rw-r--r--cc/trees/thread_proxy.cc8
-rw-r--r--cc/trees/thread_proxy.h2
-rw-r--r--webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc7
10 files changed, 73 insertions, 2 deletions
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h
index cf18a66..c924bc1 100644
--- a/cc/input/input_handler.h
+++ b/cc/input/input_handler.h
@@ -75,6 +75,9 @@ class CC_EXPORT InputHandlerClient {
virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_point) = 0;
+ virtual void DidReceiveLastInputEventForVSync(
+ base::TimeTicks frame_time) = 0;
+
protected:
InputHandlerClient() {}
virtual ~InputHandlerClient() {}
diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h
index 61555bb..8be8575 100644
--- a/cc/test/fake_layer_tree_host_impl_client.h
+++ b/cc/test/fake_layer_tree_host_impl_client.h
@@ -36,6 +36,8 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient {
virtual void RenewTreePriority() OVERRIDE {}
virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta)
OVERRIDE {}
+ virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time)
+ OVERRIDE {}
};
} // namespace cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 657e72f..3bcf3ff 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -369,6 +369,11 @@ bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) {
return false;
}
+void LayerTreeHostImpl::DidReceiveLastInputEventForVSync(
+ base::TimeTicks frame_time) {
+ client_->DidReceiveLastInputEventForVSync(frame_time);
+}
+
void LayerTreeHostImpl::TrackDamageForAllSurfaces(
LayerImpl* root_draw_layer,
const LayerImplList& render_surface_layer_list) {
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index c31fba1..f8e5ac3 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -72,6 +72,7 @@ class LayerTreeHostImplClient {
virtual bool IsInsideDraw() = 0;
virtual void RenewTreePriority() = 0;
virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
+ virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time) = 0;
protected:
virtual ~LayerTreeHostImplClient() {}
@@ -113,6 +114,8 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
base::TimeDelta duration) OVERRIDE;
virtual void ScheduleAnimation() OVERRIDE;
virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
+ virtual void DidReceiveLastInputEventForVSync(
+ base::TimeTicks frame_time) OVERRIDE;
// TopControlsManagerClient implementation.
virtual void DidChangeTopControlsPosition() OVERRIDE;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index dae900b..9e9c80d 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -126,6 +126,8 @@ class LayerTreeHostImplTest : public testing::Test,
virtual void RenewTreePriority() OVERRIDE {}
virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
OVERRIDE {}
+ virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time)
+ OVERRIDE {}
void set_reduce_memory_result(bool reduce_memory_result) {
reduce_memory_result_ = reduce_memory_result;
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 3cf4939..046699e1 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -8,6 +8,7 @@
#include "base/synchronization/lock.h"
#include "cc/animation/timing_function.h"
+#include "cc/debug/frame_rate_counter.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/io_surface_layer.h"
@@ -2296,8 +2297,7 @@ class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest {
return true;
}
- virtual void AfterTest() OVERRIDE {
- }
+ virtual void AfterTest() OVERRIDE {}
private:
base::TimeTicks frame_time_;
@@ -2305,6 +2305,43 @@ class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest {
MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification);
+class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest {
+ public:
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->render_vsync_notification_enabled = true;
+ }
+
+ virtual void BeginTest() OVERRIDE {
+ frame_time_ = base::TimeTicks::Now();
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ // Post a task to send the final input event for the current vsync; it
+ // should trigger rendering.
+ ImplThread()->PostTask(
+ base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent,
+ base::Unretained(this),
+ base::Unretained(host_impl)));
+ }
+
+ void SendFinalInputEvent(LayerTreeHostImpl* host_impl) {
+ host_impl->DidReceiveLastInputEventForVSync(frame_time_);
+ }
+
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin());
+ EndTest();
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ private:
+ base::TimeTicks frame_time_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTestInputDrivenRendering);
+
class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
: public LayerTreeHostTest {
protected:
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h
index cf29574..deb0cd9 100644
--- a/cc/trees/single_thread_proxy.h
+++ b/cc/trees/single_thread_proxy.h
@@ -71,6 +71,8 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient {
virtual void RenewTreePriority() OVERRIDE {}
virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
OVERRIDE {}
+ virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time)
+ OVERRIDE {}
// Called by the legacy path where RenderWidget does the scheduling.
void CompositeImmediately(base::TimeTicks frame_begin_time);
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 7f0f275..bd66d7c 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -1347,4 +1347,12 @@ void ThreadProxy::StartScrollbarAnimationOnImplThread() {
layer_tree_host_impl_->CurrentFrameTimeTicks());
}
+void ThreadProxy::DidReceiveLastInputEventForVSync(
+ base::TimeTicks frame_time) {
+ if (render_vsync_notification_enabled_) {
+ TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync");
+ DidVSync(frame_time);
+ }
+}
+
} // namespace cc
diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h
index fccde44..65439b7 100644
--- a/cc/trees/thread_proxy.h
+++ b/cc/trees/thread_proxy.h
@@ -86,6 +86,8 @@ class ThreadProxy : public Proxy,
virtual void RenewTreePriority() OVERRIDE;
virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
OVERRIDE;
+ virtual void DidReceiveLastInputEventForVSync(
+ base::TimeTicks frame_time) OVERRIDE;
// SchedulerClient implementation
virtual void ScheduledActionBeginFrame() OVERRIDE;
diff --git a/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc b/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
index dafde3c..e231afe 100644
--- a/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
+++ b/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
@@ -86,6 +86,13 @@ class WebToCCInputHandlerAdapter::ClientAdapter : public WebInputHandlerClient {
return client_->HaveTouchEventHandlersAt(point);
}
+ virtual void didReceiveLastInputEventForVSync(double frame_time_sec)
+ OVERRIDE {
+ base::TimeTicks frame_time = base::TimeTicks::FromInternalValue(
+ frame_time_sec * base::Time::kMicrosecondsPerSecond);
+ client_->DidReceiveLastInputEventForVSync(frame_time);
+ }
+
private:
cc::InputHandlerClient* client_;
};