diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 22:52:04 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 22:52:04 +0000 |
commit | 7dac0053f2b3e6e05bf715bb814caed72337bd05 (patch) | |
tree | 69150229d2d905e09d9c5916a5c70c222278cf08 /remoting/host | |
parent | 6aab60f6e62be9bd32bd9cdb36d637cee760a5de (diff) | |
download | chromium_src-7dac0053f2b3e6e05bf715bb814caed72337bd05.zip chromium_src-7dac0053f2b3e6e05bf715bb814caed72337bd05.tar.gz chromium_src-7dac0053f2b3e6e05bf715bb814caed72337bd05.tar.bz2 |
Only grab the full-screen image once, not per damage rect.
BUG=None
TEST=Dragging a large window around isn't glacially slow.
(ensure "xdpyinfo -ext MIT-SHM" shows SHM enabled, with no pixmap support)
Review URL: http://codereview.chromium.org/6905110
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/capturer_linux.cc | 1 | ||||
-rw-r--r-- | remoting/host/x_server_pixel_buffer.cc | 16 | ||||
-rw-r--r-- | remoting/host/x_server_pixel_buffer.h | 9 |
3 files changed, 19 insertions, 7 deletions
diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc index 6aaff4e..2c5a2d7 100644 --- a/remoting/host/capturer_linux.cc +++ b/remoting/host/capturer_linux.cc @@ -288,6 +288,7 @@ void CapturerLinux::CaptureRects( } } + x_server_pixel_buffer_.Synchronize(); for (InvalidRects::const_iterator it = rects.begin(); it != rects.end(); ++it) { diff --git a/remoting/host/x_server_pixel_buffer.cc b/remoting/host/x_server_pixel_buffer.cc index b93c40f..ae2a016 100644 --- a/remoting/host/x_server_pixel_buffer.cc +++ b/remoting/host/x_server_pixel_buffer.cc @@ -136,6 +136,15 @@ void XServerPixelBuffer::DestroyShmSegmentInfo() { } } +void XServerPixelBuffer::Synchronize() { + if (shm_segment_info_ && !shm_pixmap_) { + // XShmGetImage can fail if the display is being reconfigured. + gdk_error_trap_push(); + XShmGetImage(display_, root_window_, x_image_, 0, 0, AllPlanes); + gdk_error_trap_pop(); + } +} + uint8* XServerPixelBuffer::CaptureRect(const gfx::Rect& rect) { if (shm_segment_info_) { if (shm_pixmap_) { @@ -143,18 +152,11 @@ uint8* XServerPixelBuffer::CaptureRect(const gfx::Rect& rect) { rect.x(), rect.y(), rect.width(), rect.height(), rect.x(), rect.y()); XSync(display_, False); - } else { - // XShmGetImage can fail if the display is being reconfigured. - gdk_error_trap_push(); - XShmGetImage(display_, root_window_, x_image_, 0, 0, AllPlanes); - gdk_error_trap_pop(); } return reinterpret_cast<uint8*>(x_image_->data) + rect.y() * x_image_->bytes_per_line + rect.x() * x_image_->bits_per_pixel / 8; } else { - // XGetSubImage would allow cleaner code here, (in particular, - // CaptureComplete could be removed) but XGetImage is faster. if (x_image_) XDestroyImage(x_image_); x_image_ = XGetImage(display_, root_window_, rect.x(), rect.y(), diff --git a/remoting/host/x_server_pixel_buffer.h b/remoting/host/x_server_pixel_buffer.h index e27b9f7..9ab03bf 100644 --- a/remoting/host/x_server_pixel_buffer.h +++ b/remoting/host/x_server_pixel_buffer.h @@ -25,9 +25,18 @@ class XServerPixelBuffer { void Init(Display* display); + // If shared memory is being used without pixmaps, synchronize this pixel + // buffer with the root window contents (otherwise, this is a no-op). + // This is to avoid doing a full-screen capture for each individual + // rectangle in the capture list, when it only needs to be done once at the + // beginning. + void Synchronize(); + // Capture the specified rectangle and return a pointer to its top-left pixel // or NULL if capture fails. The returned pointer remains valid until the next // call to CaptureRect. + // In the case where the full-screen data is captured by Synchronize(), this + // simply returns the pointer without doing any more work. uint8* CaptureRect(const gfx::Rect& rect); // Return information about the most recent capture. This is only guaranteed |