summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 17:50:37 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 17:50:37 +0000
commit6a1bfd16c4dc9732d52b5857147623a7415a3096 (patch)
tree36401a5e3c5b36edf5fd17d1e921cdfa54eb6b34
parent9e6d3c8f5bf112ef84cee2dab3206af24348648b (diff)
downloadchromium_src-6a1bfd16c4dc9732d52b5857147623a7415a3096.zip
chromium_src-6a1bfd16c4dc9732d52b5857147623a7415a3096.tar.gz
chromium_src-6a1bfd16c4dc9732d52b5857147623a7415a3096.tar.bz2
Revert 178318 - broke mac compile http://build.chromium.org/p/chromium.mac/builders/Mac%20Builder%20%28dbg%29/builds/36273
> Add support for high-DPI hosts under Mac OS X. > > - Moves enumeration of display configuration(s) to helper classes, which fetch each display's logical and device-native resolutions. > - Updates VideoFrameCapturerMac and EventExecutorMac to use the helper. > > BUG=135081 > > Review URL: https://chromiumcodereview.appspot.com/11665012 TBR=wez@chromium.org Review URL: https://codereview.chromium.org/12052043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178324 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/capturer/mac/desktop_configuration.h69
-rw-r--r--remoting/capturer/mac/desktop_configuration.mm99
-rw-r--r--remoting/capturer/video_frame_capturer_mac.mm130
-rw-r--r--remoting/host/event_executor_mac.cc52
-rw-r--r--remoting/remoting.gyp2
-rw-r--r--skia/ext/skia_utils_mac.h2
6 files changed, 95 insertions, 259 deletions
diff --git a/remoting/capturer/mac/desktop_configuration.h b/remoting/capturer/mac/desktop_configuration.h
deleted file mode 100644
index 2e76f8d..0000000
--- a/remoting/capturer/mac/desktop_configuration.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_
-#define REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_
-
-#include <ApplicationServices/ApplicationServices.h>
-#include <Carbon/Carbon.h>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "third_party/skia/include/core/SkPoint.h"
-#include "third_party/skia/include/core/SkRect.h"
-
-namespace remoting {
-
-// Describes the configuration of a specific display.
-struct MacDisplayConfiguration {
- MacDisplayConfiguration();
-
- // Returns the current configuration of the specified display.
- static MacDisplayConfiguration ForDisplay(CGDirectDisplayID display_id);
-
- // Cocoa identifier for this display.
- CGDirectDisplayID id;
-
- // Bounds of this display in logical (72dpi) coordinates.
- SkIRect logical_bounds;
-
- // Bounds of the desktop in device resolution (i.e. physical) pixels.
- SkIRect pixel_bounds;
-
- // Resolution of the desktop in Dots-Per-Inch.
- SkIPoint dpi;
-
- // Scale factor from logical to pixel units.
- float logical_to_pixel_scale;
-};
-
-typedef std::vector<MacDisplayConfiguration> MacDisplayConfigurations;
-
-// Describes the configuration of the whole desktop.
-struct MacDesktopConfiguration {
- MacDesktopConfiguration();
- ~MacDesktopConfiguration();
-
- // Returns the current configuration of the desktop.
- static MacDesktopConfiguration GetCurrent();
-
- // Bounds of the desktop in logical (72dpi) coordinates.
- SkIRect logical_bounds;
-
- // Bounds of the desktop in device resolution (i.e. physical) pixels.
- SkIRect pixel_bounds;
-
- // Resolution of the desktop in Dots-Per-Inch.
- SkIPoint dpi;
-
- // Scale factor from logical to pixel units.
- float logical_to_pixel_scale;
-
- // Configurations of the displays making up the desktop area.
- MacDisplayConfigurations displays;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_
diff --git a/remoting/capturer/mac/desktop_configuration.mm b/remoting/capturer/mac/desktop_configuration.mm
deleted file mode 100644
index 1bee613..0000000
--- a/remoting/capturer/mac/desktop_configuration.mm
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "remoting/capturer/mac/desktop_configuration.h"
-
-#include <Cocoa/Cocoa.h>
-
-#include "base/logging.h"
-#include "skia/ext/skia_utils_mac.h"
-
-namespace remoting {
-
-MacDisplayConfiguration::MacDisplayConfiguration()
- : id(0),
- logical_bounds(SkIRect::MakeEmpty()),
- pixel_bounds(SkIRect::MakeEmpty()),
- dpi(SkIPoint::Make(0, 0)),
- logical_to_pixel_scale(1.0f) {
-}
-
-static SkIRect NSRectToSkIRect(const NSRect& ns_rect) {
- SkIRect result;
- gfx::CGRectToSkRect(NSRectToCGRect(ns_rect)).roundOut(&result);
- return result;
-}
-
-static MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
- MacDisplayConfiguration display_config;
-
- // Fetch the NSScreenNumber, which is also the CGDirectDisplayID.
- NSDictionary* device_description = [screen deviceDescription];
- display_config.id = static_cast<CGDirectDisplayID>(
- [[device_description objectForKey:@"NSScreenNumber"] intValue]);
-
- // Determine the display's logical & physical dimensions.
- NSRect ns_logical_bounds = [screen frame];
- NSRect ns_pixel_bounds = [screen convertRectToBacking: ns_logical_bounds];
- display_config.logical_bounds = NSRectToSkIRect(ns_logical_bounds);
- display_config.pixel_bounds = NSRectToSkIRect(ns_pixel_bounds);
-
- // Determine the display's resolution in Dots-Per-Inch.
- NSSize ns_dots_per_inch =
- [[device_description objectForKey: NSDeviceResolution] sizeValue];
- display_config.dpi.set(ns_dots_per_inch.width, ns_dots_per_inch.height);
- display_config.logical_to_pixel_scale = [screen backingScaleFactor];
-
- return display_config;
-}
-
-MacDesktopConfiguration::MacDesktopConfiguration()
- : logical_bounds(SkIRect::MakeEmpty()),
- pixel_bounds(SkIRect::MakeEmpty()),
- dpi(SkIPoint::Make(0,0)),
- logical_to_pixel_scale(1.0f) {
-}
-
-MacDesktopConfiguration::~MacDesktopConfiguration() {
-}
-
-// static
-MacDesktopConfiguration MacDesktopConfiguration::GetCurrent() {
- MacDesktopConfiguration desktop_config;
-
- NSArray* screens = [NSScreen screens];
- CHECK(screens != NULL);
-
- // 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]);
-
- // 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
- // list returned by [NSScreen screens].
- if (i == 0) {
- desktop_config.dpi = display_config.dpi;
- desktop_config.logical_to_pixel_scale =
- display_config.logical_to_pixel_scale;
- } else if (display_config.dpi != desktop_config.dpi) {
- continue;
- }
-
- CHECK_EQ(desktop_config.logical_to_pixel_scale,
- display_config.logical_to_pixel_scale);
-
- // Add the display to the configuration.
- desktop_config.displays.push_back(display_config);
-
- // Update the desktop bounds to account for this display.
- desktop_config.logical_bounds.join(display_config.logical_bounds);
- desktop_config.pixel_bounds.join(display_config.pixel_bounds);
- }
-
- return desktop_config;
-}
-
-} // namespace remoting
diff --git a/remoting/capturer/video_frame_capturer_mac.mm b/remoting/capturer/video_frame_capturer_mac.mm
index fc137f8..8b10cac 100644
--- a/remoting/capturer/video_frame_capturer_mac.mm
+++ b/remoting/capturer/video_frame_capturer_mac.mm
@@ -22,13 +22,11 @@
#include "base/synchronization/waitable_event.h"
#include "base/time.h"
#include "remoting/capturer/capture_data.h"
-#include "remoting/capturer/mac/desktop_configuration.h"
#include "remoting/capturer/mac/scoped_pixel_buffer_object.h"
#include "remoting/capturer/mouse_cursor_shape.h"
#include "remoting/capturer/video_frame.h"
#include "remoting/capturer/video_frame_capturer_helper.h"
#include "remoting/capturer/video_frame_queue.h"
-#include "skia/ext/skia_utils_mac.h"
namespace remoting {
@@ -47,9 +45,13 @@ typedef CGLError (*CGLSetFullScreenFunc)(CGLContextObj);
// skia/ext/skia_utils_mac.h only defines CGRectToSkRect().
SkIRect CGRectToSkIRect(const CGRect& rect) {
- SkIRect result;
- gfx::CGRectToSkRect(rect).round(&result);
- return result;
+ SkIRect sk_rect = {
+ SkScalarRound(rect.origin.x),
+ SkScalarRound(rect.origin.y),
+ SkScalarRound(rect.origin.x + rect.size.width),
+ SkScalarRound(rect.origin.y + rect.size.height)
+ };
+ return sk_rect;
}
// Copy pixels in the |rect| from |src_place| to |dest_plane|.
@@ -82,7 +84,7 @@ const int64 kDisplayConfigurationEventTimeoutInSeconds = 10;
// A class representing a full-frame pixel buffer.
class VideoFrameMac : public VideoFrame {
public:
- explicit VideoFrameMac(const MacDesktopConfiguration& desktop_config);
+ explicit VideoFrameMac(const SkISize& size);
virtual ~VideoFrameMac();
const SkIPoint& dpi() const { return dpi_; }
@@ -150,7 +152,8 @@ class VideoFrameCapturerMac : public VideoFrameCapturer {
VideoFrameQueue queue_;
// Current display configuration.
- MacDesktopConfiguration desktop_config_;
+ std::vector<CGDirectDisplayID> display_ids_;
+ SkIRect desktop_bounds_;
// A thread-safe list of invalid rectangles, and the size of the most
// recently captured screen.
@@ -187,9 +190,7 @@ class VideoFrameCapturerMac : public VideoFrameCapturer {
DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerMac);
};
-VideoFrameMac::VideoFrameMac(const MacDesktopConfiguration& desktop_config) {
- SkISize size = SkISize::Make(desktop_config.pixel_bounds.width(),
- desktop_config.pixel_bounds.height());
+VideoFrameMac::VideoFrameMac(const SkISize& size) {
set_bytes_per_row(size.width() * sizeof(uint32_t));
set_dimensions(size);
@@ -197,7 +198,11 @@ VideoFrameMac::VideoFrameMac(const MacDesktopConfiguration& desktop_config) {
data_.reset(new uint8[buffer_size]);
set_pixels(data_.get());
- dpi_ = desktop_config.dpi;
+ // TODO(wez): Move the ugly DPI code into a helper.
+ NSScreen* screen = [NSScreen mainScreen];
+ NSDictionary* attr = [screen deviceDescription];
+ NSSize resolution = [[attr objectForKey: NSDeviceResolution] sizeValue];
+ dpi_.set(resolution.width, resolution.height);
}
VideoFrameMac::~VideoFrameMac() {
@@ -323,7 +328,8 @@ void VideoFrameCapturerMac::CaptureFrame() {
// Note that we can't reallocate other buffers at this point, since the caller
// may still be reading from them.
if (queue_.current_frame_needs_update()) {
- scoped_ptr<VideoFrameMac> buffer(new VideoFrameMac(desktop_config_));
+ scoped_ptr<VideoFrameMac> buffer(new VideoFrameMac(
+ SkISize::Make(desktop_bounds_.width(), desktop_bounds_.height())));
queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>());
}
@@ -546,23 +552,20 @@ void VideoFrameCapturerMac::CgBlitPreLion(const VideoFrame& buffer,
buffer.bytes_per_row() * buffer_height);
}
- for (size_t i = 0; i < desktop_config_.displays.size(); ++i) {
- const MacDisplayConfiguration& display_config = desktop_config_.displays[i];
-
+ for (unsigned int d = 0; d < display_ids_.size(); ++d) {
// Use deprecated APIs to determine the display buffer layout.
DCHECK(cg_display_base_address_ && cg_display_bytes_per_row_ &&
cg_display_bits_per_pixel_);
uint8* display_base_address =
- reinterpret_cast<uint8*>((*cg_display_base_address_)(display_config.id));
+ reinterpret_cast<uint8*>((*cg_display_base_address_)(display_ids_[d]));
CHECK(display_base_address);
- int src_bytes_per_row = (*cg_display_bytes_per_row_)(display_config.id);
+ int src_bytes_per_row = (*cg_display_bytes_per_row_)(display_ids_[d]);
int src_bytes_per_pixel =
- (*cg_display_bits_per_pixel_)(display_config.id) / 8;
+ (*cg_display_bits_per_pixel_)(display_ids_[d]) / 8;
- // Determine the display's position relative to the desktop, in pixels.
- SkIRect display_bounds = display_config.pixel_bounds;
- display_bounds.offset(-desktop_config_.pixel_bounds.left(),
- -desktop_config_.pixel_bounds.top());
+ // Determine the position of the display in the buffer.
+ SkIRect display_bounds = CGRectToSkIRect(CGDisplayBounds(display_ids_[d]));
+ display_bounds.offset(-desktop_bounds_.left(), -desktop_bounds_.top());
// Determine which parts of the blit region, if any, lay within the monitor.
SkRegion copy_region;
@@ -570,8 +573,7 @@ void VideoFrameCapturerMac::CgBlitPreLion(const VideoFrame& buffer,
continue;
// Translate the region to be copied into display-relative coordinates.
- copy_region.translate(-desktop_config_.pixel_bounds.left(),
- -desktop_config_.pixel_bounds.top());
+ copy_region.translate(-display_bounds.left(), -display_bounds.top());
// Calculate where in the output buffer the display's origin is.
uint8* out_ptr = buffer.pixels() +
@@ -603,13 +605,10 @@ void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer,
buffer.bytes_per_row() * buffer_height);
}
- for (size_t i = 0; i < desktop_config_.displays.size(); ++i) {
- const MacDisplayConfiguration& display_config = desktop_config_.displays[i];
-
- // Determine the display's position relative to the desktop, in pixels.
- SkIRect display_bounds = display_config.pixel_bounds;
- display_bounds.offset(-desktop_config_.pixel_bounds.left(),
- -desktop_config_.pixel_bounds.top());
+ for (unsigned int d = 0; d < display_ids_.size(); ++d) {
+ // Determine the position of the display in the buffer.
+ SkIRect display_bounds = CGRectToSkIRect(CGDisplayBounds(display_ids_[d]));
+ display_bounds.offset(-desktop_bounds_.left(), -desktop_bounds_.top());
// Determine which parts of the blit region, if any, lay within the monitor.
SkRegion copy_region;
@@ -617,12 +616,11 @@ void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer,
continue;
// Translate the region to be copied into display-relative coordinates.
- copy_region.translate(-desktop_config_.pixel_bounds.left(),
- -desktop_config_.pixel_bounds.top());
+ copy_region.translate(-display_bounds.left(), -display_bounds.top());
// Create an image containing a snapshot of the display.
base::mac::ScopedCFTypeRef<CGImageRef> image(
- CGDisplayCreateImage(display_config.id));
+ CGDisplayCreateImage(display_ids_[d]));
if (image.get() == NULL)
continue;
@@ -661,13 +659,26 @@ void VideoFrameCapturerMac::ScreenConfigurationChanged() {
// Clear the dirty region, in case the display is down-sizing.
helper_.ClearInvalidRegion();
- // Refresh the cached desktop configuration.
- desktop_config_ = MacDesktopConfiguration::GetCurrent();
+ // Fetch the list if active displays and calculate their bounds.
+ CGDisplayCount display_count;
+ CGError error = CGGetActiveDisplayList(0, NULL, &display_count);
+ CHECK_EQ(error, CGDisplayNoErr);
+
+ display_ids_.resize(display_count);
+ error = CGGetActiveDisplayList(display_count, &display_ids_[0],
+ &display_count);
+ CHECK_EQ(error, CGDisplayNoErr);
+ CHECK_EQ(display_count, display_ids_.size());
+
+ desktop_bounds_ = SkIRect::MakeEmpty();
+ for (unsigned int d = 0; d < display_count; ++d) {
+ CGRect display_bounds = CGDisplayBounds(display_ids_[d]);
+ desktop_bounds_.join(CGRectToSkIRect(display_bounds));
+ }
// Re-mark the entire desktop as dirty.
- helper_.InvalidateScreen(
- SkISize::Make(desktop_config_.pixel_bounds.width(),
- desktop_config_.pixel_bounds.height()));
+ helper_.InvalidateScreen(SkISize::Make(desktop_bounds_.width(),
+ desktop_bounds_.height()));
// Make sure the frame buffers will be reallocated.
queue_.SetAllFramesNeedUpdate();
@@ -706,7 +717,7 @@ void VideoFrameCapturerMac::ScreenConfigurationChanged() {
CHECK(cg_display_base_address_ && cg_display_bytes_per_row_ &&
cg_display_bits_per_pixel_ && cgl_set_full_screen_);
- if (desktop_config_.displays.size() > 1) {
+ if (display_ids_.size() > 1) {
LOG(INFO) << "Using CgBlitPreLion (Multi-monitor).";
return;
}
@@ -737,36 +748,21 @@ void VideoFrameCapturerMac::ScreenConfigurationChanged() {
(*cgl_set_full_screen_)(cgl_context_);
CGLSetCurrentContext(cgl_context_);
- size_t buffer_size = desktop_config_.pixel_bounds.width() *
- desktop_config_.pixel_bounds.height() *
+ size_t buffer_size = desktop_bounds_.width() * desktop_bounds_.height() *
sizeof(uint32_t);
pixel_buffer_object_.Init(cgl_context_, buffer_size);
}
void VideoFrameCapturerMac::ScreenRefresh(CGRectCount count,
const CGRect* rect_array) {
- if (desktop_config_.pixel_bounds.isEmpty()) {
+ if (desktop_bounds_.isEmpty()) {
return;
}
SkIRect skirect_array[count];
-
for (CGRectCount i = 0; i < count; ++i) {
- // Convert from logical to pixel (device-scale) coordinates.
- NSRect rect = NSRectFromCGRect(rect_array[i]);
- SkRect sk_rect = {
- rect.origin.x * desktop_config_.logical_to_pixel_scale,
- rect.origin.y * desktop_config_.logical_to_pixel_scale,
- (rect.origin.x + rect.size.width) *
- desktop_config_.logical_to_pixel_scale,
- (rect.origin.y + rect.size.height) *
- desktop_config_.logical_to_pixel_scale
- };
-
- sk_rect.round(&skirect_array[i]);
- skirect_array[i].offset(-desktop_config_.pixel_bounds.left(),
- -desktop_config_.pixel_bounds.top());
+ skirect_array[i] = CGRectToSkIRect(rect_array[i]);
+ skirect_array[i].offset(-desktop_bounds_.left(), -desktop_bounds_.top());
}
-
SkRegion region;
region.setRects(skirect_array, count);
InvalidateRegion(region);
@@ -775,14 +771,16 @@ void VideoFrameCapturerMac::ScreenRefresh(CGRectCount count,
void VideoFrameCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
size_t count,
const CGRect* rect_array) {
- // Translate |rect_array| to identify the move's destination.
- CGRect refresh_rects[count];
+ SkIRect skirect_array[count];
for (CGRectCount i = 0; i < count; ++i) {
- refresh_rects[i] = CGRectOffset(rect_array[i], delta.dX, delta.dY);
+ CGRect rect = rect_array[i];
+ rect = CGRectOffset(rect, delta.dX, delta.dY);
+ skirect_array[i] = CGRectToSkIRect(rect);
+ skirect_array[i].offset(-desktop_bounds_.left(), -desktop_bounds_.top());
}
-
- // Currently we just treat move events the same as refreshes.
- ScreenRefresh(count, refresh_rects);
+ SkRegion region;
+ region.setRects(skirect_array, count);
+ InvalidateRegion(region);
}
void VideoFrameCapturerMac::DisplaysReconfigured(
@@ -816,7 +814,7 @@ void VideoFrameCapturerMac::ScreenRefreshCallback(CGRectCount count,
void* user_parameter) {
VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>(
user_parameter);
- if (capturer->desktop_config_.pixel_bounds.isEmpty()) {
+ if (capturer->desktop_bounds_.isEmpty()) {
capturer->ScreenConfigurationChanged();
}
capturer->ScreenRefresh(count, rect_array);
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index ab636ff..d3cdc1e 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -14,11 +14,9 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
-#include "remoting/capturer/mac/desktop_configuration.h"
#include "remoting/host/clipboard.h"
#include "remoting/proto/internal.pb.h"
#include "remoting/protocol/message_decoder.h"
-#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRect.h"
@@ -37,9 +35,13 @@ using protocol::MouseEvent;
// skia/ext/skia_utils_mac.h only defines CGRectToSkRect().
SkIRect CGRectToSkIRect(const CGRect& rect) {
- SkIRect result;
- gfx::CGRectToSkRect(rect).round(&result);
- return result;
+ SkIRect sk_rect = {
+ SkScalarRound(rect.origin.x),
+ SkScalarRound(rect.origin.y),
+ SkScalarRound(rect.origin.x + rect.size.width),
+ SkScalarRound(rect.origin.y + rect.size.height)
+ };
+ return sk_rect;
}
// A class to generate events on Mac.
@@ -188,24 +190,30 @@ void EventExecutorMac::Core::InjectMouseEvent(const MouseEvent& event) {
// Set the mouse position assuming single-monitor.
mouse_pos_ = SkIPoint::Make(event.x(), event.y());
- // Fetch the desktop configuration.
- // TODO(wez): Optimize this out, or at least only enumerate displays in
- // response to display-changed events. VideoFrameCapturer's VideoFrames
- // could be augmented to include native cursor coordinates for use by
- // MouseClampingFilter, removing the need for translation here.
- MacDesktopConfiguration desktop_config
- = MacDesktopConfiguration::GetCurrent();
-
- // Translate the mouse position into desktop coordinates.
- mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(),
- desktop_config.pixel_bounds.top());
-
- // Convert from pixel to logical coordinates.
- mouse_pos_ = SkIPoint::Make(
- SkScalarRound(mouse_pos_.x() / desktop_config.logical_to_pixel_scale),
- SkScalarRound(mouse_pos_.y() / desktop_config.logical_to_pixel_scale));
+ // Determine how many active displays there are.
+ CGDisplayCount display_count;
+ CGError error = CGGetActiveDisplayList(0, NULL, &display_count);
+ CHECK_EQ(error, CGDisplayNoErr);
+
+ if (display_count > 1) {
+ // Determine the bounding box of the displays, to get the top-left origin.
+ std::vector<CGDirectDisplayID> display_ids(display_count);
+ error = CGGetActiveDisplayList(display_count, &display_ids[0],
+ &display_count);
+ CHECK_EQ(error, CGDisplayNoErr);
+ CHECK_EQ(display_count, display_ids.size());
+
+ SkIRect desktop_bounds = SkIRect::MakeEmpty();
+ for (unsigned int d = 0; d < display_count; ++d) {
+ CGRect display_bounds = CGDisplayBounds(display_ids[d]);
+ desktop_bounds.join(CGRectToSkIRect(display_bounds));
+ }
+
+ // Adjust the injected mouse event position.
+ mouse_pos_ += SkIPoint::Make(desktop_bounds.left(), desktop_bounds.top());
+ }
- VLOG(3) << "Moving mouse to " << mouse_pos_.x() << "," << mouse_pos_.y();
+ VLOG(3) << "Moving mouse to " << event.x() << "," << event.y();
}
if (event.has_button() && event.has_button_down()) {
if (event.button() >= 1 && event.button() <= 3) {
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 1382a7c..86a68e5 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -267,8 +267,6 @@
'capturer/differ_block.h',
'capturer/linux/x_server_pixel_buffer.cc',
'capturer/linux/x_server_pixel_buffer.h',
- 'capturer/mac/desktop_configuration.mm',
- 'capturer/mac/desktop_configuration.h',
'capturer/mac/scoped_pixel_buffer_object.cc',
'capturer/mac/scoped_pixel_buffer_object.h',
'capturer/mouse_cursor_shape.cc',
diff --git a/skia/ext/skia_utils_mac.h b/skia/ext/skia_utils_mac.h
index 40eb6d4..ad5fc93 100644
--- a/skia/ext/skia_utils_mac.h
+++ b/skia/ext/skia_utils_mac.h
@@ -52,7 +52,7 @@ inline const SkPoint& CGPointToSkPoint(const CGPoint& point) {
SK_API CGAffineTransform SkMatrixToCGAffineTransform(const SkMatrix& matrix);
// Rectangle converters.
-SK_API SkRect CGRectToSkRect(const CGRect& rect);
+SkRect CGRectToSkRect(const CGRect& rect);
// Converts a Skia rect to a CoreGraphics CGRect.
CGRect SkIRectToCGRect(const SkIRect& rect);