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

Side by Side Diff: ui/snapshot/snapshot_aura.cc

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
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 "ui/snapshot/snapshot.h" 5 #include "ui/snapshot/snapshot.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/safe_numerics.h" 8 #include "base/safe_numerics.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "third_party/skia/include/core/SkPixelRef.h" 10 #include "third_party/skia/include/core/SkPixelRef.h"
(...skipping 22 matching lines...) Expand all
33 bool GrabWindowSnapshot(gfx::NativeWindow window, 33 bool GrabWindowSnapshot(gfx::NativeWindow window,
34 std::vector<unsigned char>* png_representation, 34 std::vector<unsigned char>* png_representation,
35 const gfx::Rect& snapshot_bounds) { 35 const gfx::Rect& snapshot_bounds) {
36 ui::Compositor* compositor = window->layer()->GetCompositor(); 36 ui::Compositor* compositor = window->layer()->GetCompositor();
37 37
38 gfx::RectF read_pixels_bounds = snapshot_bounds; 38 gfx::RectF read_pixels_bounds = snapshot_bounds;
39 39
40 // We must take into account the window's position on the desktop. 40 // We must take into account the window's position on the desktop.
41 read_pixels_bounds.Offset( 41 read_pixels_bounds.Offset(
42 window->GetBoundsInRootWindow().origin().OffsetFromOrigin()); 42 window->GetBoundsInRootWindow().origin().OffsetFromOrigin());
43 aura::RootWindow* root_window = window->GetRootWindow(); 43 aura::WindowEventDispatcher* dispatcher = window->GetDispatcher();
44 if (root_window) 44 if (dispatcher)
45 root_window->GetRootTransform().TransformRect(&read_pixels_bounds); 45 dispatcher->GetRootTransform().TransformRect(&read_pixels_bounds);
46 46
47 gfx::Rect read_pixels_bounds_in_pixel = 47 gfx::Rect read_pixels_bounds_in_pixel =
48 gfx::ToEnclosingRect(read_pixels_bounds); 48 gfx::ToEnclosingRect(read_pixels_bounds);
49 49
50 // Sometimes (i.e. when using Aero on Windows) the compositor's size is 50 // Sometimes (i.e. when using Aero on Windows) the compositor's size is
51 // smaller than the window bounds. So trim appropriately. 51 // smaller than the window bounds. So trim appropriately.
52 read_pixels_bounds_in_pixel.Intersect(gfx::Rect(compositor->size())); 52 read_pixels_bounds_in_pixel.Intersect(gfx::Rect(compositor->size()));
53 53
54 DCHECK_LE(0, read_pixels_bounds.x()); 54 DCHECK_LE(0, read_pixels_bounds.x());
55 DCHECK_LE(0, read_pixels_bounds.y()); 55 DCHECK_LE(0, read_pixels_bounds.y());
(...skipping 25 matching lines...) Expand all
81 bitmap.pixelRef()->pixels()); 81 bitmap.pixelRef()->pixels());
82 gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA, 82 gfx::PNGCodec::Encode(pixels, gfx::PNGCodec::FORMAT_BGRA,
83 gfx::Size(bitmap.width(), bitmap.height()), 83 gfx::Size(bitmap.width(), bitmap.height()),
84 base::checked_numeric_cast<int>(bitmap.rowBytes()), 84 base::checked_numeric_cast<int>(bitmap.rowBytes()),
85 true, std::vector<gfx::PNGCodec::Comment>(), 85 true, std::vector<gfx::PNGCodec::Comment>(),
86 png_representation); 86 png_representation);
87 return true; 87 return true;
88 } 88 }
89 89
90 } // namespace ui 90 } // namespace ui
OLDNEW
« no previous file with comments | « ui/shell_dialogs/select_file_dialog_win.cc ('k') | ui/views/controls/menu/display_change_listener_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698