/*
 * Class:     sun_java2d_windows_WinBackBufferSurfaceData
 * Method:    initSurface
 * Signature: (IIILsun/awt/windows/WinBackBufferSurfaceData;)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_WinBackBufferSurfaceData_initSurface(JNIEnv *env,
    jobject sData, jint depth, jint width, jint height, jint screen,
    jobject parentData)
{
    Win32SDOps *wsdo = (Win32SDOps *)SurfaceData_GetOps(env, sData);

    J2dTraceLn(J2D_TRACE_INFO, "Win32BBSD_initSurface");
    /* Set the correct dispose method */
    wsdo->sdOps.Dispose = Win32BBSD_Dispose;
    jboolean status =
        initOSSD_WSDO(env, wsdo, width, height, screen, JNI_FALSE);
    if (status == JNI_FALSE || parentData == NULL) {
        SurfaceData_ThrowInvalidPipeException(env,
            "Error initalizing back-buffer surface");
        return;
    }
    Win32SDOps *wsdo_parent = (Win32SDOps*)SurfaceData_GetOps(env, parentData);
    if (!DDGetAttachedSurface(env, wsdo_parent, wsdo)) {
        SurfaceData_ThrowInvalidPipeException(env,
            "Can't create attached surface");
    }
    J2dTraceLn1(J2D_TRACE_VERBOSE,
                "Win32BackBufferSurfaceData_initSurface: "\
                "completed wsdo->lpSurface=0x%x", wsdo->lpSurface);
}
Example #2
0
JNIEXPORT void JNICALL 
Java_sun_awt_windows_Win32OffScreenSurfaceData_initSurface(JNIEnv *env, 
							   jobject sData, 
							   jint depth, 
							   jint width,
							   jint height,
							   jint screen,
							   jboolean isVolatile,
                                                           jint transparency)
{
    Win32SDOps *wsdo = (Win32SDOps *)SurfaceData_GetOps(env, sData);

    DTRACE_PRINTLN("Win32OSSD_initSurface");
    initOSSD_WSDO(env, wsdo, width, height, screen, transparency);
    if (!DDCreateSurface(wsdo, isVolatile /* d3d caps desired, if possible */)) {
	DTRACE_PRINTLN1("Win32OSD.initSurface: Can't create offsc surf tr=%d\n",
			transparency);
	SurfaceData_ThrowInvalidPipeException(env, 
					      "Can't create offscreen surf");
    } else {
	wsdo->surfacePuntData.lpSurfaceVram = wsdo->lpSurface;
	if (!D3DEnabled(wsdo)) {
	    // d3d enabled by default for each surface - disable if necessary
	    env->SetBooleanField(sData, localD3dEnabledID, JNI_FALSE);
	} else {
	    env->SetBooleanField(sData, d3dClippingEnabledID, 
	    			 (DDINSTANCE_USABLE(wsdo->ddInstance) && 
	    			  wsdo->ddInstance->canClipD3dLines));
	}
    }
    // 8 is somewhat arbitrary; we want the threshhold to represent a
    // significant portion of the surface area in order to avoid
    // punting for occasional, small reads
    wsdo->surfacePuntData.pixelsReadThreshold = width * height / 8;
    /**
     * Only enable our punt-to-sysmem-surface scheme for surfaces that are:
     *   - non-transparent (we really only intended this workaround for
     *     back buffers, which are usually opaque)
     *   - volatile (non-volatile images should not even get into the punt
     *     situation since they should not be a rendering destination, but
     *     we check this just to make sure)
     * And only do so if the user did not specify that punting be disabled
     */
    wsdo->surfacePuntData.disablePunts = (transparency != TR_OPAQUE) ||
                                         !isVolatile                 ||
					 ddVramForced;
}