| 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 26 matching lines...) Expand all Loading... |
| 37 DxgiDuplicatorController::~DxgiDuplicatorController() { | 37 DxgiDuplicatorController::~DxgiDuplicatorController() { |
| 38 rtc::CritScope lock(&lock_); | 38 rtc::CritScope lock(&lock_); |
| 39 Deinitialize(); | 39 Deinitialize(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool DxgiDuplicatorController::IsSupported() { | 42 bool DxgiDuplicatorController::IsSupported() { |
| 43 rtc::CritScope lock(&lock_); | 43 rtc::CritScope lock(&lock_); |
| 44 return Initialize(); | 44 return Initialize(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool DxgiDuplicatorController::RetrieveD3dInfo(D3dInfo* info) { |
| 48 rtc::CritScope lock(&lock_); |
| 49 if (!Initialize()) { |
| 50 return false; |
| 51 } |
| 52 *info = d3d_info_; |
| 53 return true; |
| 54 } |
| 55 |
| 47 DesktopVector DxgiDuplicatorController::dpi() { | 56 DesktopVector DxgiDuplicatorController::dpi() { |
| 48 rtc::CritScope lock(&lock_); | 57 rtc::CritScope lock(&lock_); |
| 49 if (Initialize()) { | 58 if (Initialize()) { |
| 50 return dpi_; | 59 return dpi_; |
| 51 } | 60 } |
| 52 return DesktopVector(); | 61 return DesktopVector(); |
| 53 } | 62 } |
| 54 | 63 |
| 55 DesktopRect DxgiDuplicatorController::desktop_rect() { | 64 DesktopRect DxgiDuplicatorController::desktop_rect() { |
| 56 rtc::CritScope lock(&lock_); | 65 rtc::CritScope lock(&lock_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return true; | 123 return true; |
| 115 } | 124 } |
| 116 Deinitialize(); | 125 Deinitialize(); |
| 117 return false; | 126 return false; |
| 118 } | 127 } |
| 119 | 128 |
| 120 bool DxgiDuplicatorController::DoInitialize() { | 129 bool DxgiDuplicatorController::DoInitialize() { |
| 121 RTC_DCHECK(desktop_rect_.is_empty()); | 130 RTC_DCHECK(desktop_rect_.is_empty()); |
| 122 RTC_DCHECK(duplicators_.empty()); | 131 RTC_DCHECK(duplicators_.empty()); |
| 123 | 132 |
| 133 d3d_info_.min_feature_level = static_cast<D3D_FEATURE_LEVEL>(0); |
| 134 d3d_info_.max_feature_level = static_cast<D3D_FEATURE_LEVEL>(0); |
| 135 |
| 124 std::vector<D3dDevice> devices = D3dDevice::EnumDevices(); | 136 std::vector<D3dDevice> devices = D3dDevice::EnumDevices(); |
| 125 if (devices.empty()) { | 137 if (devices.empty()) { |
| 126 return false; | 138 return false; |
| 127 } | 139 } |
| 128 | 140 |
| 129 for (size_t i = 0; i < devices.size(); i++) { | 141 for (size_t i = 0; i < devices.size(); i++) { |
| 130 duplicators_.emplace_back(devices[i]); | 142 duplicators_.emplace_back(devices[i]); |
| 131 if (!duplicators_.back().Initialize()) { | 143 if (!duplicators_.back().Initialize()) { |
| 132 return false; | 144 return false; |
| 133 } | 145 } |
| 146 |
| 147 D3D_FEATURE_LEVEL feature_level = |
| 148 devices[i].d3d_device()->GetFeatureLevel(); |
| 149 if (d3d_info_.max_feature_level == 0 || |
| 150 feature_level > d3d_info_.max_feature_level) { |
| 151 d3d_info_.max_feature_level = feature_level; |
| 152 } |
| 153 if (d3d_info_.min_feature_level == 0 || |
| 154 feature_level < d3d_info_.min_feature_level) { |
| 155 d3d_info_.min_feature_level = feature_level; |
| 156 } |
| 157 |
| 134 if (desktop_rect_.is_empty()) { | 158 if (desktop_rect_.is_empty()) { |
| 135 desktop_rect_ = duplicators_.back().desktop_rect(); | 159 desktop_rect_ = duplicators_.back().desktop_rect(); |
| 136 } else { | 160 } else { |
| 137 const DesktopRect& left = desktop_rect_; | 161 const DesktopRect& left = desktop_rect_; |
| 138 const DesktopRect& right = duplicators_.back().desktop_rect(); | 162 const DesktopRect& right = duplicators_.back().desktop_rect(); |
| 139 desktop_rect_ = | 163 desktop_rect_ = |
| 140 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), | 164 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), |
| 141 std::min(left.top(), right.top()), | 165 std::min(left.top(), right.top()), |
| 142 std::max(left.right(), right.right()), | 166 std::max(left.right(), right.right()), |
| 143 std::max(left.bottom(), right.bottom())); | 167 std::max(left.bottom(), right.bottom())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 Deinitialize(); | 251 Deinitialize(); |
| 228 return false; | 252 return false; |
| 229 } | 253 } |
| 230 } | 254 } |
| 231 // id >= ScreenCount(). This is a user error, so we do not need to | 255 // id >= ScreenCount(). This is a user error, so we do not need to |
| 232 // deinitialize. | 256 // deinitialize. |
| 233 return false; | 257 return false; |
| 234 } | 258 } |
| 235 | 259 |
| 236 } // namespace webrtc | 260 } // namespace webrtc |
| OLD | NEW |