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

Unified Diff: ui/aura/root_window_host_linux.cc

Issue 10386124: Introduce XGetImage() for GrabWindowSnapshot() in ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/root_window_host_linux.cc
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index d9b9cd38d25b160dc9f1d0fcec3653705cb76afc..5b9952ff4a36803854cbbf64928b051fce112660 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -6,6 +6,7 @@
#include <X11/Xatom.h>
#include <X11/Xcursor/Xcursor.h>
+#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/extensions/XInput2.h>
#include <X11/extensions/Xfixes.h>
@@ -29,6 +30,7 @@
#include "ui/base/view_prop.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/layer.h"
+#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
using std::max;
@@ -804,6 +806,25 @@ void RootWindowHostLinux::SetFocusWhenShown(bool focus_when_shown) {
}
}
+bool RootWindowHostLinux::GrabWindowSnapshot(
+ std::vector<unsigned char>* png_representation,
+ const gfx::Rect& snapshot_bounds) {
+ XImage* image = XGetImage(
+ xdisplay_, xwindow_,
+ snapshot_bounds.x(), snapshot_bounds.y(),
+ snapshot_bounds.width(), snapshot_bounds.height(),
+ AllPlanes, ZPixmap);
+
+ unsigned char* data = reinterpret_cast<unsigned char*>(image->data);
+ gfx::PNGCodec::Encode(data, gfx::PNGCodec::FORMAT_BGRA,
Daniel Erat 2012/05/14 23:17:40 I don't love the inflexibility of doing PNG encodi
Jun Mukai 2012/05/15 22:39:24 That's why original browser::GrabWindowSnapshot re
+ snapshot_bounds.size(),
+ image->width * image->bits_per_pixel / 8,
+ true, std::vector<gfx::PNGCodec::Comment>(),
+ png_representation);
+ XFree(image);
+ return true;
+}
+
void RootWindowHostLinux::PostNativeEvent(
const base::NativeEvent& native_event) {
DCHECK(xwindow_);

Powered by Google App Engine
This is Rietveld 408576698