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. Is it running on session 0?"; | |
Sergey Ulanov
2017/06/26 23:41:41
Rephrase the second sentence as a statement instea
Hzj_jie
2017/06/27 04:37:33
Done.
| |
58 break; | |
59 } | |
60 | |
55 if (error.Error() != S_OK || !output) { | 61 if (error.Error() != S_OK || !output) { |
56 LOG(LS_WARNING) << "IDXGIAdapter::EnumOutputs returns an unexpected " | 62 LOG(LS_WARNING) << "IDXGIAdapter::EnumOutputs returns an unexpected " |
57 "result " | 63 "result " |
58 << error.ErrorMessage() << " with error code" | 64 << error.ErrorMessage() << " with error code" |
59 << error.Error(); | 65 << error.Error(); |
60 return false; | 66 continue; |
61 } | 67 } |
62 | 68 |
63 DXGI_OUTPUT_DESC desc; | 69 DXGI_OUTPUT_DESC desc; |
64 error = output->GetDesc(&desc); | 70 error = output->GetDesc(&desc); |
65 if (error.Error() == S_OK) { | 71 if (error.Error() == S_OK) { |
66 if (desc.AttachedToDesktop && IsValidRect(desc.DesktopCoordinates)) { | 72 if (desc.AttachedToDesktop && IsValidRect(desc.DesktopCoordinates)) { |
67 ComPtr<IDXGIOutput1> output1; | 73 ComPtr<IDXGIOutput1> output1; |
68 error = output.As(&output1); | 74 error = output.As(&output1); |
69 if (error.Error() != S_OK || !output1) { | 75 if (error.Error() != S_OK || !output1) { |
70 LOG(LS_WARNING) << "Failed to convert IDXGIOutput to IDXGIOutput1, " | 76 LOG(LS_WARNING) << "Failed to convert IDXGIOutput to IDXGIOutput1, " |
71 "this usually means the system does not support " | 77 "this usually means the system does not support " |
72 "DirectX 11"; | 78 "DirectX 11"; |
73 return false; | 79 continue; |
74 } | 80 } |
75 duplicators_.emplace_back(device_, output1, desc); | 81 DxgiOutputDuplicator duplicator(device_, output1, desc); |
76 if (!duplicators_.back().Initialize()) { | 82 if (!duplicator.Initialize()) { |
77 return false; | 83 LOG(LS_WARNING) << "Failed to initialize DxgiOutputDuplicator on " |
84 "output " | |
85 << i; | |
86 continue; | |
78 } | 87 } |
88 | |
89 duplicators_.push_back(std::move(duplicator)); | |
79 desktop_rect_.UnionWith(duplicators_.back().desktop_rect()); | 90 desktop_rect_.UnionWith(duplicators_.back().desktop_rect()); |
80 } | 91 } |
81 } else { | 92 } else { |
82 LOG(LS_WARNING) << "Failed to get output description of device " << i | 93 LOG(LS_WARNING) << "Failed to get output description of device " << i |
83 << ", ignore."; | 94 << ", ignore."; |
84 } | 95 } |
85 } | 96 } |
86 return true; | 97 |
98 if (duplicators_.empty()) { | |
99 LOG(LS_WARNING) << "Cannot initialize any DxgiOutputDuplicator instance."; | |
100 } | |
101 | |
102 return !duplicators_.empty(); | |
87 } | 103 } |
88 | 104 |
89 void DxgiAdapterDuplicator::Setup(Context* context) { | 105 void DxgiAdapterDuplicator::Setup(Context* context) { |
90 RTC_DCHECK(context->contexts.empty()); | 106 RTC_DCHECK(context->contexts.empty()); |
91 context->contexts.resize(duplicators_.size()); | 107 context->contexts.resize(duplicators_.size()); |
92 for (size_t i = 0; i < duplicators_.size(); i++) { | 108 for (size_t i = 0; i < duplicators_.size(); i++) { |
93 duplicators_[i].Setup(&context->contexts[i]); | 109 duplicators_[i].Setup(&context->contexts[i]); |
94 } | 110 } |
95 } | 111 } |
96 | 112 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 160 |
145 void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) { | 161 void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) { |
146 desktop_rect_.Translate(position); | 162 desktop_rect_.Translate(position); |
147 RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0); | 163 RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0); |
148 for (auto& duplicator : duplicators_) { | 164 for (auto& duplicator : duplicators_) { |
149 duplicator.TranslateRect(position); | 165 duplicator.TranslateRect(position); |
150 } | 166 } |
151 } | 167 } |
152 | 168 |
153 } // namespace webrtc | 169 } // namespace webrtc |
OLD | NEW |