OLD | NEW |
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 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 TestCaptureOneFrame(capturers, drawer.get(), rect, color); | 122 TestCaptureOneFrame(capturers, drawer.get(), rect, color); |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 void TestCaptureUpdatedRegion() { | 127 void TestCaptureUpdatedRegion() { |
128 TestCaptureUpdatedRegion({capturer_.get()}); | 128 TestCaptureUpdatedRegion({capturer_.get()}); |
129 } | 129 } |
130 | 130 |
131 #if defined(WEBRTC_WIN) | 131 #if defined(WEBRTC_WIN) |
| 132 // Enable allow_directx_capturer in DesktopCaptureOptions, but let |
| 133 // ScreenCapturer::Create to decide whether a DirectX capturer should be used. |
| 134 void MaybeCreateDirectxCapturer() { |
| 135 DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); |
| 136 options.set_allow_directx_capturer(true); |
| 137 capturer_.reset(ScreenCapturer::Create(options)); |
| 138 } |
| 139 |
132 bool CreateDirectxCapturer() { | 140 bool CreateDirectxCapturer() { |
133 if (!ScreenCapturerWinDirectx::IsSupported()) { | 141 if (!ScreenCapturerWinDirectx::IsSupported()) { |
134 LOG(LS_WARNING) << "Directx capturer is not supported"; | 142 LOG(LS_WARNING) << "Directx capturer is not supported"; |
135 return false; | 143 return false; |
136 } | 144 } |
137 | 145 |
138 DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); | 146 MaybeCreateDirectxCapturer(); |
139 options.set_allow_directx_capturer(true); | |
140 capturer_.reset(ScreenCapturer::Create(options)); | |
141 return true; | 147 return true; |
142 } | 148 } |
143 | 149 |
144 void CreateMagnifierCapturer() { | 150 void CreateMagnifierCapturer() { |
145 DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); | 151 DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); |
146 options.set_allow_use_magnification_api(true); | 152 options.set_allow_use_magnification_api(true); |
147 capturer_.reset(ScreenCapturer::Create(options)); | 153 capturer_.reset(ScreenCapturer::Create(options)); |
148 } | 154 } |
149 #endif // defined(WEBRTC_WIN) | 155 #endif // defined(WEBRTC_WIN) |
150 | 156 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); | 371 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
366 } | 372 } |
367 | 373 |
368 TEST_F(ScreenCapturerTest, TwoMagnifierCapturers) { | 374 TEST_F(ScreenCapturerTest, TwoMagnifierCapturers) { |
369 CreateMagnifierCapturer(); | 375 CreateMagnifierCapturer(); |
370 std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_); | 376 std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_); |
371 CreateMagnifierCapturer(); | 377 CreateMagnifierCapturer(); |
372 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); | 378 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
373 } | 379 } |
374 | 380 |
| 381 TEST_F(ScreenCapturerTest, MaybeCaptureUpdatedRegionWithDirectxCapturer) { |
| 382 // Even DirectX capturer is not supported in current system, we should be able |
| 383 // to select a usable capturer. |
| 384 MaybeCreateDirectxCapturer(); |
| 385 TestCaptureUpdatedRegion(); |
| 386 } |
| 387 |
375 #endif // defined(WEBRTC_WIN) | 388 #endif // defined(WEBRTC_WIN) |
376 | 389 |
377 } // namespace webrtc | 390 } // namespace webrtc |
OLD | NEW |