Commit 36ab2175 authored by wez@chromium.org's avatar wez@chromium.org

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
parent d7d57087
......@@ -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();
......
......@@ -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.
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment