| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/x_server_pixel_buffer.h" | 5 #include "remoting/host/x_server_pixel_buffer.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <sys/shm.h> | 8 #include <sys/shm.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 void XServerPixelBuffer::Synchronize() { | 142 void XServerPixelBuffer::Synchronize() { |
| 143 if (shm_segment_info_ && !shm_pixmap_) { | 143 if (shm_segment_info_ && !shm_pixmap_) { |
| 144 // XShmGetImage can fail if the display is being reconfigured. | 144 // XShmGetImage can fail if the display is being reconfigured. |
| 145 gdk_error_trap_push(); | 145 gdk_error_trap_push(); |
| 146 XShmGetImage(display_, root_window_, x_image_, 0, 0, AllPlanes); | 146 XShmGetImage(display_, root_window_, x_image_, 0, 0, AllPlanes); |
| 147 gdk_error_trap_pop(); | 147 gdk_error_trap_pop(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 uint8* XServerPixelBuffer::CaptureRect(const gfx::Rect& rect) { | 151 uint8* XServerPixelBuffer::CaptureRect(const SkIRect& rect) { |
| 152 if (shm_segment_info_) { | 152 if (shm_segment_info_) { |
| 153 if (shm_pixmap_) { | 153 if (shm_pixmap_) { |
| 154 XCopyArea(display_, root_window_, shm_pixmap_, shm_gc_, | 154 XCopyArea(display_, root_window_, shm_pixmap_, shm_gc_, |
| 155 rect.x(), rect.y(), rect.width(), rect.height(), | 155 rect.fLeft, rect.fTop, rect.width(), rect.height(), |
| 156 rect.x(), rect.y()); | 156 rect.fLeft, rect.fTop); |
| 157 XSync(display_, False); | 157 XSync(display_, False); |
| 158 } | 158 } |
| 159 return reinterpret_cast<uint8*>(x_image_->data) + | 159 return reinterpret_cast<uint8*>(x_image_->data) + |
| 160 rect.y() * x_image_->bytes_per_line + | 160 rect.fTop * x_image_->bytes_per_line + |
| 161 rect.x() * x_image_->bits_per_pixel / 8; | 161 rect.fLeft * x_image_->bits_per_pixel / 8; |
| 162 } else { | 162 } else { |
| 163 if (x_image_) | 163 if (x_image_) |
| 164 XDestroyImage(x_image_); | 164 XDestroyImage(x_image_); |
| 165 x_image_ = XGetImage(display_, root_window_, rect.x(), rect.y(), | 165 x_image_ = XGetImage(display_, root_window_, rect.fLeft, rect.fTop, |
| 166 rect.width(), rect.height(), AllPlanes, ZPixmap); | 166 rect.width(), rect.height(), AllPlanes, ZPixmap); |
| 167 return reinterpret_cast<uint8*>(x_image_->data); | 167 return reinterpret_cast<uint8*>(x_image_->data); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 int XServerPixelBuffer::GetStride() const { | 171 int XServerPixelBuffer::GetStride() const { |
| 172 return x_image_->bytes_per_line; | 172 return x_image_->bytes_per_line; |
| 173 } | 173 } |
| 174 | 174 |
| 175 int XServerPixelBuffer::GetDepth() const { | 175 int XServerPixelBuffer::GetDepth() const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 202 | 202 |
| 203 int XServerPixelBuffer::GetGreenShift() const { | 203 int XServerPixelBuffer::GetGreenShift() const { |
| 204 return ffs(x_image_->green_mask) - 1; | 204 return ffs(x_image_->green_mask) - 1; |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool XServerPixelBuffer::IsRgb() const { | 207 bool XServerPixelBuffer::IsRgb() const { |
| 208 return GetRedShift() == 16 && GetGreenShift() == 8 && GetBlueShift() == 0; | 208 return GetRedShift() == 16 && GetGreenShift() == 8 && GetBlueShift() == 0; |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace remoting | 211 } // namespace remoting |
| OLD | NEW |