diff options
author | Sven Gothel <[email protected]> | 2001-09-26 00:21:57 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2001-09-26 00:21:57 +0000 |
commit | 744ceb659539753d571dc46aebb601d4a2f0b401 (patch) | |
tree | d5dbaac2714b00532c51d8f35bcd6ec0927d235c /CNativeCode | |
parent | 26883064d71736ccd96a6f1d9b19b85b66f5ac7c (diff) |
bugfix: auto context switch
Diffstat (limited to 'CNativeCode')
-rw-r--r-- | CNativeCode/OpenGL_X11.c | 1 | ||||
-rw-r--r-- | CNativeCode/jawt_misc.c | 44 |
2 files changed, 39 insertions, 6 deletions
diff --git a/CNativeCode/OpenGL_X11.c b/CNativeCode/OpenGL_X11.c index f95ee8a..f7e0795 100644 --- a/CNativeCode/OpenGL_X11.c +++ b/CNativeCode/OpenGL_X11.c @@ -516,7 +516,6 @@ Java_gl4java_GLContext_gljMakeCurrentNative( JNIEnv *env, jobject obj, (Window)((PointerHolder)thisWin), (GLXContext)((PointerHolder)glContext) ) ) { - extern GLenum glGetError ( void ) ; fprintf(stderr, "GL4Java: gljMakeCurrent failed with GC\n Another thread may be use it now ...\n"); fflush(stderr); ret = JNI_FALSE; diff --git a/CNativeCode/jawt_misc.c b/CNativeCode/jawt_misc.c index dcdf4c3..ec71954 100644 --- a/CNativeCode/jawt_misc.c +++ b/CNativeCode/jawt_misc.c @@ -7,6 +7,12 @@ static JAWT _awt ; static jboolean _awt_init = JNI_FALSE ; +static long mem_used = 0L; +static int gdsi = 0; +static int gds = 0; + +static jboolean jawtdebug = JNI_FALSE; + jboolean LIBAPIENTRY jawt_create_offscreen (JNIEnv *env, JAWTDataHolder **ppJData, jboolean verbose) { @@ -21,6 +27,7 @@ jawt_create_offscreen (JNIEnv *env, JAWTDataHolder **ppJData, jboolean verbose) } *ppJData = calloc(1, sizeof(JAWTDataHolder)); + mem_used += sizeof(JAWTDataHolder); // Get the drawing surface (*ppJData)->ds = NULL; @@ -34,6 +41,9 @@ jawt_create_offscreen (JNIEnv *env, JAWTDataHolder **ppJData, jboolean verbose) (*ppJData)->offScreen = 1; (*ppJData)->result = JNI_TRUE; + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo create offscr): mem %ld\n", mem_used); + return JNI_TRUE; } @@ -52,6 +62,10 @@ jawt_create_open (JNIEnv *env, jobject component, } *ppJData = calloc(1, sizeof(JAWTDataHolder)); + mem_used += sizeof(JAWTDataHolder); + + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (create open): mem %ld\n", mem_used); // Get the drawing surface (*ppJData)->ds = NULL; @@ -87,8 +101,12 @@ jawt_free_close_unlock (JNIEnv *env, JAWTDataHolder **ppJData, jboolean verbose) res = jawt_close_unlock(env, *ppJData, verbose); free(*ppJData); + mem_used -= sizeof(JAWTDataHolder); *ppJData=NULL; + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo free close unlock): mem %ld\n", mem_used); + return res; } @@ -133,16 +151,16 @@ jawt_open (JNIEnv *env, jobject component, JAWTDataHolder *pJData, jboolean verb // Get the drawing surface pJData->ds = _awt.GetDrawingSurface(env, component); + gds++; pJData->result = pJData->ds != NULL; if(verbose && pJData->result==JNI_FALSE) { - if(verbose) - { - fprintf(stderr, "GL4Java-JAWT: open failed -> GetDrawingSurface()==NULL\n"); - fflush(stderr); - } + fprintf(stderr, "GL4Java-JAWT: open failed -> GetDrawingSurface()==NULL\n"); + fflush(stderr); } + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo open): gds=%d\n", gds); return pJData->result; } @@ -160,9 +178,15 @@ jawt_close_unlock (JNIEnv *env, JAWTDataHolder *pJData, jboolean verbose) // Free the drawing surface if(pJData->ds!=0) + { _awt.FreeDrawingSurface(pJData->ds); + gds--; + } pJData->ds=0; + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo close unlock): gds=%d\n", gds); + return pJData->result; } @@ -233,7 +257,12 @@ jawt_lock (JNIEnv *env, JAWTDataHolder *pJData, jboolean ignoreSurfaceChanged, // Get the drawing surface info pJData->dsi = pJData->ds->GetDrawingSurfaceInfo(pJData->ds); + gdsi++; exc = (*env)->ExceptionOccurred(env); + + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo lock): gdsi=%d\n", gdsi); + if(exc) { if(verbose) { @@ -322,7 +351,12 @@ jawt_unlock (JNIEnv *env, JAWTDataHolder *pJData, jboolean verbose) { // Free the drawing surface info pJData->ds->FreeDrawingSurfaceInfo(pJData->dsi); + gdsi--; exc = (*env)->ExceptionOccurred(env); + + if(verbose || jawtdebug) + fprintf(stdout, "GL4Java-JAWT INFO (eo unlock): gdsi=%d\n", gdsi); + if(exc) { if(verbose) { |