mac: Fix screen capture for whole-desktop capture.
DisplayStream refresh rects are in display coordinates. When the whole screen is being captured, the coordinates passed to the ScreenCapturerHelper need to be in screen coordinates. This CL translates display coordinates to screen coordinates for whole screen capture. BUG=chromium:699672 Review-Url: https://codereview.webrtc.org/2740823002 Cr-Commit-Position: refs/heads/master@{#17153}
This commit is contained in:
parent
d64862ac1b
commit
31bbee73a0
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user