|
|
95d809 |
# HG changeset patch
|
|
|
95d809 |
# User kaddepalli
|
|
|
95d809 |
# Date 1517818481 -19800
|
|
|
95d809 |
# Mon Feb 05 13:44:41 2018 +0530
|
|
|
95d809 |
# Node ID b77308735540644d4710244e3c88865067f2905a
|
|
|
95d809 |
# Parent 39bfc94b1f4265b645c2970a58389acc779dafe9
|
|
|
95d809 |
8171000, PR3542, RH1402819: Robot.createScreenCapture() crashes in wayland mode
|
|
|
95d809 |
Reviewed-by: serb, mhalder
|
|
|
95d809 |
|
|
|
95d809 |
diff --git openjdk.orig/jdk/src/solaris/native/sun/awt/multiVis.c openjdk/jdk/src/solaris/native/sun/awt/multiVis.c
|
|
|
95d809 |
--- openjdk.orig/jdk/src/solaris/native/sun/awt/multiVis.c
|
|
|
95d809 |
+++ openjdk/jdk/src/solaris/native/sun/awt/multiVis.c
|
|
|
95d809 |
@@ -394,77 +394,48 @@
|
|
|
95d809 |
XRectangle bbox; /* bounding box of grabbed area */
|
|
|
95d809 |
list_ptr regions;/* list of regions to read from */
|
|
|
95d809 |
{
|
|
|
95d809 |
- image_region_type *reg;
|
|
|
95d809 |
- int32_t dst_x, dst_y; /* where in pixmap to write (UL) */
|
|
|
95d809 |
- int32_t diff;
|
|
|
95d809 |
-
|
|
|
95d809 |
- XImage *reg_image,*ximage ;
|
|
|
95d809 |
- int32_t srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
|
|
|
95d809 |
- int32_t rem ;
|
|
|
95d809 |
- int32_t bytes_per_line;
|
|
|
95d809 |
- int32_t bitmap_unit;
|
|
|
95d809 |
-
|
|
|
95d809 |
- bitmap_unit = sizeof (long);
|
|
|
95d809 |
- if (format == ZPixmap)
|
|
|
95d809 |
- bytes_per_line = width*depth/8;
|
|
|
95d809 |
- else
|
|
|
95d809 |
- bytes_per_line = width/8;
|
|
|
95d809 |
-
|
|
|
95d809 |
-
|
|
|
95d809 |
- /* Find out how many more bytes are required for padding so that
|
|
|
95d809 |
- ** bytes per scan line will be multiples of bitmap_unit bits */
|
|
|
95d809 |
- if (format == ZPixmap) {
|
|
|
95d809 |
- rem = (bytes_per_line*8)%bitmap_unit;
|
|
|
95d809 |
- if (rem)
|
|
|
95d809 |
- bytes_per_line += (rem/8 + 1);
|
|
|
95d809 |
- }
|
|
|
95d809 |
+ XImage *ximage ;
|
|
|
95d809 |
|
|
|
95d809 |
ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
|
|
|
95d809 |
(uint32_t)width,(uint32_t)height,8,0);
|
|
|
95d809 |
|
|
|
95d809 |
- bytes_per_line = ximage->bytes_per_line;
|
|
|
95d809 |
-
|
|
|
95d809 |
- if (format == ZPixmap)
|
|
|
95d809 |
- ximage->data = malloc(height*bytes_per_line);
|
|
|
95d809 |
- else
|
|
|
95d809 |
- ximage->data = malloc(height*bytes_per_line*depth);
|
|
|
95d809 |
-
|
|
|
95d809 |
+ ximage->data = calloc(ximage->bytes_per_line*height*((format==ZPixmap)? 1 : depth), sizeof(char));
|
|
|
95d809 |
ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
|
|
|
95d809 |
|
|
|
95d809 |
- for (reg = (image_region_type *) first_in_list( regions); reg;
|
|
|
95d809 |
+ for (image_region_type* reg = (image_region_type *) first_in_list( regions); reg;
|
|
|
95d809 |
reg = (image_region_type *) next_in_list( regions))
|
|
|
95d809 |
{
|
|
|
95d809 |
- int32_t rect;
|
|
|
95d809 |
- struct my_XRegion *vis_reg;
|
|
|
95d809 |
- vis_reg = (struct my_XRegion *)(reg->visible_region);
|
|
|
95d809 |
- for (rect = 0;
|
|
|
95d809 |
- rect < vis_reg->numRects;
|
|
|
95d809 |
- rect++)
|
|
|
95d809 |
+ struct my_XRegion *vis_reg = (struct my_XRegion *)(reg->visible_region);
|
|
|
95d809 |
+ for (int32_t rect = 0; rect < vis_reg->numRects; rect++)
|
|
|
95d809 |
{
|
|
|
95d809 |
- /** ------------------------------------------------------------------------
|
|
|
95d809 |
- Intersect bbox with visible part of region giving src rect & output
|
|
|
95d809 |
- location. Width is the min right side minus the max left side.
|
|
|
95d809 |
- Similar for height. Offset src rect so x,y are relative to
|
|
|
95d809 |
- origin of win, not the root-relative visible rect of win.
|
|
|
95d809 |
- ------------------------------------------------------------------------ **/
|
|
|
95d809 |
- srcRect_width = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
|
|
|
95d809 |
- - MAX( vis_reg->rects[rect].x1, bbox.x);
|
|
|
95d809 |
+ /** ------------------------------------------------------------------------
|
|
|
95d809 |
+ Intersect bbox with visible part of region giving src rect & output
|
|
|
95d809 |
+ location. Width is the min right side minus the max left side.
|
|
|
95d809 |
+ Similar for height. Offset src rect so x,y are relative to
|
|
|
95d809 |
+ origin of win, not the root-relative visible rect of win.
|
|
|
95d809 |
+ ------------------------------------------------------------------------ **/
|
|
|
95d809 |
+ int32_t srcRect_width = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
|
|
|
95d809 |
+ - MAX( vis_reg->rects[rect].x1, bbox.x);
|
|
|
95d809 |
+
|
|
|
95d809 |
+ int32_t srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
|
|
|
95d809 |
+ - MAX( vis_reg->rects[rect].y1, bbox.y);
|
|
|
95d809 |
|
|
|
95d809 |
- srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
|
|
|
95d809 |
- - MAX( vis_reg->rects[rect].y1, bbox.y);
|
|
|
95d809 |
+ int32_t diff = bbox.x - vis_reg->rects[rect].x1;
|
|
|
95d809 |
+ int32_t srcRect_x = MAX( 0, diff) + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
|
|
|
95d809 |
+ int32_t dst_x = MAX( 0, -diff) ;
|
|
|
95d809 |
|
|
|
95d809 |
- diff = bbox.x - vis_reg->rects[rect].x1;
|
|
|
95d809 |
- srcRect_x = MAX( 0, diff) + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
|
|
|
95d809 |
- dst_x = MAX( 0, -diff) ;
|
|
|
95d809 |
- diff = bbox.y - vis_reg->rects[rect].y1;
|
|
|
95d809 |
- srcRect_y = MAX( 0, diff) + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
|
|
|
95d809 |
- dst_y = MAX( 0, -diff) ;
|
|
|
95d809 |
- reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
|
|
|
95d809 |
- (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
|
|
|
95d809 |
- TransferImage(disp,reg_image,srcRect_width,
|
|
|
95d809 |
- srcRect_height,reg,ximage,dst_x,dst_y) ;
|
|
|
95d809 |
- XDestroyImage(reg_image);
|
|
|
95d809 |
- }
|
|
|
95d809 |
+ diff = bbox.y - vis_reg->rects[rect].y1;
|
|
|
95d809 |
+ int32_t srcRect_y = MAX( 0, diff) + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
|
|
|
95d809 |
+ int32_t dst_y = MAX( 0, -diff) ;
|
|
|
95d809 |
+ XImage* reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
|
|
|
95d809 |
+ (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
|
|
|
95d809 |
+
|
|
|
95d809 |
+ if (reg_image) {
|
|
|
95d809 |
+ TransferImage(disp,reg_image,srcRect_width,
|
|
|
95d809 |
+ srcRect_height,reg,ximage,dst_x,dst_y) ;
|
|
|
95d809 |
+ XDestroyImage(reg_image);
|
|
|
95d809 |
+ }
|
|
|
95d809 |
+ }
|
|
|
95d809 |
}
|
|
|
95d809 |
return ximage ;
|
|
|
95d809 |
}
|