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

Side by Side Diff: chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc

Issue 8890027: GTK: Remove most calls to widget->window and replace with accessor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/window_snapshot/window_snapshot.h" 5 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
6 6
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "ui/base/x/x11_util.h" 11 #include "ui/base/x/x11_util.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 namespace browser { 14 namespace browser {
15 15
16 static cairo_status_t SnapshotCallback( 16 static cairo_status_t SnapshotCallback(
17 void *closure, const unsigned char *data, unsigned int length) { 17 void *closure, const unsigned char *data, unsigned int length) {
18 std::vector<unsigned char>* png_representation = 18 std::vector<unsigned char>* png_representation =
19 static_cast<std::vector<unsigned char>*>(closure); 19 static_cast<std::vector<unsigned char>*>(closure);
20 20
21 size_t old_size = png_representation->size(); 21 size_t old_size = png_representation->size();
22 png_representation->resize(old_size + length); 22 png_representation->resize(old_size + length);
23 memcpy(&(*png_representation)[old_size], data, length); 23 memcpy(&(*png_representation)[old_size], data, length);
24 return CAIRO_STATUS_SUCCESS; 24 return CAIRO_STATUS_SUCCESS;
25 } 25 }
26 26
27 bool GrabWindowSnapshot(gfx::NativeWindow window_handle, 27 bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
28 std::vector<unsigned char>* png_representation, 28 std::vector<unsigned char>* png_representation,
29 const gfx::Rect& snapshot_bounds) { 29 const gfx::Rect& snapshot_bounds) {
30 GdkWindow* gdk_window = GTK_WIDGET(window_handle)->window; 30 GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_handle));
31 Display* display = GDK_WINDOW_XDISPLAY(gdk_window); 31 Display* display = GDK_WINDOW_XDISPLAY(gdk_window);
32 XID win = GDK_WINDOW_XID(gdk_window); 32 XID win = GDK_WINDOW_XID(gdk_window);
33 33
34 gfx::Rect window_bounds; 34 gfx::Rect window_bounds;
35 if (ui::GetWindowRect(win, &window_bounds) == 0) { 35 if (ui::GetWindowRect(win, &window_bounds) == 0) {
36 LOG(ERROR) << "Couldn't get window bounds"; 36 LOG(ERROR) << "Couldn't get window bounds";
37 return false; 37 return false;
38 } 38 }
39 39
40 DCHECK_LE(snapshot_bounds.right(), window_bounds.width()); 40 DCHECK_LE(snapshot_bounds.right(), window_bounds.width());
(...skipping 23 matching lines...) Expand all
64 return false; 64 return false;
65 } 65 }
66 cairo_surface_write_to_png_stream( 66 cairo_surface_write_to_png_stream(
67 surface, SnapshotCallback, png_representation); 67 surface, SnapshotCallback, png_representation);
68 cairo_surface_destroy(surface); 68 cairo_surface_destroy(surface);
69 69
70 return true; 70 return true;
71 } 71 }
72 72
73 } // namespace browser 73 } // namespace browser
OLDNEW
« chrome/browser/ui/gtk/gtk_util.cc ('K') | « chrome/browser/ui/panels/panel_browser_window_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698