Removes usage of the Magnifier API on Windows

This CL removes the usage of the Magnifier screen capture API on
Windows. The idea is to remove the actual source in a second step
once this change lands.

Bug: chromium:1428341
Change-Id: Id2cb25632c7edbea2cf527959b14b27ee00b0e56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301164
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39856}
This commit is contained in:
henrika 2023-04-13 20:57:44 +02:00 committed by WebRTC LUCI CQ
parent 239db68b17
commit b9313b9584
5 changed files with 1 additions and 108 deletions

View file

@ -21,7 +21,7 @@ namespace {
enum class SequentialDesktopCapturerId {
kUnknown = 0,
kWgcCapturerWin = 1,
kScreenCapturerWinMagnifier = 2,
// kScreenCapturerWinMagnifier = 2,
kWindowCapturerWinGdi = 3,
kScreenCapturerWinGdi = 4,
kScreenCapturerWinDirectx = 5,
@ -35,9 +35,6 @@ void RecordCapturerImpl(uint32_t capturer_id) {
case DesktopCapturerId::kWgcCapturerWin:
sequential_id = SequentialDesktopCapturerId::kWgcCapturerWin;
break;
case DesktopCapturerId::kScreenCapturerWinMagnifier:
sequential_id = SequentialDesktopCapturerId::kScreenCapturerWinMagnifier;
break;
case DesktopCapturerId::kWindowCapturerWinGdi:
sequential_id = SequentialDesktopCapturerId::kWindowCapturerWinGdi;
break;

View file

@ -135,12 +135,6 @@ class RTC_EXPORT DesktopCaptureOptions {
enumerate_current_process_windows_ = enumerate_current_process_windows;
}
bool allow_use_magnification_api() const {
return allow_use_magnification_api_;
}
void set_allow_use_magnification_api(bool allow) {
allow_use_magnification_api_ = allow;
}
// Allowing directx based capturer or not, this capturer works on windows 7
// with platform update / windows 8 or upper.
bool allow_directx_capturer() const { return allow_directx_capturer_; }
@ -238,7 +232,6 @@ class RTC_EXPORT DesktopCaptureOptions {
#if defined(WEBRTC_WIN)
bool enumerate_current_process_windows_ = true;
bool allow_use_magnification_api_ = false;
bool allow_directx_capturer_ = false;
bool allow_cropping_window_capturer_ = false;
#if defined(RTC_ENABLE_WIN_WGC)

View file

@ -171,12 +171,6 @@ class ScreenCapturerIntegrationTest : public ::testing::Test {
MaybeCreateDirectxCapturer();
return true;
}
void CreateMagnifierCapturer() {
DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
options.set_allow_use_magnification_api(true);
capturer_ = DesktopCapturer::CreateScreenCapturer(options);
}
#endif // defined(WEBRTC_WIN)
std::unique_ptr<DesktopCapturer> capturer_;
@ -330,35 +324,6 @@ TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoDirectxCapturers) {
TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
}
TEST_F(ScreenCapturerIntegrationTest,
DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) {
// On Windows 8 or later, magnifier APIs return a frame with a border on test
// environment, so disable these tests.
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
// reproduce on my dev machine.
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
return;
}
CreateMagnifierCapturer();
TestCaptureUpdatedRegion();
}
TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) {
// On Windows 8 or later, magnifier APIs return a frame with a border on test
// environment, so disable these tests.
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
// reproduce on my dev machine.
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
return;
}
CreateMagnifierCapturer();
std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
CreateMagnifierCapturer();
TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
}
TEST_F(ScreenCapturerIntegrationTest,
DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) {
if (rtc::rtc_win::GetVersion() < rtc::rtc_win::Version::VERSION_WIN8) {

View file

@ -57,12 +57,6 @@ class ScreenCapturerTest : public ::testing::Test {
MaybeCreateDirectxCapturer();
return true;
}
void CreateMagnifierCapturer() {
DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
options.set_allow_use_magnification_api(true);
capturer_ = DesktopCapturer::CreateScreenCapturer(options);
}
#endif // defined(WEBRTC_WIN)
std::unique_ptr<DesktopCapturer> capturer_;
@ -185,23 +179,6 @@ TEST_F(ScreenCapturerTest, GdiIsDefault) {
EXPECT_EQ(frame->capturer_id(), DesktopCapturerId::kScreenCapturerWinGdi);
}
TEST_F(ScreenCapturerTest, UseMagnifier) {
CreateMagnifierCapturer();
std::unique_ptr<DesktopFrame> frame;
EXPECT_CALL(callback_,
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
.WillOnce(SaveUniquePtrArg(&frame));
capturer_->Start(&callback_);
capturer_->CaptureFrame();
ASSERT_TRUE(frame);
// Verify Magnifier API or GDI has fallback since the Magnifier API can fail
// to capture a frame on some bots.
EXPECT_TRUE(frame->capturer_id() ==
DesktopCapturerId::kScreenCapturerWinMagnifier ||
frame->capturer_id() == DesktopCapturerId::kScreenCapturerWinGdi);
}
TEST_F(ScreenCapturerTest, UseDirectxCapturer) {
if (!CreateDirectxCapturer()) {
return;
@ -218,32 +195,6 @@ TEST_F(ScreenCapturerTest, UseDirectxCapturer) {
EXPECT_EQ(frame->capturer_id(), DesktopCapturerId::kScreenCapturerWinDirectx);
}
TEST_F(ScreenCapturerTest, DirectxPrecedesMagnifier) {
// Ensure that both DirecX and Magnifier API are supported.
if (!CreateDirectxCapturer()) {
return;
}
CreateMagnifierCapturer();
EXPECT_TRUE(capturer_);
// Enable both DirectX and the Magnifier API and ensure that DirectX is
// selected.
DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
options.set_allow_directx_capturer(true);
options.set_allow_use_magnification_api(true);
capturer_ = DesktopCapturer::CreateScreenCapturer(options);
std::unique_ptr<DesktopFrame> frame;
EXPECT_CALL(callback_,
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
.WillOnce(SaveUniquePtrArg(&frame));
capturer_->Start(&callback_);
capturer_->CaptureFrame();
ASSERT_TRUE(frame);
EXPECT_EQ(frame->capturer_id(), DesktopCapturerId::kScreenCapturerWinDirectx);
}
TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) {
if (!CreateDirectxCapturer()) {
return;

View file

@ -18,7 +18,6 @@
#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
#include "modules/desktop_capture/win/screen_capturer_win_gdi.h"
#include "modules/desktop_capture/win/screen_capturer_win_magnifier.h"
namespace webrtc {
@ -33,11 +32,6 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx(
return capturer;
}
std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinMagnifier() {
std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinMagnifier());
return capturer;
}
} // namespace
// static
@ -56,13 +50,6 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
CreateScreenCapturerWinDirectx(options), std::move(capturer)));
return capturer;
}
} else if (options.allow_use_magnification_api()) {
// ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well
// as 64-bit only Windows, and it may randomly crash on multi-screen
// systems. So we may need to fallback to use original capturer.
capturer.reset(new FallbackDesktopCapturerWrapper(
CreateScreenCapturerWinMagnifier(), std::move(capturer)));
return capturer;
}
// Use GDI as default capturer without any fallback solution.