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

Unified Diff: media/video/capture/screen/mac/desktop_configuration.mm

Issue 12221103: Fix ScreenCapturerMac handling of secondary configurations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve comments. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/screen/mac/desktop_configuration.mm
diff --git a/media/video/capture/screen/mac/desktop_configuration.mm b/media/video/capture/screen/mac/desktop_configuration.mm
index 064c4efa77e1871836fbd620f3171f955c14e387..fbece4850b505b78d1a7abda19c192d4a65ec375 100644
--- a/media/video/capture/screen/mac/desktop_configuration.mm
+++ b/media/video/capture/screen/mac/desktop_configuration.mm
@@ -21,20 +21,23 @@
namespace media {
-MacDisplayConfiguration::MacDisplayConfiguration()
- : id(0),
- bounds(SkIRect::MakeEmpty()),
- pixel_bounds(SkIRect::MakeEmpty()),
- dip_to_pixel_scale(1.0f) {
-}
+namespace {
-static SkIRect NSRectToSkIRect(const NSRect& ns_rect) {
+SkIRect NSRectToSkIRect(const NSRect& ns_rect) {
SkIRect result;
gfx::CGRectToSkRect(NSRectToCGRect(ns_rect)).roundOut(&result);
return result;
}
-static MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
+// Inverts the position of |rect| from bottom-up coordinates to top-down,
+// relative to |bounds|.
+void InvertRectYOrigin(const SkIRect& bounds, SkIRect* rect) {
+ DCHECK_EQ(0, bounds.top());
+ rect->setXYWH(rect->x(), bounds.bottom() - rect->bottom(),
+ rect->width(), rect->height());
+}
+
+MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
MacDisplayConfiguration display_config;
// Fetch the NSScreenNumber, which is also the CGDirectDisplayID.
@@ -60,17 +63,26 @@ static MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
return display_config;
}
+} // namespace
+
+MacDisplayConfiguration::MacDisplayConfiguration()
+ : id(0),
+ bounds(SkIRect::MakeEmpty()),
+ pixel_bounds(SkIRect::MakeEmpty()),
+ dip_to_pixel_scale(1.0f) {
+}
+
MacDesktopConfiguration::MacDesktopConfiguration()
- : bounds(SkIRect::MakeEmpty()),
- pixel_bounds(SkIRect::MakeEmpty()),
- dip_to_pixel_scale(1.0f) {
+ : bounds(SkIRect::MakeEmpty()),
+ pixel_bounds(SkIRect::MakeEmpty()),
+ dip_to_pixel_scale(1.0f) {
}
MacDesktopConfiguration::~MacDesktopConfiguration() {
}
// static
-MacDesktopConfiguration MacDesktopConfiguration::GetCurrent() {
+MacDesktopConfiguration MacDesktopConfiguration::GetCurrent(Origin origin) {
MacDesktopConfiguration desktop_config;
NSArray* screens = [NSScreen screens];
@@ -92,6 +104,16 @@ MacDesktopConfiguration MacDesktopConfiguration::GetCurrent() {
continue;
}
+ // Cocoa uses bottom-up coordinates, so if the caller wants top-down then
+ // we need to invert the positions of secondary monitors relative to the
+ // primary one (the primary monitor's position is (0,0) in both systems).
+ if (i > 0 && origin == TopLeftOrigin) {
+ InvertRectYOrigin(desktop_config.displays[0].bounds,
+ &display_config.bounds);
+ InvertRectYOrigin(desktop_config.displays[0].pixel_bounds,
+ &display_config.pixel_bounds);
+ }
+
// Add the display to the configuration.
desktop_config.displays.push_back(display_config);
« no previous file with comments | « media/video/capture/screen/mac/desktop_configuration.h ('k') | media/video/capture/screen/screen_capturer_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698