diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-09-07 10:21:06 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-09-07 10:21:06 -0400 |
commit | f24f6863e1ff9088ff8784d63395002bb39009b1 (patch) | |
tree | c692d527d9cffd2d0ff85be7b021b4c34e010d84 | |
parent | eda05e5e1bfd7a8e6860cccbab7bfcd105765ca8 (diff) | |
download | eclipse.platform.swt-gtk3_cairo_region_create.tar.gz eclipse.platform.swt-gtk3_cairo_region_create.tar.xz eclipse.platform.swt-gtk3_cairo_region_create.zip |
Use cairo_region_create instead of gdk_region_new for GTK+3 and highergtk3_cairo_region_create
12 files changed, 73 insertions, 12 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 72220cf07f..3223a5877f 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 @@ -1179,6 +1179,18 @@ JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1reference) } #endif +#ifndef NO__1cairo_1region_1create +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1create) + (JNIEnv *env, jclass that) +{ + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1create_FUNC); + rc = (jintLong)cairo_region_create(); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1create_FUNC); + return rc; +} +#endif + #ifndef NO__1cairo_1rel_1curve_1to JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rel_1curve_1to) (JNIEnv *env, jclass that, jintLong arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5, jdouble arg6) 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 67b21fe5c2..597c59a6de 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 @@ -24,8 +24,8 @@ #ifdef NATIVE_STATS -int Cairo_nativeFunctionCount = 157; -int Cairo_nativeFunctionCallCount[157]; +int Cairo_nativeFunctionCount = 158; +int Cairo_nativeFunctionCallCount[158]; char * Cairo_nativeFunctionNames[] = { "CAIRO_1VERSION_1ENCODE", "_1cairo_1append_1path", @@ -117,6 +117,7 @@ char * Cairo_nativeFunctionNames[] = { "_1cairo_1push_1group", "_1cairo_1rectangle", "_1cairo_1reference", + "_1cairo_1region_1create", "_1cairo_1rel_1curve_1to", "_1cairo_1rel_1line_1to", "_1cairo_1rel_1move_1to", 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 62206dc2a8..04c87c4ca9 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 @@ -125,6 +125,7 @@ typedef enum { _1cairo_1push_1group_FUNC, _1cairo_1rectangle_FUNC, _1cairo_1reference_FUNC, + _1cairo_1region_1create_FUNC, _1cairo_1rel_1curve_1to_FUNC, _1cairo_1rel_1line_1to_FUNC, _1cairo_1rel_1move_1to_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 8f342be036..c147e7cbb7 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 @@ -1029,6 +1029,15 @@ public static final void cairo_rectangle(int /*long*/ cr, double x, double y, do lock.unlock(); } } +public static final native int /*long*/ _cairo_region_create(); +public static final int /*long*/cairo_region_create() { + lock.lock(); + try { + return _cairo_region_create(); + } finally { + lock.unlock(); + } +} /** @param cr cast=(cairo_t *) */ public static final native int /*long*/ _cairo_reference(int /*long*/ cr); public static final int /*long*/ cairo_reference(int /*long*/ cr) { 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 90c1ebac16..828af83613 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 @@ -6219,7 +6219,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1region_1new) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1new_FUNC); +/* rc = (jintLong)gdk_region_new(); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)(); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1new_FUNC); return rc; } 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 09073e9c3e..d16f190ce2 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 @@ -185,6 +185,7 @@ #define gdk_screen_get_n_monitors_LIB LIB_GDK #define gdk_screen_get_number_LIB LIB_GDK #define gdk_pixbuf_render_to_drawable_LIB LIB_GDK +#define gdk_region_new_LIB LIB_GDK #define gtk_scrolled_window_get_hscrollbar_LIB LIB_GTK #define gtk_scrolled_window_get_vscrollbar_LIB LIB_GTK #define gtk_status_icon_get_geometry_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 c2310b7878..460ea097b5 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 @@ -4697,6 +4697,7 @@ public static final void gdk_region_intersect(int /*long*/ source1, int /*long*/ lock.unlock(); } } +/** @method flags=dynamic */ public static final native int /*long*/ _gdk_region_new(); public static final int /*long*/ gdk_region_new() { lock.lock(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java index 1357fb9c9e..46829f25da 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java @@ -13,6 +13,7 @@ package org.eclipse.swt.internal.theme; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.cairo.Cairo; import org.eclipse.swt.internal.gtk.*; public class Theme { @@ -183,7 +184,11 @@ void transferClipping(GC gc, int /*long*/ style) { int /*long*/ clipping = clipRgn; if (damageRgn != 0) { if (clipping != 0) { - clipping = OS.gdk_region_new(); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + clipping = Cairo.cairo_region_create (); + } else { + clipping = OS.gdk_region_new (); + } OS.gdk_region_union(clipping, clipRgn); OS.gdk_region_intersect(clipping, damageRgn); } else { 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 61021eb94a..b19e462db4 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 @@ -391,7 +391,7 @@ void checkGC (int mask) { } int /*long*/ convertRgn(int /*long*/ rgn, double[] matrix) { - int /*long*/ newRgn = OS.gdk_region_new(); + int /*long*/ newRgn = cairo_region_create (); int[] nRects = new int[1]; int /*long*/[] rects = new int /*long*/[1]; OS.gdk_region_get_rectangles(rgn, rects, nRects); @@ -1156,7 +1156,7 @@ void drawImageXRender(Image srcImage, int srcX, int srcY, int srcWidth, int srcH if (clipping == 0) { clipping = data.damageRgn; } else { - clipping = OS.gdk_region_new(); + clipping = cairo_region_create (); OS.gdk_region_union(clipping, data.clipRgn); OS.gdk_region_intersect(clipping, data.damageRgn); } @@ -2373,7 +2373,7 @@ public Rectangle getClipping() { int /*long*/ clipRgn = data.clipRgn; int /*long*/ damageRgn = data.damageRgn; if (clipRgn != 0 || damageRgn != 0 || cairo != 0) { - int /*long*/ rgn = OS.gdk_region_new(); + int /*long*/ rgn = cairo_region_create (); GdkRectangle rect = new GdkRectangle(); rect.width = width; rect.height = height; @@ -3314,7 +3314,7 @@ void setClipping(int /*long*/ clipRgn) { OS.gdk_gc_set_clip_region(handle, clipping); } } else { - if (data.clipRgn == 0) data.clipRgn = OS.gdk_region_new(); + if (data.clipRgn == 0) data.clipRgn = cairo_region_create(); OS.gdk_region_subtract(data.clipRgn, data.clipRgn); OS.gdk_region_union(data.clipRgn, clipRgn); if (cairo != 0) { @@ -3324,7 +3324,7 @@ void setClipping(int /*long*/ clipRgn) { } else { int /*long*/ clipping = clipRgn; if (data.damageRgn != 0) { - clipping = OS.gdk_region_new(); + clipping = cairo_region_create (); OS.gdk_region_union(clipping, clipRgn); OS.gdk_region_intersect(clipping, data.damageRgn); } @@ -3363,7 +3363,7 @@ public void setClipping(int x, int y, int width, int height) { rect.y = y; rect.width = width; rect.height = height; - int /*long*/ clipRgn = OS.gdk_region_new(); + int /*long*/ clipRgn = cairo_region_create (); OS.gdk_region_union_with_rect(clipRgn, rect); setClipping(clipRgn); OS.gdk_region_destroy(clipRgn); @@ -4170,4 +4170,12 @@ public String toString () { return "GC {" + handle + "}"; } +int /*long*/ cairo_region_create () { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return Cairo.cairo_region_create (); + } else { + return OS.gdk_region_new (); + } +} + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java index a2b8995ec7..5f20476cd1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.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.*; @@ -74,7 +75,11 @@ public Region() { */ public Region(Device device) { super(device); - handle = OS.gdk_region_new(); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + handle = Cairo.cairo_region_create (); + } else { + handle = OS.gdk_region_new (); + } if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); init(); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java index 67695a3d5d..0a9374de97 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java @@ -837,7 +837,12 @@ public Rectangle getBounds(int start, int end) { PangoRectangle pangoRect = new PangoRectangle(); int /*long*/ iter = OS.pango_layout_get_iter(layout); if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); - int /*long*/ linesRegion = OS.gdk_region_new(); + int /*long*/ linesRegion = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + linesRegion = Cairo.cairo_region_create (); + } else { + linesRegion = OS.gdk_region_new (); + } if (linesRegion == 0) SWT.error(SWT.ERROR_NO_HANDLES); int lineEnd = 0; do { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index 9f6c6ba29f..63e6f95dbd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -731,7 +731,12 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) { event.width = rect.width; event.height = rect.height; if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; - int /*long*/ damageRgn = OS.gdk_region_new (); + int /*long*/ damageRgn = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + damageRgn = Cairo.cairo_region_create (); + } else { + damageRgn = OS.gdk_region_new (); + } OS.gdk_region_union_with_rect (damageRgn, rect); GCData data = new GCData (); data.damageRgn = damageRgn; |