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

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

Issue 2268093002: [WebRTC] A real ScreenCapturer test (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Resolve review comments Created 4 years, 3 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) 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 context->contexts_.clear(); 169 context->contexts_.clear();
170 context->contexts_.resize(duplicators_.size()); 170 context->contexts_.resize(duplicators_.size());
171 for (size_t i = 0; i < duplicators_.size(); i++) { 171 for (size_t i = 0; i < duplicators_.size(); i++) {
172 duplicators_[i].Setup(&context->contexts_[i]); 172 duplicators_[i].Setup(&context->contexts_[i]);
173 } 173 }
174 context->identity_ = identity_; 174 context->identity_ = identity_;
175 } 175 }
176 } 176 }
177 177
178 bool DxgiDuplicatorController::Duplicate(Context* context, 178 bool DxgiDuplicatorController::Duplicate(Context* context,
179 const DesktopFrame* last_frame, 179 SharedDesktopFrame* target) {
180 DesktopFrame* target) { 180 return DoDuplicate(context, -1, target);
181 return DoDuplicate(context, -1, last_frame, target);
182 } 181 }
183 182
184 bool DxgiDuplicatorController::DuplicateMonitor(Context* context, 183 bool DxgiDuplicatorController::DuplicateMonitor(Context* context,
185 int monitor_id, 184 int monitor_id,
186 const DesktopFrame* last_frame, 185 SharedDesktopFrame* target) {
187 DesktopFrame* target) {
188 RTC_DCHECK_GE(monitor_id, 0); 186 RTC_DCHECK_GE(monitor_id, 0);
189 return DoDuplicate(context, monitor_id, last_frame, target); 187 return DoDuplicate(context, monitor_id, target);
190 } 188 }
191 189
192 bool DxgiDuplicatorController::DoDuplicate(Context* context, 190 bool DxgiDuplicatorController::DoDuplicate(Context* context,
193 int monitor_id, 191 int monitor_id,
194 const DesktopFrame* last_frame, 192 SharedDesktopFrame* target) {
195 DesktopFrame* target) {
196 RTC_DCHECK(target); 193 RTC_DCHECK(target);
197 if (last_frame && !target->size().equals(last_frame->size())) {
198 return false;
199 }
200 target->mutable_updated_region()->Clear(); 194 target->mutable_updated_region()->Clear();
201 rtc::CritScope lock(&lock_); 195 rtc::CritScope lock(&lock_);
202 if (!Initialize()) { 196 if (!Initialize()) {
203 // Cannot initialize COM components now, display mode may be changing. 197 // Cannot initialize COM components now, display mode may be changing.
204 return false; 198 return false;
205 } 199 }
200
206 Setup(context); 201 Setup(context);
207 if (monitor_id < 0) { 202 if (monitor_id < 0) {
208 // Capture entire screen. 203 // Capture entire screen.
209 for (size_t i = 0; i < duplicators_.size(); i++) { 204 for (size_t i = 0; i < duplicators_.size(); i++) {
210 if (!duplicators_[i].Duplicate(&context->contexts_[i], last_frame, 205 if (!duplicators_[i].Duplicate(&context->contexts_[i], target)) {
211 target)) {
212 Deinitialize(); 206 Deinitialize();
213 return false; 207 return false;
214 } 208 }
215 } 209 }
216 target->set_dpi(dpi()); 210 target->set_dpi(dpi());
217 return true; 211 return true;
218 } 212 }
219 213
220 // Capture one monitor. 214 // Capture one monitor.
221 for (size_t i = 0; i < duplicators_.size() && i < context->contexts_.size(); 215 for (size_t i = 0; i < duplicators_.size() && i < context->contexts_.size();
222 i++) { 216 i++) {
223 if (monitor_id >= duplicators_[i].screen_count()) { 217 if (monitor_id >= duplicators_[i].screen_count()) {
224 monitor_id -= duplicators_[i].screen_count(); 218 monitor_id -= duplicators_[i].screen_count();
225 } else { 219 } else {
226 if (duplicators_[i].DuplicateMonitor(&context->contexts_[i], monitor_id, 220 if (duplicators_[i].DuplicateMonitor(&context->contexts_[i], monitor_id,
227 last_frame, target)) { 221 target)) {
228 target->set_dpi(dpi()); 222 target->set_dpi(dpi());
229 return true; 223 return true;
230 } 224 }
231 Deinitialize(); 225 Deinitialize();
232 return false; 226 return false;
233 } 227 }
234 } 228 }
235 // id >= ScreenCount(). This is a user error, so we do not need to 229 // id >= ScreenCount(). This is a user error, so we do not need to
236 // deinitialize. 230 // deinitialize.
237 return false; 231 return false;
238 } 232 }
239 233
240 } // namespace webrtc 234 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698