This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui][PATCH] Flush GDK events in Graphics drawing methods


Hi,

This patch adds gdk_flush calls to all of GdkGraphics' drawing
functions.  Since drawing can occur in a thread separate from the GTK
main loop, we need to manually flush events where they would normally be
flushed at the start of each main loop iteration.  Otherwise animations
created by drawing to a Graphics object will not update properly which
results in unsightly flickering.

I committed this patch to java-gui-branch.

Tom

2004-06-14  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (drawString):
	Wrap baseline y value in PANGO_PIXELS macro, rather than simply
	dividing by PANGO_SCALE.  Call gdk_flush before leaving GDK
	critical region.
	(drawLine): Call gdk_flush before leaving GDK critical region.
	(fillRect): Likewise.
	(drawRect): Likewise.
	(copyArea): Likewise.
	(copyPixmap): Likewise.
	(clearRect): Likewise.
	(drawArc): Likewise.
	(drawPolyline): Likewise.
	(drawPolygon): Likewise.
	(fillPolygon): Likewise.
	(fillArc): Likewise.
	(drawOval): Likewise.
	(fillOval): Likewise.

Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 gnu_java_awt_peer_gtk_GdkGraphics.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	27 May 2004 19:02:48 -0000	1.5.2.3
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	15 Jun 2004 03:17:42 -0000
@@ -228,12 +228,13 @@
 
   gdk_draw_layout (g->drawable, g->gc,
                    x + g->x_offset,
-                   y + g->y_offset - (baseline_y / PANGO_SCALE),
+                   y + g->y_offset - PANGO_PIXELS (baseline_y),
                    layout);
 
   pango_font_description_free (font_desc);
   pango_layout_iter_free (iter);
 
+  gdk_flush ();
   gdk_threads_leave ();
 
   (*env)->ReleaseStringUTFChars (env, fname, font_name);
@@ -251,6 +252,7 @@
   gdk_draw_line (g->drawable, g->gc, 
 		 x + g->x_offset, y + g->y_offset, 
 		 x2 + g->x_offset, y2 + g->y_offset);
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
@@ -265,6 +267,7 @@
 
   gdk_draw_rectangle (g->drawable, g->gc, TRUE, 
 		      x + g->x_offset, y + g->y_offset, width, height);
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
@@ -278,6 +281,7 @@
   gdk_threads_enter ();
   gdk_draw_rectangle (g->drawable, g->gc, FALSE, 
 		      x + g->x_offset, y + g->y_offset, width, height);
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
@@ -296,6 +300,7 @@
 			(GdkWindow *)g->drawable,
 			x + g->x_offset, y + g->y_offset,
 			width, height);
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
@@ -315,6 +320,7 @@
 			(GdkWindow *)g2->drawable,
 			0 + g2->x_offset, 0 + g2->y_offset, 
 			width, height);
+  gdk_flush ();
   gdk_threads_leave ();
 }
   
@@ -344,6 +350,7 @@
 			  x + g->x_offset, y + g->y_offset, width, height);
       gdk_gc_set_foreground (g->gc, &(saved.foreground));
     }
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
@@ -390,6 +397,7 @@
   gdk_draw_arc (g->drawable, g->gc, FALSE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, angle1 << 6, angle2 << 6);
+  gdk_flush ();
   gdk_threads_leave ();
 }  
 
@@ -433,6 +441,7 @@
 
   gdk_threads_enter ();
   gdk_draw_lines (g->drawable, g->gc, points, npoints);
+  gdk_flush ();
   gdk_threads_leave ();
 
   g_free (points);
@@ -456,6 +465,7 @@
 
   gdk_threads_enter ();
   gdk_draw_lines (g->drawable, g->gc, points, npoints);
+  gdk_flush ();
   gdk_threads_leave ();
 
   g_free (points);
@@ -473,6 +483,7 @@
 			     g->x_offset, g->y_offset);
   gdk_threads_enter ();
   gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
+  gdk_flush ();
   gdk_threads_leave ();
 
   g_free (points);
@@ -490,6 +501,7 @@
   gdk_draw_arc (g->drawable, g->gc, TRUE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, angle1 << 6, angle2 << 6);
+  gdk_flush ();
   gdk_threads_leave ();
 }  
 
@@ -504,6 +516,7 @@
   gdk_draw_arc (g->drawable, g->gc, FALSE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, 0, 23040);
+  gdk_flush ();
   gdk_threads_leave ();
 }  
 
@@ -518,8 +531,9 @@
   gdk_draw_arc (g->drawable, g->gc, TRUE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, 0, 23040);
+  gdk_flush ();
   gdk_threads_leave ();
-}  
+}
 
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]