| 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 |
| 11 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h" | 11 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 |
| 15 #include <memory> |
| 16 |
| 14 #include <ApplicationServices/ApplicationServices.h> | 17 #include <ApplicationServices/ApplicationServices.h> |
| 15 #include <Cocoa/Cocoa.h> | 18 #include <Cocoa/Cocoa.h> |
| 16 #include <CoreFoundation/CoreFoundation.h> | 19 #include <CoreFoundation/CoreFoundation.h> |
| 17 | 20 |
| 18 #include "webrtc/base/macutils.h" | 21 #include "webrtc/base/macutils.h" |
| 19 #include "webrtc/base/scoped_ptr.h" | |
| 20 #include "webrtc/base/scoped_ref_ptr.h" | 22 #include "webrtc/base/scoped_ref_ptr.h" |
| 21 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 23 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 22 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 24 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 23 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" | 25 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" |
| 24 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" | 26 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" |
| 25 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.
h" | 27 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.
h" |
| 26 #include "webrtc/modules/desktop_capture/mouse_cursor.h" | 28 #include "webrtc/modules/desktop_capture/mouse_cursor.h" |
| 27 #include "webrtc/system_wrappers/include/logging.h" | 29 #include "webrtc/system_wrappers/include/logging.h" |
| 28 | 30 |
| 29 namespace webrtc { | 31 namespace webrtc { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 void DisplaysReconfigured(CGDirectDisplayID display, | 47 void DisplaysReconfigured(CGDirectDisplayID display, |
| 46 CGDisplayChangeSummaryFlags flags); | 48 CGDisplayChangeSummaryFlags flags); |
| 47 | 49 |
| 48 void CaptureImage(); | 50 void CaptureImage(); |
| 49 | 51 |
| 50 rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_; | 52 rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_; |
| 51 CGWindowID window_id_; | 53 CGWindowID window_id_; |
| 52 ScreenId screen_id_; | 54 ScreenId screen_id_; |
| 53 Callback* callback_; | 55 Callback* callback_; |
| 54 Mode mode_; | 56 Mode mode_; |
| 55 rtc::scoped_ptr<MouseCursor> last_cursor_; | 57 std::unique_ptr<MouseCursor> last_cursor_; |
| 56 rtc::scoped_refptr<FullScreenChromeWindowDetector> | 58 rtc::scoped_refptr<FullScreenChromeWindowDetector> |
| 57 full_screen_chrome_window_detector_; | 59 full_screen_chrome_window_detector_; |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 MouseCursorMonitorMac::MouseCursorMonitorMac( | 62 MouseCursorMonitorMac::MouseCursorMonitorMac( |
| 61 const DesktopCaptureOptions& options, | 63 const DesktopCaptureOptions& options, |
| 62 CGWindowID window_id, | 64 CGWindowID window_id, |
| 63 ScreenId screen_id) | 65 ScreenId screen_id) |
| 64 : configuration_monitor_(options.configuration_monitor()), | 66 : configuration_monitor_(options.configuration_monitor()), |
| 65 window_id_(window_id), | 67 window_id_(window_id), |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 last_cursor_->image()->size().equals(size) && | 263 last_cursor_->image()->size().equals(size) && |
| 262 last_cursor_->hotspot().equals(hotspot) && | 264 last_cursor_->hotspot().equals(hotspot) && |
| 263 memcmp(last_cursor_->image()->data(), src_data, | 265 memcmp(last_cursor_->image()->data(), src_data, |
| 264 last_cursor_->image()->stride() * size.height()) == 0) { | 266 last_cursor_->image()->stride() * size.height()) == 0) { |
| 265 CFRelease(image_data_ref); | 267 CFRelease(image_data_ref); |
| 266 return; | 268 return; |
| 267 } | 269 } |
| 268 | 270 |
| 269 // Create a MouseCursor that describes the cursor and pass it to | 271 // Create a MouseCursor that describes the cursor and pass it to |
| 270 // the client. | 272 // the client. |
| 271 rtc::scoped_ptr<DesktopFrame> image( | 273 std::unique_ptr<DesktopFrame> image( |
| 272 new BasicDesktopFrame(DesktopSize(size.width(), size.height()))); | 274 new BasicDesktopFrame(DesktopSize(size.width(), size.height()))); |
| 273 memcpy(image->data(), src_data, | 275 memcpy(image->data(), src_data, |
| 274 size.width() * size.height() * DesktopFrame::kBytesPerPixel); | 276 size.width() * size.height() * DesktopFrame::kBytesPerPixel); |
| 275 | 277 |
| 276 CFRelease(image_data_ref); | 278 CFRelease(image_data_ref); |
| 277 | 279 |
| 278 rtc::scoped_ptr<MouseCursor> cursor( | 280 std::unique_ptr<MouseCursor> cursor( |
| 279 new MouseCursor(image.release(), hotspot)); | 281 new MouseCursor(image.release(), hotspot)); |
| 280 last_cursor_.reset(MouseCursor::CopyOf(*cursor)); | 282 last_cursor_.reset(MouseCursor::CopyOf(*cursor)); |
| 281 | 283 |
| 282 callback_->OnMouseCursor(cursor.release()); | 284 callback_->OnMouseCursor(cursor.release()); |
| 283 } | 285 } |
| 284 | 286 |
| 285 MouseCursorMonitor* MouseCursorMonitor::CreateForWindow( | 287 MouseCursorMonitor* MouseCursorMonitor::CreateForWindow( |
| 286 const DesktopCaptureOptions& options, WindowId window) { | 288 const DesktopCaptureOptions& options, WindowId window) { |
| 287 return new MouseCursorMonitorMac(options, window, kInvalidScreenId); | 289 return new MouseCursorMonitorMac(options, window, kInvalidScreenId); |
| 288 } | 290 } |
| 289 | 291 |
| 290 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( | 292 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( |
| 291 const DesktopCaptureOptions& options, | 293 const DesktopCaptureOptions& options, |
| 292 ScreenId screen) { | 294 ScreenId screen) { |
| 293 return new MouseCursorMonitorMac(options, kCGNullWindowID, screen); | 295 return new MouseCursorMonitorMac(options, kCGNullWindowID, screen); |
| 294 } | 296 } |
| 295 | 297 |
| 296 } // namespace webrtc | 298 } // namespace webrtc |
| OLD | NEW |