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

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: More compile errors. 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
« no previous file with comments | « ui/gfx/screen_mac.mm ('k') | ui/views/cocoa/bridged_content_view.mm » ('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 "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/mac/sdk_forward_declarations.h"
13 #include "base/task_runner.h" 14 #include "base/task_runner.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 bool GrabViewSnapshot(gfx::NativeView view, 20 bool GrabViewSnapshot(gfx::NativeView view,
20 std::vector<unsigned char>* png_representation, 21 std::vector<unsigned char>* png_representation,
21 const gfx::Rect& snapshot_bounds) { 22 const gfx::Rect& snapshot_bounds) {
22 NSWindow* window = [view window]; 23 NSWindow* window = [view window];
23 NSScreen* screen = [[NSScreen screens] firstObject]; 24 NSScreen* screen = [[NSScreen screens] firstObject];
24 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); 25 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
25 26
26 27
27 // Get the view bounds relative to the screen 28 // Get the view bounds relative to the screen
28 NSRect frame = [view convertRect:[view bounds] toView:nil]; 29 NSRect frame = [view convertRect:[view bounds] toView:nil];
29 frame.origin = [window convertBaseToScreen:frame.origin]; 30 frame = [window convertRectToScreen:frame];
30 31
31 gfx::Rect view_bounds = gfx::Rect(NSRectToCGRect(frame)); 32 gfx::Rect view_bounds = gfx::Rect(NSRectToCGRect(frame));
32 33
33 // Flip window coordinates based on the primary screen. 34 // Flip window coordinates based on the primary screen.
34 view_bounds.set_y( 35 view_bounds.set_y(
35 screen_bounds.height() - view_bounds.y() - view_bounds.height()); 36 screen_bounds.height() - view_bounds.y() - view_bounds.height());
36 37
37 // Convert snapshot bounds relative to window into bounds relative to 38 // Convert snapshot bounds relative to window into bounds relative to
38 // screen. 39 // screen.
39 gfx::Rect screen_snapshot_bounds = snapshot_bounds; 40 gfx::Rect screen_snapshot_bounds = snapshot_bounds;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void GrabWindowSnapshotAsync( 96 void GrabWindowSnapshotAsync(
96 gfx::NativeWindow window, 97 gfx::NativeWindow window,
97 const gfx::Rect& source_rect, 98 const gfx::Rect& source_rect,
98 scoped_refptr<base::TaskRunner> background_task_runner, 99 scoped_refptr<base::TaskRunner> background_task_runner,
99 const GrabWindowSnapshotAsyncPNGCallback& callback) { 100 const GrabWindowSnapshotAsyncPNGCallback& callback) {
100 return GrabViewSnapshotAsync([[window contentView] superview], source_rect, 101 return GrabViewSnapshotAsync([[window contentView] superview], source_rect,
101 background_task_runner, callback); 102 background_task_runner, callback);
102 } 103 }
103 104
104 } // namespace ui 105 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/screen_mac.mm ('k') | ui/views/cocoa/bridged_content_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698