diff options
author | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 23:48:08 +0000 |
---|---|---|
committer | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 23:48:08 +0000 |
commit | 948f7ab76fa314b55380a5df35768ac10af49b05 (patch) | |
tree | 7b4f5addbb2f1950de917c6f417b2b50fb3b902f /chrome/renderer | |
parent | 074283adf1264cebfd1272afae558d2d7366a988 (diff) | |
download | chromium_src-948f7ab76fa314b55380a5df35768ac10af49b05.zip chromium_src-948f7ab76fa314b55380a5df35768ac10af49b05.tar.gz chromium_src-948f7ab76fa314b55380a5df35768ac10af49b05.tar.bz2 |
This tunes up some of the snapshot creation code.
Includes:
- Makes it so that the PaintAtSize message does what it should do:
render the page at the size given and then scale (in the render
process) the result to the desired size.
- Changed some of the timeouts for updating snapshots to help with
performance
- Reduced the number of cases where we refresh snapshots in response
to tabs changing.
- Removed the need to force updates whenever we switch to overview
mode, which makes it faster, and avoids the "shuffling" effect.
- Started listening to TAB_CONTENTS_CONNECTED in order to detect new
browsers, instead of BROWSER_WINDOW_READY, because there were still
times when the tab contents didn't have any dimensions by the time
BROWSER_WINDOW_READY was sent. This helps fix the bug referenced
below.
- Stopped updating snapshots in active mode. Now we just invalidate
the snapshots and render them when we enter overview mode.
- Added a parameter to indicate whether we prefer using the backing
store or not when asking for snapshots from the thumbnail generator.
- Added tracking of a timestamp for events from the window manager so
we can avoid racing.
TEST=ran in chromeos under WM and verified snapshot contents
BUG=chromium-os:3142, 3136
Review URL: http://codereview.chromium.org/2098006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_widget.cc | 35 | ||||
-rw-r--r-- | chrome/renderer/render_widget.h | 1 |
2 files changed, 21 insertions, 15 deletions
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index e3d5390..c4656f7 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -752,16 +752,15 @@ void RenderWidget::OnImeSetComposition(WebCompositionCommand command, ime_control_busy_ = false; } -// Forces a repaint even if we're hidden, so we can update backing -// store even before a tab has been shown for the first time, and it -// does it synchronously. +// This message causes the renderer to render an image of the +// desired_size, regardless of whether the tab is hidden or not. void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, + const gfx::Size& page_size, const gfx::Size& desired_size) { if (!webwidget_ || dib_handle == TransportDIB::DefaultHandleValue()) return; - if (webwidget_->size().isEmpty() || - desired_size.IsEmpty()) { + if (page_size.IsEmpty() || desired_size.IsEmpty()) { // If one of these is empty, then we just return the dib we were // given, to avoid leaking it. Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, @@ -772,16 +771,13 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, // Map the given DIB ID into this process, and unmap it at the end // of this function. - scoped_ptr<TransportDIB> paint_at_scale_buffer(TransportDIB::Map(dib_handle)); + scoped_ptr<TransportDIB> paint_at_size_buffer(TransportDIB::Map(dib_handle)); - DCHECK(paint_at_scale_buffer.get()); - if (!paint_at_scale_buffer.get()) + DCHECK(paint_at_size_buffer.get()); + if (!paint_at_size_buffer.get()) return; - // Have to make sure we're laid out before rendering. - webwidget_->layout(); - - gfx::Size canvas_size = webwidget_->size(); + gfx::Size canvas_size = page_size; float x_scale = static_cast<float>(desired_size.width()) / static_cast<float>(canvas_size.width()); float y_scale = static_cast<float>(desired_size.height()) / @@ -793,8 +789,8 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, gfx::Rect bounds(canvas_size); scoped_ptr<skia::PlatformCanvas> canvas( - paint_at_scale_buffer->GetPlatformCanvas(canvas_size.width(), - canvas_size.height())); + paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(), + canvas_size.height())); if (!canvas.get()) { NOTREACHED(); return; @@ -808,13 +804,22 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, bounds.set_height(canvas->getDevice()->height()); canvas->save(); - // Add the scale factor to the canvas, so that we'll get what we expect. + // Add the scale factor to the canvas, so that we'll get the desired size. canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale)); + // Have to make sure we're laid out at the right size before + // rendering. + gfx::Size old_size = webwidget_->size(); + webwidget_->resize(page_size); + webwidget_->layout(); + // Paint the entire thing (using original bounds, not scaled bounds). PaintRect(orig_bounds, orig_bounds.origin(), canvas.get()); canvas->restore(); + // Return the widget to its previous size. + webwidget_->resize(old_size); + Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, dib_handle, bounds.size())); } diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 4232d28..4086137 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -162,6 +162,7 @@ class RenderWidget : public IPC::Channel::Listener, int target_start, int target_end, const string16& ime_string); void OnMsgPaintAtSize(const TransportDIB::Handle& dib_id, + const gfx::Size& page_size, const gfx::Size& desired_size); void OnMsgRepaint(const gfx::Size& size_to_paint); void OnSetTextDirection(WebKit::WebTextDirection direction); |