Fix the captured screen rect conversion.

device_mode.dmPosition is already relative to the primary display's top-left, while the expected value of GetScreenRect() is also relative to the primary display's top-left.

TESTED=verified on Windows single monitor capturing and cursor capturing is fixed.

BUG=https://code.google.com/p/chromium/issues/detail?id=362631
R=wez@chromium.org

Review URL: https://webrtc-codereview.appspot.com/11789006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5890 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
jiayl@webrtc.org 2014-04-11 22:31:15 +00:00
parent 8d1cdaa84e
commit 8ce7c72456
2 changed files with 16 additions and 13 deletions

View File

@ -28,6 +28,9 @@ class MouseCursorMonitorWin : public MouseCursorMonitor {
virtual void Capture() OVERRIDE;
private:
// Get the rect of the currently selected screen, relative to the primary
// display's top-left. If the screen is disabled or disconnected, or any error
// happens, an empty rect is returned.
DesktopRect GetScreenRect();
HWND window_;
@ -148,11 +151,10 @@ DesktopRect MouseCursorMonitorWin::GetScreenRect() {
if (!result)
return DesktopRect();
return DesktopRect::MakeXYWH(
GetSystemMetrics(SM_XVIRTUALSCREEN) + device_mode.dmPosition.x,
GetSystemMetrics(SM_YVIRTUALSCREEN) + device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
return DesktopRect::MakeXYWH(device_mode.dmPosition.x,
device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
}
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(

View File

@ -67,8 +67,9 @@ class ScreenCapturerWin : public ScreenCapturer {
// Capture the current cursor shape.
void CaptureCursor();
// Get the rect of the currently selected screen. If the screen is disabled
// or disconnected, or any error happens, an empty rect is returned.
// Get the rect of the currently selected screen, relative to the primary
// display's top-left. If the screen is disabled or disconnected, or any error
// happens, an empty rect is returned.
DesktopRect GetScreenRect();
Callback* callback_;
@ -94,7 +95,8 @@ class ScreenCapturerWin : public ScreenCapturer {
// Queue of the frames buffers.
ScreenCaptureFrameQueue queue_;
// Rectangle describing the bounds of the desktop device context.
// Rectangle describing the bounds of the desktop device context, relative to
// the primary display's top-left.
DesktopRect desktop_dc_rect_;
// Class to calculate the difference between two screen bitmaps.
@ -442,11 +444,10 @@ DesktopRect ScreenCapturerWin::GetScreenRect() {
if (!result)
return DesktopRect();
rect = DesktopRect::MakeXYWH(
rect.left() + device_mode.dmPosition.x,
rect.top() + device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
rect = DesktopRect::MakeXYWH(device_mode.dmPosition.x,
device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
return rect;
}
} // namespace