Chromium Code Reviews| 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 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 // TODO(zijiehe): Remove this overload. | 249 // TODO(zijiehe): Remove this overload. |
| 250 callback_->OnMouseCursorPosition(state, position); | 250 callback_->OnMouseCursorPosition(state, position); |
| 251 callback_->OnMouseCursorPosition( | 251 callback_->OnMouseCursorPosition( |
| 252 position.subtract(configuration.bounds.top_left())); | 252 position.subtract(configuration.bounds.top_left())); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void MouseCursorMonitorMac::CaptureImage(float scale) { | 255 void MouseCursorMonitorMac::CaptureImage(float scale) { |
| 256 NSCursor* nscursor = [NSCursor currentSystemCursor]; | 256 NSCursor* nscursor = [NSCursor currentSystemCursor]; |
| 257 | 257 |
| 258 NSImage* nsimage = [nscursor image]; | 258 NSImage* nsimage = [nscursor image]; |
| 259 if (!nsimage.isValid) { | |
|
Jamie
2017/08/07 21:49:34
According to https://developer.apple.com/documenta
Hzj_jie
2017/08/07 23:22:33
Done.
| |
| 260 return; | |
| 261 } | |
| 259 NSSize nssize = [nsimage size]; // DIP size | 262 NSSize nssize = [nsimage size]; // DIP size |
| 260 | 263 |
| 261 // No need to caputre cursor image if it's unchanged since last capture. | 264 // No need to caputre cursor image if it's unchanged since last capture. |
| 262 if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return; | 265 if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return; |
| 263 last_cursor_ = nsimage; | 266 last_cursor_ = nsimage; |
| 264 | 267 |
| 265 DesktopSize size(round(nssize.width * scale), | 268 DesktopSize size(round(nssize.width * scale), |
| 266 round(nssize.height * scale)); // Pixel size | 269 round(nssize.height * scale)); // Pixel size |
| 267 NSPoint nshotspot = [nscursor hotSpot]; | 270 NSPoint nshotspot = [nscursor hotSpot]; |
| 268 DesktopVector hotspot( | 271 DesktopVector hotspot( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 return new MouseCursorMonitorMac(options, kCGNullWindowID, screen); | 333 return new MouseCursorMonitorMac(options, kCGNullWindowID, screen); |
| 331 } | 334 } |
| 332 | 335 |
| 333 std::unique_ptr<MouseCursorMonitor> MouseCursorMonitor::Create( | 336 std::unique_ptr<MouseCursorMonitor> MouseCursorMonitor::Create( |
| 334 const DesktopCaptureOptions& options) { | 337 const DesktopCaptureOptions& options) { |
| 335 return std::unique_ptr<MouseCursorMonitor>( | 338 return std::unique_ptr<MouseCursorMonitor>( |
| 336 CreateForScreen(options, kFullDesktopScreenId)); | 339 CreateForScreen(options, kFullDesktopScreenId)); |
| 337 } | 340 } |
| 338 | 341 |
| 339 } // namespace webrtc | 342 } // namespace webrtc |
| OLD | NEW |