desktop_capture: crop border in window_capture on Win8/10

On Windows8/10, we prefer cropping desired window out from a whole screen
capture due to some reasons. The problem is Win10 has an invisible border
around the window. If we leave the border, it will expose background a bit.

This cl is about to always remove the border of desired window on Win8/10.
This will help a lot to capturing still windows during window sharing.
This cl still can't handle the background exposure issue when you move the
target window around during capturing. More investigation is needed.

BUG=chromium:737278

Review-Url: https://codereview.webrtc.org/2973853002
Cr-Commit-Position: refs/heads/master@{#18921}
This commit is contained in:
braveyao 2017-07-06 20:20:27 -07:00 committed by Commit Bot
parent f07e6b4c00
commit 4a494ffd12

View File

@ -10,6 +10,8 @@
#include "webrtc/modules/desktop_capture/win/window_capture_utils.h"
#include "webrtc/rtc_base/win32.h"
namespace webrtc {
bool
@ -29,7 +31,11 @@ GetCroppedWindowRect(HWND window,
*original_rect = DesktopRect::MakeLTRB(
rect.left, rect.top, rect.right, rect.bottom);
if (window_placement.showCmd == SW_SHOWMAXIMIZED) {
// After Windows8, transparent borders will be added by OS at
// left/bottom/right sides of a window. If the cropped window
// doesn't remove these borders, the background will be exposed a bit.
if (rtc::IsWindows8OrLater() ||
window_placement.showCmd == SW_SHOWMAXIMIZED) {
DesktopSize border = DesktopSize(GetSystemMetrics(SM_CXSIZEFRAME),
GetSystemMetrics(SM_CYSIZEFRAME));
*cropped_rect = DesktopRect::MakeLTRB(