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

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

Issue 506013: 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_view_win.cc
===================================================================
--- chrome/browser/renderer_host/render_widget_host_view_win.cc (revision 34937)
+++ chrome/browser/renderer_host/render_widget_host_view_win.cc (working copy)
@@ -568,7 +568,13 @@
return TRUE;
}
-void RenderWidgetHostViewWin::Redraw(const gfx::Rect& rect) {
+void RenderWidgetHostViewWin::Redraw() {
+ RECT damage_bounds;
+ GetUpdateRect(&damage_bounds, FALSE);
+
+ ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0));
+ GetUpdateRgn(damage_region, FALSE);
+
// Paint the invalid region synchronously. Our caller will not paint again
// until we return, so by painting to the screen here, we ensure effective
// rate-limiting of backing store updates. This helps a lot on pages that
@@ -579,12 +585,11 @@
// message dispatching we allow scrolling to be smooth, and also avoid the
// browser process locking up if the plugin process is hung.
//
- RedrawWindow(
- &rect.ToRECT(), NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
+ RedrawWindow(NULL, damage_region, RDW_UPDATENOW | RDW_NOCHILDREN);
// Send the invalid rect in screen coordinates.
gfx::Rect screen_rect = GetViewBounds();
- gfx::Rect invalid_screen_rect = rect;
+ gfx::Rect invalid_screen_rect(damage_bounds);
invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect);
@@ -619,31 +624,29 @@
}
}
-void RenderWidgetHostViewWin::DidPaintRect(const gfx::Rect& rect) {
+void RenderWidgetHostViewWin::DidPaintBackingStoreRects(
+ const std::vector<gfx::Rect>& rects) {
if (is_hidden_)
return;
- if (about_to_validate_and_paint_)
- InvalidateRect(&rect.ToRECT(), false);
- else
- Redraw(rect);
+ for (size_t i = 0; i < rects.size(); ++i)
+ InvalidateRect(&rects[i].ToRECT(), false);
+
+ if (!about_to_validate_and_paint_)
+ Redraw();
}
-void RenderWidgetHostViewWin::DidScrollRect(
+void RenderWidgetHostViewWin::DidScrollBackingStoreRect(
const gfx::Rect& rect, int dx, int dy) {
if (is_hidden_)
return;
- // We need to pass in SW_INVALIDATE to ScrollWindowEx. The MSDN
- // documentation states that it only applies to the HRGN argument, which is
- // wrong. Not passing in this flag does not invalidate the region which was
- // scrolled from, thus causing painting issues.
+ // We need to pass in SW_INVALIDATE to ScrollWindowEx. The documentation on
+ // MSDN states that it only applies to the HRGN argument, which is wrong.
+ // Not passing in this flag does not invalidate the region which was scrolled
+ // from, thus causing painting issues.
RECT clip_rect = rect.ToRECT();
ScrollWindowEx(dx, dy, NULL, &clip_rect, NULL, NULL, SW_INVALIDATE);
-
- RECT invalid_rect = {0};
- GetUpdateRect(&invalid_rect);
- Redraw(gfx::Rect(invalid_rect));
}
void RenderWidgetHostViewWin::RenderViewGone() {
@@ -765,6 +768,12 @@
// GetBackingStore(), so that if it updates the invalid rect we'll catch the
// changes and repaint them.
about_to_validate_and_paint_ = false;
+
+ // Grab the region to paint before creation of paint_dc since it clears the
+ // damage region.
+ ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0));
+ GetUpdateRgn(damage_region, FALSE);
+
CPaintDC paint_dc(m_hWnd);
gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint);
@@ -772,28 +781,38 @@
return;
if (backing_store) {
- gfx::Rect bitmap_rect(
- 0, 0, backing_store->size().width(), backing_store->size().height());
+ gfx::Rect bitmap_rect(gfx::Point(), backing_store->size());
- gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect);
- if (!paint_rect.IsEmpty()) {
- DrawResizeCorner(paint_rect, backing_store->hdc());
- bool manage_colors = BackingStore::ColorManagementEnabled();
- if (manage_colors)
- SetICMMode(paint_dc.m_hDC, ICM_ON);
- BitBlt(paint_dc.m_hDC,
- paint_rect.x(),
- paint_rect.y(),
- paint_rect.width(),
- paint_rect.height(),
- backing_store->hdc(),
- paint_rect.x(),
- paint_rect.y(),
- SRCCOPY);
- if (manage_colors)
- SetICMMode(paint_dc.m_hDC, ICM_OFF);
+ bool manage_colors = BackingStore::ColorManagementEnabled();
+ if (manage_colors)
+ SetICMMode(paint_dc.m_hDC, ICM_ON);
+
+ // Blit only the damaged regions from the backing store.
+ DWORD data_size = GetRegionData(damage_region, 0, NULL);
+ scoped_array<char> region_data_buf(new char[data_size]);
+ RGNDATA* region_data = reinterpret_cast<RGNDATA*>(region_data_buf.get());
+ GetRegionData(damage_region, data_size, region_data);
+
+ RECT* region_rects = reinterpret_cast<RECT*>(region_data->Buffer);
+ for (DWORD i = 0; i < region_data->rdh.nCount; ++i) {
+ gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i]));
+ if (!paint_rect.IsEmpty()) {
+ DrawResizeCorner(paint_rect, backing_store->hdc());
+ BitBlt(paint_dc.m_hDC,
+ paint_rect.x(),
+ paint_rect.y(),
+ paint_rect.width(),
+ paint_rect.height(),
+ backing_store->hdc(),
+ paint_rect.x(),
+ paint_rect.y(),
+ SRCCOPY);
+ }
}
+ if (manage_colors)
+ SetICMMode(paint_dc.m_hDC, ICM_OFF);
+
// Fill the remaining portion of the damaged_rect with the background
if (damaged_rect.right() > bitmap_rect.right()) {
RECT r;
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | chrome/browser/renderer_host/resource_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698