OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 bool DxgiAdapterDuplicator::DoInitialize() { | 46 bool DxgiAdapterDuplicator::DoInitialize() { |
47 for (int i = 0;; i++) { | 47 for (int i = 0;; i++) { |
48 ComPtr<IDXGIOutput> output; | 48 ComPtr<IDXGIOutput> output; |
49 _com_error error = | 49 _com_error error = |
50 device_.dxgi_adapter()->EnumOutputs(i, output.GetAddressOf()); | 50 device_.dxgi_adapter()->EnumOutputs(i, output.GetAddressOf()); |
51 if (error.Error() == DXGI_ERROR_NOT_FOUND) { | 51 if (error.Error() == DXGI_ERROR_NOT_FOUND) { |
52 break; | 52 break; |
53 } | 53 } |
54 | 54 |
| 55 if (error.Error() == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) { |
| 56 LOG(LS_WARNING) << "IDXGIAdapter::EnumOutputs returns " |
| 57 "NOT_CURRENTLY_AVAILABLE. This may happen when " |
| 58 "running in session 0."; |
| 59 break; |
| 60 } |
| 61 |
55 if (error.Error() != S_OK || !output) { | 62 if (error.Error() != S_OK || !output) { |
56 LOG(LS_WARNING) << "IDXGIAdapter::EnumOutputs returns an unexpected " | 63 LOG(LS_WARNING) << "IDXGIAdapter::EnumOutputs returns an unexpected " |
57 "result " | 64 "result " |
58 << error.ErrorMessage() << " with error code" | 65 << error.ErrorMessage() << " with error code" |
59 << error.Error(); | 66 << error.Error(); |
60 return false; | 67 continue; |
61 } | 68 } |
62 | 69 |
63 DXGI_OUTPUT_DESC desc; | 70 DXGI_OUTPUT_DESC desc; |
64 error = output->GetDesc(&desc); | 71 error = output->GetDesc(&desc); |
65 if (error.Error() == S_OK) { | 72 if (error.Error() == S_OK) { |
66 if (desc.AttachedToDesktop && IsValidRect(desc.DesktopCoordinates)) { | 73 if (desc.AttachedToDesktop && IsValidRect(desc.DesktopCoordinates)) { |
67 ComPtr<IDXGIOutput1> output1; | 74 ComPtr<IDXGIOutput1> output1; |
68 error = output.As(&output1); | 75 error = output.As(&output1); |
69 if (error.Error() != S_OK || !output1) { | 76 if (error.Error() != S_OK || !output1) { |
70 LOG(LS_WARNING) << "Failed to convert IDXGIOutput to IDXGIOutput1, " | 77 LOG(LS_WARNING) << "Failed to convert IDXGIOutput to IDXGIOutput1, " |
71 "this usually means the system does not support " | 78 "this usually means the system does not support " |
72 "DirectX 11"; | 79 "DirectX 11"; |
73 return false; | 80 continue; |
74 } | 81 } |
75 duplicators_.emplace_back(device_, output1, desc); | 82 DxgiOutputDuplicator duplicator(device_, output1, desc); |
76 if (!duplicators_.back().Initialize()) { | 83 if (!duplicator.Initialize()) { |
77 return false; | 84 LOG(LS_WARNING) << "Failed to initialize DxgiOutputDuplicator on " |
| 85 "output " |
| 86 << i; |
| 87 continue; |
78 } | 88 } |
| 89 |
| 90 duplicators_.push_back(std::move(duplicator)); |
79 desktop_rect_.UnionWith(duplicators_.back().desktop_rect()); | 91 desktop_rect_.UnionWith(duplicators_.back().desktop_rect()); |
80 } | 92 } |
81 } else { | 93 } else { |
82 LOG(LS_WARNING) << "Failed to get output description of device " << i | 94 LOG(LS_WARNING) << "Failed to get output description of device " << i |
83 << ", ignore."; | 95 << ", ignore."; |
84 } | 96 } |
85 } | 97 } |
86 return true; | 98 |
| 99 if (duplicators_.empty()) { |
| 100 LOG(LS_WARNING) << "Cannot initialize any DxgiOutputDuplicator instance."; |
| 101 } |
| 102 |
| 103 return !duplicators_.empty(); |
87 } | 104 } |
88 | 105 |
89 void DxgiAdapterDuplicator::Setup(Context* context) { | 106 void DxgiAdapterDuplicator::Setup(Context* context) { |
90 RTC_DCHECK(context->contexts.empty()); | 107 RTC_DCHECK(context->contexts.empty()); |
91 context->contexts.resize(duplicators_.size()); | 108 context->contexts.resize(duplicators_.size()); |
92 for (size_t i = 0; i < duplicators_.size(); i++) { | 109 for (size_t i = 0; i < duplicators_.size(); i++) { |
93 duplicators_[i].Setup(&context->contexts[i]); | 110 duplicators_[i].Setup(&context->contexts[i]); |
94 } | 111 } |
95 } | 112 } |
96 | 113 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 161 |
145 void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) { | 162 void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) { |
146 desktop_rect_.Translate(position); | 163 desktop_rect_.Translate(position); |
147 RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0); | 164 RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0); |
148 for (auto& duplicator : duplicators_) { | 165 for (auto& duplicator : duplicators_) { |
149 duplicator.TranslateRect(position); | 166 duplicator.TranslateRect(position); |
150 } | 167 } |
151 } | 168 } |
152 | 169 |
153 } // namespace webrtc | 170 } // namespace webrtc |
OLD | NEW |