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

Unified Diff: chrome/browser/renderer_host/render_widget_host.cc

Issue 506075: Revert 34951 - Combine ViewHostMsg_{Paint,Scroll}Rect into one IPC.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years 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: chrome/browser/renderer_host/render_widget_host.cc
===================================================================
--- chrome/browser/renderer_host/render_widget_host.cc (revision 34952)
+++ chrome/browser/renderer_host/render_widget_host.cc (working copy)
@@ -124,7 +124,8 @@
IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone)
IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove)
- IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_PaintRect, OnMsgPaintRect)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ScrollRect, OnMsgScrollRect)
IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck)
IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus)
IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur)
@@ -298,9 +299,9 @@
if (resize_ack_pending_ || !backing_store) {
IPC::Message msg;
TimeDelta max_delay = TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
- if (process_->WaitForUpdateMsg(routing_id_, max_delay, &msg)) {
- ViewHostMsg_UpdateRect::Dispatch(
- &msg, this, &RenderWidgetHost::OnMsgUpdateRect);
+ if (process_->WaitForPaintMsg(routing_id_, max_delay, &msg)) {
+ ViewHostMsg_PaintRect::Dispatch(
+ &msg, this, &RenderWidgetHost::OnMsgPaintRect);
backing_store = BackingStoreManager::GetBackingStore(this, current_size_);
}
}
@@ -617,15 +618,15 @@
}
}
-void RenderWidgetHost::OnMsgUpdateRect(
- const ViewHostMsg_UpdateRect_Params& params) {
+void RenderWidgetHost::OnMsgPaintRect(
+ const ViewHostMsg_PaintRect_Params& params) {
TimeTicks paint_start = TimeTicks::Now();
// Update our knowledge of the RenderWidget's size.
current_size_ = params.view_size;
bool is_resize_ack =
- ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags);
+ ViewHostMsg_PaintRect_Flags::is_resize_ack(params.flags);
// resize_ack_pending_ needs to be cleared before we call DidPaintRect, since
// that will end up reaching GetBackingStore.
@@ -636,7 +637,7 @@
}
bool is_repaint_ack =
- ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags);
+ ViewHostMsg_PaintRect_Flags::is_repaint_ack(params.flags);
if (is_repaint_ack) {
repaint_ack_pending_ = false;
TimeDelta delta = TimeTicks::Now() - repaint_start_time_;
@@ -652,19 +653,12 @@
if (dib) {
if (dib->size() < size) {
DLOG(WARNING) << "Transport DIB too small for given rectangle";
- process()->ReceivedBadMessage(ViewHostMsg_UpdateRect__ID);
+ process()->ReceivedBadMessage(ViewHostMsg_PaintRect__ID);
} else {
- // Scroll the backing store.
- if (!params.scroll_rect.IsEmpty()) {
- ScrollBackingStoreRect(params.dx, params.dy,
- params.scroll_rect,
- params.view_size);
- }
-
// Paint the backing store. This will update it with the renderer-supplied
// bits. The view will read out of the backing store later to actually
// draw to the screen.
- PaintBackingStoreRect(dib, params.bitmap_rect, params.copy_rects,
+ PaintBackingStoreRect(dib, params.bitmap_rect, params.update_rects,
params.view_size);
}
}
@@ -673,7 +667,7 @@
// This must be done AFTER we're done painting with the bitmap supplied by the
// renderer. This ACK is a signal to the renderer that the backing store can
// be re-used, so the bitmap may be invalid after this call.
- Send(new ViewMsg_UpdateRect_ACK(routing_id_));
+ Send(new ViewMsg_PaintRect_ACK(routing_id_));
// We don't need to update the view if the view is hidden. We must do this
// early return after the ACK is sent, however, or the renderer will not send
@@ -685,12 +679,7 @@
if (view_) {
view_->MovePluginWindows(params.plugin_window_moves);
view_being_painted_ = true;
- if (!params.scroll_rect.IsEmpty()) {
- view_->DidScrollBackingStoreRect(params.scroll_rect,
- params.dx,
- params.dy);
- }
- view_->DidPaintBackingStoreRects(params.copy_rects);
+ view_->DidPaintRect(params.bitmap_rect);
view_being_painted_ = false;
}
@@ -711,9 +700,58 @@
// Log the time delta for processing a paint message.
TimeDelta delta = TimeTicks::Now() - paint_start;
- UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta);
+ UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgPaintRect", delta);
}
+void RenderWidgetHost::OnMsgScrollRect(
+ const ViewHostMsg_ScrollRect_Params& params) {
+ TimeTicks scroll_start = TimeTicks::Now();
+
+ DCHECK(!params.view_size.IsEmpty());
+
+ const size_t size = params.bitmap_rect.height() *
+ params.bitmap_rect.width() * 4;
+ TransportDIB* dib = process_->GetTransportDIB(params.bitmap);
+ if (dib) {
+ if (dib->size() < size) {
+ LOG(WARNING) << "Transport DIB too small for given rectangle";
+ process()->ReceivedBadMessage(ViewHostMsg_PaintRect__ID);
+ } else {
+ // Scroll the backing store.
+ ScrollBackingStoreRect(dib, params.bitmap_rect,
+ params.dx, params.dy,
+ params.clip_rect, params.view_size);
+ }
+ }
+
+ // ACK early so we can prefetch the next ScrollRect if there is a next one.
+ // This must be done AFTER we're done painting with the bitmap supplied by the
+ // renderer. This ACK is a signal to the renderer that the backing store can
+ // be re-used, so the bitmap may be invalid after this call.
+ Send(new ViewMsg_ScrollRect_ACK(routing_id_));
+
+ // We don't need to update the view if the view is hidden. We must do this
+ // early return after the ACK is sent, however, or the renderer will not send
+ // is more data.
+ if (is_hidden_)
+ return;
+
+ // Paint the view. Watch out: it might be destroyed already.
+ if (view_) {
+ view_being_painted_ = true;
+ view_->MovePluginWindows(params.plugin_window_moves);
+ view_->DidScrollRect(params.clip_rect, params.dx, params.dy);
+ view_being_painted_ = false;
+ }
+
+ if (painting_observer_)
+ painting_observer_->WidgetDidUpdateBackingStore(this);
+
+ // Log the time delta for processing a scroll message.
+ TimeDelta delta = TimeTicks::Now() - scroll_start;
+ UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgScrollRect", delta);
+}
+
void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) {
// Log the time delta for processing an input event.
TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
@@ -853,7 +891,9 @@
}
}
-void RenderWidgetHost::ScrollBackingStoreRect(int dx, int dy,
+void RenderWidgetHost::ScrollBackingStoreRect(TransportDIB* bitmap,
+ const gfx::Rect& bitmap_rect,
+ int dx, int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) {
if (is_hidden_) {
@@ -870,7 +910,8 @@
BackingStore* backing_store = BackingStoreManager::Lookup(this);
if (!backing_store || (backing_store->size() != view_size))
return;
- backing_store->ScrollRect(dx, dy, clip_rect, view_size);
+ backing_store->ScrollRect(process_->GetHandle(), bitmap, bitmap_rect,
+ dx, dy, clip_rect, view_size);
}
void RenderWidgetHost::ToggleSpellPanel(bool is_currently_visible) {
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host.h ('k') | chrome/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698