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

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

Issue 1309143007: Fix ScreenCapturerWinGdi to handle DesktopFrameWin::Create() errors. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // may still be reading from them. 234 // may still be reading from them.
235 if (!queue_.current_frame() || 235 if (!queue_.current_frame() ||
236 !queue_.current_frame()->size().equals(screen_rect.size())) { 236 !queue_.current_frame()->size().equals(screen_rect.size())) {
237 assert(desktop_dc_ != NULL); 237 assert(desktop_dc_ != NULL);
238 assert(memory_dc_ != NULL); 238 assert(memory_dc_ != NULL);
239 239
240 size_t buffer_size = size.width() * size.height() * 240 size_t buffer_size = size.width() * size.height() *
241 DesktopFrame::kBytesPerPixel; 241 DesktopFrame::kBytesPerPixel;
242 SharedMemory* shared_memory = callback_->CreateSharedMemory(buffer_size); 242 SharedMemory* shared_memory = callback_->CreateSharedMemory(buffer_size);
243 243
244 rtc::scoped_ptr<DesktopFrame> buffer; 244 rtc::scoped_ptr<DesktopFrame> buffer(
245 buffer.reset(
246 DesktopFrameWin::Create(size, shared_memory, desktop_dc_)); 245 DesktopFrameWin::Create(size, shared_memory, desktop_dc_));
246 if (!buffer.get())
247 return false;
247 queue_.ReplaceCurrentFrame(buffer.release()); 248 queue_.ReplaceCurrentFrame(buffer.release());
248 } 249 }
249 250
250 // Select the target bitmap into the memory dc and copy the rect from desktop 251 // Select the target bitmap into the memory dc and copy the rect from desktop
251 // to memory. 252 // to memory.
252 DesktopFrameWin* current = static_cast<DesktopFrameWin*>( 253 DesktopFrameWin* current = static_cast<DesktopFrameWin*>(
253 queue_.current_frame()->GetUnderlyingFrame()); 254 queue_.current_frame()->GetUnderlyingFrame());
254 HGDIOBJ previous_object = SelectObject(memory_dc_, current->bitmap()); 255 HGDIOBJ previous_object = SelectObject(memory_dc_, current->bitmap());
255 if (previous_object != NULL) { 256 if (previous_object != NULL) {
256 BitBlt(memory_dc_, 257 BitBlt(memory_dc_,
257 0, 0, screen_rect.width(), screen_rect.height(), 258 0, 0, screen_rect.width(), screen_rect.height(),
258 desktop_dc_, 259 desktop_dc_,
259 screen_rect.left(), screen_rect.top(), 260 screen_rect.left(), screen_rect.top(),
260 SRCCOPY | CAPTUREBLT); 261 SRCCOPY | CAPTUREBLT);
261 262
262 // Select back the previously selected object to that the device contect 263 // Select back the previously selected object to that the device contect
263 // could be destroyed independently of the bitmap if needed. 264 // could be destroyed independently of the bitmap if needed.
264 SelectObject(memory_dc_, previous_object); 265 SelectObject(memory_dc_, previous_object);
265 } 266 }
266 return true; 267 return true;
267 } 268 }
268 269
269 } // namespace webrtc 270 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698