diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 02:16:11 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 02:16:11 +0000 |
commit | 36ab217531bda1663cc36bd9522844ece3178d92 (patch) | |
tree | 8aed9ace3ad9048590f853f60a7e25d1830da0ef /media/video | |
parent | d7d570877b98523beb95da5e8051e21444e96ee3 (diff) | |
download | chromium_src-36ab217531bda1663cc36bd9522844ece3178d92.zip chromium_src-36ab217531bda1663cc36bd9522844ece3178d92.tar.gz chromium_src-36ab217531bda1663cc36bd9522844ece3178d92.tar.bz2 |
Add CreateWithDisableAero, to allow Windows capturer to be created without disabling Aero.
BUG=195849
Review URL: https://chromiumcodereview.appspot.com/13556004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r-- | media/video/capture/screen/screen_capture_device.cc | 5 | ||||
-rw-r--r-- | media/video/capture/screen/screen_capturer.h | 6 | ||||
-rw-r--r-- | media/video/capture/screen/screen_capturer_win.cc | 37 |
3 files changed, 32 insertions, 16 deletions
diff --git a/media/video/capture/screen/screen_capture_device.cc b/media/video/capture/screen/screen_capture_device.cc index 8b00406..b22466a 100644 --- a/media/video/capture/screen/screen_capture_device.cc +++ b/media/video/capture/screen/screen_capture_device.cc @@ -278,6 +278,11 @@ void ScreenCaptureDevice::Core::DoAllocate(int frame_rate) { // ARM. See http://crbug.com/230105. if (!screen_capturer_) screen_capturer_ = ScreenCapturer::CreateWithXDamage(true); +#elif defined(OS_WIN) + // ScreenCapturerWin disables Aero by default. We don't want it disabled for + // WebRTC screen capture, though. + if (!screen_capturer_) + screen_capturer_ = ScreenCapturer::CreateWithDisableAero(false); #else if (!screen_capturer_) screen_capturer_ = ScreenCapturer::Create(); diff --git a/media/video/capture/screen/screen_capturer.h b/media/video/capture/screen/screen_capturer.h index 1dc2330..d28b935 100644 --- a/media/video/capture/screen/screen_capturer.h +++ b/media/video/capture/screen/screen_capturer.h @@ -86,7 +86,11 @@ class MEDIA_EXPORT ScreenCapturer { // Creates platform-specific capturer and instructs it whether it should use // X DAMAGE support. static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage); -#endif // defined(OS_LINUX) +#elif defined(OS_WIN) + // Creates Windows-specific capturer and instructs it whether or not to + // disable desktop compositing. + static scoped_ptr<ScreenCapturer> CreateWithDisableAero(bool disable_aero); +#endif // Called at the beginning of a capturing session. |delegate| must remain // valid until Stop() is called. diff --git a/media/video/capture/screen/screen_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc index 0817ee5..3fc02a4 100644 --- a/media/video/capture/screen/screen_capturer_win.cc +++ b/media/video/capture/screen/screen_capturer_win.cc @@ -75,7 +75,7 @@ class ScreenCaptureFrameWin : public ScreenCaptureFrame { // ScreenCapturerWin is double-buffered as required by ScreenCapturer. class ScreenCapturerWin : public ScreenCapturer { public: - ScreenCapturerWin(); + ScreenCapturerWin(bool disable_aero); virtual ~ScreenCapturerWin(); // Overridden from ScreenCapturer: @@ -203,11 +203,24 @@ void ScreenCaptureFrameWin::AllocateBitmap(HDC desktop_dc, bmi.bmiHeader.biSizeImage / std::abs(bmi.bmiHeader.biHeight)); } -ScreenCapturerWin::ScreenCapturerWin() +ScreenCapturerWin::ScreenCapturerWin(bool disable_aero) : delegate_(NULL), desktop_dc_rect_(SkIRect::MakeEmpty()), composition_func_(NULL), set_thread_execution_state_failed_(false) { + if (disable_aero) { + // Load dwmapi.dll dynamically since it is not available on XP. + if (!dwmapi_library_.is_valid()) { + base::FilePath path(base::GetNativeLibraryName( + UTF8ToUTF16(kDwmapiLibraryName))); + dwmapi_library_.Reset(base::LoadNativeLibrary(path, NULL)); + } + + if (dwmapi_library_.is_valid() && composition_func_ == NULL) { + composition_func_ = static_cast<DwmEnableCompositionFunc>( + dwmapi_library_.GetFunctionPointer("DwmEnableComposition")); + } + } } ScreenCapturerWin::~ScreenCapturerWin() { @@ -275,18 +288,6 @@ void ScreenCapturerWin::Start(Delegate* delegate) { delegate_ = delegate; - // Load dwmapi.dll dynamically since it is not available on XP. - if (!dwmapi_library_.is_valid()) { - base::FilePath path(base::GetNativeLibraryName( - UTF8ToUTF16(kDwmapiLibraryName))); - dwmapi_library_.Reset(base::LoadNativeLibrary(path, NULL)); - } - - if (dwmapi_library_.is_valid() && composition_func_ == NULL) { - composition_func_ = static_cast<DwmEnableCompositionFunc>( - dwmapi_library_.GetFunctionPointer("DwmEnableComposition")); - } - // 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. @@ -602,7 +603,13 @@ void ScreenCapturer::Delegate::ReleaseSharedBuffer( // static scoped_ptr<ScreenCapturer> ScreenCapturer::Create() { - return scoped_ptr<ScreenCapturer>(new ScreenCapturerWin()); + return CreateWithDisableAero(true); +} + +// static +scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithDisableAero( + bool disable_aero) { + return scoped_ptr<ScreenCapturer>(new ScreenCapturerWin(disable_aero)); } } // namespace media |