Patch: per-surface locking for jawt
Anthony Green
green@redhat.com
Wed Apr 6 12:34:00 GMT 2005
This changes one of the locking mechanisms in jawt from global to per-
surface and makes more jogl demos run. It also fixes a memory leak by
freeing platformInfo. Tested on x86 Linux.
Ok for 4.0 branch and HEAD?
2005-04-06 Anthony Green <green@redhat.com>
* Makefile.am (libjawt_la_CFLAGS): Add GTK_CFLAGS.
* include/jawt.h (struct _JAWT_DrawingSurface): Add lock
field.
* jawt.c (_Jv_Lock): Use lock.
(_Jv_Unlock): Ditto.
(_Jv_GetDrawingSurface): Initialize lock.
(_Jv_FreeDrawingSurface): Free lock.
(_Jv_FreeDrawingSurfaceInfo): Free platformInfo.
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.455.2.8
diff -u -r1.455.2.8 Makefile.am
--- Makefile.am 31 Mar 2005 01:13:54 -0000 1.455.2.8
+++ Makefile.am 6 Apr 2005 12:12:31 -0000
@@ -484,7 +484,7 @@
lib_gnu_java_awt_peer_gtk_la_LINK = $(LIBLINK)
libjawt_la_SOURCES = jawt.c
-libjawt_la_CFLAGS = -I$(srcdir)/jni/classpath $(PEDANTIC_CFLAGS) $(X_CFLAGS)
+libjawt_la_CFLAGS = -I$(srcdir)/jni/classpath $(PEDANTIC_CFLAGS) $(GTK_CFLAGS) $(X_CFLAGS)
## See jv_convert_LDADD.
libjawt_la_LIBADD = -L$(here)/.libs lib-gnu-java-awt-peer-gtk.la
libjawt_la_LDFLAGS = \
Index: jawt.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jawt.c,v
retrieving revision 1.2.6.1
diff -u -r1.2.6.1 jawt.c
--- jawt.c 7 Mar 2005 19:58:40 -0000 1.2.6.1
+++ jawt.c 6 Apr 2005 12:12:31 -0000
@@ -40,6 +40,7 @@
#include <jawt.h>
#include <jawt_md.h>
#include "classpath_jawt.h"
+#include "jni/gtk-peer/gtkpeer.h"
static jint (JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface);
static void (JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface);
@@ -76,14 +77,16 @@
static jint
(JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface)
{
- /* lock the drawing surface */
- return classpath_jawt_lock ();
+ JNIEnv *env = gdk_env();
+ (*env)->MonitorEnter (env, surface->lock);
+ return 0;
}
static void
(JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface)
{
- classpath_jawt_unlock ();
+ JNIEnv *env = gdk_env();
+ (*env)->MonitorExit (env, surface->lock);
}
static JAWT_DrawingSurfaceInfo*
@@ -109,6 +112,7 @@
surface_info_x11->drawable = 0;
surface_info_x11->visualID = 0;
+ free (surface_info->platformInfo);
free (surface_info);
surface_info = NULL;
}
@@ -135,6 +139,9 @@
surface->surface_info = (JAWT_DrawingSurfaceInfo*) malloc (sizeof (JAWT_DrawingSurfaceInfo));
+ surface->lock = (*env)->NewStringUTF (env, "jawt-lock");
+ NSA_SET_GLOBAL_REF (env, surface->lock);
+
if (surface->surface_info == NULL)
return NULL;
@@ -158,6 +165,8 @@
static void
(JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface)
{
+ JNIEnv *env = gdk_env();
+ NSA_DEL_GLOBAL_REF (env, surface->lock);
free (surface);
}
Index: include/jawt.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/jawt.h,v
retrieving revision 1.2.6.1
diff -u -r1.2.6.1 jawt.h
--- include/jawt.h 7 Mar 2005 19:58:41 -0000 1.2.6.1
+++ include/jawt.h 6 Apr 2005 12:12:31 -0000
@@ -72,6 +72,9 @@
struct _JAWT_DrawingSurfaceInfo* surface_info;
+ /* An object we're going to use for locking the surface. */
+ jobject lock;
+
/* FIXME: also include bounding rectangle of drawing surface. */
/* FIXME: also include current clipping region. */
};
More information about the Java-patches
mailing list