OSDN Git Service

2005-05-18 Anthony Green <green@redhat.com>
authorgreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 May 2005 14:20:53 +0000 (14:20 +0000)
committergreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 May 2005 14:20:53 +0000 (14:20 +0000)
        * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99903 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/include/jawt.h
libjava/jawt.c
libjava/jni/classpath/classpath_jawt.h
libjava/jni/gtk-peer/gtk_jawt.c

index 70c3377..985415b 100644 (file)
@@ -1,3 +1,20 @@
+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.
index fdff935..bbefe20 100644 (file)
@@ -72,6 +72,9 @@ struct _JAWT_DrawingSurface
 
   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. */
 };
index 20890da..bb03c63 100644 (file)
@@ -40,6 +40,7 @@
 #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);
@@ -76,14 +77,13 @@ JAWT_GetAWT (JNIEnv* env, JAWT* awt)
 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*
@@ -109,6 +109,7 @@ static void
   surface_info_x11->drawable = 0;
   surface_info_x11->visualID = 0;
 
+  free (surface_info->platformInfo);
   free (surface_info);
   surface_info = NULL;
 }
@@ -135,6 +136,8 @@ static JAWT_DrawingSurface*
 
   surface->surface_info = (JAWT_DrawingSurfaceInfo*) malloc (sizeof (JAWT_DrawingSurfaceInfo));
 
+  surface->lock = classpath_jawt_create_lock ();
+
   if (surface->surface_info == NULL)
     return NULL;
 
@@ -158,6 +161,7 @@ static JAWT_DrawingSurface*
 static void
 (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface)
 {
+  classpath_jawt_destroy_lock (surface->lock);
   free (surface);
 }
 
index 1629505..6ff5c53 100644 (file)
@@ -54,7 +54,11 @@ jint     classpath_jawt_get_awt_version ();
 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__ */
index cba3b15..ed5f3f5 100644 (file)
@@ -153,6 +153,21 @@ classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
 }
 
 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_enter ();
@@ -164,3 +179,19 @@ classpath_jawt_unlock ()
 {
   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);
+}