+2005-05-18 Anthony Green <green@redhat.com>
+
+ * jni/gtk-peer/gtk_jawt.c (classpath_jawt_object_lock,
+ classpath_jawt_object_unlock, classpath_jawt_create_lock,
+ classpath_jawt_destroy_lock): New functions.
+ * jni/classpath/classpath_jawt.h (classpath_jawt_object_lock,
+ classpath_jawt_object_unlock, classpath_jawt_create_lock,
+ classpath_jawt_destroy_lock): New functions.
+ * include/jawt.h (struct _JAWT_DrawingSurface): Add lock
+ field.
+ * jawt.c: #include malloc.h.
+ (_Jv_Lock): Use lock.
+ (_Jv_Unlock): Ditto.
+ (_Jv_GetDrawingSurface): Initialize lock.
+ (_Jv_FreeDrawingSurface): Destroy lock.
+ (_Jv_FreeDrawingSurfaceInfo): Free platformInfo.
+
2005-05-18 Paolo Bonzini <bonzini@gnu.org>
* Makefile.am (Makefile.deps): Do not use \0, it is unportable.
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. */
};
#include <jawt.h>
#include <jawt_md.h>
#include "classpath_jawt.h"
+#include <malloc.h>
static jint (JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface);
static void (JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface);
static jint
(JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface)
{
- /* lock the drawing surface */
- return classpath_jawt_lock ();
+ return classpath_jawt_object_lock (surface->lock);
}
static void
(JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface)
{
- classpath_jawt_unlock ();
+ classpath_jawt_object_unlock (surface->lock);
}
static JAWT_DrawingSurfaceInfo*
surface_info_x11->drawable = 0;
surface_info_x11->visualID = 0;
+ free (surface_info->platformInfo);
free (surface_info);
surface_info = NULL;
}
surface->surface_info = (JAWT_DrawingSurfaceInfo*) malloc (sizeof (JAWT_DrawingSurfaceInfo));
+ surface->lock = classpath_jawt_create_lock ();
+
if (surface->surface_info == NULL)
return NULL;
static void
(JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface)
{
+ classpath_jawt_destroy_lock (surface->lock);
free (surface);
}
Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas);
Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas);
VisualID classpath_jawt_get_visualID (JNIEnv* env, jobject canvas);
+jint classpath_jawt_object_lock (jobject lock);
+void classpath_jawt_object_unlock (jobject lock);
jint classpath_jawt_lock ();
void classpath_jawt_unlock ();
+jobject classpath_jawt_create_lock ();
+void classpath_jawt_destroy_lock (jobject lock);
#endif /* __classpath_jawt_h__ */
return drawable;
}
+jint
+classpath_jawt_object_lock (jobject lock)
+{
+ JNIEnv *env = gdk_env();
+ (*env)->MonitorEnter (env, lock);
+ return 0;
+}
+
+void
+classpath_jawt_object_unlock (jobject lock)
+{
+ JNIEnv *env = gdk_env();
+ (*env)->MonitorExit (env, lock);
+}
+
jint
classpath_jawt_lock ()
{
{
gdk_threads_leave ();
}
+
+jobject
+classpath_jawt_create_lock ()
+{
+ JNIEnv *env = gdk_env ();
+ jobject lock = (*env)->NewStringUTF (env, "jawt-lock");
+ NSA_SET_GLOBAL_REF (env, lock);
+ return lock;
+}
+
+void
+classpath_jawt_destroy_lock (jobject lock)
+{
+ JNIEnv *env = gdk_env ();
+ NSA_DEL_GLOBAL_REF (env, lock);
+}