Chromium Code Reviews| Index: webrtc/modules/desktop_capture/screen_capturer_mac.mm |
| diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac.mm b/webrtc/modules/desktop_capture/screen_capturer_mac.mm |
| index f11b36d2d2001d6fd0079d8d9464a1dcfd7c89fb..09220b798450d3b695c91f0e667167c730868a4e 100644 |
| --- a/webrtc/modules/desktop_capture/screen_capturer_mac.mm |
| +++ b/webrtc/modules/desktop_capture/screen_capturer_mac.mm |
| @@ -304,6 +304,10 @@ class ScreenCapturerMac : public DesktopCapturer { |
| bool RegisterRefreshAndMoveHandlers(); |
| void UnregisterRefreshAndMoveHandlers(); |
| + void ScreenUpdateMove(CGFloat delta_x, |
| + CGFloat delta_y, |
| + CGRectCount count, |
| + const CGRect* rect_array); |
| void ScreenRefresh(CGRectCount count, const CGRect *rect_array); |
| void ReleaseBuffers(); |
| @@ -955,10 +959,18 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() { |
| size_t count = 0; |
| const CGRect* rects = CGDisplayStreamUpdateGetRects( |
| - updateRef, kCGDisplayStreamUpdateDirtyRects, &count); |
| + updateRef, kCGDisplayStreamUpdateMovedRects, &count); |
|
Sergey Ulanov
2016/12/20 18:56:51
I would still prefer to use kCGDisplayStreamUpdate
|
| + if (count != 0) { |
| + CGFloat dx = 0; |
| + CGFloat dy = 0; |
| + CGDisplayStreamUpdateGetMovedRectsDelta(updateRef, &dx, &dy); |
| + ScreenUpdateMove(dx, dy, count, rects); |
| + } |
| + |
| + count = 0; |
| + rects = CGDisplayStreamUpdateGetRects( |
| + updateRef, kCGDisplayStreamUpdateRefreshedRects, &count); |
| if (count != 0) { |
| - // According to CGDisplayStream.h, it's safe to call |
| - // CGDisplayStreamStop() from within the callback. |
| ScreenRefresh(count, rects); |
| } |
| }; |
| @@ -984,6 +996,20 @@ void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() { |
| display_stream_manager_->UnregisterActiveStreams(); |
| } |
| +void ScreenCapturerMac::ScreenUpdateMove(CGFloat delta_x, |
| + CGFloat delta_y, |
| + CGRectCount count, |
| + const CGRect* rect_array) { |
| + // Refresh the source rects. |
| + ScreenRefresh(count, rect_array); |
| + |
| + // Refresh the destination rects. |
| + CGRect refresh_rects[count]; |
| + for (CGRectCount i = 0; i < count; ++i) |
| + refresh_rects[i] = CGRectOffset(rect_array[i], delta_x, delta_y); |
| + ScreenRefresh(count, refresh_rects); |
| +} |
| + |
| void ScreenCapturerMac::ScreenRefresh(CGRectCount count, |
| const CGRect* rect_array) { |
| if (screen_pixel_bounds_.is_empty()) |
| @@ -991,8 +1017,8 @@ void ScreenCapturerMac::ScreenRefresh(CGRectCount count, |
| DesktopRegion region; |
| for (CGRectCount i = 0; i < count; ++i) { |
| - // Convert from Density-Independent Pixel to physical pixel coordinates. |
| - DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], dip_to_pixel_scale_); |
| + // All rects are already in physical pixel coordinates. |
| + DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], 1.0); |
|
Sergey Ulanov
2016/12/20 18:56:51
It would be cleaner to write this as
DesktopRect:
|
| region.AddRect(rect); |
| } |