changeset 5581:265fd0f23c8e

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
author anthony
date Fri, 05 Oct 2012 14:58:35 +0400
parents 9ca10ab155e3
children 9741e9cbe91a
files src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
     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 @@
         // 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 @@
         }
     }
 
+
     // 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 @@
 }
 
 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;