OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 18 matching lines...) Loading... |
29 namespace { | 29 namespace { |
30 | 30 |
31 DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) { | 31 DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) { |
32 return DesktopRect::MakeLTRB( | 32 return DesktopRect::MakeLTRB( |
33 static_cast<int>(floor(ns_rect.origin.x)), | 33 static_cast<int>(floor(ns_rect.origin.x)), |
34 static_cast<int>(floor(ns_rect.origin.y)), | 34 static_cast<int>(floor(ns_rect.origin.y)), |
35 static_cast<int>(ceil(ns_rect.origin.x + ns_rect.size.width)), | 35 static_cast<int>(ceil(ns_rect.origin.x + ns_rect.size.width)), |
36 static_cast<int>(ceil(ns_rect.origin.y + ns_rect.size.height))); | 36 static_cast<int>(ceil(ns_rect.origin.y + ns_rect.size.height))); |
37 } | 37 } |
38 | 38 |
39 DesktopRect JoinRects(const DesktopRect& a, | |
40 const DesktopRect& b) { | |
41 return DesktopRect::MakeLTRB( | |
42 std::min(a.left(), b.left()), | |
43 std::min(a.top(), b.top()), | |
44 std::max(a.right(), b.right()), | |
45 std::max(a.bottom(), b.bottom())); | |
46 } | |
47 | |
48 // Inverts the position of |rect| from bottom-up coordinates to top-down, | 39 // Inverts the position of |rect| from bottom-up coordinates to top-down, |
49 // relative to |bounds|. | 40 // relative to |bounds|. |
50 void InvertRectYOrigin(const DesktopRect& bounds, | 41 void InvertRectYOrigin(const DesktopRect& bounds, |
51 DesktopRect* rect) { | 42 DesktopRect* rect) { |
52 assert(bounds.top() == 0); | 43 assert(bounds.top() == 0); |
53 *rect = DesktopRect::MakeXYWH( | 44 *rect = DesktopRect::MakeXYWH( |
54 rect->left(), bounds.bottom() - rect->bottom(), | 45 rect->left(), bounds.bottom() - rect->bottom(), |
55 rect->width(), rect->height()); | 46 rect->width(), rect->height()); |
56 } | 47 } |
57 | 48 |
(...skipping 83 matching lines...) Loading... |
141 InvertRectYOrigin(primary_bounds, &display_config.pixel_bounds); | 132 InvertRectYOrigin(primary_bounds, &display_config.pixel_bounds); |
142 } | 133 } |
143 | 134 |
144 // Add the display to the configuration. | 135 // Add the display to the configuration. |
145 desktop_config.displays.push_back(display_config); | 136 desktop_config.displays.push_back(display_config); |
146 | 137 |
147 // Update the desktop bounds to account for this display, unless the current | 138 // Update the desktop bounds to account for this display, unless the current |
148 // display uses different DPI settings. | 139 // display uses different DPI settings. |
149 if (display_config.dip_to_pixel_scale == | 140 if (display_config.dip_to_pixel_scale == |
150 desktop_config.dip_to_pixel_scale) { | 141 desktop_config.dip_to_pixel_scale) { |
151 desktop_config.bounds = | 142 desktop_config.bounds.UnionWith(display_config.bounds); |
152 JoinRects(desktop_config.bounds, display_config.bounds); | 143 desktop_config.pixel_bounds.UnionWith(display_config.pixel_bounds); |
153 desktop_config.pixel_bounds = | |
154 JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds); | |
155 } | 144 } |
156 } | 145 } |
157 | 146 |
158 return desktop_config; | 147 return desktop_config; |
159 } | 148 } |
160 | 149 |
161 // For convenience of comparing MacDisplayConfigurations in | 150 // For convenience of comparing MacDisplayConfigurations in |
162 // MacDesktopConfiguration::Equals. | 151 // MacDesktopConfiguration::Equals. |
163 bool operator==(const MacDisplayConfiguration& left, | 152 bool operator==(const MacDisplayConfiguration& left, |
164 const MacDisplayConfiguration& right) { | 153 const MacDisplayConfiguration& right) { |
(...skipping 16 matching lines...) Loading... |
181 CGDirectDisplayID id) { | 170 CGDirectDisplayID id) { |
182 for (MacDisplayConfigurations::const_iterator it = displays.begin(); | 171 for (MacDisplayConfigurations::const_iterator it = displays.begin(); |
183 it != displays.end(); ++it) { | 172 it != displays.end(); ++it) { |
184 if (it->id == id) | 173 if (it->id == id) |
185 return &(*it); | 174 return &(*it); |
186 } | 175 } |
187 return NULL; | 176 return NULL; |
188 } | 177 } |
189 | 178 |
190 } // namespace webrtc | 179 } // namespace webrtc |
OLD | NEW |