diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 17:13:06 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 17:13:06 +0000 |
commit | 32a91cb71ae90dcad13c4f7d0d19db48173c5e9a (patch) | |
tree | b8fabd3d0da6253863139e25333e3133a427bb3e | |
parent | 1b6462cde9859ae75da58fc1a566e272a381fd0b (diff) | |
download | chromium_src-32a91cb71ae90dcad13c4f7d0d19db48173c5e9a.zip chromium_src-32a91cb71ae90dcad13c4f7d0d19db48173c5e9a.tar.gz chromium_src-32a91cb71ae90dcad13c4f7d0d19db48173c5e9a.tar.bz2 |
Linux: Implement WasHidden()/DidBecomeSelected().
This is a small performance optimization to save on paint operations on hidden widgets, and not reallocate backing stores.
BUG=http://www.crbug.com/11977
TEST=Switch between tabs. Make sure nothing breaks.
Review URL: http://codereview.chromium.org/115448
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16292 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 29 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.h | 3 |
2 files changed, 27 insertions, 5 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index c11d3af..ef3e243 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -163,7 +163,8 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) popup_signal_id_(0), activatable_(true), about_to_validate_and_paint_(false), - is_loading_(false) { + is_loading_(false), + is_hidden_(false) { host_->set_view(this); } @@ -205,13 +206,25 @@ void RenderWidgetHostViewGtk::InitAsPopup( } void RenderWidgetHostViewGtk::DidBecomeSelected() { - // This is involved in calling WasRestored() on the RWH, which looks - // important. - // http://code.google.com/p/chromium/issues/detail?id=11977 + if (!is_hidden_) + return; + + is_hidden_ = false; + host_->WasRestored(); } void RenderWidgetHostViewGtk::WasHidden() { - NOTIMPLEMENTED(); + if (is_hidden_) + return; + + // If we receive any more paint messages while we are hidden, we want to + // ignore them so we don't re-allocate the backing store. We will paint + // everything again when we become selected again. + is_hidden_ = true; + + // If we have a renderer, then inform it that we are being hidden so it can + // reduce its resource utilization. + GetRenderWidgetHost()->WasHidden(); } void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { @@ -289,6 +302,9 @@ void RenderWidgetHostViewGtk::IMEUpdateStatus(int control, } void RenderWidgetHostViewGtk::DidPaintRect(const gfx::Rect& rect) { + if (is_hidden_) + return; + if (about_to_validate_and_paint_) invalid_rect_ = invalid_rect_.Union(rect); else @@ -297,6 +313,9 @@ void RenderWidgetHostViewGtk::DidPaintRect(const gfx::Rect& rect) { void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, int dy) { + if (is_hidden_) + return; + Paint(rect); } diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index cd49a8d..a0da6f9 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -113,6 +113,9 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { // The cursor for the page. This is passed up from the renderer. WebCursor current_cursor_; + + // Whether or not this widget is hidden. + bool is_hidden_; }; #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |