7200762: [macosx] Stuck in sun.java2d.opengl.CGLGraphicsConfig.getMaxTextureSize(Native Method)
Summary: Cache the GL max texture size to avoid calling in native each time the value is needed
Reviewed-by: art, bae
--- a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Mon Sep 03 14:28:00 2012 +0100
+++ b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Fri Oct 05 14:58:35 2012 +0400
@@ -84,11 +84,14 @@ public class CGLGraphicsConfig extends C
private OGLContext context;
private Object disposerReferent = new Object();
+ private final int cachedMaxTextureSize;
+
public static native int getDefaultPixFmt(int screennum);
private static native boolean initCGL();
private static native long getCGLConfigInfo(int screennum, int visualnum,
int swapInterval);
private static native int getOGLCapabilities(long configInfo);
+ private static native int _getMaxTextureSize();
static {
cglAvailable = initCGL();
@@ -108,6 +111,10 @@ public class CGLGraphicsConfig extends C
// CGLGraphicsConfigInfo data when this object goes away
Disposer.addRecord(disposerReferent,
new CGLGCDisposerRecord(pConfigInfo));
+
+ // 7200762: Workaround a deadlock by caching the value
+ // A fix for JDK 8 will remove the workaround
+ this.cachedMaxTextureSize = _getMaxTextureSize();
}
@Override
@@ -500,9 +507,12 @@ public class CGLGraphicsConfig extends C
}
}
+
// 7160609: GL still fails to create a square texture of this size,
// so we use this value to cap the total display bounds.
- native private static int getMaxTextureSize();
+ private int getMaxTextureSize() {
+ return cachedMaxTextureSize;
+ }
@Override
public int getMaxTextureWidth() {
--- a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Mon Sep 03 14:28:00 2012 +0100
+++ b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Fri Oct 05 14:58:35 2012 +0400
@@ -447,10 +447,10 @@ Java_sun_java2d_opengl_CGLGraphicsConfig
}
JNIEXPORT jint JNICALL
-Java_sun_java2d_opengl_CGLGraphicsConfig_getMaxTextureSize
+Java_sun_java2d_opengl_CGLGraphicsConfig__1getMaxTextureSize
(JNIEnv *env, jclass cglgc)
{
- J2dTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getMaxTextureSize");
+ J2dTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig__1getMaxTextureSize");
__block int max = 0;