changeset 7258:9a539116a956

RT-36960 [Monocle] A switch to change between frame buffers Reviewed-by: kselle
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Thu, 12 Jun 2014 15:11:35 +0300
parents 892d13f9dbf5
children 286217918102
files modules/graphics/src/main/java/com/sun/glass/ui/monocle/dispman/DispmanAcceleratedScreen.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/FBDevScreen.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/LinuxFrameBuffer.java modules/graphics/src/main/native-glass/monocle/dispman/DispmanAcceleratedScreen.c
diffstat 4 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/dispman/DispmanAcceleratedScreen.java	Thu Jun 12 13:33:54 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/dispman/DispmanAcceleratedScreen.java	Thu Jun 12 15:11:35 2014 +0300
@@ -28,16 +28,25 @@
 import com.sun.glass.ui.monocle.AcceleratedScreen;
 import com.sun.glass.ui.monocle.GLException;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public class DispmanAcceleratedScreen extends AcceleratedScreen {
 
     public DispmanAcceleratedScreen(int[] attributes) throws GLException {
         super(attributes);
     }
 
-    private native long _platformGetNativeWindow();
+    private native long _platformGetNativeWindow(int displayID, int layerID);
 
     @Override
     protected long platformGetNativeWindow() {
-        return _platformGetNativeWindow();
+        int displayID = AccessController.doPrivileged(
+                (PrivilegedAction<Integer>)
+                        () -> Integer.getInteger("dispman.display", 0 /* LCD */));
+        int layerID = AccessController.doPrivileged(
+                (PrivilegedAction<Integer>)
+                        () -> Integer.getInteger("dispman.layer", 1));
+        return _platformGetNativeWindow(displayID, layerID);
     }
 }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/FBDevScreen.java	Thu Jun 12 13:33:54 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/FBDevScreen.java	Thu Jun 12 15:11:35 2014 +0300
@@ -39,6 +39,8 @@
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 public class FBDevScreen implements NativeScreen {
 
@@ -50,10 +52,14 @@
     private int consoleCursorBlink;
     private Framebuffer fb;
     private LinuxFrameBuffer linuxFB;
+    private final String fbDevPath;
 
     public FBDevScreen() {
+        fbDevPath = AccessController.doPrivileged(
+                (PrivilegedAction<String>) () ->
+                        System.getProperty("monocle.screen.fb", "/dev/fb0"));
         try {
-            linuxFB = new LinuxFrameBuffer("/dev/fb0");
+            linuxFB = new LinuxFrameBuffer(fbDevPath);
             nativeHandle = 1l;
             nativeFormat = Pixels.Format.BYTE_BGRA_PRE;
             try {
@@ -109,7 +115,7 @@
 
     private void openFBDev() throws IOException {
         if (mappedFB == null) {
-            Path fbdevPath = FileSystems.getDefault().getPath("/dev/fb0");
+            Path fbdevPath = FileSystems.getDefault().getPath(fbDevPath);
             fbdev = FileChannel.open(fbdevPath, StandardOpenOption.WRITE);
         }
     }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/LinuxFrameBuffer.java	Thu Jun 12 13:33:54 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/LinuxFrameBuffer.java	Thu Jun 12 15:11:35 2014 +0300
@@ -49,7 +49,7 @@
     public LinuxFrameBuffer(String devNode) throws IOException {
         system = LinuxSystem.getLinuxSystem();
         FBIO_WAITFORVSYNC = system.IOW('F', 0x20, 4);
-        fd = system.open("/dev/fb0", LinuxSystem.O_RDWR);
+        fd = system.open(devNode, LinuxSystem.O_RDWR);
         if (fd == -1) {
             throw new IOException(system.getErrorMessage());
         }
--- a/modules/graphics/src/main/native-glass/monocle/dispman/DispmanAcceleratedScreen.c	Thu Jun 12 13:33:54 2014 +0200
+++ b/modules/graphics/src/main/native-glass/monocle/dispman/DispmanAcceleratedScreen.c	Thu Jun 12 15:11:35 2014 +0300
@@ -36,7 +36,7 @@
 #endif /* USE_DISPMAN */
 
 JNIEXPORT jlong JNICALL Java_com_sun_glass_ui_monocle_dispman_DispmanAcceleratedScreen__1platformGetNativeWindow
-    (JNIEnv *env, jobject obj) {
+    (JNIEnv *env, jobject obj, jint displayID, jint layerID) {
 
 #ifdef USE_DISPMAN
 
@@ -53,7 +53,7 @@
 
     dispmanWindow = (EGL_DISPMANX_WINDOW_T *)calloc(sizeof(EGL_DISPMANX_WINDOW_T), 1);
 
-    display = (*wr_vc_dispmanx_display_open)(0 /* LCD */);
+    display = (*wr_vc_dispmanx_display_open)(displayID);
     if (display == 0) {
         fprintf(stderr, "Dispman: Cannot open display\n");
         return 0;
@@ -84,7 +84,7 @@
     element = (*wr_vc_dispmanx_element_add)(
                   update,
                   display,
-                  1 /*layer*/,
+                  layerID,
                   &dst,
                   0 /*src*/,
                   &src,