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

Unified Diff: chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc

Issue 8523022: Change snasphotting API to take in a bounds Rect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/ui/window_snapshot/window_snapshot_gtk.cc
diff --git a/chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc b/chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc
index 4507996ad5264b6ab7102f84d2648e8b98d2de3a..a0eb05a2853b1a9795c3a2964567dcead04f2b7e 100644
--- a/chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc
+++ b/chrome/browser/ui/window_snapshot/window_snapshot_gtk.cc
@@ -25,7 +25,8 @@ static cairo_status_t SnapshotCallback(
}
gfx::Rect GrabWindowSnapshot(gfx::NativeWindow gtk_window,
- std::vector<unsigned char>* png_representation) {
+ std::vector<unsigned char>* png_representation,
+ gfx::Rect snapshot_bounds) {
GdkWindow* gdk_window = GTK_WIDGET(gtk_window)->window;
Display* display = GDK_WINDOW_XDISPLAY(gdk_window);
XID win = GDK_WINDOW_XID(gdk_window);
@@ -34,8 +35,17 @@ gfx::Rect GrabWindowSnapshot(gfx::NativeWindow gtk_window,
LOG(ERROR) << "Couldn't get window attributes";
return gfx::Rect();
}
+
+ if (snapshot_bounds.IsEmpty()) {
+ snapshot_bounds = gfx::Rect(0, 0, attr.width, attr.height);
+ }
+
+ DCHECK(snapshot_bounds.right() <= attr.width);
+ DCHECK(snapshot_bounds.bottom() <= attr.height);
+
XImage* image = XGetImage(
- display, win, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap);
+ display, win, snapshot_bounds.x(), snapshot_bounds.y(),
+ snapshot_bounds.width(), snapshot_bounds.height(), AllPlanes, ZPixmap);
if (!image) {
LOG(ERROR) << "Couldn't get image";
return gfx::Rect();

Powered by Google App Engine
This is Rietveld 408576698