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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 desktop_rect_ = duplicators_.back().desktop_rect(); | 186 desktop_rect_ = duplicators_.back().desktop_rect(); |
187 } else { | 187 } else { |
188 const DesktopRect& left = desktop_rect_; | 188 const DesktopRect& left = desktop_rect_; |
189 const DesktopRect& right = duplicators_.back().desktop_rect(); | 189 const DesktopRect& right = duplicators_.back().desktop_rect(); |
190 desktop_rect_ = | 190 desktop_rect_ = |
191 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), | 191 DesktopRect::MakeLTRB(std::min(left.left(), right.left()), |
192 std::min(left.top(), right.top()), | 192 std::min(left.top(), right.top()), |
193 std::max(left.right(), right.right()), | 193 std::max(left.right(), right.right()), |
194 std::max(left.bottom(), right.bottom())); | 194 std::max(left.bottom(), right.bottom())); |
195 } | 195 } |
196 TranslateRect(); | |
197 } | 196 } |
198 | 197 |
199 HDC hdc = GetDC(nullptr); | 198 HDC hdc = GetDC(nullptr); |
200 // Use old DPI value if failed. | 199 // Use old DPI value if failed. |
201 if (hdc) { | 200 if (hdc) { |
202 dpi_.set(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY)); | 201 dpi_.set(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY)); |
203 ReleaseDC(nullptr, hdc); | 202 ReleaseDC(nullptr, hdc); |
204 } | 203 } |
205 | 204 |
206 identity_++; | 205 identity_++; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 int64_t DxgiDuplicatorController::GetNumFramesCaptured() const { | 288 int64_t DxgiDuplicatorController::GetNumFramesCaptured() const { |
290 int64_t min = INT64_MAX; | 289 int64_t min = INT64_MAX; |
291 for (const auto& duplicator : duplicators_) { | 290 for (const auto& duplicator : duplicators_) { |
292 min = std::min(min, duplicator.GetNumFramesCaptured()); | 291 min = std::min(min, duplicator.GetNumFramesCaptured()); |
293 } | 292 } |
294 | 293 |
295 return min; | 294 return min; |
296 } | 295 } |
297 | 296 |
298 DesktopSize DxgiDuplicatorController::desktop_size() const { | 297 DesktopSize DxgiDuplicatorController::desktop_size() const { |
299 return desktop_rect_.size(); | 298 return DesktopSize(desktop_rect_.right(), desktop_rect_.bottom()); |
300 } | 299 } |
301 | 300 |
302 DesktopRect DxgiDuplicatorController::ScreenRect(int id) const { | 301 DesktopRect DxgiDuplicatorController::ScreenRect(int id) const { |
303 RTC_DCHECK(id >= 0); | 302 RTC_DCHECK(id >= 0); |
304 for (size_t i = 0; i < duplicators_.size(); i++) { | 303 for (size_t i = 0; i < duplicators_.size(); i++) { |
305 if (id >= duplicators_[i].screen_count()) { | 304 if (id >= duplicators_[i].screen_count()) { |
306 id -= duplicators_[i].screen_count(); | 305 id -= duplicators_[i].screen_count(); |
307 } else { | 306 } else { |
308 return duplicators_[i].ScreenRect(id); | 307 return duplicators_[i].ScreenRect(id); |
309 } | 308 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (!DoDuplicateAll(context, shared_frame)) { | 371 if (!DoDuplicateAll(context, shared_frame)) { |
373 return false; | 372 return false; |
374 } | 373 } |
375 if (rtc::TimeMillis() - start_ms > timeout_ms) { | 374 if (rtc::TimeMillis() - start_ms > timeout_ms) { |
376 return false; | 375 return false; |
377 } | 376 } |
378 } | 377 } |
379 return true; | 378 return true; |
380 } | 379 } |
381 | 380 |
382 void DxgiDuplicatorController::TranslateRect() { | |
383 const DesktopVector position = | |
384 DesktopVector().subtract(desktop_rect_.top_left()); | |
385 desktop_rect_.Translate(position); | |
386 for (auto& duplicator : duplicators_) { | |
387 duplicator.TranslateRect(position); | |
388 } | |
389 } | |
390 | |
391 } // namespace webrtc | 381 } // namespace webrtc |
OLD | NEW |