summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt
diff options
context:
space:
mode:
authorArun Thondapu <arunkumar.thondapu@in.ibm.com>2011-11-14 11:03:46 -0500
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2011-11-14 11:03:46 -0500
commit0504548696e73ed8e85a9f8d88ac00a2de9be404 (patch)
tree3002f357f5e2543e8ea5c258443bf6d44342c5d3 /bundles/org.eclipse.swt
parentabfdcfb2a80c73d1ca40740cee6b7363f053a0e4 (diff)
downloadeclipse.platform.swt-0504548696e73ed8e85a9f8d88ac00a2de9be404.tar.gz
eclipse.platform.swt-0504548696e73ed8e85a9f8d88ac00a2de9be404.tar.xz
eclipse.platform.swt-0504548696e73ed8e85a9f8d88ac00a2de9be404.zip
Bug 354978 - Use Cairo as backend for graphics operations (comment#5
patch)
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java21
6 files changed, 57 insertions, 3 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 841c036199..54ef237281 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
@@ -5014,6 +5014,24 @@ fail:
}
#endif
+#ifndef NO__1gdk_1cairo_1set_1source_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1window)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3)
+{
+ OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1set_1source_1window_FUNC);
+/*
+ gdk_cairo_set_source_window(arg0, (GdkWindow *)arg1, arg2, arg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_cairo_set_source_window)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, GdkWindow *, jint, jint))fp)(arg0, (GdkWindow *)arg1, arg2, arg3);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1set_1source_1window_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1color_1white
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1color_1white)
(JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
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 d3bf5c78d2..283ea9d15d 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
@@ -184,6 +184,7 @@
#define pango_cairo_font_map_set_resolution_LIB LIB_PANGOCAIRO
#define gdk_cairo_reset_clip_LIB LIB_GDK
#define gdk_cairo_set_source_color_LIB LIB_GDK
+#define gdk_cairo_set_source_window_LIB LIB_GDK
#define gdk_cairo_region_LIB LIB_GDK
#define gdk_cairo_create_LIB LIB_GDK
#define gtk_enumerate_printers_LIB LIB_GTK
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 fc1491b6a8..7a5ef021f3 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
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1398;
-int OS_nativeFunctionCallCount[1398];
+int OS_nativeFunctionCount = 1399;
+int OS_nativeFunctionCallCount[1399];
char * OS_nativeFunctionNames[] = {
#ifndef JNI64
"Call__IIII",
@@ -430,6 +430,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1cairo_1region",
"_1gdk_1cairo_1reset_1clip",
"_1gdk_1cairo_1set_1source_1color",
+ "_1gdk_1cairo_1set_1source_1window",
"_1gdk_1color_1white",
"_1gdk_1colormap_1alloc_1color",
"_1gdk_1colormap_1free_1colors",
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 656d931f98..43d38d45f9 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
@@ -438,6 +438,7 @@ typedef enum {
_1gdk_1cairo_1region_FUNC,
_1gdk_1cairo_1reset_1clip_FUNC,
_1gdk_1cairo_1set_1source_1color_FUNC,
+ _1gdk_1cairo_1set_1source_1window_FUNC,
_1gdk_1color_1white_FUNC,
_1gdk_1colormap_1alloc_1color_FUNC,
_1gdk_1colormap_1free_1colors_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 d13b28e754..ada18dffde 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
@@ -3653,6 +3653,20 @@ public static final void gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor
}
}
/**
+ * @method flags=dynamic
+ * @param window cast=(GdkWindow *)
+ */
+public static final native void _gdk_cairo_set_source_window(int /*long*/ cairo, int /*long*/ window, int x, int y);
+public static final void gdk_cairo_set_source_window(int /*long*/ cairo, int /*long*/ window, int x, int y) {
+ lock.lock();
+ try {
+ _gdk_cairo_set_source_window(cairo, window, x, y);
+ }
+ finally {
+ lock.unlock();
+ }
+}
+/**
* @param colormap cast=(GdkColormap *)
* @param color cast=(GdkColor *),flags=no_in
*/
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 995ef3f6d4..626664589f 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
@@ -448,7 +448,26 @@ public void copyArea(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- //TODO fix for USE_CAIRO
+ if (OS.USE_CAIRO) {
+ int /*long*/ cairo = Cairo.cairo_create(image.surface);
+ if (data.image != null) {
+ Cairo.cairo_set_source_surface(cairo, data.image.surface, x, y);
+ } else if (OS.GTK_VERSION >= OS.VERSION(2, 24, 0)) {
+ OS.gdk_cairo_set_source_window(cairo, data.drawable, x, y);
+ } else {
+ int[] w = new int[1], h = new int[1];
+ OS.gdk_drawable_get_size(data.drawable, w, h);
+ int width = w[0], height = h[0];
+ int /*long*/ xDisplay = OS.GDK_DISPLAY();
+ int /*long*/ xDrawable = OS.gdk_x11_drawable_get_xid(data.drawable);
+ int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system());
+ int /*long*/ srcSurface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height);
+ Cairo.cairo_set_source_surface(cairo, srcSurface, x, y);
+ }
+ Cairo.cairo_paint(cairo);
+ Cairo.cairo_destroy(cairo);
+ return;
+ }
Rectangle rect = image.getBounds();
int /*long*/ gdkGC = OS.gdk_gc_new(image.pixmap);
if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);