From 5673881707cbfd963bc0ed943607494119f5edb9 Mon Sep 17 00:00:00 2001 From: Anatoly Spektor Date: Wed, 17 Oct 2012 16:07:08 -0400 Subject: Use gdk_pixbuf_get_from_window instead of gdk_pixbuf_get_from_drawable --- .../Eclipse SWT PI/gtk/library/os.c | 30 +++++++++++++++++++++- .../Eclipse SWT PI/gtk/library/os_custom.h | 2 ++ .../Eclipse SWT PI/gtk/library/os_stats.c | 1 + .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 20 +++++++++++++-- .../gtk/org/eclipse/swt/graphics/GC.java | 16 +++++++++--- .../gtk/org/eclipse/swt/graphics/Image.java | 15 ++++++++--- .../gtk/org/eclipse/swt/internal/ImageList.java | 13 +++++++--- 8 files changed, 84 insertions(+), 14 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index f0400130ac..c101c0249b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -6028,12 +6028,40 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1from_1drawable) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1from_1drawable_FUNC); - rc = (jintLong)gdk_pixbuf_get_from_drawable((GdkPixbuf *)arg0, (GdkDrawable *)arg1, (GdkColormap *)arg2, arg3, arg4, arg5, arg6, arg7, arg8); +/* + rc = (jintLong)gdk_pixbuf_get_from_drawable((GdkPixbuf *)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_pixbuf_get_from_drawable) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkPixbuf *, jintLong, jintLong, jint, jint, jint, jint, jint, jint))fp)((GdkPixbuf *)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1from_1drawable_FUNC); return rc; } #endif +#ifndef NO__1gdk_1pixbuf_1get_1from_1window +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1from_1window) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2, jint arg3, jint arg4) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1from_1window_FUNC); +/* + rc = (jintLong)gdk_pixbuf_get_from_window((GdkWindow *)arg0, (gint)arg1, (gint)arg2, (gint)arg3, (gint)arg4); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_pixbuf_get_from_window) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkWindow *, gint, gint, gint, gint))fp)((GdkWindow *)arg0, (gint)arg1, (gint)arg2, (gint)arg3, (gint)arg4); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1from_1window_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1pixbuf_1get_1has_1alpha JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1has_1alpha) (JNIEnv *env, jclass that, jintLong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index 32943e64b3..9f72de0771 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -211,6 +211,8 @@ #define gdk_gc_set_values_LIB LIB_GDK #define gdk_gc_get_values_LIB LIB_GDK #define gdk_pixbuf_save_to_bufferv_LIB LIB_GDK +#define gdk_pixbuf_get_from_drawable_LIB LIB_GDK +#define gdk_pixbuf_get_from_window_LIB LIB_GDK #define gdk_pixbuf_render_pixmap_and_mask_LIB LIB_GDK #define gdk_pointer_grab_LIB LIB_GDK #define gdk_pointer_ungrab_LIB LIB_GDK diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 0eab77a90d..05c14835be 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -485,6 +485,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1pango_1layout_1get_1clip_1region", "_1gdk_1pixbuf_1copy_1area", "_1gdk_1pixbuf_1get_1from_1drawable", + "_1gdk_1pixbuf_1get_1from_1window", "_1gdk_1pixbuf_1get_1has_1alpha", "_1gdk_1pixbuf_1get_1height", "_1gdk_1pixbuf_1get_1pixels", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index f2b2cf6333..16a103ba09 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -495,6 +495,7 @@ typedef enum { _1gdk_1pango_1layout_1get_1clip_1region_FUNC, _1gdk_1pixbuf_1copy_1area_FUNC, _1gdk_1pixbuf_1get_1from_1drawable_FUNC, + _1gdk_1pixbuf_1get_1from_1window_FUNC, _1gdk_1pixbuf_1get_1has_1alpha_FUNC, _1gdk_1pixbuf_1get_1height_FUNC, _1gdk_1pixbuf_1get_1pixels_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index ea27101484..f63333b050 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -4513,9 +4513,8 @@ public static final void gdk_pixbuf_copy_area(long /*int*/ src_pixbuf, int src_x } } /** + * @method flags=dynamic * @param dest cast=(GdkPixbuf *) - * @param src cast=(GdkDrawable *) - * @param cmap cast=(GdkColormap *) */ public static final native long /*int*/ _gdk_pixbuf_get_from_drawable(long /*int*/ dest, long /*int*/ src, long /*int*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height); public static final long /*int*/ gdk_pixbuf_get_from_drawable(long /*int*/ dest, long /*int*/ src, long /*int*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height) { @@ -4526,6 +4525,23 @@ public static final long /*int*/ gdk_pixbuf_get_from_drawable(long /*int*/ dest, lock.unlock(); } } +/** + * @method flags=dynamic + * @param window cast=(GdkWindow *) + * @param src_x cast=(gint) + * @param src_y cast=(gint) + * @param width cast=(gint) + * @param height cast=(gint) + */ +public static final native long /*int*/ _gdk_pixbuf_get_from_window(long /*int*/ window, int src_x, int src_y, int width, int height); +public static final long /*int*/ gdk_pixbuf_get_from_window(long /*int*/ window, int src_x, int src_y, int width, int height) { + lock.lock(); + try { + return _gdk_pixbuf_get_from_window(window, src_x, src_y, width, height); + } finally { + lock.unlock(); + } +} /** @param pixbuf cast=(const GdkPixbuf *) */ public static final native boolean _gdk_pixbuf_get_has_alpha(long /*int*/ pixbuf); public static final boolean gdk_pixbuf_get_has_alpha(long /*int*/ pixbuf) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 5de2642596..b065cb0b5d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -1066,7 +1066,7 @@ void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHei long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight); if (pixbuf == 0) return; long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); + gdk_pixbuf_get_from_window (pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); byte[] line = new byte[stride]; @@ -1103,10 +1103,10 @@ void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeig long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight); if (pixbuf != 0) { long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); + gdk_pixbuf_get_from_window (pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); long /*int*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight); if (maskPixbuf != 0) { - OS.gdk_pixbuf_get_from_drawable(maskPixbuf, maskPixmap, 0, srcX, srcY, 0, 0, srcWidth, srcHeight); + gdk_pixbuf_get_from_window (maskPixbuf, maskPixmap, 0, srcX, srcY, 0, 0, srcWidth, srcHeight); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); byte[] line = new byte[stride]; @@ -1258,7 +1258,7 @@ long /*int*/ scale(long /*int*/ src, int srcX, int srcY, int srcWidth, int srcHe long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight); if (pixbuf == 0) return 0; long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, src, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); + gdk_pixbuf_get_from_window (pixbuf, src, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight); long /*int*/ scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR); OS.g_object_unref(pixbuf); return scaledPixbuf; @@ -4373,4 +4373,12 @@ void cairo_region_get_rectangles (long /*int*/ region, long /*int*/[] rectangles OS.gdk_region_get_rectangles (region, rectangles, n_rectangles); } } + +long /*int*/ gdk_pixbuf_get_from_window(long /*int*/ dest, long /*int*/ src, long /*int*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return OS.gdk_pixbuf_get_from_window (dest, src_x, src_y, width, height); + } else { + return OS.gdk_pixbuf_get_from_drawable (dest, src, cmap, src_x, src_y, dest_x, dest_y, width, height); + } +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index bdb9f1d901..676d2e0261 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -411,7 +411,7 @@ public Image(Device device, Image srcImage, int flag) { long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height); if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, 0, 0, 0, 0, width, height); + gdk_pixbuf_get_from_window (pixbuf, srcImage.pixmap, colormap, 0, 0, 0, 0, width, height); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); @@ -885,7 +885,7 @@ void createSurface() { long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, width, height); if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height); + gdk_pixbuf_get_from_window (pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); byte[] line = new byte[stride]; @@ -898,7 +898,7 @@ void createSurface() { if (mask != 0 && OS.gdk_drawable_get_depth(mask) == 1) { long /*int*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height); if (maskPixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); - OS.gdk_pixbuf_get_from_drawable(maskPixbuf, mask, 0, 0, 0, 0, 0, width, height); + gdk_pixbuf_get_from_window (maskPixbuf, mask, 0, 0, 0, 0, 0, width, height); int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf); long /*int*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf); byte[] maskLine = new byte[maskStride]; @@ -1165,7 +1165,7 @@ public ImageData getImageData() { long /*int*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height); if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); long /*int*/ colormap = OS.gdk_colormap_get_system(); - OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height); + gdk_pixbuf_get_from_window (pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); byte[] srcData = new byte[stride * height]; @@ -1687,4 +1687,11 @@ public String toString () { } } +long /*int*/ gdk_pixbuf_get_from_window(long /*int*/ dest, long /*int*/ src, long /*int*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return OS.gdk_pixbuf_get_from_window (dest, src_x, src_y, width, height); + } else { + return OS.gdk_pixbuf_get_from_drawable (dest, src, cmap, src_x, src_y, dest_x, dest_y, width, height); + } +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java index 39d0c33ae9..fea52ad56f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java @@ -112,10 +112,10 @@ public static long /*int*/ createPixbuf(Image image) { if (hasMask) { pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]); if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); + gdk_pixbuf_get_from_window (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); long /*int*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]); if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]); + gdk_pixbuf_get_from_window (maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]); int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); long /*int*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); byte[] line = new byte[stride]; @@ -140,7 +140,7 @@ public static long /*int*/ createPixbuf(Image image) { boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA; pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]); if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); + gdk_pixbuf_get_from_window (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); if (hasAlpha) { byte [] alpha = data.alphaData; int stride = OS.gdk_pixbuf_get_rowstride (pixbuf); @@ -287,4 +287,11 @@ public int size () { return result; } +static long /*int*/ gdk_pixbuf_get_from_window (long /*int*/ dest, long /*int*/ src, long /*int*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return OS.gdk_pixbuf_get_from_window (dest, src_x, src_y, width, height); + } else { + return OS.gdk_pixbuf_get_from_drawable (dest, src, cmap, src_x, src_y, dest_x, dest_y, width, height); + } +} } -- cgit v1.2.3