Skip owned window with WS_EX_LAYERED attribute when capturing with GDI.

When using GDI to capture windows, not only will the target window be
captured, but all owned windows of the target window will also be
captured, and the captured results of the owned windows will be drawn
onto the captured result of target window.

GDI (BitBlt or PrintWindow) cannot capture windows with WS_EX_LAYERED
attribute, so when the owned window has this attribute, the area of the
owned window in the result is black.

After modification, if the owned window has the WS_EX_LAYERED attribute,
it will not be captured or drawn.

Bug: webrtc:394380765
Change-Id: I5f0c7d31809a353377b0aa52452634b46247af5f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376360
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#43851}
This commit is contained in:
fizzfang 2025-02-05 16:54:59 +08:00 committed by WebRTC LUCI CQ
parent 70b65bc375
commit 0f4f802f84

View File

@ -365,6 +365,10 @@ WindowCapturerWinGdi::CaptureResults WindowCapturerWinGdi::CaptureFrame(
for (auto it = owned_windows_.rbegin(); it != owned_windows_.rend();
it++) {
HWND hwnd = *it;
LONG style = GetWindowLong(hwnd, GWL_EXSTYLE);
if (style & WS_EX_LAYERED) {
continue;
}
if (owned_window_capturer_->SelectSource(
reinterpret_cast<SourceId>(hwnd))) {
CaptureResults results = owned_window_capturer_->CaptureFrame(