summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAnatoly Spektor2012-10-19 10:31:34 (EDT)
committer Alexander Kurtakov2012-10-20 03:33:50 (EDT)
commit2b1f2830b8d411e84c9809819724a5df17bd0813 (patch)
tree446a786ef4e5579ee5304c6f1b463a1cab9c280d
parent710cb3ccdef79104211a871e409c9a15331c6d65 (diff)
downloadeclipse.platform.swt-2b1f2830b8d411e84c9809819724a5df17bd0813.zip
eclipse.platform.swt-2b1f2830b8d411e84c9809819724a5df17bd0813.tar.gz
eclipse.platform.swt-2b1f2830b8d411e84c9809819724a5df17bd0813.tar.bz2
Not use gdk_colormap_alloc_color and gdk_colormap_free_color in GTK+3
This patch version guards calls to GdkColormap methods as they are not used in GTK+3, the only exception where GdkColormap is still used is Tracker.drawRectangles, as suitable Cairo implementation is not yet implemented for this method.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java14
5 files changed, 40 insertions, 19 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 cce63b5..48a0755 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
@@ -4732,7 +4732,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1colormap_1alloc_1color)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1alloc_1color_FUNC);
if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
- rc = (jboolean)gdk_colormap_alloc_color((GdkColormap *)arg0, (GdkColor *)lparg1, (gboolean)arg2, (gboolean)arg3);
+/*
+ rc = (jboolean)gdk_colormap_alloc_color(arg0, (GdkColor *)lparg1, (gboolean)arg2, (gboolean)arg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_colormap_alloc_color)
+ if (fp) {
+ rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong, GdkColor *, gboolean, gboolean))fp)(arg0, (GdkColor *)lparg1, (gboolean)arg2, (gboolean)arg3);
+ }
+ }
fail:
if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1alloc_1color_FUNC);
@@ -4747,7 +4755,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1colormap_1free_1colors)
GdkColor _arg1, *lparg1=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1free_1colors_FUNC);
if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
- gdk_colormap_free_colors((GdkColormap *)arg0, (GdkColor *)lparg1, (gint)arg2);
+/*
+ gdk_colormap_free_colors(arg0, (GdkColor *)lparg1, (gint)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_colormap_free_colors)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, GdkColor *, gint))fp)(arg0, (GdkColor *)lparg1, (gint)arg2);
+ }
+ }
fail:
OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1free_1colors_FUNC);
}
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 9f72de0..457e305 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
@@ -340,6 +340,8 @@
#define gdk_cairo_region_create_from_surface_LIB LIB_GDK
#define gdk_cairo_region_LIB LIB_GDK
#define gdk_cairo_create_LIB LIB_GDK
+#define gdk_colormap_alloc_color_LIB LIB_GDK
+#define gdk_colormap_free_colors_LIB LIB_GDK
#define gtk_enumerate_printers_LIB LIB_GTK
#define gtk_object_sink_LIB LIB_GTK
#define gtk_orientable_set_orientation_LIB LIB_GTK
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 3088861..e4e5423 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
@@ -3595,7 +3595,7 @@ public static final boolean gdk_color_white(long /*int*/ colormap, GdkColor colo
}
}
/**
- * @param colormap cast=(GdkColormap *)
+ * @method flags=dynamic
* @param color cast=(GdkColor *)
* @param writeable cast=(gboolean)
* @param best_match cast=(gboolean)
@@ -3610,7 +3610,7 @@ public static final boolean gdk_colormap_alloc_color(long /*int*/ colormap, GdkC
}
}
/**
- * @param colormap cast=(GdkColormap *)
+ * @method flags=dynamic
* @param colors cast=(GdkColor *),flags=no_out
* @param ncolors cast=(gint)
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
index c516c86..5afd6d3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
+import org.eclipse.swt.internal.cairo.Cairo;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
@@ -117,8 +118,10 @@ void destroy() {
device.gdkColors[pixel] = null;
}
}
- long /*int*/ colormap = OS.gdk_colormap_get_system();
- OS.gdk_colormap_free_colors(colormap, handle, 1);
+ if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
+ long /*int*/ colormap = OS.gdk_colormap_get_system();
+ OS.gdk_colormap_free_colors(colormap, handle, 1);
+ }
handle = null;
}
@@ -244,11 +247,13 @@ void init(int red, int green, int blue) {
gdkColor.red = (short)((red & 0xFF) | ((red & 0xFF) << 8));
gdkColor.green = (short)((green & 0xFF) | ((green & 0xFF) << 8));
gdkColor.blue = (short)((blue & 0xFF) | ((blue & 0xFF) << 8));
- long /*int*/ colormap = OS.gdk_colormap_get_system();
- if (!OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true)) {
- /* Allocate black. */
- gdkColor = new GdkColor();
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
+ long /*int*/ colormap = OS.gdk_colormap_get_system();
+ if (!OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true)) {
+ /* Allocate black. */
+ gdkColor = new GdkColor();
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ }
}
handle = gdkColor;
if (device.colorRefCount != null) {
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 b065cb0..04d595b 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
@@ -1065,8 +1065,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();
- gdk_pixbuf_get_from_window (pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+ gdk_pixbuf_get_from_window (pixbuf, srcImage.pixmap, 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];
@@ -1102,11 +1101,10 @@ void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeig
if (srcWidth != destWidth || srcHeight != destHeight) {
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();
- gdk_pixbuf_get_from_window (pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+ gdk_pixbuf_get_from_window (pixbuf, colorPixmap, srcX, srcY, 0, 0, srcWidth, srcHeight);
long /*int*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
if (maskPixbuf != 0) {
- gdk_pixbuf_get_from_window (maskPixbuf, maskPixmap, 0, srcX, srcY, 0, 0, srcWidth, srcHeight);
+ gdk_pixbuf_get_from_window (maskPixbuf, maskPixmap, 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];
@@ -1257,8 +1255,7 @@ void drawImageXRender(Image srcImage, int srcX, int srcY, int srcWidth, int srcH
long /*int*/ scale(long /*int*/ src, int srcX, int srcY, int srcWidth, int srcHeight, int destWidth, int destHeight) {
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();
- gdk_pixbuf_get_from_window (pixbuf, src, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+ gdk_pixbuf_get_from_window (pixbuf, src, 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;
@@ -4374,10 +4371,11 @@ void cairo_region_get_rectangles (long /*int*/ region, long /*int*/[] 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) {
+long /*int*/ gdk_pixbuf_get_from_window(long /*int*/ dest, long /*int*/ src, 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 {
+ long /*int*/ cmap = OS.gdk_colormap_get_system();
return OS.gdk_pixbuf_get_from_drawable (dest, src, cmap, src_x, src_y, dest_x, dest_y, width, height);
}
}