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

Unified Diff: webrtc/modules/desktop_capture/screen_capturer_mac.mm

Issue 2588973002: Fix a screen capture issue on retina macOS devices. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..82d2f9a7ebe18388c96b89f08b65c87b8b15b19b 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,
+ size_t 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);
Sergey Ulanov 2016/12/20 00:47:04 FWIW kCGDisplayStreamUpdateDirtyRects is document
+ updateRef, kCGDisplayStreamUpdateMovedRects, &count);
+ 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,23 @@ void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
display_stream_manager_->UnregisterActiveStreams();
}
+void ScreenCapturerMac::ScreenUpdateMove(CGFloat delta_x,
+ CGFloat delta_y,
+ size_t count,
Sergey Ulanov 2016/12/20 00:47:04 CGRectCount?
erikchen 2016/12/20 03:11:24 Done.
+ const CGRect* rect_array) {
+ // Translate |rect_array| to identify the move's destination. Then take the
+ // union of that and the original rect, since we need to update both the
+ // previous position and the new position.
+ CGRect refresh_rects[count];
+ for (CGRectCount i = 0; i < count; ++i) {
+ CGRect new_rect = CGRectOffset(rect_array[i], delta_x, delta_y);
+ refresh_rects[i] = CGRectUnion(new_rect, refresh_rects[i]);
Sergey Ulanov 2016/12/20 00:47:04 I don't think we need rect union here. It would ex
erikchen 2016/12/20 03:11:24 Done.
+ }
+
+ // Currently we just treat move events the same as refreshes.
+ ScreenRefresh(count, refresh_rects);
+}
+
void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
const CGRect* rect_array) {
if (screen_pixel_bounds_.is_empty())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698