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

Side by Side Diff: media/video/capture/screen/mac/desktop_configuration.mm

Issue 15870009: mac: Move more 10.7 api stuff into sdk_forward_declarations.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "media/video/capture/screen/mac/desktop_configuration.h" 5 #include "media/video/capture/screen/mac/desktop_configuration.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <Cocoa/Cocoa.h> 9 #include <Cocoa/Cocoa.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12 #include "base/mac/sdk_forward_declarations.h"
13 #if !defined(MAC_OS_X_VERSION_10_7) || \
14 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
15
16 @interface NSScreen (LionAPI)
17 - (CGFloat)backingScaleFactor;
18 - (NSRect)convertRectToBacking:(NSRect)aRect;
19 @end
20
21 #endif // 10.7
22 13
23 namespace media { 14 namespace media {
24 15
25 namespace { 16 namespace {
26 17
27 webrtc::DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) { 18 webrtc::DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) {
28 return webrtc::DesktopRect::MakeLTRB( 19 return webrtc::DesktopRect::MakeLTRB(
29 static_cast<int>(floor(ns_rect.origin.x)), 20 static_cast<int>(floor(ns_rect.origin.x)),
30 static_cast<int>(floor(ns_rect.origin.y)), 21 static_cast<int>(floor(ns_rect.origin.y)),
31 static_cast<int>(ceil(ns_rect.origin.x + ns_rect.size.width)), 22 static_cast<int>(ceil(ns_rect.origin.x + ns_rect.size.width)),
(...skipping 29 matching lines...) Expand all
61 52
62 // Determine the display's logical & physical dimensions. 53 // Determine the display's logical & physical dimensions.
63 NSRect ns_bounds = [screen frame]; 54 NSRect ns_bounds = [screen frame];
64 display_config.bounds = NSRectToDesktopRect(ns_bounds); 55 display_config.bounds = NSRectToDesktopRect(ns_bounds);
65 56
66 // If the host is running Mac OS X 10.7+ or later, query the scaling factor 57 // If the host is running Mac OS X 10.7+ or later, query the scaling factor
67 // between logical and physical (aka "backing") pixels, otherwise assume 1:1. 58 // between logical and physical (aka "backing") pixels, otherwise assume 1:1.
68 if ([screen respondsToSelector:@selector(backingScaleFactor)] && 59 if ([screen respondsToSelector:@selector(backingScaleFactor)] &&
69 [screen respondsToSelector:@selector(convertRectToBacking:)]) { 60 [screen respondsToSelector:@selector(convertRectToBacking:)]) {
70 display_config.dip_to_pixel_scale = [screen backingScaleFactor]; 61 display_config.dip_to_pixel_scale = [screen backingScaleFactor];
71 NSRect ns_pixel_bounds = [screen convertRectToBacking: ns_bounds]; 62 NSRect ns_pixel_bounds = [screen convertRectToBacking:ns_bounds];
72 display_config.pixel_bounds = NSRectToDesktopRect(ns_pixel_bounds); 63 display_config.pixel_bounds = NSRectToDesktopRect(ns_pixel_bounds);
73 } else { 64 } else {
74 display_config.pixel_bounds = display_config.bounds; 65 display_config.pixel_bounds = display_config.bounds;
75 } 66 }
76 67
77 return display_config; 68 return display_config;
78 } 69 }
79 70
80 } // namespace 71 } // namespace
81 72
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 desktop_config.bounds = 122 desktop_config.bounds =
132 JoinRects(desktop_config.bounds, display_config.bounds); 123 JoinRects(desktop_config.bounds, display_config.bounds);
133 desktop_config.pixel_bounds = 124 desktop_config.pixel_bounds =
134 JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds); 125 JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds);
135 } 126 }
136 127
137 return desktop_config; 128 return desktop_config;
138 } 129 }
139 130
140 } // namespace media 131 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698