diff options
author | Sven Gothel <[email protected]> | 2014-01-09 20:45:28 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-09 20:45:28 +0100 |
commit | 4e9fb8d0fd1b73c592840d6ba34b91da5cca9c18 (patch) | |
tree | 3c3b5ab9315b8439cf859f18fcbd9e014062875e /src | |
parent | c828726693038011cce502eb95120ce3a7573732 (diff) |
NEWT Rasp.Pi: Add Support for multiple Windows, dynamic set size and position
Impl. manages up-to 32 windows (BCM layer elements) - dunno whether this is a proper value.
Note: Layer 2000 is reserved for out PointerIcon.
Removed 'dead code'.
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 78 | ||||
-rw-r--r-- | src/newt/native/bcm_vc_iv.c | 82 |
2 files changed, 72 insertions, 88 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index c05d8d1e8..e91c67813 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -38,6 +38,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntBitfield; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.event.MouseEvent; @@ -57,6 +58,9 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { linuxMouseTracker = LinuxMouseTracker.getSingleton(); linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton(); + layer = -1; + nativeWindowHandle = 0; + windowHandleClose = 0; } @Override @@ -64,6 +68,26 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + synchronized( layerSync ) { + if( layerCount >= MAX_LAYERS ) { + throw new RuntimeException("Max windows reached: "+layerCount+" ( "+MAX_LAYERS+" )"); + } + for(int i=0; 0 > layer && i<MAX_LAYERS; i++) { + if( !usedLayers.get(nextLayer) ) { + layer = nextLayer; + usedLayers.put(layer, true); + layerCount++; + } + nextLayer++; + if( MAX_LAYERS == nextLayer ) { + nextLayer=0; + } + } + // System.err.println("XXX.Open capacity "+usedLayers.capacity()+", count "+usedLayers.getBitCount()); + } + if( 0 > layer ) { + throw new InternalError("Could not find a free layer: count "+layerCount+", max "+MAX_LAYERS); + } final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -85,12 +109,11 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(), + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } - setVisible0(nativeWindowHandle, false); setWindowHandle(nativeWindowHandle); if (0 == getWindowHandle()) { throw new NativeWindowException("Error native Window Handle is null"); @@ -115,6 +138,13 @@ public class WindowDriver extends WindowImpl { } eglDevice.close(); + + synchronized( layerSync ) { + usedLayers.put(layer, false); + layerCount--; + layer = -1; + // System.err.println("XXX.Close capacity "+usedLayers.capacity()+", count "+usedLayers.getBitCount()); + } } @Override @@ -124,35 +154,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=nativeWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(nativeWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(nativeWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - + reconfigure0(nativeWindowHandle, x, y, width, height, flags); return true; } @@ -196,13 +198,17 @@ public class WindowDriver extends WindowImpl { private final LinuxEventDeviceTracker linuxEventDeviceTracker; protected static native boolean initIDs(); - private native long CreateWindow0(long bcmDisplay, int x, int y, int width, int height, boolean opaque, int alphaBits); + private native long CreateWindow0(long bcmDisplay, int layer, int x, int y, int width, int height, boolean opaque, int alphaBits); private native void CloseWindow0(long bcmDisplay, long eglWindowHandle); - private native void setVisible0(long eglWindowHandle, boolean visible); - private native void setPos0(long eglWindowHandle, int x, int y); - private native void setSize0(long eglWindowHandle, int width, int height); - private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); + private native void reconfigure0(long eglWindowHandle, int x, int y, int width, int height, int flags); + private int layer; private long nativeWindowHandle; private long windowHandleClose; + + private static int nextLayer = 0; + private static int layerCount = 0; + private static final int MAX_LAYERS = 32; + private static final IntBitfield usedLayers = new IntBitfield(MAX_LAYERS); + private static final Object layerSync = new Object(); } diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index ea225772f..3a802650a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -347,7 +347,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow0 - (JNIEnv *env, jobject obj, jlong display, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) + (JNIEnv *env, jobject obj, jlong display, jint layer, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; @@ -356,13 +356,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin if( 0 == display ) { return; } - dst_rect.x = 0; - dst_rect.y = 0; + dst_rect.x = x; + dst_rect.y = y; dst_rect.width = width; dst_rect.height = height; - src_rect.x = x; - src_rect.y = y; + src_rect.x = 0; + src_rect.y = 0; src_rect.width = width << 16; src_rect.height = height << 16; @@ -381,22 +381,20 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; - DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d\n", - (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits); - - DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); - DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, - 0/*layer*/, &dst_rect, 0/*src*/, - &src_rect, DISPMANX_PROTECTION_NONE, - &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d, layer %d\n", + (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits, layer); BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T)); - p->handle = dispman_element; - p->layer = 0; + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + p->layer = layer; p->x = x; p->y = y; p->width = width; p->height = height; + p->handle = vc_dispmanx_element_add ( dispman_update, dispman_display, + p->layer, &dst_rect, 0/*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); vc_dispmanx_update_submit_sync( dispman_update ); @@ -427,56 +425,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindo free( p ); } -/* - * Class: jogamp_newt_driver_bcm_vc_iv_WindowDriver - * Method: setVisible0 - * Signature: (JJZ)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setVisible0 - (JNIEnv *env, jobject obj, jlong window, jboolean visible) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScreen0 - (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0 - (JNIEnv *env, jobject obj, jlong window, jint x, jint y) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_reconfigure0 + (JNIEnv *env, jobject obj, jlong window, jint x, jint y, jint width, jint height, jint flags) { BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; if( NULL == p || 0 == p->handle ) { return; } + /*** + int isVisible = !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; + ... + see X11Window.c + */ + + int posChanged = p->x != x || p->y != y; + int sizeChanged = p->width != width || p->height != height; p->x = x; p->y = y; - - DBG_PRINT( "BCM.Display Window.Pos %p, element %p - %d/%d %dx%d\n", - p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); - - bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); -} - - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 - (JNIEnv *env, jobject obj, jlong window, jint width, jint height) -{ - BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; - - if( NULL == p || 0 == p->handle ) { - return; - } p->width = width; p->height = height; - DBG_PRINT( "BCM.Display Window.Resize %p, element %p - %d/%d %dx%d\n", + DBG_PRINT( "BCM.Display Window.Reconfig %p, element %p - %d/%d %dx%d\n", p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + if( posChanged ) { + (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); + } + if( sizeChanged ) { + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + } } - |