Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct DrawableInfoRec {
#endif /* WIN32 */

#ifdef UNIX /* LINUX || SOLARIS */
jboolean perDrwawableVSync;
#ifdef IS_EGL
EGLDisplay *egldisplay;
EGLSurface eglsurface;
Expand Down Expand Up @@ -263,6 +264,7 @@ struct ContextInfoRec {
#ifdef UNIX /* LINUX || SOLARIS */
char *glxExtensionStr;
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
#endif /* LINUX || SOLARIS */

/* gl function pointers */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, we're just fetching the first available option from the list which might not always have windows transparency. If that's the case - would it make sense to print some sort of warning on the terminal that window transparency might not work correctly? I think it could be a valuable information to the user, or at least when debugging in the future.

@kevinrushforth it's also a question to you, cause I'm not 100% sure what the JFX strategy would be in this case - if we would want this to be printed always as a warning, or only when we ex. activate -Dprism.verbose=true

visualInfo = glXGetVisualFromFBConfig(display, fbConfig);
}

if (visualInfo == NULL) {
printAndReleaseResources(display, fbConfigList, visualInfo,
win, ctx, cmap,
Expand Down