src/solaris/native/sun/java2d/x11/XRBackendNative.c

Print this page

        

@@ -29,10 +29,14 @@
 #include "Region.h"
 #include "fontscalerdefs.h"
 
 #include <X11/extensions/Xrender.h>
 
+#ifdef __linux__
+    #include <sys/utsname.h>
+#endif
+
 /* On Solaris 10 updates 8, 9, the render.h file defines these
  * protocol values but does not define the structs in Xrender.h.
  * Thus in order to get these always defined on Solaris 10
  * we will undefine the symbols if we have determined via the
  * makefiles that Xrender.h is lacking the structs. This will

@@ -129,11 +133,11 @@
  * Note that sizeof(xRenderCreateRadiaGradientReq) = 36
  */
 #define MAX_PAYLOAD (262140u - 36u)
 #define MAXUINT (0xffffffffu)
 
-static jboolean IsXRenderAvailable(jboolean verbose) {
+static jboolean IsXRenderAvailable(jboolean verbose, jboolean ignoreLinuxVersion) {
 
     void *xrenderlib;
 
     int major_opcode, first_event, first_error;
     jboolean available = JNI_TRUE;

@@ -251,20 +255,45 @@
              "\tSee the release notes for more details.\n");
       fflush(stdout);
     }
 #endif
 
+#ifdef __linux__
+    /* 
+     * Check for Linux >= 3.5 (Ubuntu 12.04.02 LTS) to avoid hitting 
+     * https://bugs.freedesktop.org/show_bug.cgi?id=48045
+     */
+    struct utsname utsbuf;    
+    if(uname(&utsbuf) >= 0) {
+        int major, minor, revision;
+        if(sscanf(utsbuf.release, "%i.%i.%i", &major, &minor, &revision) == 3) {            
+            if(major <= 3 && minor < 5) {
+                if(!ignoreLinuxVersion) {
+                    available = JNI_FALSE;
+                } 
+                else if(verbose) {
+                 printf("WARNING: Linux < 3.5 detected.\n"
+                        "The pipeline will be enabled, but graphical "
+                        "artifacts can occur with old graphic drivers.\n"
+                        "See the release notes for more details.\n");
+                        fflush(stdout);    
+                }
+            }
+        }
+    }
+#endif // __linux__
+
     return available;
 }
 /*
  * Class:     sun_awt_X11GraphicsEnvironment
  * Method:    initGLX
  * Signature: ()Z
  */
 JNIEXPORT jboolean JNICALL
 Java_sun_awt_X11GraphicsEnvironment_initXRender
-(JNIEnv *env, jclass x11ge, jboolean verbose)
+(JNIEnv *env, jclass x11ge, jboolean verbose, jboolean ignoreLinuxVersion)
 {
 #ifndef HEADLESS
     static jboolean xrenderAvailable = JNI_FALSE;
     static jboolean firstTime = JNI_TRUE;
 

@@ -275,11 +304,11 @@
             firstTime = JNI_FALSE;
             return xrenderAvailable;
         }
 #endif
         AWT_LOCK();
-        xrenderAvailable = IsXRenderAvailable(verbose);
+        xrenderAvailable = IsXRenderAvailable(verbose, ignoreLinuxVersion);
         AWT_UNLOCK();
         firstTime = JNI_FALSE;
     }
     return xrenderAvailable;
 #else