I am updating Chrome Remote Desktop to apply a scale factor when using curtain mode (i.e. a loopback RDP session) and I've found that while the changes are applied and the desktop is scaled, DXGI stops producing frames. This is essentially the same issue as crbug.com/1307357 except this issue is occurring when the DPI is changed rather than the desktop size. The fix is to look at the effective DPI for the source being captured (or the primary monitor when capturing the full desktop) and then signaling an environment change when the DPI differs. Bug: webrtc:14894,b:154733991 Change-Id: Id768d4a384434ba59e7396bc919d0ba30d0f6acc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/292791 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Joe Downing <joedow@google.com> Cr-Commit-Position: refs/heads/main@{#39305}
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "modules/desktop_capture/win/display_configuration_monitor.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include "modules/desktop_capture/win/screen_capture_utils.h"
|
|
#include "rtc_base/logging.h"
|
|
|
|
namespace webrtc {
|
|
|
|
bool DisplayConfigurationMonitor::IsChanged(
|
|
DesktopCapturer::SourceId source_id) {
|
|
DesktopRect rect = GetFullscreenRect();
|
|
DesktopVector dpi = GetDpiForSourceId(source_id);
|
|
|
|
if (!initialized_) {
|
|
initialized_ = true;
|
|
rect_ = rect;
|
|
source_dpis_.emplace(source_id, std::move(dpi));
|
|
return false;
|
|
}
|
|
|
|
if (!source_dpis_.contains(source_id)) {
|
|
// If this is the first time we've seen this source_id, use the current DPI
|
|
// so the monitor does not indicate a change and possibly get reset.
|
|
source_dpis_.emplace(source_id, dpi);
|
|
}
|
|
|
|
bool has_changed = false;
|
|
if (!rect.equals(rect_) || !source_dpis_.at(source_id).equals(dpi)) {
|
|
has_changed = true;
|
|
rect_ = rect;
|
|
source_dpis_.emplace(source_id, std::move(dpi));
|
|
}
|
|
|
|
return has_changed;
|
|
}
|
|
|
|
void DisplayConfigurationMonitor::Reset() {
|
|
initialized_ = false;
|
|
source_dpis_.clear();
|
|
rect_ = {};
|
|
}
|
|
|
|
DesktopVector DisplayConfigurationMonitor::GetDpiForSourceId(
|
|
DesktopCapturer::SourceId source_id) {
|
|
HMONITOR monitor = 0;
|
|
if (source_id == kFullDesktopScreenId) {
|
|
// Get a handle to the primary monitor when capturing the full desktop.
|
|
monitor = MonitorFromPoint({0, 0}, MONITOR_DEFAULTTOPRIMARY);
|
|
} else if (!GetHmonitorFromDeviceIndex(source_id, &monitor)) {
|
|
RTC_LOG(LS_WARNING) << "GetHmonitorFromDeviceIndex failed.";
|
|
}
|
|
return GetDpiForMonitor(monitor);
|
|
}
|
|
|
|
} // namespace webrtc
|