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

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

Issue 8588058: Implementation of window_snapshot_aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nicer diff 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/window_snapshot/window_snapshot_aura.cc
diff --git a/chrome/browser/ui/window_snapshot/window_snapshot_aura.cc b/chrome/browser/ui/window_snapshot/window_snapshot_aura.cc
index 3a652136ec15054d37a47e04d344303925ecd94d..bbf0253c723d38cfc43ad62645e0c77b0ce8fe40 100644
--- a/chrome/browser/ui/window_snapshot/window_snapshot_aura.cc
+++ b/chrome/browser/ui/window_snapshot/window_snapshot_aura.cc
@@ -5,16 +5,38 @@
#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
#include "base/logging.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/aura/desktop.h"
+#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/rect.h"
namespace browser {
-bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
+bool GrabWindowSnapshot(gfx::NativeWindow window,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
- // TODO(saintlou): Stub for Aura.
- NOTIMPLEMENTED();
- return false;
+ ui::Compositor* compositor = aura::Desktop::GetInstance()->compositor();
sky 2011/11/18 19:03:44 Get the compositor from window's layer.
+
+ gfx::Rect desktop_snapshot_bounds = gfx::Rect(
+ snapshot_bounds.origin().Add(window->bounds().origin()),
+ snapshot_bounds.size());
+
+ DCHECK_LE(desktop_snapshot_bounds.right() , compositor->size().width());
+ DCHECK_LE(desktop_snapshot_bounds.bottom(), compositor->size().height());
+
+ SkBitmap bitmap;
+ if (!compositor->ReadPixels(&bitmap, desktop_snapshot_bounds))
sky 2011/11/18 19:03:44 I believe the coordinates passed to the compositor
jonathan.backer 2011/11/18 19:37:38 Are you missing a file? or is this based off of an
+ return false;
+
+ unsigned char* pixels = reinterpret_cast<unsigned char*>(bitmap.getPixels());
+
+ gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA,
+ snapshot_bounds.size(),
+ bitmap.rowBytes(), true,
+ std::vector<gfx::PNGCodec::Comment>(),
+ png_representation);
+ return true;
}
} // namespace browser
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698