Index: ui/base/x/x11_util.cc |
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc |
index 53418bd2752f42c4b7c2a167387b67f5a8d0deca..fed7764d7b2b3058f2bad0e780076b3d4614a8f4 100644 |
--- a/ui/base/x/x11_util.cc |
+++ b/ui/base/x/x11_util.cc |
@@ -584,8 +584,28 @@ XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap) { |
return picture; |
} |
-void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
- void* pixmap_gc, const uint8* data, int width, int height) { |
+void PutARGBImage(Display* display, |
+ void* visual, int depth, |
+ XID pixmap, void* pixmap_gc, |
+ const uint8* data, |
+ int width, int height) { |
+ PutARGBImage(display, |
+ visual, depth, |
+ pixmap, pixmap_gc, |
+ data, width, height, |
+ 0, 0, // src_x, src_y |
+ 0, 0, // dst_x, dst_y |
+ width, height); |
+} |
+ |
+void PutARGBImage(Display* display, |
+ void* visual, int depth, |
+ XID pixmap, void* pixmap_gc, |
+ const uint8* data, |
+ int data_width, int data_height, |
+ int src_x, int src_y, |
+ int dst_x, int dst_y, |
+ int copy_width, int copy_height) { |
// TODO(scherkus): potential performance impact... consider passing in as a |
// parameter. |
int pixmap_bpp = BitsPerPixelForPixmapDepth(display, depth); |
@@ -593,15 +613,15 @@ void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
XImage image; |
memset(&image, 0, sizeof(image)); |
- image.width = width; |
- image.height = height; |
+ image.width = data_width; |
+ image.height = data_height; |
image.format = ZPixmap; |
image.byte_order = LSBFirst; |
image.bitmap_unit = 8; |
image.bitmap_bit_order = LSBFirst; |
image.depth = depth; |
image.bits_per_pixel = pixmap_bpp; |
- image.bytes_per_line = width * pixmap_bpp / 8; |
+ image.bytes_per_line = data_width * pixmap_bpp / 8; |
if (pixmap_bpp == 32) { |
image.red_mask = 0xff0000; |
@@ -616,8 +636,8 @@ void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
image.blue_mask == vis->blue_mask) { |
image.data = const_cast<char*>(reinterpret_cast<const char*>(data)); |
XPutImage(display, pixmap, static_cast<GC>(pixmap_gc), &image, |
- 0, 0 /* source x, y */, 0, 0 /* dest x, y */, |
- width, height); |
+ src_x, src_y, dst_x, dst_y, |
+ copy_width, copy_height); |
} else { |
// Otherwise, we need to shuffle the colors around. Assume red and blue |
// need to be swapped. |
@@ -625,13 +645,14 @@ void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
// It's possible to use some fancy SSE tricks here, but since this is the |
// slow path anyway, we do it slowly. |
- uint8_t* bitmap32 = static_cast<uint8_t*>(malloc(4 * width * height)); |
+ uint8_t* bitmap32 = |
+ static_cast<uint8_t*>(malloc(4 * data_width * data_height)); |
if (!bitmap32) |
return; |
uint8_t* const orig_bitmap32 = bitmap32; |
const uint32_t* bitmap_in = reinterpret_cast<const uint32_t*>(data); |
- for (int y = 0; y < height; ++y) { |
- for (int x = 0; x < width; ++x) { |
+ for (int y = 0; y < data_height; ++y) { |
+ for (int x = 0; x < data_width; ++x) { |
const uint32_t pixel = *(bitmap_in++); |
bitmap32[0] = (pixel >> 16) & 0xff; // Red |
bitmap32[1] = (pixel >> 8) & 0xff; // Green |
@@ -642,21 +663,22 @@ void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
} |
image.data = reinterpret_cast<char*>(orig_bitmap32); |
XPutImage(display, pixmap, static_cast<GC>(pixmap_gc), &image, |
- 0, 0 /* source x, y */, 0, 0 /* dest x, y */, |
- width, height); |
+ src_x, src_y, dst_x, dst_y, |
+ copy_width, copy_height); |
free(orig_bitmap32); |
} |
} else if (pixmap_bpp == 16) { |
// Some folks have VNC setups which still use 16-bit visuals and VNC |
// doesn't include Xrender. |
- uint16_t* bitmap16 = static_cast<uint16_t*>(malloc(2 * width * height)); |
+ uint16_t* bitmap16 = |
+ static_cast<uint16_t*>(malloc(2 * data_width * data_height)); |
if (!bitmap16) |
return; |
uint16_t* const orig_bitmap16 = bitmap16; |
const uint32_t* bitmap_in = reinterpret_cast<const uint32_t*>(data); |
- for (int y = 0; y < height; ++y) { |
- for (int x = 0; x < width; ++x) { |
+ for (int y = 0; y < data_height; ++y) { |
+ for (int x = 0; x < data_width; ++x) { |
const uint32_t pixel = *(bitmap_in++); |
uint16_t out_pixel = ((pixel >> 8) & 0xf800) | |
((pixel >> 5) & 0x07e0) | |
@@ -671,8 +693,8 @@ void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, |
image.blue_mask = 0x001f; |
XPutImage(display, pixmap, static_cast<GC>(pixmap_gc), &image, |
- 0, 0 /* source x, y */, 0, 0 /* dest x, y */, |
- width, height); |
+ src_x, src_y, dst_x, dst_y, |
+ copy_width, copy_height); |
free(orig_bitmap16); |
} else { |
LOG(FATAL) << "Sorry, we don't support your visual depth without " |