summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-04 02:25:36 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-04 02:25:36 +0000
commit585bc6f40fc00347270c11c27380d58a9b9c9a4e (patch)
tree820813c8b3bcf11efa3cab69485db05972ab44de /webkit/tools/test_shell
parent35496ce00c46c40baac183e083057b4f2a6da76f (diff)
downloadchromium_src-585bc6f40fc00347270c11c27380d58a9b9c9a4e.zip
chromium_src-585bc6f40fc00347270c11c27380d58a9b9c9a4e.tar.gz
chromium_src-585bc6f40fc00347270c11c27380d58a9b9c9a4e.tar.bz2
Turn off gtk double buffering of webwidget host's view_ widget, and manually update underlying gdk window during paint operation.
Review URL: http://codereview.chromium.org/13082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index 08e8753..bafc570 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -158,6 +158,9 @@ WebWidgetHost* WebWidgetHost::Create(gfx::WindowHandle box,
WebWidgetHost* host = new WebWidgetHost();
host->view_ = CreateWindow(box, host);
host->webwidget_ = WebWidget::Create(delegate);
+ // We manage our own double buffering because we need to be able to update
+ // the expose area in an ExposeEvent within the lifetime of the event handler.
+ gtk_widget_set_double_buffered(GTK_WIDGET(host->view_), false);
return host;
}
@@ -232,6 +235,9 @@ void WebWidgetHost::Paint() {
// Paint the canvas if necessary. Allow painting to generate extra rects the
// first time we call it. This is necessary because some WebCore rendering
// objects update their layout only when painted.
+ // Store the total area painted in total_paint. Then tell the gdk window
+ // to update that area after we're done painting it.
+ gfx::Rect total_paint;
for (int i = 0; i < 2; ++i) {
paint_rect_ = client_rect.Intersect(paint_rect_);
if (!paint_rect_.IsEmpty()) {
@@ -240,19 +246,32 @@ void WebWidgetHost::Paint() {
DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
PaintRect(rect);
+ total_paint = total_paint.Union(rect);
}
}
DCHECK(paint_rect_.IsEmpty());
- // BitBlit to the X server
+ // Invalidate the paint region on the widget's underlying gdk window. Note
+ // that gdk_window_invalidate_* will generate extra expose events, which
+ // we wish to avoid. So instead we use calls to begin_paint/end_paint.
+ GdkRectangle grect = {
+ total_paint.x(),
+ total_paint.y(),
+ total_paint.width(),
+ total_paint.height(),
+ };
+ gdk_window_begin_paint_rect(view_->window, &grect);
+
+ // BitBlit to the gdk window.
gfx::PlatformDeviceLinux &platdev = canvas_->getTopPlatformDevice();
gfx::BitmapPlatformDeviceLinux* const bitdev =
static_cast<gfx::BitmapPlatformDeviceLinux* >(&platdev);
-
cairo_t* cairo_drawable = gdk_cairo_create(view_->window);
cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0);
cairo_paint(cairo_drawable);
cairo_destroy(cairo_drawable);
+
+ gdk_window_end_paint(view_->window);
}
void WebWidgetHost::ResetScrollRect() {