Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEWT: Adding support for BCM VC IV (Broadcom VideoCodec 4) and Linux …
…console mouse tracker Rasperry PI uses the 'BCM VC IV' GPU via console as it's default configuration. This driver enables direct support for JOGL/NEWT. Due to the lack of detection (TODO) users have to specify the Java property: -Dnativewindow.ws.name=jogamp.newt.driver.bcm.vc.iv - Autodetection should be included in 'NativeWindowFactory._getNativeWindowingType()' while adding a new TYPE: 'TYPE_BCM_VC_IV'. - Autodetection may need to detect whether an X11 Display runs and the installed EGL library uses it (instead of the default console one) This work is authored in coop w/ Xerxes Rånby <xerxes@zafena.se>!
- Loading branch information
Showing
11 changed files
with
934 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright 2012 JogAmp Community. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are | ||
* permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of | ||
* conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list | ||
* of conditions and the following disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* The views and conclusions contained in the software and documentation are those of the | ||
* authors and should not be interpreted as representing official policies, either expressed | ||
* or implied, of JogAmp Community. | ||
*/ | ||
|
||
package jogamp.newt.driver.bcm.vc.iv; | ||
|
||
import javax.media.nativewindow.AbstractGraphicsDevice; | ||
import javax.media.nativewindow.NativeWindowException; | ||
|
||
import jogamp.newt.DisplayImpl; | ||
import jogamp.newt.NEWTJNILibLoader; | ||
import jogamp.opengl.egl.EGL; | ||
import jogamp.opengl.egl.EGLDisplayUtil; | ||
|
||
public class Display extends DisplayImpl { | ||
static { | ||
NEWTJNILibLoader.loadNEWT(); | ||
|
||
if (!Display.initIDs()) { | ||
throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); | ||
} | ||
if (!Screen.initIDs()) { | ||
throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); | ||
} | ||
if (!Window.initIDs()) { | ||
throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); | ||
} | ||
} | ||
|
||
public static void initSingleton() { | ||
// just exist to ensure static init has been run | ||
} | ||
|
||
|
||
public Display() { | ||
} | ||
|
||
protected void createNativeImpl() { | ||
// FIXME: map name to EGL_*_DISPLAY | ||
aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); | ||
} | ||
|
||
protected void closeNativeImpl() { | ||
aDevice.close(); | ||
} | ||
|
||
protected void dispatchMessagesNative() { | ||
DispatchMessages(); | ||
} | ||
|
||
protected static native boolean initIDs(); | ||
private native void DispatchMessages(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright 2012 JogAmp Community. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are | ||
* permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of | ||
* conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list | ||
* of conditions and the following disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* The views and conclusions contained in the software and documentation are those of the | ||
* authors and should not be interpreted as representing official policies, either expressed | ||
* or implied, of JogAmp Community. | ||
*/ | ||
|
||
package jogamp.newt.driver.bcm.vc.iv; | ||
|
||
import javax.media.nativewindow.DefaultGraphicsScreen; | ||
import javax.media.nativewindow.util.Dimension; | ||
import javax.media.nativewindow.util.Point; | ||
|
||
import jogamp.newt.ScreenImpl; | ||
|
||
public class Screen extends ScreenImpl { | ||
static { | ||
Display.initSingleton(); | ||
} | ||
|
||
public Screen() { | ||
} | ||
|
||
protected void createNativeImpl() { | ||
aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); | ||
initNative(); | ||
} | ||
|
||
protected void closeNativeImpl() { } | ||
|
||
protected int validateScreenIndex(int idx) { | ||
return 0; // only one screen available | ||
} | ||
|
||
protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { | ||
virtualOrigin.setX(0); | ||
virtualOrigin.setY(0); | ||
virtualSize.setWidth(cachedWidth); | ||
virtualSize.setHeight(cachedHeight); | ||
} | ||
|
||
protected void setScreenSize(int width, int height) { | ||
cachedWidth = width; | ||
cachedHeight = height; | ||
} | ||
|
||
private static int cachedWidth = 0; | ||
private static int cachedHeight = 0; | ||
|
||
protected static native boolean initIDs(); | ||
protected native void initNative(); | ||
} |
149 changes: 149 additions & 0 deletions
149
src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/** | ||
* Copyright 2012 JogAmp Community. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are | ||
* permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of | ||
* conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list | ||
* of conditions and the following disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* The views and conclusions contained in the software and documentation are those of the | ||
* authors and should not be interpreted as representing official policies, either expressed | ||
* or implied, of JogAmp Community. | ||
*/ | ||
|
||
package jogamp.newt.driver.bcm.vc.iv; | ||
|
||
import javax.media.nativewindow.AbstractGraphicsConfiguration; | ||
import javax.media.nativewindow.GraphicsConfigurationFactory; | ||
import javax.media.nativewindow.NativeWindowException; | ||
import javax.media.nativewindow.VisualIDHolder; | ||
import javax.media.nativewindow.util.Insets; | ||
import javax.media.nativewindow.util.Point; | ||
|
||
import jogamp.newt.WindowImpl; | ||
import jogamp.newt.driver.linux.LinuxMouseTracker; | ||
|
||
public class Window extends WindowImpl { | ||
private static final String WINDOW_CLASS_NAME = "NewtWindow"; | ||
|
||
static { | ||
Display.initSingleton(); | ||
} | ||
|
||
public Window() { | ||
} | ||
|
||
protected void createNativeImpl() { | ||
if(0!=getParentWindowHandle()) { | ||
throw new RuntimeException("Window parenting not supported (yet)"); | ||
} | ||
final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( | ||
capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); | ||
if (null == cfg) { | ||
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); | ||
} | ||
setGraphicsConfiguration(cfg); | ||
|
||
nativeWindowHandle = CreateWindow(getWidth(), getHeight()); | ||
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"); | ||
} | ||
windowHandleClose = nativeWindowHandle; | ||
addWindowListener(LinuxMouseTracker.getSingleton()); | ||
focusChanged(false, true); | ||
} | ||
|
||
protected void closeNativeImpl() { | ||
removeWindowListener(LinuxMouseTracker.getSingleton()); | ||
|
||
if(0!=windowHandleClose) { | ||
CloseWindow(windowHandleClose, windowUserData); | ||
windowUserData=0; | ||
} | ||
} | ||
|
||
protected void requestFocusImpl(boolean reparented) { | ||
focusChanged(false, true); | ||
} | ||
|
||
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)); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
protected Point getLocationOnScreenImpl(int x, int y) { | ||
return new Point(x,y); | ||
} | ||
|
||
protected void updateInsetsImpl(Insets insets) { | ||
// nop .. | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// Internals only | ||
// | ||
|
||
protected static native boolean initIDs(); | ||
private native long CreateWindow(int width, int height); | ||
private native long RealizeWindow(long eglWindowHandle); | ||
private native int CloseWindow(long eglWindowHandle, long userData); | ||
private native void setVisible0(long eglWindowHandle, boolean visible); | ||
private native void setSize0(long eglWindowHandle, int width, int height); | ||
private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); | ||
|
||
private void windowCreated(long userData) { | ||
windowUserData=userData; | ||
} | ||
|
||
private long nativeWindowHandle; | ||
private long windowHandleClose; | ||
private long windowUserData; | ||
} |
Oops, something went wrong.