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

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

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 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 fbece4850b505b78d1a7abda19c192d4a65ec375..53b8e1377952e4de087b4e1bffed9828f0406b0b 100644
--- a/media/video/capture/screen/mac/desktop_configuration.mm
+++ b/media/video/capture/screen/mac/desktop_configuration.mm
@@ -4,10 +4,11 @@
#include "media/video/capture/screen/mac/desktop_configuration.h"
+#include <math.h>
+#include <algorithm>
#include <Cocoa/Cocoa.h>
#include "base/logging.h"
-#include "skia/ext/skia_utils_mac.h"
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@@ -23,18 +24,31 @@ namespace media {
namespace {
-SkIRect NSRectToSkIRect(const NSRect& ns_rect) {
- SkIRect result;
- gfx::CGRectToSkRect(NSRectToCGRect(ns_rect)).roundOut(&result);
- return result;
+webrtc::DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) {
+ return webrtc::DesktopRect::MakeLTRB(
+ static_cast<int>(floor(ns_rect.origin.x)),
+ static_cast<int>(floor(ns_rect.origin.y)),
+ static_cast<int>(ceil(ns_rect.origin.x + ns_rect.size.width)),
+ static_cast<int>(ceil(ns_rect.origin.y + ns_rect.size.height)));
+}
+
+webrtc::DesktopRect JoinRects(const webrtc::DesktopRect& a,
+ const webrtc::DesktopRect& b) {
+ return webrtc::DesktopRect::MakeLTRB(
+ std::min(a.left(), b.left()),
+ std::min(a.top(), b.top()),
+ std::max(a.right(), b.right()),
+ std::max(a.bottom(), b.bottom()));
}
// Inverts the position of |rect| from bottom-up coordinates to top-down,
// relative to |bounds|.
-void InvertRectYOrigin(const SkIRect& bounds, SkIRect* rect) {
+void InvertRectYOrigin(const webrtc::DesktopRect& bounds,
+ webrtc::DesktopRect* rect) {
DCHECK_EQ(0, bounds.top());
- rect->setXYWH(rect->x(), bounds.bottom() - rect->bottom(),
- rect->width(), rect->height());
+ *rect = webrtc::DesktopRect::MakeXYWH(
+ rect->left(), bounds.bottom() - rect->bottom(),
+ rect->width(), rect->height());
}
MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
@@ -47,7 +61,7 @@ MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
// Determine the display's logical & physical dimensions.
NSRect ns_bounds = [screen frame];
- display_config.bounds = NSRectToSkIRect(ns_bounds);
+ display_config.bounds = NSRectToDesktopRect(ns_bounds);
// If the host is running Mac OS X 10.7+ or later, query the scaling factor
// between logical and physical (aka "backing") pixels, otherwise assume 1:1.
@@ -55,7 +69,7 @@ MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
[screen respondsToSelector:@selector(convertRectToBacking:)]) {
display_config.dip_to_pixel_scale = [screen backingScaleFactor];
NSRect ns_pixel_bounds = [screen convertRectToBacking: ns_bounds];
- display_config.pixel_bounds = NSRectToSkIRect(ns_pixel_bounds);
+ display_config.pixel_bounds = NSRectToDesktopRect(ns_pixel_bounds);
} else {
display_config.pixel_bounds = display_config.bounds;
}
@@ -67,15 +81,11 @@ MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
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) {
+ : dip_to_pixel_scale(1.0f) {
}
MacDesktopConfiguration::~MacDesktopConfiguration() {
@@ -91,8 +101,8 @@ MacDesktopConfiguration MacDesktopConfiguration::GetCurrent(Origin origin) {
// Iterator over the monitors, adding the primary monitor and monitors whose
// DPI match that of the primary monitor.
for (NSUInteger i = 0; i < [screens count]; ++i) {
- MacDisplayConfiguration display_config
- = GetConfigurationForScreen([screens objectAtIndex: i]);
+ MacDisplayConfiguration display_config =
+ GetConfigurationForScreen([screens objectAtIndex: i]);
// Handling mixed-DPI is hard, so we only return displays that match the
// "primary" display's DPI. The primary display is always the first in the
@@ -118,8 +128,10 @@ MacDesktopConfiguration MacDesktopConfiguration::GetCurrent(Origin origin) {
desktop_config.displays.push_back(display_config);
// Update the desktop bounds to account for this display.
- desktop_config.bounds.join(display_config.bounds);
- desktop_config.pixel_bounds.join(display_config.pixel_bounds);
+ desktop_config.bounds =
+ JoinRects(desktop_config.bounds, display_config.bounds);
+ desktop_config.pixel_bounds =
+ JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds);
}
return desktop_config;
« no previous file with comments | « media/video/capture/screen/mac/desktop_configuration.h ('k') | media/video/capture/screen/mouse_cursor_shape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698