Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-10-24 20:12:23 +0000
committerEric Williams2019-10-25 13:21:39 +0000
commit894fbbcf2964c434da1c6bd3695634e7ab423fee (patch)
treec1214deabee4635c65f7fd9dfc16dd710a82a9a2 /bundles
parentd17f2303152f85b1cc84f9ca5d702a6e16705fdb (diff)
downloadeclipse.platform.swt-894fbbcf2964c434da1c6bd3695634e7ab423fee.tar.gz
eclipse.platform.swt-894fbbcf2964c434da1c6bd3695634e7ab423fee.tar.xz
eclipse.platform.swt-894fbbcf2964c434da1c6bd3695634e7ab423fee.zip
Bug 551982: [GTK] Nothing is rendered when creating new GC on canvas
Revert back to using gdk_cairo_create() for all GTK3 versions. GTK4 uses something else, and gdk_window_begin_draw_frame() is gone there anyway. gdk_cairo_create() is much more stable and hasn't introduced any regressions. Tested on GTK3.24 using the snippet provided. No AllNonBrowser JUnit tests fail. Change-Id: Ic405edaebd7e6ffa3a199f74b2d8b9dc22d12e29 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java41
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java7
8 files changed, 12 insertions, 165 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 b3aa96a79d..c9bd6bf74a 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
@@ -922,26 +922,6 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1drag_1status)
}
#endif
-#ifndef NO__1gdk_1drawing_1context_1get_1cairo_1context
-JNIEXPORT jlong JNICALL GDK_NATIVE(_1gdk_1drawing_1context_1get_1cairo_1context)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- jlong rc = 0;
- GDK_NATIVE_ENTER(env, that, _1gdk_1drawing_1context_1get_1cairo_1context_FUNC);
-/*
- rc = (jlong)gdk_drawing_context_get_cairo_context((GdkDrawingContext *)arg0);
-*/
- {
- GDK_LOAD_FUNCTION(fp, gdk_drawing_context_get_cairo_context)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(GdkDrawingContext *))fp)((GdkDrawingContext *)arg0);
- }
- }
- GDK_NATIVE_EXIT(env, that, _1gdk_1drawing_1context_1get_1cairo_1context_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gdk_1event_1copy
JNIEXPORT jlong JNICALL GDK_NATIVE(_1gdk_1event_1copy)
(JNIEnv *env, jclass that, jlong arg0)
@@ -2759,26 +2739,6 @@ JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1visual_1get_1depth)
}
#endif
-#ifndef NO__1gdk_1window_1begin_1draw_1frame
-JNIEXPORT jlong JNICALL GDK_NATIVE(_1gdk_1window_1begin_1draw_1frame)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- jlong rc = 0;
- GDK_NATIVE_ENTER(env, that, _1gdk_1window_1begin_1draw_1frame_FUNC);
-/*
- rc = (jlong)gdk_window_begin_draw_frame((GdkWindow *)arg0, (cairo_region_t *)arg1);
-*/
- {
- GDK_LOAD_FUNCTION(fp, gdk_window_begin_draw_frame)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(GdkWindow *, cairo_region_t *))fp)((GdkWindow *)arg0, (cairo_region_t *)arg1);
- }
- }
- GDK_NATIVE_EXIT(env, that, _1gdk_1window_1begin_1draw_1frame_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gdk_1window_1create_1similar_1surface
JNIEXPORT jlong JNICALL GDK_NATIVE(_1gdk_1window_1create_1similar_1surface)
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3)
@@ -2801,26 +2761,6 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1destroy)
}
#endif
-#ifndef NO__1gdk_1window_1end_1draw_1frame
-JNIEXPORT jlong JNICALL GDK_NATIVE(_1gdk_1window_1end_1draw_1frame)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- jlong rc = 0;
- GDK_NATIVE_ENTER(env, that, _1gdk_1window_1end_1draw_1frame_FUNC);
-/*
- rc = (jlong)gdk_window_end_draw_frame((GdkWindow *)arg0, (GdkDrawingContext *)arg1);
-*/
- {
- GDK_LOAD_FUNCTION(fp, gdk_window_end_draw_frame)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(GdkWindow *, GdkDrawingContext *))fp)((GdkWindow *)arg0, (GdkDrawingContext *)arg1);
- }
- }
- GDK_NATIVE_EXIT(env, that, _1gdk_1window_1end_1draw_1frame_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gdk_1window_1focus
JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1focus)
(JNIEnv *env, jclass that, jlong arg0, jint arg1)
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 55747011df..561cd7f972 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
@@ -87,7 +87,6 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1drag_1context_1get_1selected_1action",
"_1gdk_1drag_1context_1list_1targets",
"_1gdk_1drag_1status",
- "_1gdk_1drawing_1context_1get_1cairo_1context",
"_1gdk_1event_1copy",
"_1gdk_1event_1free",
"_1gdk_1event_1get",
@@ -213,10 +212,8 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1unicode_1to_1keyval",
"_1gdk_1utf8_1to_1string_1target",
"_1gdk_1visual_1get_1depth",
- "_1gdk_1window_1begin_1draw_1frame",
"_1gdk_1window_1create_1similar_1surface",
"_1gdk_1window_1destroy",
- "_1gdk_1window_1end_1draw_1frame",
"_1gdk_1window_1focus",
"_1gdk_1window_1get_1children",
"_1gdk_1window_1get_1device_1position",
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 e484f05a7b..87d3bdfb1b 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
@@ -97,7 +97,6 @@ typedef enum {
_1gdk_1drag_1context_1get_1selected_1action_FUNC,
_1gdk_1drag_1context_1list_1targets_FUNC,
_1gdk_1drag_1status_FUNC,
- _1gdk_1drawing_1context_1get_1cairo_1context_FUNC,
_1gdk_1event_1copy_FUNC,
_1gdk_1event_1free_FUNC,
_1gdk_1event_1get_FUNC,
@@ -223,10 +222,8 @@ typedef enum {
_1gdk_1unicode_1to_1keyval_FUNC,
_1gdk_1utf8_1to_1string_1target_FUNC,
_1gdk_1visual_1get_1depth_FUNC,
- _1gdk_1window_1begin_1draw_1frame_FUNC,
_1gdk_1window_1create_1similar_1surface_FUNC,
_1gdk_1window_1destroy_FUNC,
- _1gdk_1window_1end_1draw_1frame_FUNC,
_1gdk_1window_1focus_FUNC,
_1gdk_1window_1get_1children_FUNC,
_1gdk_1window_1get_1device_1position_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 16e7f629f0..43a1da94e1 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
@@ -524,34 +524,6 @@ public class GDK extends OS {
}
/**
* @param window cast=(GdkWindow *)
- * @param region cast=(cairo_region_t *)
- * @method flags=dynamic
- */
- public static final native long _gdk_window_begin_draw_frame(long window, long region);
- public static final long gdk_window_begin_draw_frame(long window, long region) {
- lock.lock();
- try {
- return _gdk_window_begin_draw_frame(window, region);
- } finally {
- lock.unlock();
- }
- }
- /**
- * @param window cast=(GdkWindow *)
- * @param context cast=(GdkDrawingContext *)
- * @method flags=dynamic
- */
- public static final native long _gdk_window_end_draw_frame(long window, long context);
- public static final long gdk_window_end_draw_frame(long window, long context) {
- lock.lock();
- try {
- return _gdk_window_end_draw_frame(window, context);
- } finally {
- lock.unlock();
- }
- }
- /**
- * @param window cast=(GdkWindow *)
*/
public static final native int _gdk_window_get_state(long window);
/** [GTK3 only, if-def'd in os.h] */
@@ -994,19 +966,6 @@ public class GDK extends OS {
lock.unlock();
}
}
- /**
- * @param context cast=(GdkDrawingContext *)
- * @method flags=dynamic
- */
- public static final native long _gdk_drawing_context_get_cairo_context(long context);
- public static final long gdk_drawing_context_get_cairo_context(long context) {
- lock.lock();
- try {
- return _gdk_drawing_context_get_cairo_context(context);
- } finally {
- lock.unlock();
- }
- }
/** @param event cast=(GdkEvent *) */
public static final native long _gdk_event_copy(long event);
public static final long gdk_event_copy(long event) {
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 0a9c534a1f..8d270c5c2a 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
@@ -2671,16 +2671,11 @@ void init(Drawable drawable, GCData data, long gdkGC) {
void initCairo() {
long cairo = data.cairo;
if (cairo != 0) return;
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long surface;
- if (GTK.GTK4) {
- surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_A8, data.width, data.height);
- } else {
- surface = GDK.gdk_window_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
- }
+ if (GTK.GTK4) {
+ long surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_A8, data.width, data.height);
data.cairo = cairo = Cairo.cairo_create(surface);
} else {
- data.cairo = cairo = GDK.gdk_cairo_create(data.drawable);
+ data.cairo = cairo = Cairo.cairo_create(data.drawable);
}
if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
data.disposeCairo = true;
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 e5a3478986..34227dc069 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
@@ -384,15 +384,7 @@ void scrollInPixels (int destX, int destY, int x, int y, int width, int height,
redrawWidget (x, y, width, height, false, false, false);
redrawWidget (destX, destY, width, height, false, false, false);
} else {
- long cairo = 0;
- long context = 0;
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long cairo_region = GDK.gdk_window_get_visible_region(window);
- context = GDK.gdk_window_begin_draw_frame(window, cairo_region);
- cairo = GDK.gdk_drawing_context_get_cairo_context(context);
- } else {
- cairo = GDK.gdk_cairo_create(window);
- }
+ long cairo = GDK.gdk_cairo_create(window);
if (Cairo.cairo_version() < Cairo.CAIRO_VERSION_ENCODE(1, 12, 0)) {
GDK.gdk_cairo_set_source_window(cairo, window, 0, 0);
} else {
@@ -406,11 +398,7 @@ void scrollInPixels (int destX, int destY, int x, int y, int width, int height,
Cairo.cairo_rectangle(cairo, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height);
Cairo.cairo_clip(cairo);
Cairo.cairo_paint(cairo);
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- if (context != 0) GDK.gdk_window_end_draw_frame(window, context);
- } else {
- Cairo.cairo_destroy(cairo);
- }
+ Cairo.cairo_destroy(cairo);
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();
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 00eaa8333f..494b0fce02 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
@@ -207,7 +207,7 @@ void deregister () {
}
void drawBackground (Control control, long gdkResource, long cr, int x, int y, int width, int height) {
- long cairo, context = 0;
+ long cairo = 0;
long region = 0;
if (GTK.GTK4) {
// TODO: once Eclipse runs on GTK4, check for bug 547466.
@@ -228,17 +228,7 @@ void drawBackground (Control control, long gdkResource, long cr, int x, int y, i
region = Cairo.cairo_region_create_rectangle(regionRect);
}
} else {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- if (cr == 0) {
- long cairo_region = GDK.gdk_window_get_visible_region(gdkResource);
- context = GDK.gdk_window_begin_draw_frame(gdkResource, cairo_region);
- cairo = GDK.gdk_drawing_context_get_cairo_context(context);
- } else {
- cairo = cr;
- }
- } else {
- cairo = cr != 0 ? cr : GDK.gdk_cairo_create(gdkResource);
- }
+ cairo = cr != 0 ? cr : GDK.gdk_cairo_create(gdkResource);
}
/*
* It's possible that a client is using an SWT.NO_BACKGROUND Composite with custom painting
@@ -277,11 +267,7 @@ void drawBackground (Control control, long gdkResource, long cr, int x, int y, i
Cairo.cairo_rectangle (cairo, x, y, width, height);
Cairo.cairo_fill (cairo);
if (!GTK.GTK4 ) {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- if (cairo != cr && context != 0) GDK.gdk_window_end_draw_frame(gdkResource, context);
- } else {
- if (cairo != cr) Cairo.cairo_destroy(cairo);
- }
+ if (cairo != cr) Cairo.cairo_destroy(cairo);
}
}
@@ -4283,19 +4269,9 @@ public long internal_new_GC (GCData data) {
if (gc != 0) {
Cairo.cairo_reference (gc);
} else {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long surface;
- if (GTK.GTK4) {
- surface = GDK.gdk_surface_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
- gc = Cairo.cairo_create(surface);
- } else {
- long cairo_region = GDK.gdk_window_get_visible_region(gdkResource);
- long drawingContext = GDK.gdk_window_begin_draw_frame(gdkResource, cairo_region);
- Cairo.cairo_region_destroy(cairo_region);
- gc = Cairo.cairo_reference(GDK.gdk_drawing_context_get_cairo_context(drawingContext));
- GDK.gdk_window_end_draw_frame(gdkResource, drawingContext);
- }
-
+ if (GTK.GTK4) {
+ long surface = GDK.gdk_surface_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ gc = Cairo.cairo_create(surface);
} else {
gc = GDK.gdk_cairo_create (gdkResource);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index b0547fa326..719ed729a1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -3815,12 +3815,7 @@ public long internal_new_GC (GCData data) {
gc = Cairo.cairo_create(surface);
} else {
root = GDK.gdk_get_default_root_window();
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long surface = GDK.gdk_window_create_similar_surface(root, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
- gc = Cairo.cairo_create(surface);
- } else {
- gc = GDK.gdk_cairo_create(root);
- }
+ gc = GDK.gdk_cairo_create(root);
}
if (gc == 0) error (SWT.ERROR_NO_HANDLES);
//TODO how gdk_gc_set_subwindow is done in cairo?

Back to the top