diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-09-07 15:49:22 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-09-07 15:49:22 -0400 |
commit | e59e15224e7146b6504c1a88ffe0da3b0b706912 (patch) | |
tree | 44fb8a058e1d780f3ba6f953054d6c52fbdc3be2 | |
parent | eda05e5e1bfd7a8e6860cccbab7bfcd105765ca8 (diff) | |
download | eclipse.platform.swt-e59e15224e7146b6504c1a88ffe0da3b0b706912.tar.gz eclipse.platform.swt-e59e15224e7146b6504c1a88ffe0da3b0b706912.tar.xz eclipse.platform.swt-e59e15224e7146b6504c1a88ffe0da3b0b706912.zip |
Use cairo_region_substact() instead of gdk_region_substract() for GTK+3gtk3_region_substract
This patch implements GTK+3 API and uses cairo_region_substract()
instead of deprecated gtk_region_substract() for GTK+3 and higher
10 files changed, 70 insertions, 13 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..d3cde36427 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_1subtract +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1subtract) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1subtract_FUNC); + rc = (jintLong)cairo_region_subtract((cairo_region_t *)arg0, (const cairo_region_t *)arg1); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1subtract_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..73b53693f4 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_1subtract", "_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..26fd729f81 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_1subtract_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..f75aff874a 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,19 @@ public static final void cairo_rectangle(int /*long*/ cr, double x, double y, do lock.unlock(); } } +/** + * @param dst cast=(cairo_region_t *) + * @param other cast=(const cairo_region_t *) + */ +public static final native int /*long*/ _cairo_region_subtract(int /*long*/ dst, int /*long*/ other); +public static final int /*long*/ cairo_region_subtract(int /*long*/ dst, int /*long*/ other) { + lock.lock(); + try { + return _cairo_region_subtract(dst, other); + } 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..abda9ce009 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 @@ -6298,7 +6298,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1subtract) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) { OS_NATIVE_ENTER(env, that, _1gdk_1region_1subtract_FUNC); - gdk_region_subtract((GdkRegion *)arg0, (GdkRegion *)arg1); +/* + gdk_region_subtract(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_subtract) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1subtract_FUNC); } #endif 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..a7764e3a90 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 @@ -230,6 +230,7 @@ #define gtk_widget_set_visible_LIB LIB_GTK #define gtk_range_get_slider_range_LIB LIB_GTK #define gdk_pango_context_set_colormap_LIB LIB_GDK +#define gdk_region_subtract_LIB LIB_GDK #define gdk_x11_screen_get_window_manager_name_LIB LIB_GDK #define gdk_x11_screen_lookup_visual_LIB LIB_GDK #define gdk_x11_window_lookup_for_display_LIB LIB_GDK 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..9752200d2a 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 @@ -4771,8 +4771,7 @@ public static final int /*long*/ gdk_region_rect_in(int /*long*/ region, GdkRect } } /** - * @param source1 cast=(GdkRegion *) - * @param source2 cast=(GdkRegion *) + * @method flags=dynamic */ public static final native void _gdk_region_subtract(int /*long*/ source1, int /*long*/ source2); public static final void gdk_region_subtract(int /*long*/ source1, int /*long*/ source2) { 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..95728da1f1 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 @@ -555,7 +555,7 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d int /*long*/ copyRegion = OS.gdk_region_rectangle (srcRect); OS.gdk_region_intersect(copyRegion, visibleRegion); int /*long*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_subtract (invalidateRegion, visibleRegion); + cairo_region_subtract (invalidateRegion, visibleRegion); OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); OS.gdk_window_invalidate_region(drawable, invalidateRegion, false); OS.gdk_region_destroy (visibleRegion); @@ -2430,7 +2430,7 @@ public void getClipping(Region region) { if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); int /*long*/ clipping = region.handle; - OS.gdk_region_subtract(clipping, clipping); + cairo_region_subtract(clipping, clipping); int /*long*/ cairo = data.cairo; int /*long*/ clipRgn = data.clipRgn; if (clipRgn == 0) { @@ -2459,7 +2459,7 @@ public void getClipping(Region region) { Cairo.cairo_get_matrix(cairo, matrix); Cairo.cairo_matrix_invert(matrix); int /*long*/ rgn = convertRgn(clipping, matrix); - OS.gdk_region_subtract(clipping, clipping); + cairo_region_subtract(clipping, clipping); OS.gdk_region_union(clipping, rgn); OS.gdk_region_destroy(rgn); } @@ -3315,7 +3315,7 @@ void setClipping(int /*long*/ clipRgn) { } } else { if (data.clipRgn == 0) data.clipRgn = OS.gdk_region_new(); - OS.gdk_region_subtract(data.clipRgn, data.clipRgn); + cairo_region_subtract(data.clipRgn, data.clipRgn); OS.gdk_region_union(data.clipRgn, clipRgn); if (cairo != 0) { if (data.clippingTransform == null) data.clippingTransform = new double[6]; @@ -4170,4 +4170,12 @@ public String toString () { return "GC {" + handle + "}"; } +void cairo_region_subtract(int /*long*/ dst, int /*long*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_subtract(dst, other); + } else { + OS.gdk_region_subtract(dst, other); + } +} + } 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..2dacb08b19 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.*; @@ -463,7 +464,7 @@ public void subtract (int[] pointArray) { */ if (pointArray.length < 6) return; int /*long*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gdk_region_subtract(handle, polyRgn); + cairo_region_subtract(handle, polyRgn); OS.gdk_region_destroy(polyRgn); } @@ -516,7 +517,7 @@ public void subtract(int x, int y, int width, int height) { gdkRect.width = width; gdkRect.height = height; int /*long*/ rectRgn = OS.gdk_region_rectangle(gdkRect); - OS.gdk_region_subtract(handle, rectRgn); + cairo_region_subtract(handle, rectRgn); OS.gdk_region_destroy(rectRgn); } @@ -541,7 +542,7 @@ public void subtract(Region region) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - OS.gdk_region_subtract(handle, region.handle); + cairo_region_subtract(handle, region.handle); } /** @@ -593,4 +594,12 @@ public String toString () { if (isDisposed()) return "Region {*DISPOSED*}"; return "Region {" + handle + "}"; } + +void cairo_region_subtract(int /*long*/ dst, int /*long*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_subtract(dst, other); + } else { + OS.gdk_region_subtract(dst, other); + } +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java index 9ebbe8e7e9..422273317f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java @@ -12,6 +12,7 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.cairo.Cairo; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.*; @@ -259,7 +260,11 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b int /*long*/ copyRegion = OS.gdk_region_rectangle (srcRect); OS.gdk_region_intersect(copyRegion, visibleRegion); int /*long*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_subtract (invalidateRegion, visibleRegion); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_subtract(invalidateRegion, visibleRegion); + } else { + OS.gdk_region_subtract(invalidateRegion, visibleRegion); + } OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); GdkRectangle copyRect = new GdkRectangle(); OS.gdk_region_get_clipbox (copyRegion, copyRect); |