Chromium Code Reviews| 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::SupportedFeatureLevels( | |
| 48 D3D_FEATURE_LEVEL* min_feature_level, | |
| 49 D3D_FEATURE_LEVEL* max_feature_level) { | |
| 50 rtc::CritScope lock(&lock_); | |
| 51 if (!Initialize()) { | |
| 52 return false; | |
| 53 } | |
| 54 if (min_feature_level != nullptr) { | |
|
Sergey Ulanov
2016/11/07 19:37:16
nit: remove "!=nullptr" part.
Hzj_jie
2016/11/08 01:25:40
Done.
| |
| 55 *min_feature_level = min_feature_level_; | |
| 56 } | |
| 57 if (max_feature_level != nullptr) { | |
| 58 *max_feature_level = max_feature_level_; | |
| 59 } | |
| 60 return true; | |
| 61 } | |
| 62 | |
| 47 DesktopVector DxgiDuplicatorController::dpi() { | 63 DesktopVector DxgiDuplicatorController::dpi() { |
| 48 rtc::CritScope lock(&lock_); | 64 rtc::CritScope lock(&lock_); |
| 49 if (Initialize()) { | 65 if (Initialize()) { |
| 50 return dpi_; | 66 return dpi_; |
| 51 } | 67 } |
| 52 return DesktopVector(); | 68 return DesktopVector(); |
| 53 } | 69 } |
| 54 | 70 |
| 55 DesktopRect DxgiDuplicatorController::desktop_rect() { | 71 DesktopRect DxgiDuplicatorController::desktop_rect() { |
| 56 rtc::CritScope lock(&lock_); | 72 rtc::CritScope lock(&lock_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 return true; | 130 return true; |
| 115 } | 131 } |
| 116 Deinitialize(); | 132 Deinitialize(); |
| 117 return false; | 133 return false; |
| 118 } | 134 } |
| 119 | 135 |
| 120 bool DxgiDuplicatorController::DoInitialize() { | 136 bool DxgiDuplicatorController::DoInitialize() { |
| 121 RTC_DCHECK(desktop_rect_.is_empty()); | 137 RTC_DCHECK(desktop_rect_.is_empty()); |
| 122 RTC_DCHECK(duplicators_.empty()); | 138 RTC_DCHECK(duplicators_.empty()); |
| 123 | 139 |
| 140 // The maximum and minimum D3D_FEATURE_LEVEL supported by D3D11CreateDevice by | |
| 141 // default. | |
| 142 min_feature_level_ = D3D_FEATURE_LEVEL_11_0; | |
| 143 max_feature_level_ = D3D_FEATURE_LEVEL_9_1; | |
|
Sergey Ulanov
2016/11/07 19:37:16
Maybe set these to -1 for initialization. Otherwis
Hzj_jie
2016/11/08 01:25:39
In D3dDevice::EnumDevices(), since we do not provi
| |
| 144 | |
| 124 std::vector<D3dDevice> devices = D3dDevice::EnumDevices(); | 145 std::vector<D3dDevice> devices = D3dDevice::EnumDevices(); |
| 125 if (devices.empty()) { | 146 if (devices.empty()) { |
| 126 return false; | 147 return false; |
| 127 } | 148 } |
| 128 | 149 |
| 129 for (size_t i = 0; i < devices.size(); i++) { | 150 for (size_t i = 0; i < devices.size(); i++) { |
| 130 duplicators_.emplace_back(devices[i]); | 151 duplicators_.emplace_back(devices[i]); |
| 131 if (!duplicators_.back().Initialize()) { | 152 if (!duplicators_.back().Initialize()) { |
| 132 return false; | 153 return false; |
| 133 } | 154 } |
| 155 | |
| 156 D3D_FEATURE_LEVEL feature_level = | |
| 157 devices[i].d3d_device()->GetFeatureLevel(); | |
| 158 if (feature_level > max_feature_level_) { | |
| 159 max_feature_level_ = feature_level; | |
| 160 } | |
| 161 if (feature_level < min_feature_level_) { | |
| 162 min_feature_level_ = feature_level; | |
| 163 } | |
| 164 | |
| 134 if (desktop_rect_.is_empty()) { | 165 if (desktop_rect_.is_empty()) { |
| 135 desktop_rect_ = duplicators_.back().desktop_rect(); | 166 desktop_rect_ = duplicators_.back().desktop_rect(); |
| 136 } else { | 167 } else { |
| 137 const DesktopRect& left = desktop_rect_; | 168 const DesktopRect& left = desktop_rect_; |
| 138 const DesktopRect& right = duplicators_.back().desktop_rect(); | 169 const DesktopRect& right = duplicators_.back().desktop_rect(); |
| 139 desktop_rect_ = | 170 desktop_rect_ = |
| 140 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), | 171 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), |
| 141 std::min(left.top(), right.top()), | 172 std::min(left.top(), right.top()), |
| 142 std::max(left.right(), right.right()), | 173 std::max(left.right(), right.right()), |
| 143 std::max(left.bottom(), right.bottom())); | 174 std::max(left.bottom(), right.bottom())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 Deinitialize(); | 258 Deinitialize(); |
| 228 return false; | 259 return false; |
| 229 } | 260 } |
| 230 } | 261 } |
| 231 // id >= ScreenCount(). This is a user error, so we do not need to | 262 // id >= ScreenCount(). This is a user error, so we do not need to |
| 232 // deinitialize. | 263 // deinitialize. |
| 233 return false; | 264 return false; |
| 234 } | 265 } |
| 235 | 266 |
| 236 } // namespace webrtc | 267 } // namespace webrtc |
| OLD | NEW |