diff options
author | Nikita Nemkin | 2020-11-19 11:13:23 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2021-08-12 13:05:29 +0000 |
commit | 94219602a3ecaf70f0d9c72c94302c7e3ce79ad7 (patch) | |
tree | 23aacccf8518d09abf67c8e212fce7bb6ca9ad6c | |
parent | f76cb5a3c7cb55167b1af6387a3583cb681d985f (diff) | |
download | eclipse.platform.swt-94219602a3ecaf70f0d9c72c94302c7e3ce79ad7.tar.gz eclipse.platform.swt-94219602a3ecaf70f0d9c72c94302c7e3ce79ad7.tar.xz eclipse.platform.swt-94219602a3ecaf70f0d9c72c94302c7e3ce79ad7.zip |
Bug 568859 - [GTK] Avoid Cairo XCB surfaces to make Image thread-agnostic
SWT Image and image GC are supposed to be thread-agnostic.
gdk_window_create_similar_surface() creates Cairo surfaces backed
by XCB surfaces. Operations on these surfaces require serializing all
X11 display access. In the past this was accomplished by locking around
GTK, GDK and Cairo functions, but this lock has been removed.
Now, the only reasonable option is to avoid XCB surfaces altogether
and use display-intependent Cairo image surfaces exclusively.
Change-Id: Id3c600fdceab9925dffe9ab1b7747022e569b826
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/172497
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
7 files changed, 13 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 057294e221..ed36cf650b 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 @@ -2728,14 +2728,14 @@ JNIEXPORT jint JNICALL GDK_NATIVE(gdk_1visual_1get_1depth) } #endif -#ifndef NO_gdk_1window_1create_1similar_1surface -JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1window_1create_1similar_1surface) - (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3) +#ifndef NO_gdk_1window_1create_1similar_1image_1surface +JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1window_1create_1similar_1image_1surface) + (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3, jint arg4) { jlong rc = 0; - GDK_NATIVE_ENTER(env, that, gdk_1window_1create_1similar_1surface_FUNC); - rc = (jlong)gdk_window_create_similar_surface((GdkWindow *)arg0, (cairo_content_t)arg1, arg2, arg3); - GDK_NATIVE_EXIT(env, that, gdk_1window_1create_1similar_1surface_FUNC); + GDK_NATIVE_ENTER(env, that, gdk_1window_1create_1similar_1image_1surface_FUNC); + rc = (jlong)gdk_window_create_similar_image_surface((GdkWindow *)arg0, (cairo_format_t)arg1, arg2, arg3, arg4); + GDK_NATIVE_EXIT(env, that, gdk_1window_1create_1similar_1image_1surface_FUNC); return rc; } #endif diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h index ccb7cf64db..5ee8fdce26 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h @@ -219,7 +219,7 @@ #define NO_gdk_1get_1default_1root_1window #define NO_gdk_1property_1get #define NO_gdk_1window_1begin_1draw_1frame -#define NO_gdk_1window_1create_1similar_1surface +#define NO_gdk_1window_1create_1similar_1image_1surface #define NO_gdk_1window_1destroy #define NO_gdk_1window_1end_1draw_1frame #define NO_gdk_1window_1focus 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 9dc6008721..0db038ddc8 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 @@ -198,7 +198,7 @@ char * GDK_nativeFunctionNames[] = { "gdk_1unicode_1to_1keyval", "gdk_1utf8_1to_1string_1target", "gdk_1visual_1get_1depth", - "gdk_1window_1create_1similar_1surface", + "gdk_1window_1create_1similar_1image_1surface", "gdk_1window_1destroy", "gdk_1window_1focus", "gdk_1window_1get_1children", 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 5cb41d469c..7e517fa0c1 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 @@ -208,7 +208,7 @@ typedef enum { gdk_1unicode_1to_1keyval_FUNC, gdk_1utf8_1to_1string_1target_FUNC, gdk_1visual_1get_1depth_FUNC, - gdk_1window_1create_1similar_1surface_FUNC, + gdk_1window_1create_1similar_1image_1surface_FUNC, gdk_1window_1destroy_FUNC, gdk_1window_1focus_FUNC, gdk_1window_1get_1children_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java index 7e5e26275b..38363090a5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java @@ -1079,10 +1079,10 @@ public class GDK extends OS { public static final native int gdk_visual_get_depth(long visual); /** * @param window cast=(GdkWindow *) - * @param content cast=(cairo_content_t) + * @param format cast=(cairo_format_t) */ /* [GTK3 only, if-def'd in os.h] */ - public static final native long gdk_window_create_similar_surface(long window, int content, int width, int height); + public static final native long gdk_window_create_similar_image_surface(long window, int format, int width, int height, int scale); /** * @param window cast=(GdkSurface *) * @param content cast=(cairo_content_t) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java index d20d5ff2cf..c2eca8975f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java @@ -706,7 +706,7 @@ protected void init () { surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, 10, 10); } else { gdkResource = GDK.gdk_get_default_root_window(); - surface = GDK.gdk_window_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR, 10, 10); + surface = GDK.gdk_window_create_similar_image_surface(gdkResource, Cairo.CAIRO_FORMAT_RGB24, 10, 10, 0); } Cairo.cairo_surface_get_device_scale(surface, sx, sy); DPIUtil.setUseCairoAutoScale((sx[0]*100) == DPIUtil.getDeviceZoom() || OS.isGNOME); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index 7fb2c8e421..9b09b90df1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -1241,7 +1241,7 @@ void init(int width, int height) { if (GTK.GTK4) { surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, width, height); } else { - surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height); + surface = GDK.gdk_window_create_similar_image_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_FORMAT_RGB24, width, height, 0); } if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); // When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale. |