gtk_jawt.c (classpath_jawt_object_lock, [...]): New functions.

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.

From-SVN: r99903
This commit is contained in:
Anthony Green 2005-05-18 14:20:53 +00:00 committed by Anthony Green
parent 4e876a0fb9
commit 9a6411ed30
5 changed files with 62 additions and 3 deletions

View 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.

View 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. */
};

View 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);
}

View 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__ */

View File

@ -152,6 +152,21 @@ classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
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 ()
{
@ -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);
}