OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); | 21 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); |
22 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame])); | 22 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame])); |
23 | 23 |
24 // Flip window coordinates based on the primary screen. | 24 // Flip window coordinates based on the primary screen. |
25 window_bounds.set_y( | 25 window_bounds.set_y( |
26 screen_bounds.height() - window_bounds.y() - window_bounds.height()); | 26 screen_bounds.height() - window_bounds.y() - window_bounds.height()); |
27 | 27 |
28 // Convert snapshot bounds relative to window into bounds relative to | 28 // Convert snapshot bounds relative to window into bounds relative to |
29 // screen. | 29 // screen. |
30 gfx::Rect screen_snapshot_bounds = gfx::Rect( | 30 gfx::Rect screen_snapshot_bounds = gfx::Rect( |
31 window_bounds.origin().Add(snapshot_bounds.origin()), | 31 window_bounds.origin().Add(snapshot_bounds.DistanceFromOrigin()), |
32 snapshot_bounds.size()); | 32 snapshot_bounds.size()); |
33 | 33 |
34 DCHECK_LE(screen_snapshot_bounds.right(), window_bounds.right()); | 34 DCHECK_LE(screen_snapshot_bounds.right(), window_bounds.right()); |
35 DCHECK_LE(screen_snapshot_bounds.bottom(), window_bounds.bottom()); | 35 DCHECK_LE(screen_snapshot_bounds.bottom(), window_bounds.bottom()); |
36 | 36 |
37 png_representation->clear(); | 37 png_representation->clear(); |
38 | 38 |
39 // Make sure to grab the "window frame" view so we get current tab + | 39 // Make sure to grab the "window frame" view so we get current tab + |
40 // tabstrip. | 40 // tabstrip. |
41 NSView* view = [[window contentView] superview]; | 41 NSView* view = [[window contentView] superview]; |
(...skipping 12 matching lines...) Expand all Loading... |
54 return false; | 54 return false; |
55 | 55 |
56 png_representation->assign(buf, buf + length); | 56 png_representation->assign(buf, buf + length); |
57 DCHECK(!png_representation->empty()); | 57 DCHECK(!png_representation->empty()); |
58 | 58 |
59 return true; | 59 return true; |
60 } | 60 } |
61 | 61 |
62 } // namespace internal | 62 } // namespace internal |
63 } // namespace chrome | 63 } // namespace chrome |
OLD | NEW |