Fix 'Screen flickering on ScreenCapturerWinDirectx'
Bug: webrtc:15718
Change-Id: I230a0a7d196a4a3aea3b3e47cdf4f47c437e7196
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330800
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Zijie He <zijiehe@chromium.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#42177}
diff --git a/AUTHORS b/AUTHORS
index 01ef5ab..e7592cf 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -121,6 +121,7 @@
Stefan Gula <steweg@gmail.com>
Stephan Hartmann <stha09@googlemail.com>
Steve Reid <sreid@sea-to-sky.net>
+Tao chen <meemetao@gmail.com>
Takaaki Suzuki <takaakisuzuki.14@gmail.com>
Tarun Chawla <trnkumarchawla@gmail.com>
Todd Wong <todd.wong.ndq@gmail.com>
diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
index 973aa3f..6fda5a8 100644
--- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc
+++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
@@ -500,6 +500,13 @@
// ensure the video adapter has time to update the screen.
webrtc::SleepMs(ms_per_frame);
}
+ // When capturing multiple monitors, we need to update the captured region to
+ // prevent flickering by re-setting context. See
+ // https://crbug.com/webrtc/15718 for details.
+ if (shared_frame != target) {
+ context->Reset();
+ Setup(context);
+ }
return true;
}