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

Unified Diff: chrome/renderer/render_widget.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
« no previous file with comments | « chrome/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_widget.cc
===================================================================
--- chrome/renderer/render_widget.cc (revision 34952)
+++ chrome/renderer/render_widget.cc (working copy)
@@ -50,8 +50,9 @@
render_thread_(render_thread),
host_window_(0),
current_paint_buf_(NULL),
+ current_scroll_buf_(NULL),
next_paint_flags_(0),
- update_reply_pending_(false),
+ paint_reply_pending_(false),
did_show_(false),
is_hidden_(false),
needs_repainting_on_restore_(false),
@@ -78,6 +79,10 @@
RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
current_paint_buf_ = NULL;
}
+ if (current_scroll_buf_) {
+ RenderProcess::current()->ReleaseTransportDIB(current_scroll_buf_);
+ current_scroll_buf_ = NULL;
+ }
RenderProcess::current()->ReleaseProcess();
}
@@ -137,7 +142,8 @@
IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
IPC_MESSAGE_HANDLER(ViewMsg_WasRestored, OnWasRestored)
- IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
+ IPC_MESSAGE_HANDLER(ViewMsg_PaintRect_ACK, OnPaintRectAck)
+ IPC_MESSAGE_HANDLER(ViewMsg_ScrollRect_ACK, OnScrollRectAck)
IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent)
IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost)
IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus)
@@ -252,17 +258,11 @@
didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
}
-void RenderWidget::OnRequestMoveAck() {
- DCHECK(pending_window_rect_count_);
- pending_window_rect_count_--;
-}
-
-void RenderWidget::OnUpdateRectAck() {
- DCHECK(update_reply_pending());
- update_reply_pending_ = false;
-
- // If we sent an UpdateRect message with a zero-sized bitmap, then we should
- // have no current update buf.
+void RenderWidget::OnPaintRectAck() {
+ DCHECK(paint_reply_pending());
+ paint_reply_pending_ = false;
+ // If we sent a PaintRect message with a zero-sized bitmap, then
+ // we should have no current paint buf.
if (current_paint_buf_) {
RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
current_paint_buf_ = NULL;
@@ -275,6 +275,23 @@
CallDoDeferredUpdate();
}
+void RenderWidget::OnRequestMoveAck() {
+ DCHECK(pending_window_rect_count_);
+ pending_window_rect_count_--;
+}
+
+void RenderWidget::OnScrollRectAck() {
+ DCHECK(scroll_reply_pending());
+
+ if (current_scroll_buf_) {
+ RenderProcess::current()->ReleaseTransportDIB(current_scroll_buf_);
+ current_scroll_buf_ = NULL;
+ }
+
+ // Continue scrolling if necessary...
+ CallDoDeferredUpdate();
+}
+
void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
void* iter = NULL;
@@ -388,17 +405,9 @@
if (!kPaintBorder)
return;
- // Cycle through these colors to help distinguish new paint rects.
- const SkColor colors[] = {
- SkColorSetARGB(0x3F, 0xFF, 0, 0),
- SkColorSetARGB(0x3F, 0xFF, 0, 0xFF),
- SkColorSetARGB(0x3F, 0, 0, 0xFF),
- };
- static int color_selector = 0;
-
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
- paint.setColor(colors[color_selector++ % arraysize(colors)]);
+ paint.setColor(SkColorSetARGB(0x3F, 0xFF, 0, 0));
paint.setStrokeWidth(1);
SkIRect irect;
@@ -417,7 +426,7 @@
void RenderWidget::DoDeferredUpdate() {
if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() ||
- update_reply_pending())
+ paint_reply_pending() || scroll_reply_pending())
return;
// Suppress updating when we are hidden.
@@ -435,57 +444,87 @@
PaintAggregator::PendingUpdate update = paint_aggregator_.GetPendingUpdate();
paint_aggregator_.ClearPendingUpdate();
- gfx::Rect scroll_damage = update.GetScrollDamage();
- gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
+ if (!update.scroll_rect.IsEmpty()) {
+ // Optmized scrolling
- // Compute a buffer for painting and cache it.
- scoped_ptr<skia::PlatformCanvas> canvas(
- RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_, bounds));
- if (!canvas.get()) {
- NOTREACHED();
- return;
- }
+ // Compute the region we will expose by scrolling, and paint that into a
+ // shared memory section.
+ gfx::Rect damaged_rect = update.GetScrollDamage();
- // We may get back a smaller canvas than we asked for.
- // TODO(darin): This seems like it could cause painting problems!
- DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
- DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
- bounds.set_width(canvas->getDevice()->width());
- bounds.set_height(canvas->getDevice()->height());
+ scoped_ptr<skia::PlatformCanvas> canvas(
+ RenderProcess::current()->GetDrawingCanvas(&current_scroll_buf_,
+ damaged_rect));
+ if (!canvas.get()) {
+ NOTREACHED();
+ return;
+ }
- HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size());
+ // We may get back a smaller canvas than we asked for.
+ damaged_rect.set_width(canvas->getDevice()->width());
+ damaged_rect.set_height(canvas->getDevice()->height());
- // The scroll damage is just another rectangle to paint and copy.
- std::vector<gfx::Rect> copy_rects;
- copy_rects.swap(update.paint_rects);
- if (!scroll_damage.IsEmpty())
- copy_rects.push_back(scroll_damage);
+ // Set these parameters before calling Paint, since that could result in
+ // further invalidates (uncommon).
+ ViewHostMsg_ScrollRect_Params params;
+ params.bitmap_rect = damaged_rect;
+ params.dx = update.scroll_delta.x();
+ params.dy = update.scroll_delta.y();
+ params.clip_rect = update.scroll_rect;
+ params.view_size = size_;
+ params.plugin_window_moves = plugin_window_moves_;
+ params.bitmap = current_scroll_buf_->id();
- // TODO(darin): Re-enable painting multiple damage rects once the
- // page-cycler regressions are resolved. See bug 29589.
- if (update.scroll_rect.IsEmpty()) {
- update.paint_rects.clear();
- update.paint_rects.push_back(bounds);
+ plugin_window_moves_.clear();
+
+ PaintRect(damaged_rect, damaged_rect.origin(), canvas.get());
+ Send(new ViewHostMsg_ScrollRect(routing_id_, params));
}
- for (size_t i = 0; i < copy_rects.size(); ++i)
- PaintRect(copy_rects[i], bounds.origin(), canvas.get());
+ if (!update.paint_rects.empty()) {
+ // Normal painting
- ViewHostMsg_UpdateRect_Params params;
- params.bitmap = current_paint_buf_->id();
- params.bitmap_rect = bounds;
- params.dx = update.scroll_delta.x();
- params.dy = update.scroll_delta.y();
- params.scroll_rect = update.scroll_rect;
- params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds?
- params.view_size = size_;
- params.plugin_window_moves.swap(plugin_window_moves_);
- params.flags = next_paint_flags_;
+ gfx::Rect bounds = update.GetPaintBounds();
- update_reply_pending_ = true;
- Send(new ViewHostMsg_UpdateRect(routing_id_, params));
- next_paint_flags_ = 0;
+ // Compute a buffer for painting and cache it.
+ scoped_ptr<skia::PlatformCanvas> canvas(
+ RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
+ bounds));
+ if (!canvas.get()) {
+ NOTREACHED();
+ return;
+ }
+ // We may get back a smaller canvas than we asked for.
+ bounds.set_width(canvas->getDevice()->width());
+ bounds.set_height(canvas->getDevice()->height());
+
+ HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size());
+
+ // TODO(darin): Re-enable painting multiple damage rects once the
+ // page-cycler regressions are resolved. See bug 29589.
+ if (update.scroll_rect.IsEmpty()) {
+ update.paint_rects.clear();
+ update.paint_rects.push_back(bounds);
+ }
+
+ for (size_t i = 0; i < update.paint_rects.size(); ++i)
+ PaintRect(update.paint_rects[i], bounds.origin(), canvas.get());
+
+ ViewHostMsg_PaintRect_Params params;
+ params.bitmap_rect = bounds;
+ params.update_rects = update.paint_rects; // TODO(darin): clip to bounds?
+ params.view_size = size_;
+ params.plugin_window_moves = plugin_window_moves_;
+ params.flags = next_paint_flags_;
+ params.bitmap = current_paint_buf_->id();
+
+ plugin_window_moves_.clear();
+
+ paint_reply_pending_ = true;
+ Send(new ViewHostMsg_PaintRect(routing_id_, params));
+ next_paint_flags_ = 0;
+ }
+
UpdateIME();
}
@@ -509,7 +548,7 @@
return;
if (!paint_aggregator_.HasPendingUpdate())
return;
- if (update_reply_pending())
+ if (paint_reply_pending() || scroll_reply_pending())
return;
// Perform updating asynchronously. This serves two purposes:
@@ -538,7 +577,7 @@
return;
if (!paint_aggregator_.HasPendingUpdate())
return;
- if (update_reply_pending())
+ if (paint_reply_pending() || scroll_reply_pending())
return;
// Perform updating asynchronously. This serves two purposes:
@@ -734,23 +773,23 @@
}
bool RenderWidget::next_paint_is_resize_ack() const {
- return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_);
+ return ViewHostMsg_PaintRect_Flags::is_resize_ack(next_paint_flags_);
}
bool RenderWidget::next_paint_is_restore_ack() const {
- return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_);
+ return ViewHostMsg_PaintRect_Flags::is_restore_ack(next_paint_flags_);
}
void RenderWidget::set_next_paint_is_resize_ack() {
- next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
+ next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK;
}
void RenderWidget::set_next_paint_is_restore_ack() {
- next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK;
+ next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESTORE_ACK;
}
void RenderWidget::set_next_paint_is_repaint_ack() {
- next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
+ next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_REPAINT_ACK;
}
void RenderWidget::UpdateIME() {
« no previous file with comments | « chrome/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698