summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java47
8 files changed, 75 insertions, 29 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
index e9ed5add0b..f12c814aa9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
@@ -15,7 +15,7 @@
*
* IBM
* - Binding to permit interfacing between Cairo and SWT
- * - Copyright (C) 2005, 2009 IBM Corp. All Rights Reserved.
+ * - Copyright (C) 2005, 2011 IBM Corp. All Rights Reserved.
*
* ***** END LICENSE BLOCK ***** */
@@ -298,6 +298,26 @@ JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1font_1options_1set_1antialias)
}
#endif
+#ifndef NO__1cairo_1format_1stride_1for_1width
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1format_1stride_1for_1width)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ jint rc = 0;
+ Cairo_NATIVE_ENTER(env, that, _1cairo_1format_1stride_1for_1width_FUNC);
+/*
+ rc = (jint)cairo_format_stride_for_width(arg0, arg1);
+*/
+ {
+ LOAD_FUNCTION(fp, cairo_format_stride_for_width)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jint, jint))fp)(arg0, arg1);
+ }
+ }
+ Cairo_NATIVE_EXIT(env, that, _1cairo_1format_1stride_1for_1width_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1cairo_1get_1antialias
JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1antialias)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
index 0eb3d234d9..9d08cda12d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
@@ -28,7 +28,8 @@
#define LIB_CAIRO "libcairo.so.2"
#endif
+#define cairo_format_stride_for_width_LIB LIB_CAIRO
#define cairo_pdf_surface_set_size_LIB LIB_CAIRO
#define cairo_ps_surface_set_size_LIB LIB_CAIRO
#define cairo_surface_set_fallback_resolution_LIB LIB_CAIRO
-#define cairo_surface_get_type_LIB LIB_CAIRO
+#define cairo_surface_get_type_LIB LIB_CAIRO \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
index b387ce344c..4404269235 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
@@ -15,7 +15,7 @@
*
* IBM
* - Binding to permit interfacing between Cairo and SWT
- * - Copyright (C) 2005, 2009 IBM Corp. All Rights Reserved.
+ * - Copyright (C) 2005, 2011 IBM Corp. All Rights Reserved.
*
* ***** END LICENSE BLOCK ***** */
@@ -24,8 +24,8 @@
#ifdef NATIVE_STATS
-int Cairo_nativeFunctionCount = 145;
-int Cairo_nativeFunctionCallCount[145];
+int Cairo_nativeFunctionCount = 146;
+int Cairo_nativeFunctionCallCount[146];
char * Cairo_nativeFunctionNames[] = {
"CAIRO_1VERSION_1ENCODE",
"_1cairo_1append_1path",
@@ -50,6 +50,7 @@ char * Cairo_nativeFunctionNames[] = {
"_1cairo_1font_1options_1destroy",
"_1cairo_1font_1options_1get_1antialias",
"_1cairo_1font_1options_1set_1antialias",
+ "_1cairo_1format_1stride_1for_1width",
"_1cairo_1get_1antialias",
"_1cairo_1get_1current_1point",
"_1cairo_1get_1fill_1rule",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
index f5f3bbf495..b3a532b299 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
@@ -15,7 +15,7 @@
*
* IBM
* - Binding to permit interfacing between Cairo and SWT
- * - Copyright (C) 2005, 2009 IBM Corp. All Rights Reserved.
+ * - Copyright (C) 2005, 2011 IBM Corp. All Rights Reserved.
*
* ***** END LICENSE BLOCK ***** */
@@ -58,6 +58,7 @@ typedef enum {
_1cairo_1font_1options_1destroy_FUNC,
_1cairo_1font_1options_1get_1antialias_FUNC,
_1cairo_1font_1options_1set_1antialias_FUNC,
+ _1cairo_1format_1stride_1for_1width_FUNC,
_1cairo_1get_1antialias_FUNC,
_1cairo_1get_1current_1point_FUNC,
_1cairo_1get_1fill_1rule_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
index 8836edda56..1e2e2553ac 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
@@ -327,6 +327,16 @@ public static final void cairo_font_options_set_antialias(int /*long*/ options,
lock.unlock();
}
}
+/** @method flags=dynamic */
+public static final native int _cairo_format_stride_for_width(int format, int width);
+public static final int cairo_format_stride_for_width(int format, int width) {
+ lock.lock();
+ try {
+ return _cairo_format_stride_for_width(format, width);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param cr cast=(cairo_t *) */
public static final native int _cairo_get_antialias(int /*long*/ cr);
public static final int cairo_get_antialias(int /*long*/ cr) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index 5a0ea64eb5..ba668ccb3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -580,7 +580,7 @@ public boolean getWarnings () {
protected void init () {
this.dpi = getDPI();
- if (xDisplay != 0) {
+ if (xDisplay != 0 && OS.GTK_VERSION < OS.VERSION(2, 22, 0)) {
int[] event_basep = new int[1], error_basep = new int [1];
if (OS.XRenderQueryExtension (xDisplay, event_basep, error_basep)) {
int[] major_versionp = new int[1], minor_versionp = new int [1];
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 cd51b3b4fd..298ad0b212 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
@@ -770,11 +770,11 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
- int[] width = new int[1];
- int[] height = new int[1];
- OS.gdk_drawable_get_size(srcImage.pixmap, width, height);
- int imgWidth = width[0];
- int imgHeight = height[0];
+// int[] width = new int[1];
+// int[] height = new int[1];
+// OS.gdk_drawable_get_size(srcImage.pixmap, width, height);
+ int imgWidth = srcImage.width;
+ int imgHeight = srcImage.height;
if (simple) {
srcWidth = destWidth = imgWidth;
srcHeight = destHeight = imgHeight;
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 c70a42a8a7..36c0370911 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
@@ -981,24 +981,36 @@ void init(int width, int height) {
void init(ImageData image) {
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int width = image.width;
- int height = image.height;
+ int width = this.width = image.width;
+ int height = this.height = image.height;
PaletteData palette = image.palette;
if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||
((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
- int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
- if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
- int /*long*/ data = OS.gdk_pixbuf_get_pixels(pixbuf);
+ int stride, destDepth;
+ int /*long*/ data, pixbuf = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 22, 0)) {
+ stride = Cairo.cairo_format_stride_for_width(Cairo.CAIRO_FORMAT_ARGB32, width);
+ data = surfaceData = OS.g_malloc(stride * height);
+ if (surfaceData == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ surface = Cairo.cairo_image_surface_create_for_data(surfaceData, Cairo.CAIRO_FORMAT_ARGB32, width, height, stride);
+ if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ destDepth = 32;
+ } else {
+ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+ if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+ data = OS.gdk_pixbuf_get_pixels(pixbuf);
+ destDepth = 24;
+ }
byte[] buffer = image.data;
- if (!palette.isDirect || image.depth != 24 || stride != image.bytesPerLine || palette.redMask != 0xFF0000 || palette.greenMask != 0xFF00 || palette.blueMask != 0xFF) {
+ if (!palette.isDirect || image.depth != destDepth || stride != image.bytesPerLine || palette.redMask != 0xFF0000 || palette.greenMask != 0xFF00 || palette.blueMask != 0xFF) {
buffer = new byte[stride * height];
if (palette.isDirect) {
ImageData.blit(ImageData.BLIT_SRC,
image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, palette.redMask, palette.greenMask, palette.blueMask,
ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- buffer, 24, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+ buffer, destDepth, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
false, false);
} else {
RGB[] rgbs = palette.getRGBs();
@@ -1016,19 +1028,20 @@ void init(ImageData image) {
ImageData.blit(ImageData.BLIT_SRC,
image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, srcReds, srcGreens, srcBlues,
ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- buffer, 24, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+ buffer, destDepth, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
false, false);
}
}
OS.memmove(data, buffer, stride * height);
- int /*long*/ pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), width, height, -1);
- if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
- if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.gdk_pixbuf_render_to_drawable(pixbuf, pixmap, gdkGC, 0, 0, 0, 0, width, height, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
- OS.g_object_unref(gdkGC);
- OS.g_object_unref(pixbuf);
-
+ if (OS.GTK_VERSION < OS.VERSION(2, 22, 0) ) {
+ int /*long*/ pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), width, height, -1);
+ if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+ if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_render_to_drawable(pixbuf, pixmap, gdkGC, 0, 0, 0, 0, width, height, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+ OS.g_object_unref(gdkGC);
+ OS.g_object_unref(pixbuf);
+ }
boolean isIcon = image.getTransparencyType() == SWT.TRANSPARENCY_MASK;
if (isIcon || image.transparentPixel != -1) {
if (image.transparentPixel != -1) {