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

Side by Side Diff: chrome/browser/ui/window_snapshot/window_snapshot_aura.cc

Issue 9630002: Ash: Remove compact window mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OpaqueBrowserFrameView, MultipleWindowIndicatorButton Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shell.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
11 #include "ui/gfx/codec/png_codec.h" 10 #include "ui/gfx/codec/png_codec.h"
12 #include "ui/gfx/compositor/compositor.h" 11 #include "ui/gfx/compositor/compositor.h"
13 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
14 13
15 namespace browser { 14 namespace browser {
16 15
17 bool GrabWindowSnapshot(gfx::NativeWindow window, 16 bool GrabWindowSnapshot(gfx::NativeWindow window,
18 std::vector<unsigned char>* png_representation, 17 std::vector<unsigned char>* png_representation,
19 const gfx::Rect& snapshot_bounds) { 18 const gfx::Rect& snapshot_bounds) {
20 ui::Compositor* compositor = window->layer()->GetCompositor(); 19 ui::Compositor* compositor = window->layer()->GetCompositor();
21 20
22 gfx::Rect read_pixels_bounds = snapshot_bounds; 21 gfx::Rect read_pixels_bounds = snapshot_bounds;
23 22
24 // When not in compact mode we must take into account the window's position on 23 // When not in compact mode we must take into account the window's position on
25 // the desktop. 24 // the desktop.
26 if (!ash::Shell::GetInstance()->IsWindowModeCompact()) 25 read_pixels_bounds.set_origin(
27 read_pixels_bounds.set_origin( 26 snapshot_bounds.origin().Add(window->bounds().origin()));
28 snapshot_bounds.origin().Add(window->bounds().origin()));
29 27
30 DCHECK_GE(compositor->size().width(), read_pixels_bounds.right()); 28 DCHECK_GE(compositor->size().width(), read_pixels_bounds.right());
31 DCHECK_GE(compositor->size().height(), read_pixels_bounds.bottom()); 29 DCHECK_GE(compositor->size().height(), read_pixels_bounds.bottom());
32 DCHECK_LE(0, read_pixels_bounds.x()); 30 DCHECK_LE(0, read_pixels_bounds.x());
33 DCHECK_LE(0, read_pixels_bounds.y()); 31 DCHECK_LE(0, read_pixels_bounds.y());
34 32
35 SkBitmap bitmap; 33 SkBitmap bitmap;
36 if (!compositor->ReadPixels(&bitmap, read_pixels_bounds)) 34 if (!compositor->ReadPixels(&bitmap, read_pixels_bounds))
37 return false; 35 return false;
38 36
39 unsigned char* pixels = reinterpret_cast<unsigned char*>(bitmap.getPixels()); 37 unsigned char* pixels = reinterpret_cast<unsigned char*>(bitmap.getPixels());
40 38
41 gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA, 39 gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA,
42 snapshot_bounds.size(), 40 snapshot_bounds.size(),
43 bitmap.rowBytes(), true, 41 bitmap.rowBytes(), true,
44 std::vector<gfx::PNGCodec::Comment>(), 42 std::vector<gfx::PNGCodec::Comment>(),
45 png_representation); 43 png_representation);
46 return true; 44 return true;
47 } 45 }
48 46
49 } // namespace browser 47 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698