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

Side by Side Diff: ui/snapshot/snapshot_mac.mm

Issue 1777653002: Prepare ui/ module for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/task_runner.h" 13 #include "base/task_runner.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 bool GrabViewSnapshot(gfx::NativeView view, 19 bool GrabViewSnapshot(gfx::NativeView view,
20 std::vector<unsigned char>* png_representation, 20 std::vector<unsigned char>* png_representation,
21 const gfx::Rect& snapshot_bounds) { 21 const gfx::Rect& snapshot_bounds) {
22 NSWindow* window = [view window]; 22 NSWindow* window = [view window];
23 NSScreen* screen = [[NSScreen screens] firstObject]; 23 NSScreen* screen = [[NSScreen screens] firstObject];
24 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); 24 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
25 25
26 26
27 // Get the view bounds relative to the screen 27 // Get the view bounds relative to the screen
28 NSRect frame = [view convertRect:[view bounds] toView:nil]; 28 NSRect frame = [view convertRect:[view bounds] toView:nil];
29 frame.origin = [window convertBaseToScreen:frame.origin]; 29 frame.origin = [window convertRectToScreen:frame].origin;
Avi (use Gerrit) 2016/03/08 20:07:54 Just do frame = [window convertRectToScreen:frame
erikchen 2016/03/08 20:57:41 Done.
30 30
31 gfx::Rect view_bounds = gfx::Rect(NSRectToCGRect(frame)); 31 gfx::Rect view_bounds = gfx::Rect(NSRectToCGRect(frame));
32 32
33 // Flip window coordinates based on the primary screen. 33 // Flip window coordinates based on the primary screen.
34 view_bounds.set_y( 34 view_bounds.set_y(
35 screen_bounds.height() - view_bounds.y() - view_bounds.height()); 35 screen_bounds.height() - view_bounds.y() - view_bounds.height());
36 36
37 // Convert snapshot bounds relative to window into bounds relative to 37 // Convert snapshot bounds relative to window into bounds relative to
38 // screen. 38 // screen.
39 gfx::Rect screen_snapshot_bounds = snapshot_bounds; 39 gfx::Rect screen_snapshot_bounds = snapshot_bounds;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void GrabWindowSnapshotAsync( 95 void GrabWindowSnapshotAsync(
96 gfx::NativeWindow window, 96 gfx::NativeWindow window,
97 const gfx::Rect& source_rect, 97 const gfx::Rect& source_rect,
98 scoped_refptr<base::TaskRunner> background_task_runner, 98 scoped_refptr<base::TaskRunner> background_task_runner,
99 const GrabWindowSnapshotAsyncPNGCallback& callback) { 99 const GrabWindowSnapshotAsyncPNGCallback& callback) {
100 return GrabViewSnapshotAsync([[window contentView] superview], source_rect, 100 return GrabViewSnapshotAsync([[window contentView] superview], source_rect,
101 background_task_runner, callback); 101 background_task_runner, callback);
102 } 102 }
103 103
104 } // namespace ui 104 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698