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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/aura/desktop.h"
10 #include "ui/gfx/codec/png_codec.h"
11 #include "ui/gfx/compositor/compositor.h"
8 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
9 13
10 namespace browser { 14 namespace browser {
11 15
12 bool GrabWindowSnapshot(gfx::NativeWindow window_handle, 16 bool GrabWindowSnapshot(gfx::NativeWindow window,
13 std::vector<unsigned char>* png_representation, 17 std::vector<unsigned char>* png_representation,
14 const gfx::Rect& snapshot_bounds) { 18 const gfx::Rect& snapshot_bounds) {
15 // TODO(saintlou): Stub for Aura. 19 ui::Compositor* compositor = aura::Desktop::GetInstance()->compositor();
sky 2011/11/18 19:03:44 Get the compositor from window's layer.
16 NOTIMPLEMENTED(); 20
17 return false; 21 gfx::Rect desktop_snapshot_bounds = gfx::Rect(
22 snapshot_bounds.origin().Add(window->bounds().origin()),
23 snapshot_bounds.size());
24
25 DCHECK_LE(desktop_snapshot_bounds.right() , compositor->size().width());
26 DCHECK_LE(desktop_snapshot_bounds.bottom(), compositor->size().height());
27
28 SkBitmap bitmap;
29 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
30 return false;
31
32 unsigned char* pixels = reinterpret_cast<unsigned char*>(bitmap.getPixels());
33
34 gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA,
35 snapshot_bounds.size(),
36 bitmap.rowBytes(), true,
37 std::vector<gfx::PNGCodec::Comment>(),
38 png_representation);
39 return true;
18 } 40 }
19 41
20 } // namespace browser 42 } // namespace browser
OLDNEW
« 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