diff --git a/modules/javafx.graphics/src/main/native-prism-es2/PrismES2Defs.h b/modules/javafx.graphics/src/main/native-prism-es2/PrismES2Defs.h index aa43478e350..34b31750b65 100644 --- a/modules/javafx.graphics/src/main/native-prism-es2/PrismES2Defs.h +++ b/modules/javafx.graphics/src/main/native-prism-es2/PrismES2Defs.h @@ -179,6 +179,7 @@ struct DrawableInfoRec { #endif /* WIN32 */ #ifdef UNIX /* LINUX || SOLARIS */ + jboolean perDrwawableVSync; #ifdef IS_EGL EGLDisplay *egldisplay; EGLSurface eglsurface; @@ -263,6 +264,7 @@ struct ContextInfoRec { #ifdef UNIX /* LINUX || SOLARIS */ char *glxExtensionStr; PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; + PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; #endif /* LINUX || SOLARIS */ /* gl function pointers */ diff --git a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLContext.c b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLContext.c index fde0bf57458..f688bc6eb27 100644 --- a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLContext.c +++ b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLContext.c @@ -270,6 +270,14 @@ JNIEXPORT jlong JNICALL Java_com_sun_prism_es2_X11GLContext_nInitialize dlsym(RTLD_DEFAULT,"glBlitFramebuffer"); if (isExtensionSupported(ctxInfo->glxExtensionStr, + "GLX_EXT_swap_control")) { + ctxInfo->glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) + dlsym(RTLD_DEFAULT, "glXSwapIntervalEXT"); + if (ctxInfo->glXSwapIntervalEXT == NULL) { + ctxInfo->glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) + glXGetProcAddress((const GLubyte *)"glXSwapIntervalEXT"); + } + } else if (isExtensionSupported(ctxInfo->glxExtensionStr, "GLX_SGI_swap_control")) { ctxInfo->glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) dlsym(RTLD_DEFAULT, "glXSwapIntervalSGI"); @@ -278,14 +286,14 @@ JNIEXPORT jlong JNICALL Java_com_sun_prism_es2_X11GLContext_nInitialize ctxInfo->glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress((const GLubyte *)"glXSwapIntervalSGI"); } - } - // initialize platform states and properties to match - // cached states and properties - if (ctxInfo->glXSwapIntervalSGI != NULL) { + if (ctxInfo->glXSwapIntervalEXT != NULL) { + ctxInfo->glXSwapIntervalEXT(dInfo->display, dInfo->win, 0); + } else if (ctxInfo->glXSwapIntervalSGI != NULL) { ctxInfo->glXSwapIntervalSGI(0); } + ctxInfo->state.vSyncEnabled = JNI_FALSE; ctxInfo->vSyncRequested = vSyncRequested; @@ -333,7 +341,12 @@ JNIEXPORT void JNICALL Java_com_sun_prism_es2_X11GLContext_nMakeCurrent } interval = (vSyncNeeded) ? 1 : 0; ctxInfo->state.vSyncEnabled = vSyncNeeded; - if (ctxInfo->glXSwapIntervalSGI != NULL) { + + if (ctxInfo->glXSwapIntervalEXT != NULL) { + ctxInfo->glXSwapIntervalEXT(dInfo->display, dInfo->win, interval); + dInfo->perDrwawableVSync = vSyncNeeded; + } else if (ctxInfo->glXSwapIntervalSGI != NULL) { ctxInfo->glXSwapIntervalSGI(interval); + dInfo->perDrwawableVSync = JNI_FALSE; } } diff --git a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLDrawable.c b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLDrawable.c index e23b344fe9c..52e678cce4b 100644 --- a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLDrawable.c +++ b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLDrawable.c @@ -109,6 +109,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_prism_es2_X11GLDrawable_nSwapBuffers return JNI_FALSE; } glXSwapBuffers(dInfo->display, dInfo->win); + + if (dInfo->perDrwawableVSync) { + glFinish(); + } + return JNI_TRUE; } diff --git a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLFactory.c b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLFactory.c index 07e5d57df79..5275f11026b 100644 --- a/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLFactory.c +++ b/modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLFactory.c @@ -88,6 +88,9 @@ void setGLXAttrs(jint *attrs, int *glxAttrs) { glxAttrs[index++] = GLX_DEPTH_SIZE; glxAttrs[index++] = attrs[DEPTH_SIZE]; + glxAttrs[index++] = GLX_CONFIG_CAVEAT; + glxAttrs[index++] = GLX_NONE; + glxAttrs[index] = None; } @@ -215,7 +218,26 @@ JNIEXPORT jlong JNICALL Java_com_sun_prism_es2_X11GLFactory_nInitialize return 0; } - visualInfo = glXGetVisualFromFBConfig(display, fbConfigList[0]); + GLXFBConfig fbConfig; + // X Visual of depth = 32 is required for window transparency + for (int i = 0; i < numFBConfigs; i++) { + XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbConfigList[i]); + if (!vi) continue; + + if (vi->depth == 32) { + fbConfig = fbConfigList[i]; + visualInfo = vi; + break; + } + + XFree(vi); + } + + if (visualInfo == NULL) { + fbConfig = fbConfigList[0]; + visualInfo = glXGetVisualFromFBConfig(display, fbConfig); + } + if (visualInfo == NULL) { printAndReleaseResources(display, fbConfigList, visualInfo, win, ctx, cmap,