diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-10-12 10:37:12 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-10-12 10:37:12 -0400 |
commit | 06b398c9efc2d1bae1c090fe5159dc78fdcc628a (patch) | |
tree | 52ed328ab12376ed23e1df93c489b61ce5559635 | |
parent | d60ebbc0b5b9ce8a80e6d5bc426685845f8eea01 (diff) | |
download | eclipse.platform.swt-gtk3_region_64.tar.gz eclipse.platform.swt-gtk3_region_64.tar.xz eclipse.platform.swt-gtk3_region_64.zip |
Replace GdkRegion with Cairo methods for GTK + 3.0 and highergtk3_region_64
21 files changed, 1691 insertions, 340 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..2d054c7911 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,294 @@ JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1reference) } #endif +#ifndef NO__1cairo_1region_1contains_1point +JNIEXPORT jboolean JNICALL Cairo_NATIVE(_1cairo_1region_1contains_1point) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2) +{ + jboolean rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1contains_1point_FUNC); +/* + rc = (jboolean)cairo_region_contains_point(arg0, arg1, arg2); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_contains_point) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong, jint, jint))fp)(arg0, arg1, arg2); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1contains_1point_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1contains_1rectangle +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1contains_1rectangle) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + cairo_rectangle_int_t _arg1, *lparg1=NULL; + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1contains_1rectangle_FUNC); + if (arg1) if ((lparg1 = getcairo_rectangle_int_tFields(env, arg1, &_arg1)) == NULL) goto fail; +/* + rc = (jintLong)cairo_region_contains_rectangle(arg0, lparg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_contains_rectangle) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, cairo_rectangle_int_t *))fp)(arg0, lparg1); + } + } +fail: + if (arg1 && lparg1) setcairo_rectangle_int_tFields(env, arg1, lparg1); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1contains_1rectangle_FUNC); + return rc; +} +#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_LOAD_FUNCTION(fp, cairo_region_create) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)(); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1create_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1create_1rectangle +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1create_1rectangle) + (JNIEnv *env, jclass that, jobject arg0) +{ + cairo_rectangle_int_t _arg0, *lparg0=NULL; + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1create_1rectangle_FUNC); + if (arg0) if ((lparg0 = getcairo_rectangle_int_tFields(env, arg0, &_arg0)) == NULL) goto fail; +/* + rc = (jintLong)cairo_region_create_rectangle(lparg0); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_create_rectangle) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(cairo_rectangle_int_t *))fp)(lparg0); + } + } +fail: + if (arg0 && lparg0) setcairo_rectangle_int_tFields(env, arg0, lparg0); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1create_1rectangle_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1destroy +JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1region_1destroy) + (JNIEnv *env, jclass that, jintLong arg0) +{ + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1destroy_FUNC); +/* + cairo_region_destroy(arg0); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_destroy) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1destroy_FUNC); +} +#endif + +#ifndef NO__1cairo_1region_1get_1extents +JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1region_1get_1extents) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + cairo_rectangle_int_t _arg1, *lparg1=NULL; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1get_1extents_FUNC); + if (arg1) if ((lparg1 = getcairo_rectangle_int_tFields(env, arg1, &_arg1)) == NULL) goto fail; +/* + cairo_region_get_extents(arg0, lparg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_get_extents) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, cairo_rectangle_int_t *))fp)(arg0, lparg1); + } + } +fail: + if (arg1 && lparg1) setcairo_rectangle_int_tFields(env, arg1, lparg1); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1get_1extents_FUNC); +} +#endif + +#ifndef NO__1cairo_1region_1get_1rectangle +JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1region_1get_1rectangle) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintLong arg2) +{ + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1get_1rectangle_FUNC); +/* + cairo_region_get_rectangle(arg0, arg1, arg2); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_get_rectangle) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, jintLong))fp)(arg0, arg1, arg2); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1get_1rectangle_FUNC); +} +#endif + +#ifndef NO__1cairo_1region_1intersect +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1intersect) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1intersect_FUNC); +/* + rc = (jintLong)cairo_region_intersect(arg0, arg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_intersect) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1intersect_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1is_1empty +JNIEXPORT jboolean JNICALL Cairo_NATIVE(_1cairo_1region_1is_1empty) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jboolean rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1is_1empty_FUNC); +/* + rc = (jboolean)cairo_region_is_empty(arg0); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_is_empty) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1is_1empty_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1num_1rectangles +JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1region_1num_1rectangles) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jint rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1num_1rectangles_FUNC); +/* + rc = (jint)cairo_region_num_rectangles(arg0); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_num_rectangles) + if (fp) { + rc = (jint)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1num_1rectangles_FUNC); + return rc; +} +#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(arg0, arg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_subtract) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1subtract_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1translate +JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1region_1translate) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2) +{ + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1translate_FUNC); +/* + cairo_region_translate(arg0, arg1, arg2); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_translate) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, jint))fp)(arg0, arg1, arg2); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1translate_FUNC); +} +#endif + +#ifndef NO__1cairo_1region_1union +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1union) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1union_FUNC); +/* + rc = (jintLong)cairo_region_union(arg0, arg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_union) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1union_FUNC); + return rc; +} +#endif + +#ifndef NO__1cairo_1region_1union_1rectangle +JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1region_1union_1rectangle) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + cairo_rectangle_int_t _arg1, *lparg1=NULL; + jintLong rc = 0; + Cairo_NATIVE_ENTER(env, that, _1cairo_1region_1union_1rectangle_FUNC); + if (arg1) if ((lparg1 = getcairo_rectangle_int_tFields(env, arg1, &_arg1)) == NULL) goto fail; +/* + rc = (jintLong)cairo_region_union_rectangle(arg0, lparg1); +*/ + { + Cairo_LOAD_FUNCTION(fp, cairo_region_union_rectangle) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, cairo_rectangle_int_t *))fp)(arg0, lparg1); + } + } +fail: + if (arg1 && lparg1) setcairo_rectangle_int_tFields(env, arg1, lparg1); + Cairo_NATIVE_EXIT(env, that, _1cairo_1region_1union_1rectangle_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) @@ -1939,6 +2227,18 @@ JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1path_1t_1sizeof) } #endif +#ifndef NO_cairo_1rectangle_1int_1t_1sizeof +JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1rectangle_1int_1t_1sizeof) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + Cairo_NATIVE_ENTER(env, that, cairo_1rectangle_1int_1t_1sizeof_FUNC); + rc = (jint)cairo_rectangle_int_t_sizeof(); + Cairo_NATIVE_EXIT(env, that, cairo_1rectangle_1int_1t_1sizeof_FUNC); + return rc; +} +#endif + #ifndef NO_cairo_1text_1extents_1t_1sizeof JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1text_1extents_1t_1sizeof) (JNIEnv *env, jclass that) @@ -2013,6 +2313,31 @@ fail: } #endif +#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ) && defined(JNI64)) +#ifndef JNI64 +JNIEXPORT void JNICALL Cairo_NATIVE(memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2) +#else +JNIEXPORT void JNICALL Cairo_NATIVE(memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2) +#endif +{ + cairo_rectangle_int_t _arg0, *lparg0=NULL; +#ifndef JNI64 + Cairo_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II_FUNC); +#else + Cairo_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ_FUNC); +#endif + if (arg0) if ((lparg0 = getcairo_rectangle_int_tFields(env, arg0, &_arg0)) == NULL) goto fail; + memmove((void *)lparg0, (const void *)arg1, (size_t)arg2); +fail: + if (arg0 && lparg0) setcairo_rectangle_int_tFields(env, arg0, lparg0); +#ifndef JNI64 + Cairo_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II_FUNC); +#else + Cairo_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ_FUNC); +#endif +} +#endif + #if (!defined(NO_memmove___3DII) && !defined(JNI64)) || (!defined(NO_memmove___3DJJ) && defined(JNI64)) #ifndef JNI64 JNIEXPORT void JNICALL Cairo_NATIVE(memmove___3DII)(JNIEnv *env, jclass that, jdoubleArray arg0, jintLong arg1, jintLong arg2) 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 f050ad143a..4415a1f365 100644 --- 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 @@ -42,3 +42,17 @@ #define cairo_surface_get_content_LIB LIB_CAIRO #define cairo_push_group_LIB LIB_CAIRO #define cairo_pop_group_to_source_LIB LIB_CAIRO +#define cairo_region_create_LIB LIB_CAIRO +#define cairo_region_destroy_LIB LIB_CAIRO +#define cairo_region_is_empty_LIB LIB_CAIRO +#define cairo_region_subtract_LIB LIB_CAIRO +#define cairo_region_translate_LIB LIB_CAIRO +#define cairo_region_union_LIB LIB_CAIRO +#define cairo_region_intersect_LIB LIB_CAIRO +#define cairo_region_create_rectangle_LIB LIB_CAIRO +#define cairo_region_contains_rectangle_LIB LIB_CAIRO +#define cairo_region_union_rectangle_LIB LIB_CAIRO +#define cairo_region_get_extents_LIB LIB_CAIRO +#define cairo_region_contains_point_LIB LIB_CAIRO +#define cairo_region_num_rectangles_LIB LIB_CAIRO +#define cairo_region_get_rectangle_LIB LIB_CAIRO 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 dce4e6c014..971d91071b 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 @@ -115,6 +115,20 @@ char * Cairo_nativeFunctionNames[] = { "_1cairo_1push_1group", "_1cairo_1rectangle", "_1cairo_1reference", + "_1cairo_1region_1contains_1point", + "_1cairo_1region_1contains_1rectangle", + "_1cairo_1region_1create", + "_1cairo_1region_1create_1rectangle", + "_1cairo_1region_1destroy", + "_1cairo_1region_1get_1extents", + "_1cairo_1region_1get_1rectangle", + "_1cairo_1region_1intersect", + "_1cairo_1region_1is_1empty", + "_1cairo_1region_1num_1rectangles", + "_1cairo_1region_1subtract", + "_1cairo_1region_1translate", + "_1cairo_1region_1union", + "_1cairo_1region_1union_1rectangle", "_1cairo_1rel_1curve_1to", "_1cairo_1rel_1line_1to", "_1cairo_1rel_1move_1to", @@ -177,6 +191,7 @@ char * Cairo_nativeFunctionNames[] = { "cairo_1font_1extents_1t_1sizeof", "cairo_1path_1data_1t_1sizeof", "cairo_1path_1t_1sizeof", + "cairo_1rectangle_1int_1t_1sizeof", "cairo_1text_1extents_1t_1sizeof", "cairo_1version", #ifndef JNI64 @@ -190,6 +205,11 @@ char * Cairo_nativeFunctionNames[] = { "memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2JJ", #endif #ifndef JNI64 + "memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II", +#else + "memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ", +#endif +#ifndef JNI64 "memmove___3DII", #else "memmove___3DJJ", 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..79975f2281 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,20 @@ typedef enum { _1cairo_1push_1group_FUNC, _1cairo_1rectangle_FUNC, _1cairo_1reference_FUNC, + _1cairo_1region_1contains_1point_FUNC, + _1cairo_1region_1contains_1rectangle_FUNC, + _1cairo_1region_1create_FUNC, + _1cairo_1region_1create_1rectangle_FUNC, + _1cairo_1region_1destroy_FUNC, + _1cairo_1region_1get_1extents_FUNC, + _1cairo_1region_1get_1rectangle_FUNC, + _1cairo_1region_1intersect_FUNC, + _1cairo_1region_1is_1empty_FUNC, + _1cairo_1region_1num_1rectangles_FUNC, + _1cairo_1region_1subtract_FUNC, + _1cairo_1region_1translate_FUNC, + _1cairo_1region_1union_FUNC, + _1cairo_1region_1union_1rectangle_FUNC, _1cairo_1rel_1curve_1to_FUNC, _1cairo_1rel_1line_1to_FUNC, _1cairo_1rel_1move_1to_FUNC, @@ -187,6 +201,7 @@ typedef enum { cairo_1font_1extents_1t_1sizeof_FUNC, cairo_1path_1data_1t_1sizeof_FUNC, cairo_1path_1t_1sizeof_FUNC, + cairo_1rectangle_1int_1t_1sizeof_FUNC, cairo_1text_1extents_1t_1sizeof_FUNC, cairo_1version_FUNC, #ifndef JNI64 @@ -200,6 +215,11 @@ typedef enum { memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2JJ_FUNC, #endif #ifndef JNI64 + memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2II_FUNC, +#else + memmove__Lorg_eclipse_swt_internal_cairo_cairo_1rectangle_1int_1t_2JJ_FUNC, +#endif +#ifndef JNI64 memmove___3DII_FUNC, #else memmove___3DJJ_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c index 085d180aaf..c04617f862 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.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, 2012 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ @@ -136,6 +136,46 @@ void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct } #endif +#ifndef NO_cairo_rectangle_int_t +typedef struct cairo_rectangle_int_t_FID_CACHE { + int cached; + jclass clazz; + jfieldID x, y, width, height; +} cairo_rectangle_int_t_FID_CACHE; + +cairo_rectangle_int_t_FID_CACHE cairo_rectangle_int_tFc; + +void cachecairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject) +{ + if (cairo_rectangle_int_tFc.cached) return; + cairo_rectangle_int_tFc.clazz = (*env)->GetObjectClass(env, lpObject); + cairo_rectangle_int_tFc.x = (*env)->GetFieldID(env, cairo_rectangle_int_tFc.clazz, "x", "I"); + cairo_rectangle_int_tFc.y = (*env)->GetFieldID(env, cairo_rectangle_int_tFc.clazz, "y", "I"); + cairo_rectangle_int_tFc.width = (*env)->GetFieldID(env, cairo_rectangle_int_tFc.clazz, "width", "I"); + cairo_rectangle_int_tFc.height = (*env)->GetFieldID(env, cairo_rectangle_int_tFc.clazz, "height", "I"); + cairo_rectangle_int_tFc.cached = 1; +} + +cairo_rectangle_int_t *getcairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject, cairo_rectangle_int_t *lpStruct) +{ + if (!cairo_rectangle_int_tFc.cached) cachecairo_rectangle_int_tFields(env, lpObject); + lpStruct->x = (*env)->GetIntField(env, lpObject, cairo_rectangle_int_tFc.x); + lpStruct->y = (*env)->GetIntField(env, lpObject, cairo_rectangle_int_tFc.y); + lpStruct->width = (*env)->GetIntField(env, lpObject, cairo_rectangle_int_tFc.width); + lpStruct->height = (*env)->GetIntField(env, lpObject, cairo_rectangle_int_tFc.height); + return lpStruct; +} + +void setcairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject, cairo_rectangle_int_t *lpStruct) +{ + if (!cairo_rectangle_int_tFc.cached) cachecairo_rectangle_int_tFields(env, lpObject); + (*env)->SetIntField(env, lpObject, cairo_rectangle_int_tFc.x, (jint)lpStruct->x); + (*env)->SetIntField(env, lpObject, cairo_rectangle_int_tFc.y, (jint)lpStruct->y); + (*env)->SetIntField(env, lpObject, cairo_rectangle_int_tFc.width, (jint)lpStruct->width); + (*env)->SetIntField(env, lpObject, cairo_rectangle_int_tFc.height, (jint)lpStruct->height); +} +#endif + #ifndef NO_cairo_text_extents_t typedef struct cairo_text_extents_t_FID_CACHE { int cached; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h index 1e0ece9cf7..2a91d40f20 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.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, 2012 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ @@ -57,6 +57,18 @@ void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct #define cairo_path_t_sizeof() 0 #endif +#ifndef NO_cairo_rectangle_int_t +void cachecairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject); +cairo_rectangle_int_t *getcairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject, cairo_rectangle_int_t *lpStruct); +void setcairo_rectangle_int_tFields(JNIEnv *env, jobject lpObject, cairo_rectangle_int_t *lpStruct); +#define cairo_rectangle_int_t_sizeof() sizeof(cairo_rectangle_int_t) +#else +#define cachecairo_rectangle_int_tFields(a,b) +#define getcairo_rectangle_int_tFields(a,b,c) NULL +#define setcairo_rectangle_int_tFields(a,b,c) +#define cairo_rectangle_int_t_sizeof() 0 +#endif + #ifndef NO_cairo_text_extents_t void cachecairo_text_extents_tFields(JNIEnv *env, jobject lpObject); cairo_text_extents_t *getcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct); 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 79a3c48820..2c0d59c705 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 @@ -93,6 +93,7 @@ public class Cairo extends Platform { public static final native int cairo_font_extents_t_sizeof (); public static final native int cairo_path_data_t_sizeof (); public static final native int cairo_path_t_sizeof (); +public static final native int cairo_rectangle_int_t_sizeof (); public static final native int cairo_text_extents_t_sizeof (); /** Natives */ @@ -1697,6 +1698,148 @@ public static final int cairo_xlib_surface_get_width(long /*int*/ surface) { lock.unlock(); } } +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_create(); +public static final long /*int*/cairo_region_create() { + lock.lock(); + try { + return _cairo_region_create(); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _cairo_region_destroy(long /*int*/ region); +public static final void cairo_region_destroy(long /*int*/ region) { + lock.lock(); + try { + _cairo_region_destroy(region); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native boolean _cairo_region_is_empty(long /*int*/ region); +public static final boolean cairo_region_is_empty(long /*int*/ region) { + lock.lock(); + try { + return _cairo_region_is_empty (region); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + */ +public static final native long /*int*/ _cairo_region_subtract(long /*int*/ dst, long /*int*/ other); +public static final long /*int*/ cairo_region_subtract(long /*int*/ dst, long /*int*/ other) { + lock.lock(); + try { + return _cairo_region_subtract(dst, other); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _cairo_region_translate(long /*int*/ region, int dx, int dy); +public static final void cairo_region_translate(long /*int*/ region, int dx, int dy) { + lock.lock(); + try { + _cairo_region_translate(region, dx, dy); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_union(long /*int*/ dst, long /*int*/ other); +public static final long /*int*/ cairo_region_union(long /*int*/ dst, long /*int*/ other) { + lock.lock(); + try { + return _cairo_region_union(dst,other); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_intersect(long /*int*/ dst, long /*int*/ other); +public static final long /*int*/ cairo_region_intersect(long /*int*/ dst, long /*int*/ other) { + lock.lock(); + try { + return _cairo_region_intersect(dst,other); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_create_rectangle(cairo_rectangle_int_t rectangle); +public static final long /*int*/ cairo_region_create_rectangle(cairo_rectangle_int_t rectangle) { + lock.lock(); + try { + return _cairo_region_create_rectangle(rectangle); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_contains_rectangle(long /*int*/ region, cairo_rectangle_int_t rectangle); +public static final long /*int*/ cairo_region_contains_rectangle(long /*int*/ region, cairo_rectangle_int_t rectangle) { + lock.lock(); + try { + return _cairo_region_contains_rectangle(region,rectangle); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _cairo_region_union_rectangle(long /*int*/ dst, cairo_rectangle_int_t rectangle); +public static final long /*int*/ cairo_region_union_rectangle(long /*int*/ dst, cairo_rectangle_int_t rectangle) { + lock.lock(); + try { + return _cairo_region_union_rectangle(dst,rectangle); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _cairo_region_get_extents(long /*int*/ region, cairo_rectangle_int_t extents); +public static final void cairo_region_get_extents(long /*int*/ region, cairo_rectangle_int_t extents) { + lock.lock(); + try { + _cairo_region_contains_rectangle(region,extents); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native boolean _cairo_region_contains_point(long /*int*/ region, int x, int y); +public static final boolean cairo_region_contains_point(long /*int*/ region, int x, int y) { + lock.lock(); + try { + return _cairo_region_contains_point(region, x, y); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native int _cairo_region_num_rectangles(long /*int*/ region); +public static final int cairo_region_num_rectangles(long /*int*/ region) { + lock.lock(); + try { + return _cairo_region_num_rectangles(region); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _cairo_region_get_rectangle(long /*int*/ region, int nth, long /*int*/ rectangle); +public static final void cairo_region_get_rectangle(long /*int*/ region, int nth, long /*int*/ rectangle) { + lock.lock(); + try { + _cairo_region_get_rectangle(region,nth,rectangle); + } finally { + lock.unlock(); + } +} /** * @param dest cast=(void *) * @param src cast=(const void *) @@ -1708,6 +1851,12 @@ public static final native void memmove(cairo_path_t dest, long /*int*/ src, lon * @param src cast=(const void *) * @param size cast=(size_t) */ +public static final native void memmove(cairo_rectangle_int_t dest, long /*int*/ src, long /*int*/ size); +/** + * @param dest cast=(void *) + * @param src cast=(const void *) + * @param size cast=(size_t) + */ public static final native void memmove(cairo_path_data_t dest, long /*int*/ src, long /*int*/ size); /** * @param dest cast=(void *) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_rectangle_int_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_rectangle_int_t.java new file mode 100644 index 0000000000..5e38d821db --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_rectangle_int_t.java @@ -0,0 +1,29 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Contributor(s): + * + * Red Hat Inc. + * - Binding to permit interfacing between Cairo and SWT + * - Copyright (C) 2012 Red Hat Inc. All Rights Reserved. + * + * ***** END LICENSE BLOCK ***** */ +package org.eclipse.swt.internal.cairo; + +public class cairo_rectangle_int_t { + public int x; + public int y; + public int width; + public int height; + public static final int sizeof = Cairo.cairo_rectangle_int_t_sizeof(); +}
\ No newline at end of file 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 aeab8e68b7..b210c3166b 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 @@ -4619,6 +4619,26 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1region) } #endif +#ifndef NO__1gdk_1cairo_1region_1create_1from_1surface +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1cairo_1region_1create_1from_1surface) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1region_1create_1from_1surface_FUNC); +/* + rc = (jintLong)gdk_cairo_region_create_from_surface(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_cairo_region_create_from_surface) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1region_1create_1from_1surface_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1cairo_1reset_1clip JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1reset_1clip) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) @@ -6372,7 +6392,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1destroy) (JNIEnv *env, jclass that, jintLong arg0) { OS_NATIVE_ENTER(env, that, _1gdk_1region_1destroy_FUNC); - gdk_region_destroy((GdkRegion *)arg0); +/* + gdk_region_destroy(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_destroy) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1destroy_FUNC); } #endif @@ -6383,7 +6411,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1region_1empty) { jboolean rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1empty_FUNC); - rc = (jboolean)gdk_region_empty((GdkRegion *)arg0); +/* + rc = (jboolean)gdk_region_empty(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_empty) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1empty_FUNC); return rc; } @@ -6395,8 +6431,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1get_1clipbox) { GdkRectangle _arg1, *lparg1=NULL; OS_NATIVE_ENTER(env, that, _1gdk_1region_1get_1clipbox_FUNC); - if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail; - gdk_region_get_clipbox((GdkRegion *)arg0, (GdkRectangle *)lparg1); + if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail; +/* + gdk_region_get_clipbox(arg0, lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_get_clipbox) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, GdkRectangle *))fp)(arg0, lparg1); + } + } fail: if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1); OS_NATIVE_EXIT(env, that, _1gdk_1region_1get_1clipbox_FUNC); @@ -6412,7 +6456,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1get_1rectangles) OS_NATIVE_ENTER(env, that, _1gdk_1region_1get_1rectangles_FUNC); if (arg1) if ((lparg1 = (*env)->GetIntLongArrayElements(env, arg1, NULL)) == NULL) goto fail; if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; - gdk_region_get_rectangles((GdkRegion *)arg0, (GdkRectangle **)lparg1, (gint *)lparg2); +/* + gdk_region_get_rectangles(arg0, lparg1, (gint *)lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_get_rectangles) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong *, gint *))fp)(arg0, lparg1, (gint *)lparg2); + } + } fail: if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); if (arg1 && lparg1) (*env)->ReleaseIntLongArrayElements(env, arg1, lparg1, 0); @@ -6425,7 +6477,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1intersect) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) { OS_NATIVE_ENTER(env, that, _1gdk_1region_1intersect_FUNC); - gdk_region_intersect((GdkRegion *)arg0, (GdkRegion *)arg1); +/* + gdk_region_intersect(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_intersect) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1intersect_FUNC); } #endif @@ -6436,7 +6496,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; } @@ -6447,7 +6515,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1offset) (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2) { OS_NATIVE_ENTER(env, that, _1gdk_1region_1offset_FUNC); - gdk_region_offset((GdkRegion *)arg0, (gint)arg1, (gint)arg2); +/* + gdk_region_offset(arg0, (gint)arg1, (gint)arg2); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_offset) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, gint, gint))fp)(arg0, (gint)arg1, (gint)arg2); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1offset_FUNC); } #endif @@ -6458,7 +6534,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1region_1point_1in) { jboolean rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1point_1in_FUNC); - rc = (jboolean)gdk_region_point_in((GdkRegion *)arg0, (gint)arg1, (gint)arg2); +/* + rc = (jboolean)gdk_region_point_in(arg0, (gint)arg1, (gint)arg2); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_point_in) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong, gint, gint))fp)(arg0, (gint)arg1, (gint)arg2); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1point_1in_FUNC); return rc; } @@ -6472,7 +6556,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1region_1polygon) jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1polygon_FUNC); if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail; - rc = (jintLong)gdk_region_polygon((GdkPoint *)lparg0, arg1, (GdkFillRule)arg2); +/* + rc = (jintLong)gdk_region_polygon(lparg0, arg1, arg2); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_polygon) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jint *, jint, jint))fp)(lparg0, arg1, arg2); + } + } fail: if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); OS_NATIVE_EXIT(env, that, _1gdk_1region_1polygon_FUNC); @@ -6488,7 +6580,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1region_1rect_1in) jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1rect_1in_FUNC); if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail; - rc = (jintLong)gdk_region_rect_in((GdkRegion *)arg0, (GdkRectangle *)lparg1); +/* + rc = (jintLong)gdk_region_rect_in(arg0, (GdkRectangle *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_rect_in) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, GdkRectangle *))fp)(arg0, (GdkRectangle *)lparg1); + } + } fail: OS_NATIVE_EXIT(env, that, _1gdk_1region_1rect_1in_FUNC); return rc; @@ -6503,8 +6603,17 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1region_1rectangle) jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1region_1rectangle_FUNC); if (arg0) if ((lparg0 = getGdkRectangleFields(env, arg0, &_arg0)) == NULL) goto fail; +/* rc = (jintLong)gdk_region_rectangle(lparg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_rectangle) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkRectangle *))fp)(lparg0); + } + } fail: + if (arg0 && lparg0) setGdkRectangleFields(env, arg0, lparg0); OS_NATIVE_EXIT(env, that, _1gdk_1region_1rectangle_FUNC); return rc; } @@ -6515,7 +6624,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 @@ -6525,7 +6642,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1union) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) { OS_NATIVE_ENTER(env, that, _1gdk_1region_1union_FUNC); - gdk_region_union((GdkRegion *)arg0, (GdkRegion *)arg1); +/* + gdk_region_union(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_union) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1region_1union_FUNC); } #endif @@ -6537,7 +6662,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1union_1with_1rect) GdkRectangle _arg1, *lparg1=NULL; OS_NATIVE_ENTER(env, that, _1gdk_1region_1union_1with_1rect_FUNC); if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail; - gdk_region_union_with_rect((GdkRegion *)arg0, (GdkRectangle *)lparg1); +/* + gdk_region_union_with_rect(arg0, (GdkRectangle *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_region_union_with_rect) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, GdkRectangle *))fp)(arg0, (GdkRectangle *)lparg1); + } + } fail: OS_NATIVE_EXIT(env, that, _1gdk_1region_1union_1with_1rect_FUNC); } @@ -6877,6 +7010,24 @@ fail: } #endif +#ifndef NO__1gdk_1window_1begin_1paint_1region +JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1begin_1paint_1region) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gdk_1window_1begin_1paint_1region_FUNC); +/* + gdk_window_begin_paint_region((GdkWindow *)arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_window_begin_paint_region) + if (fp) { + ((void (CALLING_CONVENTION*)(GdkWindow *, jintLong))fp)((GdkWindow *)arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1window_1begin_1paint_1region_FUNC); +} +#endif + #ifndef NO__1gdk_1window_1create_1similar_1surface JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1window_1create_1similar_1surface) (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2, jint arg3) @@ -17374,6 +17525,24 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1visible) } #endif +#ifndef NO__1gtk_1widget_1shape_1combine_1region +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1shape_1combine_1region) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1shape_1combine_1region_FUNC); +/* + gtk_widget_shape_combine_region(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_shape_combine_region) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1shape_1combine_1region_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1show JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1show) (JNIEnv *env, jclass that, jintLong arg0) 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 b4b96bc1ab..c24464cdea 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 @@ -210,6 +210,20 @@ #define gdk_pixbuf_save_to_bufferv_LIB LIB_GDK #define gdk_pointer_grab_LIB LIB_GDK #define gdk_pointer_ungrab_LIB LIB_GDK +#define gdk_region_new_LIB LIB_GDK +#define gdk_region_rectangle_LIB LIB_GDK +#define gdk_region_destroy_LIB LIB_GDK +#define gdk_region_empty_LIB LIB_GDK +#define gdk_region_subtract_LIB LIB_GDK +#define gdk_region_offset_LIB LIB_GDK +#define gdk_region_union_LIB LIB_GDK +#define gdk_region_intersect_LIB LIB_GDK +#define gdk_region_rect_in_LIB LIB_GDK +#define gdk_region_get_clipbox_LIB LIB_GDK +#define gdk_region_union_with_rect_LIB LIB_GDK +#define gdk_region_point_in_LIB LIB_GDK +#define gdk_region_polygon_LIB LIB_GDK +#define gdk_region_get_rectangles_LIB LIB_GDK #define gdk_screen_get_default_LIB LIB_GDK #define gdk_screen_get_monitor_at_point_LIB LIB_GDK #define gdk_screen_get_monitor_at_window_LIB LIB_GDK @@ -243,6 +257,7 @@ #define gdk_window_create_similar_surface_LIB LIB_GDK #define gdk_window_lookup_LIB LIB_GDK #define gdk_window_restack_LIB LIB_GDK +#define gdk_window_begin_paint_region_LIB LIB_GDK #define gdk_window_get_device_position_LIB LIB_GDK #define gdk_window_get_pointer_LIB LIB_GDK #define gdk_window_at_pointer_LIB LIB_GDK @@ -278,6 +293,7 @@ #define gtk_widget_set_sensitive_LIB LIB_GTK #define gtk_widget_set_receives_default_LIB LIB_GTK #define gtk_widget_set_visible_LIB LIB_GTK +#define gtk_widget_shape_combine_region_LIB LIB_GTK #define gtk_range_get_slider_range_LIB LIB_GTK #define gdk_pango_context_set_colormap_LIB LIB_GDK #define gdk_x11_screen_get_window_manager_name_LIB LIB_GDK @@ -312,6 +328,7 @@ #define gdk_cairo_set_source_pixbuf_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_create_from_surface_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 2e93db0168..db705dc9b9 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 @@ -402,6 +402,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1bitmap_1create_1from_1data", "_1gdk_1cairo_1create", "_1gdk_1cairo_1region", + "_1gdk_1cairo_1region_1create_1from_1surface", "_1gdk_1cairo_1reset_1clip", "_1gdk_1cairo_1set_1source_1color", "_1gdk_1cairo_1set_1source_1pixbuf", @@ -538,6 +539,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1window_1add_1filter", "_1gdk_1window_1at_1pointer", "_1gdk_1window_1begin_1paint_1rect", + "_1gdk_1window_1begin_1paint_1region", "_1gdk_1window_1create_1similar_1surface", "_1gdk_1window_1destroy", "_1gdk_1window_1end_1paint", @@ -1316,6 +1318,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1set_1state", "_1gtk_1widget_1set_1tooltip_1text", "_1gtk_1widget_1set_1visible", + "_1gtk_1widget_1shape_1combine_1region", "_1gtk_1widget_1show", "_1gtk_1widget_1size_1allocate", "_1gtk_1widget_1size_1request", 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 64c93e3041..c0edc5908a 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 @@ -412,6 +412,7 @@ typedef enum { _1gdk_1bitmap_1create_1from_1data_FUNC, _1gdk_1cairo_1create_FUNC, _1gdk_1cairo_1region_FUNC, + _1gdk_1cairo_1region_1create_1from_1surface_FUNC, _1gdk_1cairo_1reset_1clip_FUNC, _1gdk_1cairo_1set_1source_1color_FUNC, _1gdk_1cairo_1set_1source_1pixbuf_FUNC, @@ -548,6 +549,7 @@ typedef enum { _1gdk_1window_1add_1filter_FUNC, _1gdk_1window_1at_1pointer_FUNC, _1gdk_1window_1begin_1paint_1rect_FUNC, + _1gdk_1window_1begin_1paint_1region_FUNC, _1gdk_1window_1create_1similar_1surface_FUNC, _1gdk_1window_1destroy_FUNC, _1gdk_1window_1end_1paint_FUNC, @@ -1326,6 +1328,7 @@ typedef enum { _1gtk_1widget_1set_1state_FUNC, _1gtk_1widget_1set_1tooltip_1text_FUNC, _1gtk_1widget_1set_1visible_FUNC, + _1gtk_1widget_1shape_1combine_1region_FUNC, _1gtk_1widget_1show_FUNC, _1gtk_1widget_1size_1allocate_FUNC, _1gtk_1widget_1size_1request_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 a8edc1713b..166c7308bf 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 @@ -4804,7 +4804,7 @@ public static final boolean gdk_property_get(long /*int*/ window, long /*int*/ p lock.unlock(); } } -/** @param region cast=(GdkRegion *) */ +/** @method flags=dynamic */ public static final native void _gdk_region_destroy(long /*int*/ region); public static final void gdk_region_destroy(long /*int*/ region) { lock.lock(); @@ -4814,7 +4814,7 @@ public static final void gdk_region_destroy(long /*int*/ region) { lock.unlock(); } } -/** @param region cast=(GdkRegion *) */ +/** @method flags=dynamic */ public static final native boolean _gdk_region_empty(long /*int*/ region); public static final boolean gdk_region_empty(long /*int*/ region) { lock.lock(); @@ -4824,10 +4824,7 @@ public static final boolean gdk_region_empty(long /*int*/ region) { lock.unlock(); } } -/** - * @param region cast=(GdkRegion *) - * @param rectangle cast=(GdkRectangle *),flags=no_in - */ +/** @method flags=dynamic */ public static final native void _gdk_region_get_clipbox(long /*int*/ region, GdkRectangle rectangle); public static final void gdk_region_get_clipbox(long /*int*/ region, GdkRectangle rectangle) { lock.lock(); @@ -4838,8 +4835,7 @@ public static final void gdk_region_get_clipbox(long /*int*/ region, GdkRectangl } } /** - * @param region cast=(GdkRegion *) - * @param rectangles cast=(GdkRectangle **) + * @method flags=dynamic * @param n_rectangles cast=(gint *) */ public static final native void _gdk_region_get_rectangles(long /*int*/ region, long /*int*/[] rectangles, int[] n_rectangles); @@ -4851,10 +4847,7 @@ public static final void gdk_region_get_rectangles(long /*int*/ region, long /*i lock.unlock(); } } -/** - * @param source1 cast=(GdkRegion *) - * @param source2 cast=(GdkRegion *) - */ +/** @method flags=dynamic */ public static final native void _gdk_region_intersect(long /*int*/ source1, long /*int*/ source2); public static final void gdk_region_intersect(long /*int*/ source1, long /*int*/ source2) { lock.lock(); @@ -4864,6 +4857,27 @@ public static final void gdk_region_intersect(long /*int*/ source1, long /*int*/ lock.unlock(); } } +/** @method flags=dynamic */ +public static final native long /*int*/ _gdk_cairo_region_create_from_surface(long /*int*/ surface); +public static final long /*int*/ gdk_cairo_region_create_from_surface(long /*int*/ surface) { + lock.lock(); + try { + return _gdk_cairo_region_create_from_surface(surface); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _gtk_widget_shape_combine_region(long /*int*/ widget, long /*int*/ region); +public static final void gtk_widget_shape_combine_region(long /*int*/ widget, long /*int*/ region) { + lock.lock(); + try { + _gtk_widget_shape_combine_region(widget,region); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ public static final native long /*int*/ _gdk_region_new(); public static final long /*int*/ gdk_region_new() { lock.lock(); @@ -4874,7 +4888,7 @@ public static final long /*int*/ gdk_region_new() { } } /** - * @param region cast=(GdkRegion *) + * @method flags=dynamic * @param dx cast=(gint) * @param dy cast=(gint) */ @@ -4888,7 +4902,7 @@ public static final void gdk_region_offset(long /*int*/ region, int dx, int dy) } } /** - * @param region cast=(GdkRegion *) + * @method flags=dynamic * @param x cast=(gint) * @param y cast=(gint) */ @@ -4901,10 +4915,7 @@ public static final boolean gdk_region_point_in(long /*int*/ region, int x, int lock.unlock(); } } -/** - * @param points cast=(GdkPoint *) - * @param fill_rule cast=(GdkFillRule) - */ +/** @method flags=dynamic */ public static final native long /*int*/ _gdk_region_polygon(int[] points, int npoints, int fill_rule); public static final long /*int*/ gdk_region_polygon(int[] points, int npoints, int fill_rule) { lock.lock(); @@ -4914,7 +4925,7 @@ public static final long /*int*/ gdk_region_polygon(int[] points, int npoints, i lock.unlock(); } } -/** @param rectangle flags=no_out */ +/** @method flags=dynamic */ public static final native long /*int*/ _gdk_region_rectangle(GdkRectangle rectangle); public static final long /*int*/ gdk_region_rectangle(GdkRectangle rectangle) { lock.lock(); @@ -4925,7 +4936,7 @@ public static final long /*int*/ gdk_region_rectangle(GdkRectangle rectangle) { } } /** - * @param region cast=(GdkRegion *) + * @method flags=dynamic * @param rect cast=(GdkRectangle *),flags=no_out */ public static final native long /*int*/ _gdk_region_rect_in(long /*int*/ region, GdkRectangle rect); @@ -4937,10 +4948,7 @@ public static final long /*int*/ gdk_region_rect_in(long /*int*/ region, GdkRect lock.unlock(); } } -/** - * @param source1 cast=(GdkRegion *) - * @param source2 cast=(GdkRegion *) - */ +/** @method flags=dynamic */ public static final native void _gdk_region_subtract(long /*int*/ source1, long /*int*/ source2); public static final void gdk_region_subtract(long /*int*/ source1, long /*int*/ source2) { lock.lock(); @@ -4950,10 +4958,7 @@ public static final void gdk_region_subtract(long /*int*/ source1, long /*int*/ lock.unlock(); } } -/** - * @param source1 cast=(GdkRegion *) - * @param source2 cast=(GdkRegion *) - */ +/** @method flags=dynamic */ public static final native void _gdk_region_union(long /*int*/ source1, long /*int*/ source2); public static final void gdk_region_union(long /*int*/ source1, long /*int*/ source2) { lock.lock(); @@ -4964,7 +4969,7 @@ public static final void gdk_region_union(long /*int*/ source1, long /*int*/ sou } } /** - * @param region cast=(GdkRegion *) + * @method flags=dynamic * @param rect cast=(GdkRectangle *),flags=no_out */ public static final native void _gdk_region_union_with_rect(long /*int*/ region, GdkRectangle rect); @@ -5209,6 +5214,19 @@ public static final void gdk_window_begin_paint_rect(long /*int*/ window, GdkRec } } /** + * @method flags=dynamic + * @param window cast=(GdkWindow *) + */ +public static final native void _gdk_window_begin_paint_region(long /*int*/ window, long /*int*/ region); +public static final void gdk_window_begin_paint_region(long /*int*/ window, long /*int*/ region) { + lock.lock(); + try { + _gdk_window_begin_paint_region(window, region); + } finally { + lock.unlock(); + } +} +/** * @method flags=dynamic * @param window cast=(GdkWindow *) */ 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 0d384038be..a36ca00849 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 { @@ -187,9 +188,15 @@ void transferClipping(GC gc, long /*int*/ style) { long /*int*/ clipping = clipRgn; if (damageRgn != 0) { if (clipping != 0) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + clipping = Cairo.cairo_region_create (); + Cairo.cairo_region_union (clipping, clipRgn); + Cairo.cairo_region_intersect (clipping, damageRgn); + } else { clipping = OS.gdk_region_new(); - OS.gdk_region_union(clipping, clipRgn); - OS.gdk_region_intersect(clipping, damageRgn); + OS.gdk_region_union (clipping, clipRgn); + OS.gdk_region_intersect (clipping, damageRgn); + } } else { clipping = damageRgn; } @@ -216,7 +223,11 @@ void transferClipping(GC gc, long /*int*/ style) { OS.gtk_style_get_white_gc (style, curGC); if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping); if (clipping != clipRgn && clipping != damageRgn) { - OS.gdk_region_destroy(clipping); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_destroy ( clipping); + } else { + OS.gdk_region_destroy (clipping); + } } } } 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 f2e4407cf3..d00ef55cba 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 @@ -425,10 +425,10 @@ void checkGC (int mask) { } long /*int*/ convertRgn(long /*int*/ rgn, double[] matrix) { - long /*int*/ newRgn = OS.gdk_region_new(); + long /*int*/ newRgn = cairo_region_create (); int[] nRects = new int[1]; long /*int*/[] rects = new long /*int*/[1]; - OS.gdk_region_get_rectangles(rgn, rects, nRects); + cairo_region_get_rectangles (rgn, rects, nRects); GdkRectangle rect = new GdkRectangle(); int[] pointArray = new int[8]; double[] x = new double[1], y = new double[1]; @@ -454,9 +454,26 @@ long /*int*/ convertRgn(long /*int*/ rgn, double[] matrix) { Cairo.cairo_matrix_transform_point(matrix, x, y); pointArray[6] = (int)x[0]; pointArray[7] = (int)Math.round(y[0]); - long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gdk_region_union(newRgn, polyRgn); - OS.gdk_region_destroy(polyRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*ing*/ cairo = OS.gdk_cairo_create(newRgn); + int count = pointArray.length / 2; + if (count == 0) return 0; + Cairo.cairo_move_to(cairo, pointArray[0], pointArray[1]); + for (int n=1,j=2; n<count; n++,j+=2) { + Cairo.cairo_move_to(cairo, pointArray[j]+0.5, pointArray[j+1]+0.5); + } + Cairo.cairo_close_path(cairo); + Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); + Cairo.cairo_fill(cairo); + long /*ing*/ surface = Cairo.cairo_get_target(cairo); + long /*int*/ polyRgn = OS.gdk_cairo_region_create_from_surface(surface); + Cairo.cairo_region_union(newRgn, polyRgn); + Cairo.cairo_destroy(cairo); + } else { + long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); + OS.gdk_region_union(newRgn, polyRgn); + OS.gdk_region_destroy(polyRgn); + } } if (rects[0] != 0) OS.g_free(rects[0]); return newRgn; @@ -581,20 +598,37 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d Cairo.cairo_restore(handle); if (paint) { long /*int*/ visibleRegion = OS.gdk_drawable_get_visible_region (drawable); - GdkRectangle srcRect = new GdkRectangle (); - srcRect.x = srcX; - srcRect.y = srcY; - srcRect.width = width; - srcRect.height = height; - long /*int*/ copyRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_intersect(copyRegion, visibleRegion); - long /*int*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_subtract (invalidateRegion, visibleRegion); - OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); - OS.gdk_window_invalidate_region(drawable, invalidateRegion, false); - OS.gdk_region_destroy (visibleRegion); - OS.gdk_region_destroy (copyRegion); - OS.gdk_region_destroy (invalidateRegion); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t srcRect = new cairo_rectangle_int_t (); + srcRect.x = srcX; + srcRect.y = srcY; + srcRect.width = width; + srcRect.height = height; + long /*int*/ copyRegion = Cairo.cairo_region_create_rectangle (srcRect); + Cairo.cairo_region_intersect (copyRegion, visibleRegion); + long /*int*/ invalidateRegion = Cairo.cairo_region_create_rectangle (srcRect); + Cairo.cairo_region_subtract (invalidateRegion, visibleRegion); + Cairo.cairo_region_translate (invalidateRegion, deltaX, deltaY); + OS.gdk_window_invalidate_region(drawable, invalidateRegion, false); + Cairo.cairo_region_destroy (visibleRegion); + Cairo.cairo_region_destroy (copyRegion); + Cairo.cairo_region_destroy (invalidateRegion); + } else { + GdkRectangle srcRect = new GdkRectangle (); + srcRect.x = srcX; + srcRect.y = srcY; + srcRect.width = width; + srcRect.height = height; + long /*int*/ copyRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_intersect (copyRegion, visibleRegion); + long /*int*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_subtract (invalidateRegion, visibleRegion); + OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); + OS.gdk_window_invalidate_region(drawable, invalidateRegion, false); + OS.gdk_region_destroy (visibleRegion); + OS.gdk_region_destroy (copyRegion); + OS.gdk_region_destroy (invalidateRegion); + } } } } else { @@ -673,7 +707,7 @@ void destroy() { /* Free resources */ long /*int*/ clipRgn = data.clipRgn; - if (clipRgn != 0) OS.gdk_region_destroy(clipRgn); + if (clipRgn != 0) cairo_region_destroy (clipRgn); Image image = data.image; if (image != null) { image.memGC = null; @@ -1118,9 +1152,9 @@ void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeig long /*int*/ mask = OS.gdk_bitmap_create_from_data(0, maskData, newWidth, newHeight); if (mask != 0) { long /*int*/ gc = OS.gdk_gc_new(mask); - OS.gdk_region_offset(data.clipRgn, -destX + srcX, -destY + srcY); + cairo_region_translate (data.clipRgn, -destX + srcX, -destY + srcY); OS.gdk_gc_set_clip_region(gc, data.clipRgn); - OS.gdk_region_offset(data.clipRgn, destX - srcX, destY - srcY); + cairo_region_translate (data.clipRgn, destX - srcX, destY - srcY); GdkColor color = new GdkColor(); color.pixel = 1; OS.gdk_gc_set_foreground(gc, color); @@ -1190,27 +1224,47 @@ void drawImageXRender(Image srcImage, int srcX, int srcY, int srcWidth, int srcH if (clipping == 0) { clipping = data.damageRgn; } else { - clipping = OS.gdk_region_new(); - OS.gdk_region_union(clipping, data.clipRgn); - OS.gdk_region_intersect(clipping, data.damageRgn); + clipping = cairo_region_create (); + cairo_region_union (clipping, data.clipRgn); + cairo_region_intersect (clipping, data.damageRgn); } } if (clipping != 0) { int[] nRects = new int[1]; long /*int*/[] rects = new long /*int*/[1]; - OS.gdk_region_get_rectangles(clipping, rects, nRects); - GdkRectangle rect = new GdkRectangle(); - short[] xRects = new short[nRects[0] * 4]; - for (int i=0, j=0; i<nRects[0]; i++, j+=4) { - OS.memmove(rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof); - xRects[j] = (short)(translateX + rect.x); - xRects[j+1] = (short)(translateY + rect.y); - xRects[j+2] = (short)rect.width; - xRects[j+3] = (short)rect.height; - } - OS.XRenderSetPictureClipRectangles(xDisplay, destPict, 0, 0, xRects, nRects[0]); - if (clipping != data.clipRgn && clipping != data.damageRgn) { - OS.gdk_region_destroy(clipping); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int num = Cairo.cairo_region_num_rectangles (clipping); + for (int n = 0; n < num; n++) { + Cairo.cairo_region_get_rectangle (clipping, n, nRects[n]); + } + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + short[] xRects = new short[nRects[0] * 4]; + for (int i=0, j=0; i<nRects[0]; i++, j+=4) { + Cairo.memmove(rect, rects[0] + (i * cairo_rectangle_int_t.sizeof), cairo_rectangle_int_t.sizeof); + xRects[j] = (short)(translateX + rect.x); + xRects[j+1] = (short)(translateY + rect.y); + xRects[j+2] = (short)rect.width; + xRects[j+3] = (short)rect.height; + } + OS.XRenderSetPictureClipRectangles(xDisplay, destPict, 0, 0, xRects, nRects[0]); + if (clipping != data.clipRgn && clipping != data.damageRgn) { + Cairo.cairo_region_destroy(clipping); + } + } else { + OS.gdk_region_get_rectangles(clipping, rects, nRects); + GdkRectangle rect = new GdkRectangle(); + short[] xRects = new short[nRects[0] * 4]; + for (int i=0, j=0; i<nRects[0]; i++, j+=4) { + OS.memmove(rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof); + xRects[j] = (short)(translateX + rect.x); + xRects[j+1] = (short)(translateY + rect.y); + xRects[j+2] = (short)rect.width; + xRects[j+3] = (short)rect.height; + } + OS.XRenderSetPictureClipRectangles(xDisplay, destPict, 0, 0, xRects, nRects[0]); + if (clipping != data.clipRgn && clipping != data.damageRgn) { + OS.gdk_region_destroy(clipping); + } } if (rects[0] != 0) OS.g_free(rects[0]); } @@ -2406,41 +2460,80 @@ public Rectangle getClipping() { long /*int*/ cairo = data.cairo; long /*int*/ clipRgn = data.clipRgn; long /*int*/ damageRgn = data.damageRgn; + long /*int*/ rgn = 0; if (clipRgn != 0 || damageRgn != 0 || cairo != 0) { - long /*int*/ rgn = OS.gdk_region_new(); - GdkRectangle rect = new GdkRectangle(); - rect.width = width; - rect.height = height; - OS.gdk_region_union_with_rect(rgn, rect); - if (damageRgn != 0) { - OS.gdk_region_intersect (rgn, damageRgn); - } - /* Intersect visible bounds with clipping */ - if (clipRgn != 0) { - /* Convert clipping to device space if needed */ - if (data.clippingTransform != null) { - clipRgn = convertRgn(clipRgn, data.clippingTransform); - OS.gdk_region_intersect(rgn, clipRgn); - OS.gdk_region_destroy(clipRgn); - } else { - OS.gdk_region_intersect(rgn, clipRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + rgn = Cairo.cairo_region_create (); + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + rect.width = width; + rect.height = height; + Cairo.cairo_region_union_rectangle (rgn, rect); + if (damageRgn != 0) { + Cairo.cairo_region_intersect (rgn, damageRgn); } + /* Intersect visible bounds with clipping */ + if (clipRgn != 0) { + /* Convert clipping to device space if needed */ + if (data.clippingTransform != null) { + clipRgn = convertRgn(clipRgn, data.clippingTransform); + Cairo.cairo_region_intersect (rgn, clipRgn); + Cairo.cairo_region_destroy (clipRgn); + } else { + Cairo.cairo_region_intersect (rgn, clipRgn); + } + } + /* Convert to user space */ + if (cairo != 0) { + double[] matrix = new double[6]; + Cairo.cairo_get_matrix(cairo, matrix); + Cairo.cairo_matrix_invert(matrix); + clipRgn = convertRgn(rgn, matrix); + Cairo.cairo_region_destroy (rgn); + rgn = clipRgn; + } + Cairo.cairo_region_get_extents (rgn, rect); + Cairo.cairo_region_destroy (rgn); + x = rect.x; + y = rect.y; + width = rect.width; + height = rect.height; + } else { + rgn = OS.gdk_region_new (); + GdkRectangle rect = new GdkRectangle(); + rect.width = width; + rect.height = height; + OS.gdk_region_union_with_rect(rgn, rect); + if (damageRgn != 0) { + OS.gdk_region_intersect (rgn, damageRgn); + } + /* Intersect visible bounds with clipping */ + if (clipRgn != 0) { + /* Convert clipping to device space if needed */ + if (data.clippingTransform != null) { + clipRgn = convertRgn(clipRgn, data.clippingTransform); + OS.gdk_region_intersect (rgn, clipRgn); + OS.gdk_region_destroy (clipRgn); + } else { + OS.gdk_region_intersect (rgn, clipRgn); + } + } + /* Convert to user space */ + if (cairo != 0) { + double[] matrix = new double[6]; + Cairo.cairo_get_matrix(cairo, matrix); + Cairo.cairo_matrix_invert(matrix); + clipRgn = convertRgn(rgn, matrix); + OS.gdk_region_destroy (rgn); + rgn = clipRgn; + } + OS.gdk_region_get_clipbox(rgn, rect); + OS.gdk_region_destroy (rgn); + x = rect.x; + y = rect.y; + width = rect.width; + height = rect.height; } - /* Convert to user space */ - if (cairo != 0) { - double[] matrix = new double[6]; - Cairo.cairo_get_matrix(cairo, matrix); - Cairo.cairo_matrix_invert(matrix); - clipRgn = convertRgn(rgn, matrix); - OS.gdk_region_destroy(rgn); - rgn = clipRgn; - } - OS.gdk_region_get_clipbox(rgn, rect); - OS.gdk_region_destroy(rgn); - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; + } return new Rectangle(x, y, width, height); } @@ -2464,28 +2557,37 @@ public void getClipping(Region region) { if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); long /*int*/ clipping = region.handle; - OS.gdk_region_subtract(clipping, clipping); + cairo_region_subtract (clipping, clipping); long /*int*/ cairo = data.cairo; long /*int*/ clipRgn = data.clipRgn; if (clipRgn == 0) { - GdkRectangle rect = new GdkRectangle(); - int[] width = new int[1], height = new int[1]; - getSize(width, height); - rect.width = width[0]; - rect.height = height[0]; - OS.gdk_region_union_with_rect(clipping, rect); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + int[] width = new int[1], height = new int[1]; + getSize(width, height); + rect.width = width[0]; + rect.height = height[0]; + Cairo.cairo_region_union_rectangle (clipping, rect); + } else { + GdkRectangle rect = new GdkRectangle(); + int[] width = new int[1], height = new int[1]; + getSize(width, height); + rect.width = width[0]; + rect.height = height[0]; + OS.gdk_region_union_with_rect(clipping, rect); + } } else { /* Convert clipping to device space if needed */ if (data.clippingTransform != null) { long /*int*/ rgn = convertRgn(clipRgn, data.clippingTransform); - OS.gdk_region_union(clipping, rgn); - OS.gdk_region_destroy(rgn); + cairo_region_union (clipping, rgn); + cairo_region_destroy (rgn); } else { - OS.gdk_region_union(clipping, clipRgn); + cairo_region_union (clipping, clipRgn); } } if (data.damageRgn != 0) { - OS.gdk_region_intersect(clipping, data.damageRgn); + cairo_region_intersect (clipping, data.damageRgn); } /* Convert to user space */ if (cairo != 0) { @@ -2493,9 +2595,9 @@ public void getClipping(Region region) { Cairo.cairo_get_matrix(cairo, matrix); Cairo.cairo_matrix_invert(matrix); long /*int*/ rgn = convertRgn(clipping, matrix); - OS.gdk_region_subtract(clipping, clipping); - OS.gdk_region_union(clipping, rgn); - OS.gdk_region_destroy(rgn); + cairo_region_subtract(clipping, clipping); + cairo_region_union (clipping, rgn); + cairo_region_destroy (rgn); } } @@ -3337,7 +3439,7 @@ void setClipping(long /*int*/ clipRgn) { long /*int*/ cairo = data.cairo; if (clipRgn == 0) { if (data.clipRgn != 0) { - OS.gdk_region_destroy(data.clipRgn); + cairo_region_destroy (data.clipRgn); data.clipRgn = 0; } if (cairo != 0) { @@ -3348,9 +3450,9 @@ void setClipping(long /*int*/ clipRgn) { OS.gdk_gc_set_clip_region(handle, clipping); } } else { - if (data.clipRgn == 0) data.clipRgn = OS.gdk_region_new(); - OS.gdk_region_subtract(data.clipRgn, data.clipRgn); - OS.gdk_region_union(data.clipRgn, clipRgn); + if (data.clipRgn == 0) data.clipRgn = cairo_region_create (); + cairo_region_subtract (data.clipRgn, data.clipRgn); + cairo_region_union (data.clipRgn, clipRgn); if (cairo != 0) { if (data.clippingTransform == null) data.clippingTransform = new double[6]; Cairo.cairo_get_matrix(cairo, data.clippingTransform); @@ -3358,9 +3460,9 @@ void setClipping(long /*int*/ clipRgn) { } else { long /*int*/ clipping = clipRgn; if (data.damageRgn != 0) { - clipping = OS.gdk_region_new(); - OS.gdk_region_union(clipping, clipRgn); - OS.gdk_region_intersect(clipping, data.damageRgn); + clipping = cairo_region_create (); + cairo_region_union (clipping, clipRgn); + cairo_region_intersect (clipping, data.damageRgn); } OS.gdk_gc_set_clip_region(handle, clipping); if (clipping != clipRgn) OS.gdk_region_destroy(clipping); @@ -3392,15 +3494,27 @@ public void setClipping(int x, int y, int width, int height) { y = y + height; height = -height; } - GdkRectangle rect = new GdkRectangle(); - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - long /*int*/ clipRgn = OS.gdk_region_new(); - OS.gdk_region_union_with_rect(clipRgn, rect); - setClipping(clipRgn); - OS.gdk_region_destroy(clipRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + long /*int*/ clipRgn = Cairo.cairo_region_create (); + Cairo.cairo_region_union_rectangle (clipRgn, rect); + setClipping(clipRgn); + Cairo.cairo_region_destroy (clipRgn); + } else { + GdkRectangle rect = new GdkRectangle(); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + long /*int*/ clipRgn = OS.gdk_region_new (); + OS.gdk_region_union_with_rect(clipRgn, rect); + setClipping(clipRgn); + OS.gdk_region_destroy (clipRgn); + } } /** @@ -4220,4 +4334,63 @@ void gtk_render_focus (long /*int*/ style, long /*int*/ window, int state_type, OS.gtk_paint_focus (style, window, state_type, area, widget, detail, x, y, width, height); } } + +void cairo_region_destroy (long /*int*/ region) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_destroy ( region); + } else { + OS.gdk_region_destroy (region); + } +} + +void cairo_region_union (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_union (dst, other); + } else { + OS.gdk_region_union (dst, other); + } +} + +long /*int*/ cairo_region_create () { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return Cairo.cairo_region_create (); + } else { + return OS.gdk_region_new (); + } +} + +void cairo_region_translate (long /*int*/ region, int dx, int dy) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_translate (region, dx, dy); + } else { + OS.gdk_region_offset (region, dx, dy); + } +} + +void cairo_region_subtract (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_subtract (dst, other); + } else { + OS.gdk_region_subtract (dst, other); + } +} + +void cairo_region_intersect (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_intersect (dst, other); + } else { + OS.gdk_region_intersect (dst, other); + } +} + +void cairo_region_get_rectangles (long /*int*/ region, long /*int*/[] rectangles, int[] n_rectangles) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int num = Cairo.cairo_region_num_rectangles (region); + for (int n = 0; n < num; n++) { + Cairo.cairo_region_get_rectangle (region, n, rectangles[n]); + } + } else { + OS.gdk_region_get_rectangles (region, rectangles, n_rectangles); + } +} } 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 e4e069953d..9b46b2ae96 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.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.*; @@ -74,7 +75,7 @@ public Region() { */ public Region(Device device) { super(device); - handle = OS.gdk_region_new(); + handle = cairo_region_create (); if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); init(); } @@ -109,9 +110,27 @@ public void add (int[] pointArray) { * with enough points for a polygon. */ if (pointArray.length < 6) return; - long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gdk_region_union(handle, polyRgn); - OS.gdk_region_destroy(polyRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*ing*/ cairo = OS.gdk_cairo_create(handle); + int count = pointArray.length / 2; + if (count == 0) return; + Cairo.cairo_move_to(cairo, pointArray[0], pointArray[1]); + for (int i=1,j=2; i<count; i++,j+=2) { + Cairo.cairo_move_to(cairo, pointArray[j]+0.5, pointArray[j+1]+0.5); + } + Cairo.cairo_close_path(cairo); + Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); + Cairo.cairo_fill(cairo); + long /*ing*/ surface = Cairo.cairo_get_target(cairo); + long /*int*/ polyRgn = OS.gdk_cairo_region_create_from_surface(surface); + Cairo.cairo_region_union (handle, polyRgn); + Cairo.cairo_destroy(cairo); + } else { + long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); + OS.gdk_region_union(handle, polyRgn); + OS.gdk_region_destroy(polyRgn); + } + } /** @@ -155,12 +174,21 @@ public void add(Rectangle rect) { public void add(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = x; - gdkRect.y = y; - gdkRect.width = width; - gdkRect.height = height; - OS.gdk_region_union_with_rect(handle, gdkRect); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t cairoRect = new cairo_rectangle_int_t(); + cairoRect.x = x; + cairoRect.y = y; + cairoRect.width = width; + cairoRect.height = height; + Cairo.cairo_region_union_rectangle (handle, cairoRect); + } else { + GdkRectangle gdkRect = new GdkRectangle(); + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; + OS.gdk_region_union_with_rect(handle, gdkRect); + } } /** @@ -182,7 +210,7 @@ public void add(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_union(handle, region.handle); + cairo_region_union (handle, region.handle); } /** @@ -200,7 +228,11 @@ public void add(Region region) { */ public boolean contains(int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return OS.gdk_region_point_in(handle, x, y); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return Cairo.cairo_region_contains_point (handle, x, y); + } else { + return OS.gdk_region_point_in(handle, x, y); + } } /** @@ -224,7 +256,7 @@ public boolean contains(Point pt) { } void destroy() { - OS.gdk_region_destroy(handle); + cairo_region_destroy (handle); handle = 0; } @@ -260,9 +292,15 @@ public boolean equals(Object object) { */ public Rectangle getBounds() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - GdkRectangle gdkRect = new GdkRectangle(); - OS.gdk_region_get_clipbox(handle, gdkRect); - return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t cairoRect = new cairo_rectangle_int_t (); + Cairo.cairo_region_get_extents (handle, cairoRect); + return new Rectangle(cairoRect.x, cairoRect.y, cairoRect.width, cairoRect.height); + } else { + GdkRectangle gdkRect = new GdkRectangle(); + OS.gdk_region_get_clipbox(handle, gdkRect); + return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height); + } } /** @@ -342,14 +380,25 @@ public void intersect(Rectangle rect) { public void intersect(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = x; - gdkRect.y = y; - gdkRect.width = width; - gdkRect.height = height; - long /*int*/ rectRgn = OS.gdk_region_rectangle(gdkRect); - OS.gdk_region_intersect(handle, rectRgn); - OS.gdk_region_destroy(rectRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t cairoRect = new cairo_rectangle_int_t (); + cairoRect.x = x; + cairoRect.y = y; + cairoRect.width = width; + cairoRect.height = height; + long /*int*/ rectRgn = Cairo.cairo_region_create_rectangle (cairoRect); + Cairo.cairo_region_intersect (handle, rectRgn); + Cairo.cairo_region_destroy (rectRgn); + } else { + GdkRectangle gdkRect = new GdkRectangle(); + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; + long /*int*/ rectRgn = OS.gdk_region_rectangle(gdkRect); + OS.gdk_region_intersect (handle, rectRgn); + OS.gdk_region_destroy (rectRgn); + } } /** @@ -373,7 +422,7 @@ public void intersect(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_intersect(handle, region.handle); + cairo_region_intersect (handle, region.handle); } /** @@ -395,12 +444,21 @@ public void intersect(Region region) { */ public boolean intersects (int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = x; - gdkRect.y = y; - gdkRect.width = width; - gdkRect.height = height; - return OS.gdk_region_rect_in(handle, gdkRect) != OS.GDK_OVERLAP_RECTANGLE_OUT; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t cairoRect = new cairo_rectangle_int_t (); + cairoRect.x = x; + cairoRect.y = y; + cairoRect.width = width; + cairoRect.height = height; + return Cairo.cairo_region_contains_rectangle (handle, cairoRect) != OS.GDK_OVERLAP_RECTANGLE_OUT; + } else { + GdkRectangle gdkRect = new GdkRectangle(); + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; + return OS.gdk_region_rect_in(handle, gdkRect) != OS.GDK_OVERLAP_RECTANGLE_OUT; + } } /** * Returns <code>true</code> if the given rectangle intersects @@ -451,7 +509,11 @@ public boolean isDisposed() { */ public boolean isEmpty() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return OS.gdk_region_empty(handle); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return Cairo.cairo_region_is_empty(handle); + } else { + return OS.gdk_region_empty(handle); + } } /** @@ -478,9 +540,26 @@ public void subtract (int[] pointArray) { * with enough points for a polygon. */ if (pointArray.length < 6) return; - long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gdk_region_subtract(handle, polyRgn); - OS.gdk_region_destroy(polyRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*ing*/ cairo = OS.gdk_cairo_create(handle); + int count = pointArray.length / 2; + if (count == 0) return; + Cairo.cairo_move_to(cairo, pointArray[0], pointArray[1]); + for (int i=1,j=2; i<count; i++,j+=2) { + Cairo.cairo_move_to(cairo, pointArray[j]+0.5, pointArray[j+1]+0.5); + } + Cairo.cairo_close_path(cairo); + Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); + Cairo.cairo_fill(cairo); + long /*ing*/ surface = Cairo.cairo_get_target(cairo); + long /*int*/ polyRgn = OS.gdk_cairo_region_create_from_surface(surface); + Cairo.cairo_region_subtract(handle, polyRgn); + Cairo.cairo_destroy(cairo); + } else { + long /*int*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE); + OS.gdk_region_subtract(handle, polyRgn); + OS.gdk_region_destroy(polyRgn); + } } /** @@ -526,14 +605,25 @@ public void subtract(Rectangle rect) { public void subtract(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = x; - gdkRect.y = y; - gdkRect.width = width; - gdkRect.height = height; - long /*int*/ rectRgn = OS.gdk_region_rectangle(gdkRect); - OS.gdk_region_subtract(handle, rectRgn); - OS.gdk_region_destroy(rectRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t cairoRect = new cairo_rectangle_int_t (); + cairoRect.x = x; + cairoRect.y = y; + cairoRect.width = width; + cairoRect.height = height; + long /*int*/ rectRgn = Cairo.cairo_region_create_rectangle (cairoRect); + Cairo.cairo_region_subtract (handle, rectRgn); + Cairo.cairo_region_destroy (rectRgn); + } else { + GdkRectangle gdkRect = new GdkRectangle(); + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; + long /*int*/ rectRgn = OS.gdk_region_rectangle(gdkRect); + OS.gdk_region_subtract (handle, rectRgn); + OS.gdk_region_destroy (rectRgn); + } } /** @@ -557,7 +647,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); } /** @@ -575,7 +665,7 @@ public void subtract(Region region) { */ public void translate (int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - OS.gdk_region_offset (handle, x, y); + cairo_region_translate (handle, x, y); } /** @@ -609,4 +699,52 @@ public String toString () { if (isDisposed()) return "Region {*DISPOSED*}"; return "Region {" + handle + "}"; } + +long /*int*/ cairo_region_create () { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + return Cairo.cairo_region_create (); + } else { + return OS.gdk_region_new (); + } +} + +void cairo_region_translate (long /*int*/ region, int dx, int dy) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_translate (region, dx, dy); + } else { + OS.gdk_region_offset (region, dx, dy); + } +} + +void cairo_region_subtract (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_subtract (dst, other); + } else { + OS.gdk_region_subtract (dst, other); + } +} + +void cairo_region_union (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_union (dst, other); + } else { + OS.gdk_region_union (dst, other); + } +} + +void cairo_region_intersect (long /*int*/ dst, long /*int*/ other) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_intersect (dst, other); + } else { + OS.gdk_region_intersect (dst, other); + } +} + +void cairo_region_destroy (long /*int*/ region) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_destroy ( region); + } else { + OS.gdk_region_destroy (region); + } +} } 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 c61fadbe30..fef1763364 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 @@ -571,7 +571,7 @@ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Colo long /*int*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2); if (rgn != 0) { OS.gdk_gc_set_clip_region(gc.handle, rgn); - OS.gdk_region_destroy(rgn); + cairo_region_destroy (rgn); } OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle); drawBorder(gc, x, y, selectionForeground.handle); @@ -601,7 +601,7 @@ void drawWithCairo(GC gc, int x, int y, int start, int end, boolean fullSelectio Cairo.cairo_clip(cairo); Cairo.cairo_set_source_rgba(cairo, (bg.red & 0xFFFF) / (float)0xFFFF, (bg.green & 0xFFFF) / (float)0xFFFF, (bg.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF); Cairo.cairo_paint(cairo); - OS.gdk_region_destroy(rgn); + cairo_region_destroy (rgn); } Cairo.cairo_set_source_rgba(cairo, (fg.red & 0xFFFF) / (float)0xFFFF, (fg.green & 0xFFFF) / (float)0xFFFF, (fg.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF); Cairo.cairo_move_to(cairo, x, y); @@ -640,7 +640,7 @@ void drawBorder(GC gc, int x, int y, GdkColor selectionColor) { if (rgn != 0) { int[] nRects = new int[1]; long /*int*/[] rects = new long /*int*/[1]; - OS.gdk_region_get_rectangles(rgn, rects, nRects); + cairo_region_get_rectangles (rgn, rects, nRects); GdkRectangle rect = new GdkRectangle(); GdkColor color = null; if (color == null && style.borderColor != null) color = style.borderColor.handle; @@ -697,7 +697,7 @@ void drawBorder(GC gc, int x, int y, GdkColor selectionColor) { } } if (rects[0] != 0) OS.g_free(rects[0]); - OS.gdk_region_destroy(rgn); + cairo_region_destroy (rgn); } } } @@ -827,44 +827,84 @@ public Rectangle getBounds(int start, int end) { int[] ranges = new int[]{byteStart, byteEnd}; long /*int*/ clipRegion = OS.gdk_pango_layout_get_clip_region(layout, 0, 0, ranges, 1); if (clipRegion == 0) return new Rectangle(0, 0, 0, 0); - GdkRectangle rect = new GdkRectangle(); - - /* - * Bug in Pango. The region returned by gdk_pango_layout_get_clip_region() - * includes areas from lines outside of the requested range. The fix - * is to subtract these areas from the clip region. - */ - PangoRectangle pangoRect = new PangoRectangle(); - long /*int*/ iter = OS.pango_layout_get_iter(layout); - if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); - long /*int*/ linesRegion = OS.gdk_region_new(); - if (linesRegion == 0) SWT.error(SWT.ERROR_NO_HANDLES); - int lineEnd = 0; - do { - OS.pango_layout_iter_get_line_extents(iter, null, pangoRect); - if (OS.pango_layout_iter_next_line(iter)) { - lineEnd = OS.pango_layout_iter_get_index(iter) - 1; - } else { - lineEnd = strlen; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); + /* + * Bug in Pango. The region returned by gdk_pango_layout_get_clip_region() + * includes areas from lines outside of the requested range. The fix + * is to subtract these areas from the clip region. + */ + PangoRectangle pangoRect = new PangoRectangle(); + long /*int*/ iter = OS.pango_layout_get_iter(layout); + if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); + long /*int*/ linesRegion = Cairo.cairo_region_create (); + if (linesRegion == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int lineEnd = 0; + do { + OS.pango_layout_iter_get_line_extents(iter, null, pangoRect); + if (OS.pango_layout_iter_next_line(iter)) { + lineEnd = OS.pango_layout_iter_get_index(iter) - 1; + } else { + lineEnd = strlen; + } + if (byteStart > lineEnd) continue; + rect.x = OS.PANGO_PIXELS(pangoRect.x); + rect.y = OS.PANGO_PIXELS(pangoRect.y); + rect.width = OS.PANGO_PIXELS(pangoRect.width); + rect.height = OS.PANGO_PIXELS(pangoRect.height); + Cairo.cairo_region_union_rectangle (linesRegion, rect); + } while (lineEnd + 1 <= byteEnd); + Cairo.cairo_region_intersect (clipRegion, linesRegion); + Cairo.cairo_region_destroy (linesRegion); + OS.pango_layout_iter_free(iter); + + Cairo.cairo_region_get_extents (clipRegion, rect); + Cairo.cairo_region_destroy (clipRegion); + if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { + rect.x = width() - rect.x - rect.width; } - if (byteStart > lineEnd) continue; - rect.x = OS.PANGO_PIXELS(pangoRect.x); - rect.y = OS.PANGO_PIXELS(pangoRect.y); - rect.width = OS.PANGO_PIXELS(pangoRect.width); - rect.height = OS.PANGO_PIXELS(pangoRect.height); - OS.gdk_region_union_with_rect(linesRegion, rect); - } while (lineEnd + 1 <= byteEnd); - OS.gdk_region_intersect(clipRegion, linesRegion); - OS.gdk_region_destroy(linesRegion); - OS.pango_layout_iter_free(iter); - - OS.gdk_region_get_clipbox(clipRegion, rect); - OS.gdk_region_destroy(clipRegion); - if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { - rect.x = width() - rect.x - rect.width; + rect.x += Math.min (indent, wrapIndent); + return new Rectangle(rect.x, rect.y, rect.width, rect.height); + } else { + GdkRectangle rect = new GdkRectangle(); + /* + * Bug in Pango. The region returned by gdk_pango_layout_get_clip_region() + * includes areas from lines outside of the requested range. The fix + * is to subtract these areas from the clip region. + */ + PangoRectangle pangoRect = new PangoRectangle(); + long /*int*/ iter = OS.pango_layout_get_iter(layout); + if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); + long /*int*/ linesRegion = OS.gdk_region_new (); + if (linesRegion == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int lineEnd = 0; + do { + OS.pango_layout_iter_get_line_extents(iter, null, pangoRect); + if (OS.pango_layout_iter_next_line(iter)) { + lineEnd = OS.pango_layout_iter_get_index(iter) - 1; + } else { + lineEnd = strlen; + } + if (byteStart > lineEnd) continue; + rect.x = OS.PANGO_PIXELS(pangoRect.x); + rect.y = OS.PANGO_PIXELS(pangoRect.y); + rect.width = OS.PANGO_PIXELS(pangoRect.width); + rect.height = OS.PANGO_PIXELS(pangoRect.height); + OS.gdk_region_union_with_rect(linesRegion, rect); + } while (lineEnd + 1 <= byteEnd); + OS.gdk_region_intersect (clipRegion, linesRegion); + OS.gdk_region_destroy (linesRegion); + OS.pango_layout_iter_free(iter); + + OS.gdk_region_get_clipbox(clipRegion, rect); + OS.gdk_region_destroy (clipRegion); + if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { + rect.x = width() - rect.x - rect.width; + } + rect.x += Math.min (indent, wrapIndent); + return new Rectangle(rect.x, rect.y, rect.width, rect.height); } - rect.x += Math.min (indent, wrapIndent); - return new Rectangle(rect.x, rect.y, rect.width, rect.height); + } /** @@ -2223,4 +2263,23 @@ int width () { return OS.PANGO_PIXELS(w[0]); } +void cairo_region_get_rectangles (long /*int*/ region, long /*int*/[] rectangles, int[] n_rectangles) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int num = Cairo.cairo_region_num_rectangles (region); + for (int n = 0; n < num; n++) { + Cairo.cairo_region_get_rectangle (region, n, rectangles[n]); + } + } else { + OS.gdk_region_get_rectangles (region, rectangles, n_rectangles); + } +} + +void cairo_region_destroy (long /*int*/ region) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + Cairo.cairo_region_destroy ( region); + } else { + OS.gdk_region_destroy (region); + } +} + } 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 f3392944bf..3537f46bda 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 @@ -13,6 +13,7 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.cairo.Cairo; +import org.eclipse.swt.internal.cairo.cairo_rectangle_int_t; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.*; @@ -252,76 +253,149 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b if (isFocus) caret.killFocus (); long /*int*/ window = paintWindow (); long /*int*/ visibleRegion = OS.gdk_drawable_get_visible_region (window); - GdkRectangle srcRect = new GdkRectangle (); - srcRect.x = x; - srcRect.y = y; - srcRect.width = width; - srcRect.height = height; - long /*int*/ copyRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_intersect(copyRegion, visibleRegion); - long /*int*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); - OS.gdk_region_subtract (invalidateRegion, visibleRegion); - OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); - GdkRectangle copyRect = new GdkRectangle(); - OS.gdk_region_get_clipbox (copyRegion, copyRect); - if (copyRect.width != 0 && copyRect.height != 0) { - update (); - } - Control control = findBackgroundControl (); - if (control == null) control = this; - if (control.backgroundImage != null) { - redrawWidget (x, y, width, height, false, false, false); - redrawWidget (destX, destY, width, height, false, false, false); - } else { -// GC gc = new GC (this); -// gc.copyArea (x, y, width, height, destX, destY); -// gc.dispose (); - if (OS.USE_CAIRO) { - OS.gdk_window_invalidate_rect (window, copyRect, true); - long /*int*/ cairo = OS.gdk_cairo_create (window); - OS.gdk_cairo_set_source_window (cairo, window, 0, 0); - Cairo.cairo_rectangle (cairo, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); - Cairo.cairo_fill (cairo); - Cairo.cairo_destroy (cairo); - } else { - long /*int*/ gdkGC = OS.gdk_gc_new (window); - OS.gdk_gc_set_exposures (gdkGC, true); - OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); - OS.g_object_unref (gdkGC); + if(OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t srcRect = new cairo_rectangle_int_t(); + srcRect.x = x; + srcRect.y = y; + srcRect.width = width; + srcRect.height = height; + long /*int*/ copyRegion = Cairo.cairo_region_create_rectangle (srcRect); + Cairo.cairo_region_intersect (copyRegion, visibleRegion); + long /*int*/ invalidateRegion = Cairo.cairo_region_create_rectangle (srcRect); + Cairo.cairo_region_subtract (invalidateRegion, visibleRegion); + Cairo.cairo_region_translate (invalidateRegion, deltaX, deltaY); + cairo_rectangle_int_t copyRect = new cairo_rectangle_int_t (); + Cairo.cairo_region_get_extents (copyRegion, copyRect); + if (copyRect.width != 0 && copyRect.height != 0) { + update (); } - boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY); - if (disjoint) { - GdkRectangle rect = new GdkRectangle (); - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - OS.gdk_region_union_with_rect (invalidateRegion, rect); + Control control = findBackgroundControl (); + if (control == null) control = this; + if (control.backgroundImage != null) { + redrawWidget (x, y, width, height, false, false, false); + redrawWidget (destX, destY, width, height, false, false, false); } else { - GdkRectangle rect = new GdkRectangle (); - if (deltaX != 0) { - int newX = destX - deltaX; - if (deltaX < 0) newX = destX + width; - rect.x = newX; + // GC gc = new GC (this); + // gc.copyArea (x, y, width, height, destX, destY); + // gc.dispose (); + if (OS.USE_CAIRO) { + OS.gdk_window_invalidate_region (window, copyRegion, true); + long /*int*/ cairo = OS.gdk_cairo_create (window); + OS.gdk_cairo_set_source_window (cairo, window, 0, 0); + Cairo.cairo_rectangle (cairo, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); + Cairo.cairo_fill (cairo); + Cairo.cairo_destroy (cairo); + } else { + long /*int*/ gdkGC = OS.gdk_gc_new (window); + OS.gdk_gc_set_exposures (gdkGC, true); + OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); + OS.g_object_unref (gdkGC); + } + boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY); + if (disjoint) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + rect.x = x; rect.y = y; - rect.width = Math.abs(deltaX); + rect.width = width; rect.height = height; - OS.gdk_region_union_with_rect (invalidateRegion, rect); + Cairo.cairo_region_union_rectangle (invalidateRegion, rect); + } else { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + if (deltaX != 0) { + int newX = destX - deltaX; + if (deltaX < 0) newX = destX + width; + rect.x = newX; + rect.y = y; + rect.width = Math.abs(deltaX); + rect.height = height; + Cairo.cairo_region_union_rectangle (invalidateRegion, rect); + } + if (deltaY != 0) { + int newY = destY - deltaY; + if (deltaY < 0) newY = destY + height; + rect.x = x; + rect.y = newY; + rect.width = width; + rect.height = Math.abs(deltaY); + Cairo.cairo_region_union_rectangle (invalidateRegion, rect); + } + } + Cairo.cairo_region_destroy (visibleRegion); + Cairo.cairo_region_destroy (copyRegion); + Cairo.cairo_region_destroy (invalidateRegion); + } + } else { + GdkRectangle srcRect = new GdkRectangle (); + srcRect.x = x; + srcRect.y = y; + srcRect.width = width; + srcRect.height = height; + long /*int*/ copyRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_intersect(copyRegion, visibleRegion); + long /*int*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_subtract (invalidateRegion, visibleRegion); + OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); + GdkRectangle copyRect = new GdkRectangle(); + OS.gdk_region_get_clipbox (copyRegion, copyRect); + if (copyRect.width != 0 && copyRect.height != 0) { + update (); } - if (deltaY != 0) { - int newY = destY - deltaY; - if (deltaY < 0) newY = destY + height; + Control control = findBackgroundControl (); + if (control == null) control = this; + if (control.backgroundImage != null) { + redrawWidget (x, y, width, height, false, false, false); + redrawWidget (destX, destY, width, height, false, false, false); + } else { +// GC gc = new GC (this); +// gc.copyArea (x, y, width, height, destX, destY); +// gc.dispose (); + if (OS.USE_CAIRO) { + OS.gdk_window_invalidate_region (window, copyRegion, true); + long /*int*/ cairo = OS.gdk_cairo_create (window); + OS.gdk_cairo_set_source_window (cairo, window, 0, 0); + Cairo.cairo_rectangle (cairo, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); + Cairo.cairo_fill (cairo); + Cairo.cairo_destroy (cairo); + } else { + long /*int*/ gdkGC = OS.gdk_gc_new (window); + OS.gdk_gc_set_exposures (gdkGC, true); + OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); + OS.g_object_unref (gdkGC); + } + boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY); + if (disjoint) { + GdkRectangle rect = new GdkRectangle (); rect.x = x; - rect.y = newY; + rect.y = y; rect.width = width; - rect.height = Math.abs(deltaY); + rect.height = height; OS.gdk_region_union_with_rect (invalidateRegion, rect); - } - } - OS.gdk_window_invalidate_region(window, invalidateRegion, all); - OS.gdk_region_destroy (visibleRegion); - OS.gdk_region_destroy (copyRegion); - OS.gdk_region_destroy (invalidateRegion); + } else { + GdkRectangle rect = new GdkRectangle (); + if (deltaX != 0) { + int newX = destX - deltaX; + if (deltaX < 0) newX = destX + width; + rect.x = newX; + rect.y = y; + rect.width = Math.abs(deltaX); + rect.height = height; + OS.gdk_region_union_with_rect (invalidateRegion, rect); + } + if (deltaY != 0) { + int newY = destY - deltaY; + if (deltaY < 0) newY = destY + height; + rect.x = x; + rect.y = newY; + rect.width = width; + rect.height = Math.abs(deltaY); + OS.gdk_region_union_with_rect (invalidateRegion, rect); + } + } + OS.gdk_window_invalidate_region(window, invalidateRegion, all); + OS.gdk_region_destroy (visibleRegion); + OS.gdk_region_destroy (copyRegion); + OS.gdk_region_destroy (invalidateRegion); + } } if (all) { Control [] children = _getChildren (); 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 872c010852..e23bf0a52d 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 @@ -730,25 +730,51 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) { OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof); long /*int*/ [] rectangles = new long /*int*/ [1]; int [] n_rectangles = new int [1]; - OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles); - GdkRectangle rect = new GdkRectangle (); - for (int i=0; i<n_rectangles[0]; i++) { - Event event = new Event (); - OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof); - event.x = rect.x; - event.y = rect.y; - event.width = rect.width; - event.height = rect.height; - if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; - long /*int*/ damageRgn = OS.gdk_region_new (); - OS.gdk_region_union_with_rect (damageRgn, rect); - GCData data = new GCData (); - data.damageRgn = damageRgn; - GC gc = event.gc = GC.gtk_new (this, data); - sendEvent (SWT.Paint, event); - gc.dispose (); - OS.gdk_region_destroy (damageRgn); - event.gc = null; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int num = Cairo.cairo_region_num_rectangles (gdkEvent.region); + for (int n = 0; n < num; n++) { + Cairo.cairo_region_get_rectangle (gdkEvent.region, n, rectangles[n]); + } + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + for (int i=0; i<n_rectangles[0]; i++) { + Event event = new Event (); + Cairo.memmove (rect, rectangles [0] + i * cairo_rectangle_int_t.sizeof, cairo_rectangle_int_t.sizeof); + event.x = rect.x; + event.y = rect.y; + event.width = rect.width; + event.height = rect.height; + if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; + long /*int*/ damageRgn = Cairo.cairo_region_create (); + Cairo.cairo_region_union_rectangle (damageRgn, rect); + GCData data = new GCData (); + data.damageRgn = damageRgn; + GC gc = event.gc = GC.gtk_new (this, data); + sendEvent (SWT.Paint, event); + gc.dispose (); + Cairo.cairo_region_destroy (damageRgn); + event.gc = null; + } + } else { + OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles); + GdkRectangle rect = new GdkRectangle (); + for (int i=0; i<n_rectangles[0]; i++) { + Event event = new Event (); + OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof); + event.x = rect.x; + event.y = rect.y; + event.width = rect.width; + event.height = rect.height; + if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; + long /*int*/ damageRgn = OS.gdk_region_new (); + OS.gdk_region_union_with_rect (damageRgn, rect); + GCData data = new GCData (); + data.damageRgn = damageRgn; + GC gc = event.gc = GC.gtk_new (this, data); + sendEvent (SWT.Paint, event); + gc.dispose (); + OS.gdk_region_destroy (damageRgn); + event.gc = null; + } } OS.g_free (rectangles [0]); return 0; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 5202b30295..dc70882a25 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -413,31 +413,60 @@ void printWidget (GC gc, long /*int*/ drawable, int depth, int x, int y) { void printWindow (boolean first, Control control, GC gc, long /*int*/ drawable, int depth, long /*int*/ window, int x, int y) { if (OS.gdk_drawable_get_depth (window) != depth) return; - GdkRectangle rect = new GdkRectangle (); - int [] width = new int [1], height = new int [1]; - gdk_window_get_size (window, width, height); - rect.width = width [0]; - rect.height = height [0]; - OS.gdk_window_begin_paint_rect (window, rect); long /*int*/ [] real_drawable = new long /*int*/ [1]; int [] x_offset = new int [1], y_offset = new int [1]; - OS.gdk_window_get_internal_paint_info (window, real_drawable, x_offset, y_offset); - long /*int*/ [] userData = new long /*int*/ [1]; - OS.gdk_window_get_user_data (window, userData); - if (userData [0] != 0) { - long /*int*/ eventPtr = OS.gdk_event_new (OS.GDK_EXPOSE); - GdkEventExpose event = new GdkEventExpose (); - event.type = OS.GDK_EXPOSE; - event.window = OS.g_object_ref (window); - event.area_width = rect.width; - event.area_height = rect.height; - event.region = OS.gdk_region_rectangle (rect); - OS.memmove (eventPtr, event, GdkEventExpose.sizeof); - OS.gtk_widget_send_expose (userData [0], eventPtr); - OS.gdk_event_free (eventPtr); + int [] width = new int [1], height = new int [1]; + int srcX, srcY, destX, destY, destWidth, destHeight; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + gdk_window_get_size (window, width, height); + rect.width = width [0]; + rect.height = height [0]; + long /*int*/ cr = Cairo.cairo_region_create_rectangle (rect); + OS.gdk_window_begin_paint_region(window, cr); + OS.gdk_window_get_internal_paint_info (window, real_drawable, x_offset, y_offset); + long /*int*/ [] userData = new long /*int*/ [1]; + OS.gdk_window_get_user_data (window, userData); + if (userData [0] != 0) { + long /*int*/ eventPtr = OS.gdk_event_new (OS.GDK_EXPOSE); + GdkEventExpose event = new GdkEventExpose (); + event.type = OS.GDK_EXPOSE; + event.window = OS.g_object_ref (window); + event.area_width = rect.width; + event.area_height = rect.height; + event.region = Cairo.cairo_region_create_rectangle (rect); + OS.memmove (eventPtr, event, GdkEventExpose.sizeof); + OS.gtk_widget_send_expose (userData [0], eventPtr); + OS.gdk_event_free (eventPtr); + } + } else { + GdkRectangle rect = new GdkRectangle (); + gdk_window_get_size (window, width, height); + rect.width = width [0]; + rect.height = height [0]; + OS.gdk_window_begin_paint_rect (window, rect); + OS.gdk_window_get_internal_paint_info (window, real_drawable, x_offset, y_offset); + long /*int*/ [] userData = new long /*int*/ [1]; + OS.gdk_window_get_user_data (window, userData); + if (userData [0] != 0) { + long /*int*/ eventPtr = OS.gdk_event_new (OS.GDK_EXPOSE); + GdkEventExpose event = new GdkEventExpose (); + event.type = OS.GDK_EXPOSE; + event.window = OS.g_object_ref (window); + event.area_width = rect.width; + event.area_height = rect.height; + event.region = OS.gdk_region_rectangle (rect); + OS.memmove (eventPtr, event, GdkEventExpose.sizeof); + OS.gtk_widget_send_expose (userData [0], eventPtr); + OS.gdk_event_free (eventPtr); + } } - int srcX = x_offset [0], srcY = y_offset [0]; - int destX = x, destY = y, destWidth = width [0], destHeight = height [0]; + srcX = x_offset [0]; + srcY = y_offset [0]; + destX = x; + destY = y; + destWidth = width [0]; + destHeight = height [0]; if (!first) { int [] cX = new int [1], cY = new int [1]; OS.gdk_window_get_position (window, cX, cY); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java index 6ba97d92db..a6053a2524 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java @@ -249,11 +249,33 @@ void configure () { OS.gtk_window_move (handle, Math.min(dest.width - w, x - w + 17), y - h - TIP_HEIGHT); } } - long /*int*/ rgn = OS.gdk_region_polygon (polyline, polyline.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gtk_widget_realize (handle); - long /*int*/ window = gtk_widget_get_window (handle); - OS.gdk_window_shape_combine_region (window, rgn, 0, 0); - OS.gdk_region_destroy (rgn); + OS.gtk_widget_realize(handle); + long /*ing*/ window = gtk_widget_get_window (handle); + /* + As methods required to replicate gdk_window_shape_combine_region () + are available starting from GTK+ 3, Cairo implementation that replicates + gdk_region_polygon () should be also available to GTK+ 3.0 and higher. + */ + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + long /*ing*/ cairo = OS.gdk_cairo_create(window); + int count = polyline.length / 2; + if (count == 0) return; + Cairo.cairo_move_to(cairo, polyline[0], polyline[1]); + for (int i=1,j=2; i<count; i++,j+=2) { + Cairo.cairo_move_to(cairo, polyline[j]+0.5, polyline[j+1]+0.5); + } + Cairo.cairo_close_path(cairo); + Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); + Cairo.cairo_fill(cairo); + long /*ing*/ surface = Cairo.cairo_get_target(cairo); + long /*int*/ region = OS.gdk_cairo_region_create_from_surface(surface); + OS.gtk_widget_shape_combine_region (window, region); + Cairo.cairo_destroy(cairo); + } else { + long /*int*/ rgn = OS.gdk_region_polygon (polyline, polyline.length / 2, OS.GDK_EVEN_ODD_RULE); + OS.gdk_window_shape_combine_region (window, rgn, 0, 0); + OS.gdk_region_destroy (rgn); + } } void createHandle (int index) { |