< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 274,284 **** jobject xgc, jint jx, jint jy, jint jwidth, jint jheight, - jint scale, jintArray pixelArray, jboolean useGtk) { XImage *image; jint *ary; /* Array of jints for sending pixel values back * to parent process. --- 274,283 ----
*** 296,310 **** adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); DASSERT(adata != NULL); AWT_LOCK(); - jint sx = jx * scale; - jint sy = jy * scale; - jint swidth = jwidth * scale; - jint sheight = jheight * scale; - rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); if (!useGtk) { if (hasXCompositeOverlayExtension(awt_display) && isXCompositeDisplay(awt_display, adata->awt_visInfo.screen)) --- 295,304 ----
*** 312,371 **** rootWindow = compositeGetOverlayWindow(awt_display, rootWindow); } } if (!XGetWindowAttributes(awt_display, rootWindow, &attr) ! || sx + swidth <= attr.x ! || attr.x + attr.width <= sx ! || sy + sheight <= attr.y ! || attr.y + attr.height <= sy) { AWT_UNLOCK(); return; // Does not intersect with root window } gboolean gtk_failed = TRUE; jint _x, _y; ! jint x = MAX(sx, attr.x); ! jint y = MAX(sy, attr.y); ! jint width = MIN(sx + swidth, attr.x + attr.width) - x; ! jint height = MIN(sy + sheight, attr.y + attr.height) - y; ! ! int dx = attr.x > sx ? attr.x - sx : 0; ! int dy = attr.y > sy ? attr.y - sy : 0; int index; if (useGtk) { gtk->gdk_threads_enter(); gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width, ! height, jwidth, dx, dy, scale); gtk->gdk_threads_leave(); } if (gtk_failed) { ! image = getWindowImage(awt_display, rootWindow, sx, sy, swidth, sheight); ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL); if (!ary) { XDestroyImage(image); AWT_UNLOCK(); return; } - dx /= scale; - dy /= scale; - width /= scale; - height /= scale; - /* convert to Java ARGB pixels */ for (_y = 0; _y < height; _y++) { for (_x = 0; _x < width; _x++) { ! jint pixel = (jint) XGetPixel(image, _x * scale, _y * scale); /* Note ignore upper * 32-bits on 64-bit * OSes. */ pixel |= 0xff000000; /* alpha - full opacity */ --- 306,359 ---- rootWindow = compositeGetOverlayWindow(awt_display, rootWindow); } } if (!XGetWindowAttributes(awt_display, rootWindow, &attr) ! || jx + jwidth <= attr.x ! || attr.x + attr.width <= jx ! || jy + jheight <= attr.y ! || attr.y + attr.height <= jy) { AWT_UNLOCK(); return; // Does not intersect with root window } gboolean gtk_failed = TRUE; jint _x, _y; ! jint x = MAX(jx, attr.x); ! jint y = MAX(jy, attr.y); ! jint width = MIN(jx + jwidth, attr.x + attr.width) - x; ! jint height = MIN(jy + jheight, attr.y + attr.height) - y; ! int dx = attr.x > jx ? attr.x - jx : 0; ! int dy = attr.y > jy ? attr.y - jy : 0; int index; if (useGtk) { gtk->gdk_threads_enter(); gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width, ! height, jwidth, dx, dy, 1); gtk->gdk_threads_leave(); } if (gtk_failed) { ! image = getWindowImage(awt_display, rootWindow, x, y, width, height); ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL); if (!ary) { XDestroyImage(image); AWT_UNLOCK(); return; } /* convert to Java ARGB pixels */ for (_y = 0; _y < height; _y++) { for (_x = 0; _x < width; _x++) { ! jint pixel = (jint) XGetPixel(image, _x, _y); /* Note ignore upper * 32-bits on 64-bit * OSes. */ pixel |= 0xff000000; /* alpha - full opacity */
< prev index next >