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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 27147: Linux: server side backing stores (Closed)
Patch Set: ... Created 11 years, 10 months 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #include <cairo/cairo.h> 9 #include <cairo/cairo.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/common/x11_util.h"
13 #include "chrome/browser/renderer_host/backing_store.h" 14 #include "chrome/browser/renderer_host/backing_store.h"
14 #include "chrome/browser/renderer_host/render_widget_host.h" 15 #include "chrome/browser/renderer_host/render_widget_host.h"
15 #include "skia/ext/bitmap_platform_device_linux.h" 16 #include "skia/ext/bitmap_platform_device_linux.h"
16 #include "skia/ext/platform_device_linux.h" 17 #include "skia/ext/platform_device_linux.h"
17 #include "webkit/glue/webinputevent.h" 18 #include "webkit/glue/webinputevent.h"
18 19
19 namespace { 20 namespace {
20 21
21 // This class is a simple convenience wrapper for Gtk functions. It has only 22 // This class is a simple convenience wrapper for Gtk functions. It has only
22 // static methods. 23 // static methods.
23 class RenderWidgetHostViewGtkWidget { 24 class RenderWidgetHostViewGtkWidget {
24 public: 25 public:
25 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { 26 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) {
26 GtkWidget* widget = gtk_drawing_area_new(); 27 GtkWidget* widget = gtk_drawing_area_new();
28 gtk_widget_set_double_buffered(widget, FALSE);
27 29
28 gtk_widget_add_events(widget, GDK_EXPOSURE_MASK | 30 gtk_widget_add_events(widget, GDK_EXPOSURE_MASK |
29 GDK_POINTER_MOTION_MASK | 31 GDK_POINTER_MOTION_MASK |
30 GDK_BUTTON_PRESS_MASK | 32 GDK_BUTTON_PRESS_MASK |
31 GDK_BUTTON_RELEASE_MASK | 33 GDK_BUTTON_RELEASE_MASK |
32 GDK_KEY_PRESS_MASK | 34 GDK_KEY_PRESS_MASK |
33 GDK_KEY_RELEASE_MASK); 35 GDK_KEY_RELEASE_MASK);
34 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); 36 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
35 37
36 g_signal_connect(widget, "configure-event", 38 g_signal_connect(widget, "configure-event",
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 269 }
268 270
269 void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { 271 void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) {
270 if (tooltip_text.empty()) { 272 if (tooltip_text.empty()) {
271 gtk_widget_set_has_tooltip(view_, FALSE); 273 gtk_widget_set_has_tooltip(view_, FALSE);
272 } else { 274 } else {
273 gtk_widget_set_tooltip_text(view_, WideToUTF8(tooltip_text).c_str()); 275 gtk_widget_set_tooltip_text(view_, WideToUTF8(tooltip_text).c_str());
274 } 276 }
275 } 277 }
276 278
279 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore(
280 const gfx::Size& size) {
281 Display* display = x11_util::GetXDisplay();
282 void* visual = x11_util::GetVisualFromGtkWidget(view_);
283 XID parent_window = x11_util::GetX11WindowFromGtkWidget(view_);
284 bool use_shared_memory = x11_util::QuerySharedMemorySupport(display);
285 int depth = gtk_widget_get_visual(view_)->depth;
286
287 return new BackingStore(size, display, depth, visual, parent_window,
288 use_shared_memory);
289 }
290
277 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { 291 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) {
278 BackingStore* backing_store = host_->GetBackingStore(); 292 BackingStore* backing_store = host_->GetBackingStore();
279 293
280 if (backing_store) { 294 if (backing_store) {
281 GdkRectangle grect = {
282 damage_rect.x(),
283 damage_rect.y(),
284 damage_rect.width(),
285 damage_rect.height()
286 };
287
288 // Only render the widget if it is attached to a window; there's a short 295 // Only render the widget if it is attached to a window; there's a short
289 // period where this object isn't attached to a window but hasn't been 296 // period where this object isn't attached to a window but hasn't been
290 // Destroy()ed yet and it receives paint messages... 297 // Destroy()ed yet and it receives paint messages...
291 GdkWindow* window = view_->window; 298 GdkWindow* window = view_->window;
292 if (window) { 299 if (window)
293 gdk_window_begin_paint_rect(window, &grect); 300 backing_store->ShowRect(damage_rect);
294
295 skia::PlatformDeviceLinux &platdev =
296 backing_store->canvas()->getTopPlatformDevice();
297 skia::BitmapPlatformDeviceLinux* const bitdev =
298 static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev);
299 cairo_t* cairo_drawable = gdk_cairo_create(window);
300 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0);
301 cairo_paint(cairo_drawable);
302 cairo_destroy(cairo_drawable);
303 gdk_window_end_paint(window);
304 }
305 301
306 } else { 302 } else {
307 NOTIMPLEMENTED(); 303 NOTIMPLEMENTED();
308 } 304 }
309 } 305 }
310 306
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_gtk.h ('k') | chrome/browser/renderer_host/render_widget_host_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698