Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_win.cc

Issue 2933893003: Add reference counter of DxgiDuplicatorController to unload DXGI components (Closed)
Patch Set: Add reference counter for DxgiDuplicatorController Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper .h" 14 #include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper .h"
15 #include "webrtc/modules/desktop_capture/desktop_capturer.h" 15 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
16 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 16 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
17 #include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h" 17 #include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h"
18 #include "webrtc/modules/desktop_capture/rgba_color.h" 18 #include "webrtc/modules/desktop_capture/rgba_color.h"
19 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" 19 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
20 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h" 20 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h"
21 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" 21 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 24
25 namespace { 25 namespace {
26 26
27 std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx( 27 std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx(
28 const DesktopCaptureOptions& options) { 28 const DesktopCaptureOptions& options) {
29 std::unique_ptr<DesktopCapturer> capturer( 29 std::unique_ptr<DesktopCapturer> capturer(
30 new ScreenCapturerWinDirectx(options)); 30 new ScreenCapturerWinDirectx());
31 capturer.reset(new BlankDetectorDesktopCapturerWrapper( 31 capturer.reset(new BlankDetectorDesktopCapturerWrapper(
32 std::move(capturer), RgbaColor(0, 0, 0, 0))); 32 std::move(capturer), RgbaColor(0, 0, 0, 0)));
33 return capturer; 33 return capturer;
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 // static 38 // static
39 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer( 39 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
40 const DesktopCaptureOptions& options) { 40 const DesktopCaptureOptions& options) {
41 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options)); 41 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options));
42 if (options.allow_directx_capturer() && 42 if (options.allow_directx_capturer()) {
43 ScreenCapturerWinDirectx::IsSupported()) { 43 // |directx_capturer| should be alive in this scope to ensure it won't
44 capturer.reset(new FallbackDesktopCapturerWrapper( 44 // unload DxgiDuplicatorController.
45 CreateScreenCapturerWinDirectx(options), std::move(capturer))); 45 ScreenCapturerWinDirectx directx_capturer;
46 if (directx_capturer.IsAvailable()) {
47 capturer.reset(new FallbackDesktopCapturerWrapper(
48 CreateScreenCapturerWinDirectx(options), std::move(capturer)));
49 }
46 } 50 }
47 51
48 if (options.allow_use_magnification_api()) { 52 if (options.allow_use_magnification_api()) {
49 // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well 53 // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well
50 // as 64-bit only Windows, and it may randomly crash on multi-screen 54 // as 64-bit only Windows, and it may randomly crash on multi-screen
51 // systems. So we may need to fallback to use original capturer. 55 // systems. So we may need to fallback to use original capturer.
52 capturer.reset(new FallbackDesktopCapturerWrapper( 56 capturer.reset(new FallbackDesktopCapturerWrapper(
53 std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()), 57 std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()),
54 std::move(capturer))); 58 std::move(capturer)));
55 } 59 }
56 60
57 return capturer; 61 return capturer;
58 } 62 }
59 63
60 } // namespace webrtc 64 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698