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

Side by Side Diff: webrtc/modules/desktop_capture/mac/desktop_configuration.mm

Issue 2845213002: DesktopRect::UnionWith() to extend current rect to cover the input rect (Closed)
Patch Set: Sync latest changes Created 3 years, 7 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 /* 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...) Expand all
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...) Expand 10 before | Expand all | Expand 10 after
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...) Expand all
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
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/desktop_geometry.cc ('k') | webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698