Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1722)

Side by Side Diff: webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc

Issue 2409833002: Remove DesktopRegion parameter in DesktopCapturer::Capture. (Closed)
Patch Set: Change Capture2 to CaptureFrame Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 "magnifier initialization failed."; 65 "magnifier initialization failed.";
66 StartFallbackCapturer(); 66 StartFallbackCapturer();
67 } 67 }
68 } 68 }
69 69
70 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory( 70 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory(
71 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) { 71 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {
72 shared_memory_factory_ = std::move(shared_memory_factory); 72 shared_memory_factory_ = std::move(shared_memory_factory);
73 } 73 }
74 74
75 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { 75 void ScreenCapturerWinMagnifier::CaptureFrame() {
76 if (!magnifier_initialized_ || 76 if (!magnifier_initialized_ ||
77 !magnifier_capture_succeeded_ || 77 !magnifier_capture_succeeded_ ||
78 GetSystemMetrics(SM_CMONITORS) != 1) { 78 GetSystemMetrics(SM_CMONITORS) != 1) {
79 // Do not try to use the magnifier if it failed before and in multi-screen 79 // Do not try to use the magnifier if it failed before and in multi-screen
80 // setup (where the API crashes sometimes). 80 // setup (where the API crashes sometimes).
81 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because " 81 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because "
82 "initialization or last capture attempt failed, or " 82 "initialization or last capture attempt failed, or "
83 "execute on multi-screen system."; 83 "execute on multi-screen system.";
84 StartFallbackCapturer(); 84 StartFallbackCapturer();
85 fallback_capturer_->Capture(region); 85 fallback_capturer_->CaptureFrame();
86 return; 86 return;
87 } 87 }
88 88
89 int64_t capture_start_time_nanos = rtc::TimeNanos(); 89 int64_t capture_start_time_nanos = rtc::TimeNanos();
90 90
91 // Switch to the desktop receiving user input if different from the current 91 // Switch to the desktop receiving user input if different from the current
92 // one. 92 // one.
93 std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop()); 93 std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop());
94 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { 94 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) {
95 // Release GDI resources otherwise SetThreadDesktop will fail. 95 // Release GDI resources otherwise SetThreadDesktop will fail.
96 if (desktop_dc_) { 96 if (desktop_dc_) {
97 ReleaseDC(NULL, desktop_dc_); 97 ReleaseDC(NULL, desktop_dc_);
98 desktop_dc_ = NULL; 98 desktop_dc_ = NULL;
99 } 99 }
100 // If SetThreadDesktop() fails, the thread is still assigned a desktop. 100 // If SetThreadDesktop() fails, the thread is still assigned a desktop.
101 // So we can continue capture screen bits, just from the wrong desktop. 101 // So we can continue capture screen bits, just from the wrong desktop.
102 desktop_.SetThreadDesktop(input_desktop.release()); 102 desktop_.SetThreadDesktop(input_desktop.release());
103 } 103 }
104 104
105 DesktopRect rect = GetScreenRect(current_screen_id_, current_device_key_); 105 DesktopRect rect = GetScreenRect(current_screen_id_, current_device_key_);
106 queue_.MoveToNextFrame(); 106 queue_.MoveToNextFrame();
107 CreateCurrentFrameIfNecessary(rect.size()); 107 CreateCurrentFrameIfNecessary(rect.size());
108 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So 108 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So
109 // defer to the fallback capturer if magnifier capturer did not work. 109 // defer to the fallback capturer if magnifier capturer did not work.
110 if (!CaptureImage(rect)) { 110 if (!CaptureImage(rect)) {
111 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because " 111 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because "
112 "last capture attempt failed."; 112 "last capture attempt failed.";
113 StartFallbackCapturer(); 113 StartFallbackCapturer();
114 fallback_capturer_->Capture(region); 114 fallback_capturer_->CaptureFrame();
115 return; 115 return;
116 } 116 }
117 117
118 // Emit the current frame. 118 // Emit the current frame.
119 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share(); 119 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share();
120 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), 120 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX),
121 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); 121 GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
122 frame->mutable_updated_region()->SetRect( 122 frame->mutable_updated_region()->SetRect(
123 DesktopRect::MakeSize(frame->size())); 123 DesktopRect::MakeSize(frame->size()));
124 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / 124 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 RTC_DCHECK(fallback_capturer_); 380 RTC_DCHECK(fallback_capturer_);
381 if (!fallback_capturer_started_) { 381 if (!fallback_capturer_started_) {
382 fallback_capturer_started_ = true; 382 fallback_capturer_started_ = true;
383 383
384 fallback_capturer_->Start(callback_); 384 fallback_capturer_->Start(callback_);
385 fallback_capturer_->SelectScreen(current_screen_id_); 385 fallback_capturer_->SelectScreen(current_screen_id_);
386 } 386 }
387 } 387 }
388 388
389 } // namespace webrtc 389 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698