changeset 7263:e6fc9e16cece

Fix for RT-37513 [Monocle] Should not show an exception trace when falling back to software rendering Reviewed-by dblaukopf Tested with HelloSanity
author Lisa.Selle@oracle.com
date Thu, 12 Jun 2014 17:04:53 -0400
parents 5e7640e45127
children 9f5303fb78fb
files modules/graphics/src/main/java/com/sun/glass/ui/monocle/AcceleratedScreen.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatform.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/mx6/MX6AcceleratedScreen.java modules/graphics/src/main/java/com/sun/prism/es2/MonocleGLFactory.java
diffstat 4 files changed, 47 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/AcceleratedScreen.java	Thu Jun 12 10:43:40 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/AcceleratedScreen.java	Thu Jun 12 17:04:53 2014 -0400
@@ -43,12 +43,22 @@
         return 0L;
     }
 
-    public AcceleratedScreen(int[] attributes) throws GLException {
+    public AcceleratedScreen(int[] attributes) throws GLException, UnsatisfiedLinkError {
         initPlatformLibraries();
 
         int major[] = {0}, minor[]={0};
+        long nativeDisplay = platformGetNativeDisplay();
+        long nativeWindow = platformGetNativeWindow();
+
+        if (nativeDisplay == -1l) { // error condition
+            throw new GLException(0, "Could not get native display");
+        }
+        if (nativeWindow == -1l) { // error condition
+            throw new GLException(0, "Could not get native window");
+        }
+
         eglDisplay =
-                EGL.eglGetDisplay(platformGetNativeDisplay());
+                EGL.eglGetDisplay(nativeDisplay);
         if (eglDisplay == EGL.EGL_NO_DISPLAY) {
             throw new GLException(EGL.eglGetError(), "Could not get EGL display");
         }
@@ -71,7 +81,7 @@
 
         eglSurface =
                 EGL.eglCreateWindowSurface(eglDisplay, eglConfigs[0],
-                        platformGetNativeWindow(), null);
+                        nativeWindow, null);
         if (eglSurface == EGL.EGL_NO_SURFACE) {
             throw new GLException(EGL.eglGetError(), "Could not get EGL surface");
         }
@@ -92,12 +102,18 @@
         }
     }
 
-    protected boolean initPlatformLibraries() {
+    protected boolean initPlatformLibraries() throws UnsatisfiedLinkError{
         if (!initialized) {
             glesLibraryHandle = ls.dlopen("libGLESv2.so",
                     LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL);
+            if (glesLibraryHandle == 0l) {
+                throw new UnsatisfiedLinkError("Error loading libGLESv2.so");
+            }
             eglLibraryHandle = ls.dlopen("libEGL.so",
                     LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL);
+            if (eglLibraryHandle == 0l) {
+                throw new UnsatisfiedLinkError("Error loading libEGL.so");
+            }
             initialized = true;
         }
         return true;
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatform.java	Thu Jun 12 10:43:40 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatform.java	Thu Jun 12 17:04:53 2014 -0400
@@ -81,7 +81,7 @@
     }
 
     public synchronized AcceleratedScreen getAcceleratedScreen(int[] attributes)
-            throws GLException {
+            throws GLException, UnsatisfiedLinkError {
         if (accScreen == null) {
             accScreen = new AcceleratedScreen(attributes);
         }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/mx6/MX6AcceleratedScreen.java	Thu Jun 12 10:43:40 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/mx6/MX6AcceleratedScreen.java	Thu Jun 12 17:04:53 2014 -0400
@@ -45,13 +45,21 @@
     @Override
     protected long platformGetNativeWindow() {
         fbCreateWindowHandle = ls.dlsym(getEGLHandle(), "fbCreateWindow");
-        return _platformGetNativeWindow(fbCreateWindowHandle, cachedNativeDisplay);
+        if (fbCreateWindowHandle == 0l) {
+            return -1l;
+        } else {
+            return _platformGetNativeWindow(fbCreateWindowHandle, cachedNativeDisplay);
+        }
     }
 
     @Override
     protected long platformGetNativeDisplay() {
         fbGetDisplayByIndexHandle = ls.dlsym(getEGLHandle(), "fbGetDisplayByIndex");
-        cachedNativeDisplay = _platformGetNativeDisplay(fbGetDisplayByIndexHandle);
-        return cachedNativeDisplay;
+        if (fbGetDisplayByIndexHandle == 0l) {
+            return -1l;
+        } else {
+            cachedNativeDisplay = _platformGetNativeDisplay(fbGetDisplayByIndexHandle);
+            return cachedNativeDisplay;
+        }
     }
 }
--- a/modules/graphics/src/main/java/com/sun/prism/es2/MonocleGLFactory.java	Thu Jun 12 10:43:40 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/es2/MonocleGLFactory.java	Thu Jun 12 17:04:53 2014 -0400
@@ -32,6 +32,7 @@
 import com.sun.glass.ui.monocle.EGL;
 import com.sun.glass.ui.monocle.NativeScreen;
 import com.sun.glass.ui.monocle.AcceleratedScreen;
+import com.sun.prism.impl.PrismSettings;
 
 class MonocleGLFactory extends GLFactory {
 
@@ -109,6 +110,12 @@
 
                     attrArr);
 
+            // If the native platform can't provide hardware accelerated rendering,
+            // accScreen can be null
+            if (accScreen == null) {
+                return false;
+            }
+
             accScreen.enableRendering(true);
 
             nativeCtxInfo = nPopulateNativeCtxInfo(accScreen.getGLHandle());
@@ -123,7 +130,14 @@
                 return true;
             }
         } catch (GLException e) {
-            e.printStackTrace();
+            if (PrismSettings.verbose) {
+                e.printStackTrace();
+            }
+            return false;
+        } catch (UnsatisfiedLinkError e) {
+            if (PrismSettings.verbose) {
+                e.printStackTrace();
+            }
             return false;
         }
     }