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

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

Issue 16290002: Android: Throttle BeginFrame messages sent from the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only allow one pending beginFrame Created 7 years, 7 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 739dd3f676ede9b8b9199822e9280e22c3a15050..6e96ce21fda1381557101dc0ff64cbeed471557d 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -81,7 +81,8 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
ime_adapter_android_(this),
cached_background_color_(SK_ColorWHITE),
texture_id_in_layer_(0),
- weak_ptr_factory_(this) {
+ weak_ptr_factory_(this),
+ begin_frame_pending_(false) {
if (CompositorImpl::UsesDirectGL()) {
surface_texture_transport_.reset(new SurfaceTextureTransportClient());
layer_ = surface_texture_transport_->Initialize();
@@ -409,9 +410,19 @@ void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor(
void RenderWidgetHostViewAndroid::SendBeginFrame(
base::TimeTicks frame_time) {
- if (host_)
+ // Throttle the renderer if we are behind. Also only send another beginFrame
+ // if we received a frame for the last beginFrame.
+ if (!ack_callbacks_.empty() || begin_frame_pending_) {
+ if (content_view_core_)
+ content_view_core_->SetVSyncNotificationEnabled(true);
+ return;
+ }
+
+ if (host_) {
+ begin_frame_pending_ = true;
host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(),
frame_time));
+ }
}
void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrame(
@@ -592,6 +603,7 @@ void RenderWidgetHostViewAndroid::ComputeContentsSize(
void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
scoped_ptr<cc::CompositorFrame> frame) {
+ begin_frame_pending_ = false;
// Always let ContentViewCore know about the new frame first, so it can decide
// to schedule a Draw immediately when it sees the texture layer invalidation.
if (content_view_core_) {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | content/renderer/gpu/mailbox_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698