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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 457913002: Android WebView: flush input events during onVSync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: subscriberTypes + postInvalidate during VSync Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index dd65887f78db5d47ad01b2adc5b5da168d243a18..a0437b11d2a291f0f5e51be3e6f71fa2e8c971eb 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -201,6 +201,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
using_synchronous_compositor_(SynchronousCompositorImpl::FromID(
widget_host->GetProcess()->GetID(),
widget_host->GetRoutingID()) != NULL),
+ vsync_subscribers_(0),
frame_evictor_(new DelegatedFrameEvictor(this)),
locks_on_frame_count_(0),
observing_root_window_(false) {
boliu 2014/08/20 02:54:16 vsync_subscribers_ can replace observing_root_wind
hush (inactive) 2014/08/20 03:47:21 yes indeed.
@@ -260,9 +261,8 @@ void RenderWidgetHostViewAndroid::WasShown() {
host_->WasShown(ui::LatencyInfo());
if (content_view_core_ && !using_synchronous_compositor_) {
- content_view_core_->GetWindowAndroid()->AddObserver(this);
+ SubscribeToVSync(INPUT | BEGIN_FRAME);
content_view_core_->GetWindowAndroid()->RequestVSyncUpdate();
- observing_root_window_ = true;
}
}
@@ -811,6 +811,10 @@ void RenderWidgetHostViewAndroid::ShowDisambiguationPopup(
scoped_ptr<SyntheticGestureTarget>
RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() {
+ DCHECK(content_view_core_);
+ if (using_synchronous_compositor_)
+ SubscribeToVSync(INPUT);
+
return scoped_ptr<SyntheticGestureTarget>(new SyntheticGestureTargetAndroid(
host_, content_view_core_->CreateTouchEventSynthesizer()));
}
@@ -1470,8 +1474,7 @@ void RenderWidgetHostViewAndroid::SetContentViewCore(
return;
if (!using_synchronous_compositor_) {
- content_view_core_->GetWindowAndroid()->AddObserver(this);
- observing_root_window_ = true;
+ SubscribeToVSync(INPUT | BEGIN_FRAME);
if (needs_begin_frame_)
content_view_core_->GetWindowAndroid()->RequestVSyncUpdate();
}
@@ -1518,17 +1521,31 @@ void RenderWidgetHostViewAndroid::OnDetachCompositor() {
RunAckCallbacks();
}
+void RenderWidgetHostViewAndroid::SubscribeToVSync(int type) {
boliu 2014/08/20 02:54:16 Where is Unsubscribe?
hush (inactive) 2014/08/20 03:47:21 Will add it... On 2014/08/20 02:54:16, boliu wrote
+ if (!observing_root_window_) {
+ content_view_core_->GetWindowAndroid()->AddObserver(this);
+ observing_root_window_ = true;
+ }
+
+ vsync_subscribers_ |= type;
+ // Synchronous compositor does not request begin frames OnVSync.
+ DCHECK(using_synchronous_compositor_ && !(vsync_subscribers_ & BEGIN_FRAME));
boliu 2014/08/20 02:54:16 This DCHECK can't be right. It fails if using_sync
hush (inactive) 2014/08/20 03:47:21 yeah.. you are right. Done On 2014/08/20 02:54:16,
+}
+
void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time,
base::TimeDelta vsync_period) {
TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::OnVSync");
if (!host_)
return;
- if (flush_input_requested_) {
+ if (vsync_subscribers_ & INPUT & flush_input_requested_) {
flush_input_requested_ = false;
host_->FlushInput();
}
+ if (!(vsync_subscribers_ & BEGIN_FRAME))
+ return;
+
TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::SendBeginFrame");
base::TimeTicks display_time = frame_time + vsync_period;

Powered by Google App Engine
This is Rietveld 408576698