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

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

Issue 2740823002: mac: Fix screen capture for whole-desktop capture. (Closed)
Patch Set: Created 3 years, 9 months 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 b1d7c9048e91d3c482fc249eaa5db701b61279cc..aed7e25e8d87933418878cdeeffd4499cfd93029 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_mac.mm
+++ b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
@@ -304,7 +304,9 @@ class ScreenCapturerMac : public DesktopCapturer {
bool RegisterRefreshAndMoveHandlers();
void UnregisterRefreshAndMoveHandlers();
- void ScreenRefresh(CGRectCount count, const CGRect *rect_array);
+ void ScreenRefresh(CGRectCount count,
+ const CGRect *rect_array,
+ DesktopVector display_origin);
void ReleaseBuffers();
std::unique_ptr<DesktopFrame> CreateFrame();
@@ -938,6 +940,8 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
DisplayStreamManager* manager = display_stream_manager_;
int unique_id = manager->GetUniqueId();
CGDirectDisplayID display_id = config.id;
+ DesktopVector display_origin = config.pixel_bounds.top_left();
+
CGDisplayStreamFrameAvailableHandler handler =
^(CGDisplayStreamFrameStatus status, uint64_t display_time,
IOSurfaceRef frame_surface, CGDisplayStreamUpdateRef updateRef) {
@@ -959,7 +963,7 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
if (count != 0) {
// According to CGDisplayStream.h, it's safe to call
// CGDisplayStreamStop() from within the callback.
- ScreenRefresh(count, rects);
+ ScreenRefresh(count, rects, display_origin);
}
};
CGDisplayStreamRef display_stream = CGDisplayStreamCreate(
@@ -985,16 +989,28 @@ void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
}
void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
- const CGRect* rect_array) {
+ const CGRect* rect_array,
+ DesktopVector display_origin) {
if (screen_pixel_bounds_.is_empty())
ScreenConfigurationChanged();
+ // The refresh rects are in display coordinates. We want to translate to
+ // framebuffer coordinates. If a specific display is being captured, then no
+ // change is necessary. If all displays are being captured, then we want to
+ // translate by the origin of the display.
+ DesktopVector translate_vector;
+ if (!current_display_)
+ translate_vector = display_origin;
+
DesktopRegion region;
for (CGRectCount i = 0; i < count; ++i) {
// All rects are already in physical pixel coordinates.
DesktopRect rect = DesktopRect::MakeXYWH(
rect_array[i].origin.x, rect_array[i].origin.y,
rect_array[i].size.width, rect_array[i].size.height);
+
+ rect.Translate(translate_vector);
+
region.AddRect(rect);
}
« 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