Chromium Code Reviews| 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 4f42775ff14aa9e8c40e44b6a4b72b2f86672dab..97e8c0d68b6f972bdcc9bfb4b06913bf8a7fef3c 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::GrabSnapshot( |
| + 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/15 23:35:08
I don't think it's safe to assume the image format
Jun Mukai
2012/05/16 18:07:43
Wrote a simple detector. Thanks for pointing.
|
| + 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_); |