JNIEXPORT void JNICALL
    awt_Unlock(JNIEnv* env)
{
    if (awtLockInited) {
        AWT_FLUSH_UNLOCK();
    }
}
Ejemplo n.º 2
0
/**
 * This function invokes the native threadsafe flushing and unlocking
 * mechanism (e.g. the AWT_FLUSH_UNLOCK() macro in the GLX case) to ensure
 * the preceding OpenGL commands are completed before the surface is unlocked
 * in a synchronized manner.  See OGLSurfaceData.h for more information
 * on the recognized constant values for the flushFlag parameter.
 */
void
OGLSD_UnlockImpl(JNIEnv *env, jint flushFlag)
{
    J2dTraceLn1(J2D_TRACE_INFO, "in OGLSD_UnlockImpl (flush=%d)", flushFlag);

    switch (flushFlag) {
    case OGLSD_FLUSH_ON_JED:
        // if we're on the JED thread, we can use the native Toolkit thread
        // flushing mechanism, which will post an asynchronous event that will
        // eventually flush the context that is current to this thread
        needGLFlush = JNI_TRUE;
        AWT_FLUSH_UNLOCK();
        break;

    case OGLSD_FLUSH_NOW:
        // otherwise, we have no choice but to flush immediately (or else
        // any rendering not invoked from the JED thread could be left
        // unflushed)
        j2d_glFlush();
        // FALLTHROUGH

    case OGLSD_NO_FLUSH:
    default:
        AWT_UNLOCK();
        break;
    }
}
Ejemplo n.º 3
0
/**
 * This is the native dispose method that gets invoked when the Java-level
 * thread associated with this context is about to go away.  This method
 * invokes the AWT_LOCK mechanism for thread safety, then destroys the
 * OGLContext kept in thread-local storage.
 */
static void
GLXGC_DisposeOGLContext(JNIEnv *env, jlong pData)
{
    OGLContext *oglc = (OGLContext *)jlong_to_ptr(pData);

    J2dTraceLn(J2D_TRACE_INFO, "in GLXGC_DisposeOGLContext");

    AWT_LOCK();
    GLXGC_DestroyOGLContext(env, oglc);
    AWT_FLUSH_UNLOCK();
}
/*
 * Unlock the drawing surface of the target component for native rendering.
 */
JNIEXPORT void JNICALL awt_DrawingSurface_Unlock(JAWT_DrawingSurface* ds)
{
    JNIEnv* env;
    if (ds == NULL) {
#ifdef DEBUG
        fprintf(stderr, "Drawing Surface is NULL\n");
#endif
        return;
    }
    env = ds->env;
    AWT_FLUSH_UNLOCK();
}
Ejemplo n.º 5
0
/*
 * Lock the surface of the target component for native rendering.
 * When finished drawing, the surface must be unlocked with
 * Unlock().  This function returns a bitmask with one or more of the
 * following values:
 *
 * JAWT_LOCK_ERROR - When an error has occurred and the surface could not
 * be locked.
 *
 * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
 *
 * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
 *
 * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
 */
JNIEXPORT jint JNICALL awt_DrawingSurface_Lock(JAWT_DrawingSurface* ds)
{
    JNIEnv* env;
    jobject target, peer;
    jclass componentClass;
    jint drawState;

    if (ds == NULL) {
#ifdef DEBUG
        fprintf(stderr, "Drawing Surface is NULL\n");
#endif
        return (jint)JAWT_LOCK_ERROR;
    }
    env = ds->env;
    target = ds->target;

    /* Make sure the target is a java.awt.Component */
    componentClass = (*env)->FindClass(env, "java/awt/Component");
    if (!(*env)->IsInstanceOf(env, target, componentClass)) {
#ifdef DEBUG
	    fprintf(stderr, "Target is not a component\n");
#endif
        return (jint)JAWT_LOCK_ERROR;
	}

    if (!awtLockInited) {
        return (jint)JAWT_LOCK_ERROR;
    }
    AWT_LOCK();

    /* Get the peer of the target component */
    peer = (*env)->GetObjectField(env, target, componentIDs.peer);
    if (JNU_IsNull(env, peer)) {
#ifdef DEBUG
        fprintf(stderr, "Component peer is NULL\n");
#endif
		AWT_FLUSH_UNLOCK();
        return (jint)JAWT_LOCK_ERROR;
    }

#ifndef XAWT
    drawState = (*env)->GetIntField(env, peer, mComponentPeerIDs.drawState);
    (*env)->SetIntField(env, peer, mComponentPeerIDs.drawState, 0);
#else
   drawState = (*env)->GetIntField(env, peer, drawStateID);
    (*env)->SetIntField(env, peer, drawStateID, 0);
#endif    
    return drawState;
}