Bug 1497606 - Remove disable_composition_ in screen_capturer_win_gdi; r=ng
authorDan Minor <dminor@mozilla.com>
Wed, 05 Dec 2018 18:55:57 +0000
changeset 508811 b3f5cca4be44c01024b1ef7b5d4951c7297a112a
parent 508810 1d93612673dcaf876931bce20e7772868137ed2a
child 508812 e1b3f3624b87b0ae2a4719ef9df36c3ffe6aa391
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng
bugs1497606
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497606 - Remove disable_composition_ in screen_capturer_win_gdi; r=ng This removes disable_composition_ and instead uses the value of composition_func_ to determine whether or not composition is disabled. This is what is done by upstream webrtc.org. We call options.set_disable_effects(false) in desktop_capture_impl.cc. Differential Revision: https://phabricator.services.mozilla.com/D13839
media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc
media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc
@@ -33,33 +33,37 @@ const UINT DWM_EC_DISABLECOMPOSITION = 0
 const UINT DWM_EC_ENABLECOMPOSITION = 1;
 
 const wchar_t kDwmapiLibraryName[] = L"dwmapi.dll";
 
 }  // namespace
 
 ScreenCapturerWinGdi::ScreenCapturerWinGdi(
     const DesktopCaptureOptions& options) {
-  // Load dwmapi.dll dynamically since it is not available on XP.
-  if (!dwmapi_library_)
-    dwmapi_library_ = LoadLibrary(kDwmapiLibraryName);
+  if (options.disable_effects()) {
+    // Load dwmapi.dll dynamically since it is not available on XP.
+    if (!dwmapi_library_)
+      dwmapi_library_ = LoadLibrary(kDwmapiLibraryName);
 
-  if (dwmapi_library_) {
-    composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>(
-      GetProcAddress(dwmapi_library_, "DwmEnableComposition"));
-    composition_enabled_func_ = reinterpret_cast<DwmIsCompositionEnabledFunc>
-      (GetProcAddress(dwmapi_library_, "DwmIsCompositionEnabled"));
+    if (dwmapi_library_) {
+      composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>(
+        GetProcAddress(dwmapi_library_, "DwmEnableComposition"));
+      composition_enabled_func_ = reinterpret_cast<DwmIsCompositionEnabledFunc>
+        (GetProcAddress(dwmapi_library_, "DwmIsCompositionEnabled"));
+    }
   }
-
-  disable_composition_ = options.disable_effects();
 }
 
 ScreenCapturerWinGdi::~ScreenCapturerWinGdi() {
   Stop();
 
+  // Restore Aero.
+  if (composition_func_)
+    (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
+
   if (dwmapi_library_)
     FreeLibrary(dwmapi_library_);
 }
 
 void ScreenCapturerWinGdi::SetSharedMemoryFactory(
     std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {
   shared_memory_factory_ = std::move(shared_memory_factory);
 }
@@ -108,37 +112,33 @@ void ScreenCapturerWinGdi::Start(Callbac
   RTC_DCHECK(!callback_);
   RTC_DCHECK(callback);
 
   callback_ = callback;
 
   // Vote to disable Aero composited desktop effects while capturing. Windows
   // will restore Aero automatically if the process exits. This has no effect
   // under Windows 8 or higher.  See crbug.com/124018.
-  if (disable_composition_) {
-    if (composition_func_)
-      (*composition_func_)(DWM_EC_DISABLECOMPOSITION);
-  }
+  if (composition_func_)
+    (*composition_func_)(DWM_EC_DISABLECOMPOSITION);
 }
 
 void ScreenCapturerWinGdi::Stop() {
   if (desktop_dc_) {
     ReleaseDC(NULL, desktop_dc_);
     desktop_dc_ = NULL;
   }
   if (memory_dc_) {
     DeleteDC(memory_dc_);
     memory_dc_ = NULL;
   }
 
-  if (disable_composition_) {
-    // Restore Aero.
-    if (composition_func_)
-      (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
-  }
+  // Restore Aero.
+  if (composition_func_)
+    (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
   callback_ = NULL;
 }
 
 void ScreenCapturerWinGdi::PrepareCaptureResources() {
   // Switch to the desktop receiving user input if different from the current
   // one.
   std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop());
   if (input_desktop && !desktop_.IsSame(*input_desktop)) {
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h
@@ -73,16 +73,14 @@ class ScreenCapturerWinGdi : public Desk
   ScreenCaptureFrameQueue<SharedDesktopFrame> queue_;
 
   DisplayConfigurationMonitor display_configuration_monitor_;
 
   HMODULE dwmapi_library_ = NULL;
   DwmEnableCompositionFunc composition_func_ = nullptr;
   DwmIsCompositionEnabledFunc composition_enabled_func_;
 
-  bool disable_composition_;
-
   RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinGdi);
 };
 
 }  // namespace webrtc
 
 #endif  // MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_GDI_H_