Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 image->red_mask == 0xff0000 && | 53 image->red_mask == 0xff0000 && |
| 54 image->green_mask == 0xff00 && | 54 image->green_mask == 0xff00 && |
| 55 image->blue_mask == 0xff; | 55 image->blue_mask == 0xff; |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 namespace webrtc { | 60 namespace webrtc { |
| 61 | 61 |
| 62 XServerPixelBuffer::XServerPixelBuffer() | 62 XServerPixelBuffer::XServerPixelBuffer() |
| 63 : display_(NULL), window_(0), | 63 : display_(NULL), |
| 64 window_(0), | |
| 64 x_image_(NULL), | 65 x_image_(NULL), |
| 65 shm_segment_info_(NULL), shm_pixmap_(0), shm_gc_(NULL) { | 66 shm_segment_info_(NULL), |
| 66 } | 67 shm_pixmap_(0), |
| 68 shm_gc_(NULL), | |
| 69 is_xshmgetimage_success_(false) {} | |
|
Sergey Ulanov
2016/06/09 22:04:21
Move all initializers to the class definition in t
GeorgeZ
2016/06/10 20:10:37
Done.
| |
| 67 | 70 |
| 68 XServerPixelBuffer::~XServerPixelBuffer() { | 71 XServerPixelBuffer::~XServerPixelBuffer() { |
| 69 Release(); | 72 Release(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void XServerPixelBuffer::Release() { | 75 void XServerPixelBuffer::Release() { |
| 73 if (x_image_) { | 76 if (x_image_) { |
| 74 XDestroyImage(x_image_); | 77 XDestroyImage(x_image_); |
| 75 x_image_ = NULL; | 78 x_image_ = NULL; |
| 76 } | 79 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 return false; | 225 return false; |
| 223 } | 226 } |
| 224 } | 227 } |
| 225 return true; | 228 return true; |
| 226 } | 229 } |
| 227 | 230 |
| 228 void XServerPixelBuffer::Synchronize() { | 231 void XServerPixelBuffer::Synchronize() { |
| 229 if (shm_segment_info_ && !shm_pixmap_) { | 232 if (shm_segment_info_ && !shm_pixmap_) { |
| 230 // XShmGetImage can fail if the display is being reconfigured. | 233 // XShmGetImage can fail if the display is being reconfigured. |
| 231 XErrorTrap error_trap(display_); | 234 XErrorTrap error_trap(display_); |
| 232 XShmGetImage(display_, window_, x_image_, 0, 0, AllPlanes); | 235 if (XShmGetImage(display_, window_, x_image_, 0, 0, AllPlanes)) |
|
Sergey Ulanov
2016/06/09 22:04:21
is_xshmgetimage_success_ = XShmGetImage(...);
Sergey Ulanov
2016/06/09 22:04:21
Add a comment that the call may also fail if the w
GeorgeZ
2016/06/10 20:10:37
Done.
GeorgeZ
2016/06/10 20:10:37
Done.
| |
| 236 is_xshmgetimage_success_ = true; | |
| 237 else | |
| 238 is_xshmgetimage_success_ = false; | |
| 233 } | 239 } |
| 234 } | 240 } |
| 235 | 241 |
| 236 void XServerPixelBuffer::CaptureRect(const DesktopRect& rect, | 242 void XServerPixelBuffer::CaptureRect(const DesktopRect& rect, |
| 237 DesktopFrame* frame) { | 243 DesktopFrame* frame) { |
| 238 assert(rect.right() <= window_size_.width()); | 244 assert(rect.right() <= window_size_.width()); |
| 239 assert(rect.bottom() <= window_size_.height()); | 245 assert(rect.bottom() <= window_size_.height()); |
| 240 | 246 |
| 241 uint8_t* data; | 247 uint8_t* data; |
| 242 | 248 |
| 243 if (shm_segment_info_) { | 249 if (shm_segment_info_ && is_xshmgetimage_success_) { |
|
Sergey Ulanov
2016/06/09 22:04:21
This code won't work correctly when using shm_pixm
GeorgeZ
2016/06/10 20:10:37
Done. Good to know.
| |
| 244 if (shm_pixmap_) { | 250 if (shm_pixmap_) { |
| 245 XCopyArea(display_, window_, shm_pixmap_, shm_gc_, | 251 XCopyArea(display_, window_, shm_pixmap_, shm_gc_, |
| 246 rect.left(), rect.top(), rect.width(), rect.height(), | 252 rect.left(), rect.top(), rect.width(), rect.height(), |
| 247 rect.left(), rect.top()); | 253 rect.left(), rect.top()); |
| 248 XSync(display_, False); | 254 XSync(display_, False); |
| 249 } | 255 } |
| 250 data = reinterpret_cast<uint8_t*>(x_image_->data) + | 256 data = reinterpret_cast<uint8_t*>(x_image_->data) + |
| 251 rect.top() * x_image_->bytes_per_line + | 257 rect.top() * x_image_->bytes_per_line + |
| 252 rect.left() * x_image_->bits_per_pixel / 8; | 258 rect.left() * x_image_->bits_per_pixel / 8; |
| 253 } else { | 259 } else { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 // Write as 32-bit RGB. | 334 // Write as 32-bit RGB. |
| 329 dst_pos_32[x] = ((r >> 8) & 0xff0000) | ((g >> 16) & 0xff00) | | 335 dst_pos_32[x] = ((r >> 8) & 0xff0000) | ((g >> 16) & 0xff00) | |
| 330 ((b >> 24) & 0xff); | 336 ((b >> 24) & 0xff); |
| 331 } | 337 } |
| 332 dst_pos += frame->stride(); | 338 dst_pos += frame->stride(); |
| 333 src_pos += src_stride; | 339 src_pos += src_stride; |
| 334 } | 340 } |
| 335 } | 341 } |
| 336 | 342 |
| 337 } // namespace webrtc | 343 } // namespace webrtc |
| OLD | NEW |