changeset 3786:8af9dc9dae1c

RT-30722 System property prism.glBufferSize sets color depth. Options are: 16, 24 or the default 32.
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Mon, 03 Jun 2013 12:49:39 +0300
parents c51b01afa79b
children fbf4a8a33a98
files prism-es2-native/src/eglfb/eglUtils.c prism-es2/src/com/sun/prism/es2/GLPixelFormat.java
diffstat 2 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/prism-es2-native/src/eglfb/eglUtils.c	Mon Jun 03 12:48:25 2013 +0300
+++ b/prism-es2-native/src/eglfb/eglUtils.c	Mon Jun 03 12:49:39 2013 +0300
@@ -134,14 +134,25 @@
 
     // NOTE: EGL_TRANSPARENT_TYPE ?
 
-    eglAttrs[index++] = EGL_RED_SIZE;
-    eglAttrs[index++] = attrs[RED_SIZE];
-    eglAttrs[index++] = EGL_GREEN_SIZE;
-    eglAttrs[index++] = attrs[GREEN_SIZE];
-    eglAttrs[index++] = EGL_BLUE_SIZE;
-    eglAttrs[index++] = attrs[BLUE_SIZE];
-    eglAttrs[index++] = EGL_ALPHA_SIZE;
-    eglAttrs[index++] = attrs[ALPHA_SIZE];
+    if (attrs[RED_SIZE] == 5 && attrs[GREEN_SIZE] == 6
+            && attrs[BLUE_SIZE] == 5 && attrs[ALPHA_SIZE] == 0) {
+        // Optimization for Raspberry Pi model B. Even though the result
+        // of setting EGL_BUFFER_SIZE to 16 should be the same as setting
+        // component sizes separately, we get less per-frame overhead if we
+        // only set EGL_BUFFER_SIZE.
+        eglAttrs[index++] = EGL_BUFFER_SIZE;
+        eglAttrs[index++] = 16;
+    } else {
+        eglAttrs[index++] = EGL_RED_SIZE;
+        eglAttrs[index++] = attrs[RED_SIZE];
+        eglAttrs[index++] = EGL_GREEN_SIZE;
+        eglAttrs[index++] = attrs[GREEN_SIZE];
+        eglAttrs[index++] = EGL_BLUE_SIZE;
+        eglAttrs[index++] = attrs[BLUE_SIZE];
+        eglAttrs[index++] = EGL_ALPHA_SIZE;
+        eglAttrs[index++] = attrs[ALPHA_SIZE];
+    }
+
     eglAttrs[index++] = EGL_DEPTH_SIZE;
     eglAttrs[index++] = attrs[DEPTH_SIZE];
     eglAttrs[index++] = EGL_RENDERABLE_TYPE;
--- a/prism-es2/src/com/sun/prism/es2/GLPixelFormat.java	Mon Jun 03 12:48:25 2013 +0300
+++ b/prism-es2/src/com/sun/prism/es2/GLPixelFormat.java	Mon Jun 03 12:49:39 2013 +0300
@@ -37,12 +37,14 @@
     final private long nativeScreen;
     private long nativePFInfo;
     private static int defaultDepthSize;
+    private static int defaultBufferSize;
 
     static {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
 
             public Void run() {
                defaultDepthSize = Integer.getInteger("egl.depthSize", 24);
+               defaultBufferSize = Integer.getInteger("prism.glBufferSize", 32);
                 return null;
             }
         });
@@ -93,7 +95,23 @@
             onScreen = true;
             doubleBuffer = true;
             depthSize = defaultDepthSize;
-            redSize = greenSize = blueSize = alphaSize = 8;
+            switch (defaultBufferSize) {
+                case 32:
+                    redSize = greenSize = blueSize = alphaSize = 8;
+                    break;
+                case 24:
+                    redSize = greenSize = blueSize = 8;
+                    alphaSize = 0;
+                    break;
+                case 16:
+                    redSize = blueSize = 5;
+                    greenSize = 6;
+                    alphaSize = 0;
+                    break;
+                default:
+                    throw new IllegalArgumentException("color buffer size "
+                            + defaultBufferSize + " not supported");
+            }
         }
 
         boolean isOnScreen() {