| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/tools/test_shell/webwidget_host.h" | 5 #include "webkit/tools/test_shell/webwidget_host.h" |
| 6 | 6 |
| 7 #include <cairo/cairo.h> |
| 7 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/gfx/platform_canvas_linux.h" | 11 #include "base/gfx/platform_canvas_linux.h" |
| 11 #include "base/gfx/platform_device_linux.h" | 12 #include "base/gfx/platform_device_linux.h" |
| 12 #include "base/gfx/bitmap_platform_device_linux.h" | 13 #include "base/gfx/bitmap_platform_device_linux.h" |
| 13 #include "webkit/glue/webinputevent.h" | 14 #include "webkit/glue/webinputevent.h" |
| 14 #include "webkit/glue/webwidget.h" | 15 #include "webkit/glue/webwidget.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; | 226 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; |
| 226 PaintRect(rect); | 227 PaintRect(rect); |
| 227 } | 228 } |
| 228 } | 229 } |
| 229 DCHECK(paint_rect_.IsEmpty()); | 230 DCHECK(paint_rect_.IsEmpty()); |
| 230 | 231 |
| 231 // BitBlit to the X server | 232 // BitBlit to the X server |
| 232 gfx::PlatformDeviceLinux &platdev = canvas_->getTopPlatformDevice(); | 233 gfx::PlatformDeviceLinux &platdev = canvas_->getTopPlatformDevice(); |
| 233 gfx::BitmapPlatformDeviceLinux* const bitdev = | 234 gfx::BitmapPlatformDeviceLinux* const bitdev = |
| 234 static_cast<gfx::BitmapPlatformDeviceLinux* >(&platdev); | 235 static_cast<gfx::BitmapPlatformDeviceLinux* >(&platdev); |
| 235 gdk_draw_pixbuf(view_->window, NULL, bitdev->pixbuf(), | 236 |
| 236 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NONE, 0, 0); | 237 cairo_t* cairo_drawable = gdk_cairo_create(view_->window); |
| 238 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0); |
| 239 cairo_paint(cairo_drawable); |
| 240 cairo_destroy(cairo_drawable); |
| 237 } | 241 } |
| 238 | 242 |
| 239 void WebWidgetHost::ResetScrollRect() { | 243 void WebWidgetHost::ResetScrollRect() { |
| 240 scroll_rect_ = gfx::Rect(); | 244 scroll_rect_ = gfx::Rect(); |
| 241 scroll_dx_ = 0; | 245 scroll_dx_ = 0; |
| 242 scroll_dy_ = 0; | 246 scroll_dy_ = 0; |
| 243 } | 247 } |
| 244 | 248 |
| 245 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 249 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 246 set_painting(true); | 250 set_painting(true); |
| 247 webwidget_->Paint(canvas_.get(), rect); | 251 webwidget_->Paint(canvas_.get(), rect); |
| 248 set_painting(false); | 252 set_painting(false); |
| 249 } | 253 } |
| 250 | 254 |
| 251 // ----------------------------------------------------------------------------- | 255 // ----------------------------------------------------------------------------- |
| 252 // This is called when the GTK window is destroyed. In the Windows code this | 256 // This is called when the GTK window is destroyed. In the Windows code this |
| 253 // deletes this object. Since it's only test_shell it probably doesn't matter | 257 // deletes this object. Since it's only test_shell it probably doesn't matter |
| 254 // that much. | 258 // that much. |
| 255 // ----------------------------------------------------------------------------- | 259 // ----------------------------------------------------------------------------- |
| 256 void WebWidgetHost::WindowDestroyed() { | 260 void WebWidgetHost::WindowDestroyed() { |
| 257 delete this; | 261 delete this; |
| 258 } | 262 } |
| OLD | NEW |