< prev index next >

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

Print this page

        

@@ -43,11 +43,11 @@
 #include "robot_common.h"
 #include "canvas.h"
 #include "wsutils.h"
 #include "list.h"
 #include "multiVis.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 
 #if defined(__linux__) || defined(MACOSX)
 #include <sys/socket.h>
 #endif
 

@@ -262,74 +262,14 @@
     int dy = attr.y > sy ? attr.y - sy : 0;
 
     int index;
 
     if (isGtkSupported) {
-        GdkPixbuf *pixbuf;
-        (*fp_gdk_threads_enter)();
-        GdkWindow *root = (*fp_gdk_get_default_root_window)();
-
-        pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL,
-                                                    x, y, 0, 0, width, height);
-        if (pixbuf && scale != 1) {
-            GdkPixbuf *scaledPixbuf;
-            x /= scale;
-            y /= scale;
-            width /= scale;
-            height /= scale;
-            dx /= scale;
-            dy /= scale;
-            scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
-                                                         GDK_INTERP_BILINEAR);
-            (*fp_g_object_unref)(pixbuf);
-            pixbuf = scaledPixbuf;
-        }
-
-        if (pixbuf) {
-            int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
-            int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
-
-            if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
-                    && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
-                    && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
-                    && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
-                    && nchan >= 3
-                    ) {
-                guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
-
-                ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
-                if (!ary) {
-                    (*fp_g_object_unref)(pixbuf);
-                    (*fp_gdk_threads_leave)();
-                    AWT_UNLOCK();
-                    return;
-                }
-
-                for (_y = 0; _y < height; _y++) {
-                    for (_x = 0; _x < width; _x++) {
-                        p = pix + _y * stride + _x * nchan;
-
-                        index = (_y + dy) * jwidth + (_x + dx);
-                        ary[index] = 0xff000000
-                                        | (p[0] << 16)
-                                        | (p[1] << 8)
-                                        | (p[2]);
-
-                    }
-                }
-                (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
-                if ((*env)->ExceptionCheck(env)) {
-                    (*fp_g_object_unref)(pixbuf);
-                    (*fp_gdk_threads_leave)();
-                    AWT_UNLOCK();
-                    return;
-                }
-                gtk_failed = FALSE;
-            }
-            (*fp_g_object_unref)(pixbuf);
-        }
-        (*fp_gdk_threads_leave)();
+        gtk->gdk_threads_enter();
+        gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width,
+                                            jwidth, height, dx, dy, scale);
+        gtk->gdk_threads_leave();
     }
 
     if (gtk_failed) {
         image = getWindowImage(awt_display, rootWindow, sx, sy, swidth, sheight);
 
< prev index next >