summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-09 18:44:35 +0100
committerSven Gothel <[email protected]>2014-01-09 18:44:35 +0100
commitbf0e93260dbd6cb8b6ee0cd10d81341906e62da9 (patch)
treebfba843071f6976247ef6f19595bfbdc4377fde4
parent2b899a55e365aa03aeb234187600526777c1a9ac (diff)
Bug 676 - Add support for native Mouse Pointer rendering (Rasp.-Pi.)
- Utilizing layer element 2000 for PointerIcon - Using NEWT PointerIcon code - Using MouseListener to update PointerIcon position - FIXME: Check whether we shall intercept sendMouseEvent directly (lag) Misc: - Properly open, assign and close the BCM display handle - Properly destroy the window (BCM element) - Prepare for multiple windows, set position and size
-rw-r--r--make/scripts/tests.sh6
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java131
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java78
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java2
-rw-r--r--src/newt/native/bcm_vc_iv.c325
-rw-r--r--src/newt/native/bcm_vc_iv.h125
7 files changed, 620 insertions, 59 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 55973eb12..c1cdaeb5a 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -229,7 +229,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer"
- #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon"
+ D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon"
#D_ARGS="-Djogl.debug.JPEGImage"
#D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser"
#X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false"
@@ -323,9 +323,9 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
-testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $*
#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
index d8d93f123..3d563d88f 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
@@ -28,15 +28,28 @@
package jogamp.newt.driver.bcm.vc.iv;
+import java.net.URLConnection;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.util.PixelFormat;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.PNGPixelRect;
import jogamp.newt.DisplayImpl;
import jogamp.newt.NEWTJNILibLoader;
+import jogamp.newt.PointerIconImpl;
+import jogamp.newt.driver.linux.LinuxMouseTracker;
import jogamp.opengl.egl.EGL;
import jogamp.opengl.egl.EGLDisplayUtil;
public class DisplayDriver extends DisplayImpl {
+ static final PNGPixelRect defaultPointerIconImage;
+
static {
NEWTJNILibLoader.loadNEWT();
@@ -49,6 +62,18 @@ public class DisplayDriver extends DisplayImpl {
if (!WindowDriver.initIDs()) {
throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs");
}
+
+ PNGPixelRect image = null;
+ if( DisplayImpl.isPNGUtilAvailable() ) {
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(DisplayDriver.class, new String[] { "newt/data/pointer-grey-alpha-16x24.png" } );
+ try {
+ final URLConnection urlConn = res.resolve(0);
+ image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ defaultPointerIconImage = image;
}
public static void initSingleton() {
@@ -57,25 +82,127 @@ public class DisplayDriver extends DisplayImpl {
public DisplayDriver() {
+ bcmHandle = 0;
+ activePointerIcon = 0;
+ activePointerIconVisible = false;
}
@Override
protected void createNativeImpl() {
// FIXME: map name to EGL_*_DISPLAY
+ bcmHandle = OpenBCMDisplay0();
aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+
+ defaultPointerIcon = (PointerIconImpl) createPointerIcon(defaultPointerIconImage, 0, 0);
+ if( DEBUG_POINTER_ICON ) {
+ System.err.println("Display.PointerIcon.createDefault: "+defaultPointerIcon);
+ }
+ if( null != defaultPointerIcon ) {
+ final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton();
+ setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY());
+ }
}
+ private PointerIconImpl defaultPointerIcon = null;
@Override
protected void closeNativeImpl(AbstractGraphicsDevice aDevice) {
aDevice.close();
+ CloseBCMDisplay0(bcmHandle);
+ bcmHandle = 0;
}
+ /* pp */ final long getBCMHandle() { return bcmHandle; }
+
@Override
protected void dispatchMessagesNative() {
- DispatchMessages();
+ DispatchMessages0();
+ }
+
+ // @Override
+ // public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; }
+
+ @Override
+ protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) {
+ return CreatePointerIcon(bcmHandle, pixels, width, height, hotX, hotY);
+ }
+
+ @Override
+ protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) {
+ DestroyPointerIcon0(piHandle);
+ }
+
+ /* pp */ void setPointerIconActive(long piHandle, final int x, final int y) {
+ synchronized(pointerIconSync) {
+ if( DEBUG_POINTER_ICON ) {
+ System.err.println("Display.PointerIcon.set.0: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> "+toHexString(piHandle));
+ }
+ if( 0 != activePointerIcon && activePointerIconVisible ) {
+ SetPointerIcon0(bcmHandle, activePointerIcon, false, x, y);
+ }
+ if( 0 == piHandle && null != defaultPointerIcon ) {
+ piHandle = defaultPointerIcon.getHandle();
+ }
+ if( 0 != piHandle ) {
+ SetPointerIcon0(bcmHandle, piHandle, true, x, y);
+ activePointerIconVisible = true;
+ } else {
+ activePointerIconVisible = false;
+ }
+ activePointerIcon = piHandle;
+ if( DEBUG_POINTER_ICON ) {
+ System.err.println("Display.PointerIcon.set.X: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"]");
+ }
+ }
+ }
+ /* pp */ void setActivePointerIconVisible(final boolean visible, final int x, final int y) {
+ synchronized(pointerIconSync) {
+ if( DEBUG_POINTER_ICON ) {
+ System.err.println("Display.PointerIcon.visible: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> visible "+visible);
+ }
+ if( activePointerIconVisible != visible ) {
+ if( 0 != activePointerIcon ) {
+ SetPointerIcon0(bcmHandle, activePointerIcon, visible, x, y);
+ }
+ activePointerIconVisible = visible;
+ }
+ }
+ }
+ /* pp */ void moveActivePointerIcon(final int x, final int y) {
+ synchronized(pointerIconSync) {
+ if( DEBUG_POINTER_ICON ) {
+ System.err.println("Display.PointerIcon.move: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"], "+x+"/"+y);
+ }
+ if( 0 != activePointerIcon && activePointerIconVisible ) {
+ MovePointerIcon0(activePointerIcon, x, y);
+ }
+ }
}
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
protected static native boolean initIDs();
- private native void DispatchMessages();
+ private static native long OpenBCMDisplay0();
+ private static native void CloseBCMDisplay0(long handle);
+
+ private static long CreatePointerIcon(long bcmHandle, Buffer pixels, int width, int height, int hotX, int hotY) {
+ final boolean pixels_is_direct = Buffers.isDirect(pixels);
+ return CreatePointerIcon0(pixels_is_direct ? pixels : Buffers.getArray(pixels),
+ pixels_is_direct ? Buffers.getDirectBufferByteOffset(pixels) : Buffers.getIndirectBufferByteOffset(pixels),
+ pixels_is_direct,
+ width, height, hotX, hotY);
+ }
+ private static native long CreatePointerIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY);
+ private static native void DestroyPointerIcon0(long handle);
+ private static native void SetPointerIcon0(long bcmHandle, long handle, boolean enable, int x, int y);
+ private static native void MovePointerIcon0(long handle, int x, int y);
+
+ private static native void DispatchMessages0();
+
+ private long bcmHandle;
+ private long activePointerIcon;
+ private boolean activePointerIconVisible;
+ private final Object pointerIconSync = new Object();
}
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 4d4977776..5109d0fbb 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
@@ -39,7 +39,10 @@ import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.event.MouseAdapter;
+import jogamp.newt.PointerIconImpl;
import jogamp.newt.WindowImpl;
import jogamp.newt.driver.linux.LinuxEventDeviceTracker;
import jogamp.newt.driver.linux.LinuxMouseTracker;
@@ -53,6 +56,8 @@ public class WindowDriver extends WindowImpl {
}
public WindowDriver() {
+ linuxMouseTracker = LinuxMouseTracker.getSingleton();
+ linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton();
}
@Override
@@ -60,9 +65,12 @@ public class WindowDriver extends WindowImpl {
if(0!=getParentWindowHandle()) {
throw new RuntimeException("Window parenting not supported (yet)");
}
+ final ScreenDriver screen = (ScreenDriver) getScreen();
+ final DisplayDriver display = (DisplayDriver) screen.getDisplay();
+
// Create own screen/device resource instance allowing independent ownership,
// while still utilizing shared EGL resources.
- final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
+ final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice();
final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID());
final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex());
@@ -78,7 +86,8 @@ public class WindowDriver extends WindowImpl {
chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque());
}
setGraphicsConfiguration(cfg);
- nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits());
+ nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(),
+ chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits());
if (nativeWindowHandle == 0) {
throw new NativeWindowException("Error creating egl window: "+cfg);
}
@@ -88,21 +97,37 @@ public class WindowDriver extends WindowImpl {
throw new NativeWindowException("Error native Window Handle is null");
}
windowHandleClose = nativeWindowHandle;
- addWindowListener(LinuxMouseTracker.getSingleton());
- addWindowListener(LinuxEventDeviceTracker.getSingleton());
+
+ addWindowListener(linuxEventDeviceTracker);
+ addWindowListener(linuxMouseTracker);
+ addMouseListener(mousePointerTracker);
focusChanged(false, true);
}
+ final MouseListener mousePointerTracker = new MouseAdapter() {
+ @Override
+ public void mouseMoved(com.jogamp.newt.event.MouseEvent e) {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ display.moveActivePointerIcon(e.getX(), e.getY());
+ }
+
+ @Override
+ public void mouseDragged(com.jogamp.newt.event.MouseEvent e) {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ display.moveActivePointerIcon(e.getX(), e.getY());
+ }
+ };
@Override
protected void closeNativeImpl() {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice();
- removeWindowListener(LinuxMouseTracker.getSingleton());
- removeWindowListener(LinuxEventDeviceTracker.getSingleton());
+ removeMouseListener(mousePointerTracker);
+ removeWindowListener(linuxMouseTracker);
+ removeWindowListener(linuxEventDeviceTracker);
if(0!=windowHandleClose) {
- CloseWindow(windowHandleClose, windowUserData);
- windowUserData=0;
+ CloseWindow0(display.getBCMHandle(), windowHandleClose);
}
eglDevice.close();
@@ -157,23 +182,44 @@ public class WindowDriver extends WindowImpl {
// nop ..
}
+ /**
+ @Override
+ public final void sendMouseEvent(final short eventType, final int modifiers,
+ final int x, final int y, final short button, final float rotation) {
+ if( MouseEvent.MOUSE_MOVED == eventType ) {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ display.moveActivePointerIcon(x, y);
+ }
+ super.sendMouseEvent(eventType, modifiers, x, y, button, rotation);
+ } */
+
+ @Override
+ protected void setPointerIconImpl(final PointerIconImpl pi) {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY());
+ }
+
+ @Override
+ protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ display.setActivePointerIconVisible(pointerVisible, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY());
+ return true;
+ }
+
//----------------------------------------------------------------------
// Internals only
//
+ private final LinuxMouseTracker linuxMouseTracker;
+ private final LinuxEventDeviceTracker linuxEventDeviceTracker;
protected static native boolean initIDs();
- private native long CreateWindow(int width, int height, boolean opaque, int alphaBits);
- private native long RealizeWindow(long eglWindowHandle);
- private native int CloseWindow(long eglWindowHandle, long userData);
+ private native long CreateWindow0(long bcmDisplay, 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 void windowCreated(long userData) {
- windowUserData=userData;
- }
-
private long nativeWindowHandle;
private long windowHandleClose;
- private long windowUserData;
}
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
index 1e314b7f4..9d7b8931b 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
@@ -68,9 +68,14 @@ public class LinuxMouseTracker implements WindowListener {
private short buttonDown = 0;
private int old_x = 0;
private int old_y = 0;
+ private volatile int lastFocusedX = 0;
+ private volatile int lastFocusedY = 0;
private short old_buttonDown = 0;
private WindowImpl focusedWindow = null;
- private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller();
+ private final MouseDevicePoller mouseDevicePoller = new MouseDevicePoller();
+
+ public final int getLastX() { return lastFocusedX; }
+ public final int getLastY() { return lastFocusedY; }
@Override
public void windowResized(WindowEvent e) { }
@@ -179,10 +184,11 @@ public class LinuxMouseTracker implements WindowListener {
if( y >= focusedWindow.getScreen().getHeight() ) {
y = focusedWindow.getScreen().getHeight() - 1;
}
- int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY();
-
+ final int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY();
if(old_x != x || old_y != y) {
// mouse moved
+ lastFocusedX = wx;
+ lastFocusedY = wy;
focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 );
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
index 4d1388eec..391b8b19d 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
@@ -165,7 +165,7 @@ public class DisplayDriver extends DisplayImpl {
}
private static native long createPointerIcon0(long display, Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY);
- static native void destroyPointerIcon0(long display, long handle);
+ private static native void destroyPointerIcon0(long display, long handle);
/** X11 Window delete atom marker used on EDT */
private long windowDeleteAtom;
diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c
index f3474ee34..50f0c140a 100644
--- a/src/newt/native/bcm_vc_iv.c
+++ b/src/newt/native/bcm_vc_iv.c
@@ -39,15 +39,36 @@
#define VERBOSE_ON 1
#ifdef VERBOSE_ON
- #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__)
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
#else
#define DBG_PRINT(...)
#endif
+typedef struct {
+ DISPMANX_ELEMENT_HANDLE_T handle; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T)
+ int width; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T)
+ int height; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T)
+ int x;
+ int y;
+ int32_t layer;
+} BCM_ELEMENT_T;
+
+typedef struct {
+ DISPMANX_RESOURCE_HANDLE_T handle;
+ VC_IMAGE_TYPE_T type;
+ uint32_t native_image_handle;
+} BCM_RESOURCE_T;
+
+typedef struct {
+ BCM_ELEMENT_T element;
+ BCM_RESOURCE_T resource;
+ int hotX, hotY;
+} POINTER_ICON_T;
+
static jmethodID setScreenSizeID = NULL;
-static jmethodID windowCreatedID = NULL;
static jmethodID sizeChangedID = NULL;
+static jmethodID positionChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
@@ -64,11 +85,210 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initI
return JNI_TRUE;
}
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages
- (JNIEnv *env, jobject obj)
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_OpenBCMDisplay0
+ (JNIEnv *env, jclass clazz)
+{
+ DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
+ DBG_PRINT( "BCM.Display Open %p\n", (void*)(intptr_t)dispman_display);
+ return (jlong) (intptr_t) dispman_display;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CloseBCMDisplay0
+ (JNIEnv *env, jclass clazz, jlong display)
+{
+ DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display;
+ DBG_PRINT( "BCM.Display Close %p\n", (void*)(intptr_t)dispman_display);
+ vc_dispmanx_display_close( dispman_display );
+}
+
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages0
+ (JNIEnv *env, jclass clazz)
{
}
+static void bcm_moveTo(DISPMANX_ELEMENT_HANDLE_T element, uint32_t layer, int x, int y, int width, int height) {
+ VC_RECT_T src_rect;
+ VC_RECT_T dst_rect;
+ uint32_t change_flags = DISPMANX_ELEMENT_CHANGE_DEST_RECT | DISPMANX_ELEMENT_CHANGE_SRC_RECT;
+ DISPMANX_RESOURCE_HANDLE_T mask = 0;
+ DISPMANX_TRANSFORM_T transform = 0;
+
+ uint8_t opacity = 0; // NOP
+
+ dst_rect.x = x;
+ dst_rect.y = y;
+ dst_rect.width = width;
+ dst_rect.height = height;
+
+ src_rect.x = 0;
+ src_rect.y = 0;
+ src_rect.width = width << 16;
+ src_rect.height = height << 16;
+
+ DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
+ vc_dispmanx_element_change_attributes( dispman_update,
+ element,
+ change_flags,
+ layer,
+ opacity,
+ &dst_rect,
+ &src_rect,
+ mask,
+ transform );
+ vc_dispmanx_update_submit_sync( dispman_update );
+}
+
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CreatePointerIcon0
+ (JNIEnv *env, jclass clazz, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY)
+{
+ if( 0 == pixels ) {
+ return 0;
+ }
+ int32_t success = 0;
+ VC_RECT_T dst_rect;
+ VC_RECT_T src_rect;
+ int x = 0;
+ int y = 0;
+ int pitch = width * 4; // RGBA
+
+ const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ?
+ (*env)->GetDirectBufferAddress(env, pixels) :
+ (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) );
+
+ POINTER_ICON_T * p = calloc(1, sizeof(POINTER_ICON_T));
+ p->hotX = hotX;
+ p->hotY = hotY;
+ p->element.layer = 2000;
+ p->element.x = x;
+ p->element.y = y;
+ p->element.width = width;
+ p->element.height = height;
+ p->resource.type = VC_IMAGE_ARGB8888; /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */
+ p->resource.handle = vc_dispmanx_resource_create( p->resource.type,
+ width,
+ height,
+ &(p->resource.native_image_handle) );
+
+ dst_rect.x = x;
+ dst_rect.y = y;
+ dst_rect.width = width;
+ dst_rect.height = height;
+
+ vc_dispmanx_resource_write_data( p->resource.handle,
+ p->resource.type,
+ pitch,
+ (void*)(intptr_t)(pixelPtr + pixels_byte_offset),
+ &dst_rect );
+
+ if ( JNI_FALSE == pixels_is_direct ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT);
+ }
+
+ DBG_PRINT( "BCM.Display PointerIcon.Create PI %p, resource %p\n", p, (void*)(intptr_t)p->resource.handle);
+ return (jlong) (intptr_t) p;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DestroyPointerIcon0
+ (JNIEnv *env, jclass clazz, jlong handle)
+{
+ POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ;
+ if( 0 == p ) {
+ return;
+ }
+
+ DBG_PRINT( "BCM.Display PointerIcon.Destroy.0 PI %p, resource %p, element %p\n",
+ p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle);
+
+ if( 0 != p->element.handle ) {
+ DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
+ vc_dispmanx_element_remove( dispman_update, p->element.handle );
+ p->element.handle = 0;
+ vc_dispmanx_update_submit_sync( dispman_update );
+ }
+ if( 0 != p->resource.handle ) {
+ vc_dispmanx_resource_delete( p->resource.handle );
+ p->resource.handle = 0;
+ }
+ free( p );
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_SetPointerIcon0
+ (JNIEnv *env, jclass clazz, jlong display, jlong handle, jboolean enable, jint x, jint y)
+{
+ DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display;
+ POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ;
+ VC_RECT_T dst_rect;
+ VC_RECT_T src_rect;
+
+ if( 0 == dispman_display || NULL == p || 0 == p->resource.handle ) {
+ return;
+ }
+
+ DBG_PRINT( "BCM.Display PointerIcon.Set.0 %p, PI %p, resource %p, element %p - enable %d - %d/%d\n",
+ (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y);
+
+ if( enable ) {
+ if( 0 != p->element.handle ) {
+ return;
+ }
+
+ p->element.x = x;
+ p->element.y = y;
+ dst_rect.x = p->element.x - p->hotX;
+ dst_rect.y = p->element.y - p->hotY;
+ dst_rect.width = p->element.width;
+ dst_rect.height = p->element.height;
+
+ src_rect.x = 0;
+ src_rect.y = 0;
+ src_rect.width = p->element.width << 16;
+ src_rect.height = p->element.height << 16;
+
+ VC_DISPMANX_ALPHA_T dispman_alpha;
+ memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T));
+ dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ;
+ dispman_alpha.opacity = 0xFF;
+ dispman_alpha.mask = 0xFF;
+
+ DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
+ p->element.handle = vc_dispmanx_element_add ( dispman_update, dispman_display,
+ p->element.layer, &dst_rect,
+ p->resource.handle /*src*/,
+ &src_rect, DISPMANX_PROTECTION_NONE,
+ &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/);
+ vc_dispmanx_update_submit_sync( dispman_update );
+ } else {
+ // DISABLE
+ if( 0 == p->element.handle ) {
+ return;
+ }
+ p->element.x = x;
+ p->element.y = y;
+ DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
+ vc_dispmanx_element_remove( dispman_update, p->element.handle );
+ p->element.handle = 0;
+ vc_dispmanx_update_submit_sync( dispman_update );
+ }
+ DBG_PRINT( "BCM.Display PointerIcon.Set.X %p, PI %p, resource %p, element %p - enable %d - %d/%d\n",
+ (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y);
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_MovePointerIcon0
+ (JNIEnv *env, jclass clazz, jlong handle, jint x, jint y)
+{
+ POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ;
+
+ if( NULL == p || 0 == p->element.handle ) {
+ return;
+ }
+ DBG_PRINT( "BCM.Display PointerIcon.Move.0 PI %p, resource %p, element %p - %d/%d\n",
+ p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, x, y);
+ p->element.x = x;
+ p->element.y = y;
+ bcm_moveTo( p->element.handle, p->element.layer, p->element.x - p->hotX, p->element.y - p->hotY, p->element.width, p->element.height);
+}
+
/**
* Screen
*/
@@ -111,12 +331,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs
(JNIEnv *env, jclass clazz)
{
- windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
+ positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
- if (windowCreatedID == NULL ||
- sizeChangedID == NULL ||
+ if (sizeChangedID == NULL ||
+ positionChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL) {
DBG_PRINT( "initIDs failed\n" );
@@ -126,20 +346,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID
return JNI_TRUE;
}
-JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow
- (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits)
+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)
{
int32_t success = 0;
VC_RECT_T dst_rect;
VC_RECT_T src_rect;
+ if( 0 == display ) {
+ return;
+ }
dst_rect.x = 0;
dst_rect.y = 0;
dst_rect.width = width;
dst_rect.height = height;
- src_rect.x = 0;
- src_rect.y = 0;
+ src_rect.x = x;
+ src_rect.y = y;
src_rect.width = width << 16;
src_rect.height = height << 16;
@@ -156,37 +379,52 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin
dispman_alpha.mask = 0xFF;
}
- DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
+ 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*/);
- EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T));
- nativeWindowPtr->element = dispman_element;
- nativeWindowPtr->width = width;
- nativeWindowPtr->height = height;
+ BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T));
+ p->handle = dispman_element;
+ p->layer = 0;
+ p->x = x;
+ p->y = y;
+ p->width = width;
+ p->height = height;
vc_dispmanx_update_submit_sync( dispman_update );
(*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ?
- return (jlong) (intptr_t) nativeWindowPtr;
-}
+ DBG_PRINT( "BCM.Display Window.Create.X %p, element %p\n",
+ (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle);
-JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_RealizeWindow
- (JNIEnv *env, jobject obj, jlong window)
-{
- return (jlong) (intptr_t) 0;
+ return (jlong) (intptr_t) p;
}
-JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow
- (JNIEnv *env, jobject obj, jlong window, jlong juserData)
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow0
+ (JNIEnv *env, jobject obj, jlong display, jlong window)
{
- EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ;
- free( nativeWindowPtr );
- return 0;
+ DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display;
+ BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ;
+
+ DBG_PRINT( "BCM.Display Window.Close %p, element %p\n",
+ (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle);
+
+ if( 0 == dispman_display || NULL == p || 0 == p->handle ) {
+ return;
+ }
+ DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
+ vc_dispmanx_element_remove( dispman_update, p->handle );
+ p->handle = 0;
+ vc_dispmanx_update_submit_sync( dispman_update );
+ free( p );
}
/*
@@ -204,10 +442,41 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScr
{
}
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0
+ (JNIEnv *env, jobject obj, jlong window, jint x, jint y)
+{
+ BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ;
+
+ if( NULL == p || 0 == p->handle ) {
+ return;
+ }
+ 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)
{
- // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE);
+ 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",
+ 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);
}
diff --git a/src/newt/native/bcm_vc_iv.h b/src/newt/native/bcm_vc_iv.h
index b43483c10..f98700e4e 100644
--- a/src/newt/native/bcm_vc_iv.h
+++ b/src/newt/native/bcm_vc_iv.h
@@ -150,12 +150,6 @@ typedef struct {
} DISPMANX_CLAMP_T;
-typedef struct {
- DISPMANX_ELEMENT_HANDLE_T element;
- int width; /* This is necessary because dispmanx elements are not queriable. */
- int height;
-} EGL_DISPMANX_WINDOW_T;
-
typedef struct tag_VC_RECT_T {
int32_t x;
int32_t y;
@@ -163,6 +157,102 @@ typedef struct tag_VC_RECT_T {
int32_t height;
} VC_RECT_T;
+/* Types of image supported. */
+/* Please add any new types to the *end* of this list. Also update
+ * case_VC_IMAGE_ANY_xxx macros (below), and the vc_image_type_info table in
+ * vc_image/vc_image_helper.c.
+ */
+typedef enum
+{
+ VC_IMAGE_MIN = 0, //bounds for error checking
+
+ VC_IMAGE_RGB565 = 1,
+ VC_IMAGE_1BPP,
+ VC_IMAGE_YUV420,
+ VC_IMAGE_48BPP,
+ VC_IMAGE_RGB888,
+ VC_IMAGE_8BPP,
+ VC_IMAGE_4BPP, // 4bpp palettised image
+ VC_IMAGE_3D32, /* A separated format of 16 colour/light shorts followed by 16 z values */
+ VC_IMAGE_3D32B, /* 16 colours followed by 16 z values */
+ VC_IMAGE_3D32MAT, /* A separated format of 16 material/colour/light shorts followed by 16 z values */
+ VC_IMAGE_RGB2X9, /* 32 bit format containing 18 bits of 6.6.6 RGB, 9 bits per short */
+ VC_IMAGE_RGB666, /* 32-bit format holding 18 bits of 6.6.6 RGB */
+ VC_IMAGE_PAL4_OBSOLETE, // 4bpp palettised image with embedded palette
+ VC_IMAGE_PAL8_OBSOLETE, // 8bpp palettised image with embedded palette
+ VC_IMAGE_RGBA32, /* RGB888 with an alpha byte after each pixel */ /* xxx: isn't it BEFORE each pixel? */
+ VC_IMAGE_YUV422, /* a line of Y (32-byte padded), a line of U (16-byte padded), and a line of V (16-byte padded) */
+ VC_IMAGE_RGBA565, /* RGB565 with a transparent patch */
+ VC_IMAGE_RGBA16, /* Compressed (4444) version of RGBA32 */
+ VC_IMAGE_YUV_UV, /* VCIII codec format */
+ VC_IMAGE_TF_RGBA32, /* VCIII T-format RGBA8888 */
+ VC_IMAGE_TF_RGBX32, /* VCIII T-format RGBx8888 */
+ VC_IMAGE_TF_FLOAT, /* VCIII T-format float */
+ VC_IMAGE_TF_RGBA16, /* VCIII T-format RGBA4444 */
+ VC_IMAGE_TF_RGBA5551, /* VCIII T-format RGB5551 */
+ VC_IMAGE_TF_RGB565, /* VCIII T-format RGB565 */
+ VC_IMAGE_TF_YA88, /* VCIII T-format 8-bit luma and 8-bit alpha */
+ VC_IMAGE_TF_BYTE, /* VCIII T-format 8 bit generic sample */
+ VC_IMAGE_TF_PAL8, /* VCIII T-format 8-bit palette */
+ VC_IMAGE_TF_PAL4, /* VCIII T-format 4-bit palette */
+ VC_IMAGE_TF_ETC1, /* VCIII T-format Ericsson Texture Compressed */
+ VC_IMAGE_BGR888, /* RGB888 with R & B swapped */
+ VC_IMAGE_BGR888_NP, /* RGB888 with R & B swapped, but with no pitch, i.e. no padding after each row of pixels */
+ VC_IMAGE_BAYER, /* Bayer image, extra defines which variant is being used */
+ VC_IMAGE_CODEC, /* General wrapper for codec images e.g. JPEG from camera */
+ VC_IMAGE_YUV_UV32, /* VCIII codec format */
+ VC_IMAGE_TF_Y8, /* VCIII T-format 8-bit luma */
+ VC_IMAGE_TF_A8, /* VCIII T-format 8-bit alpha */
+ VC_IMAGE_TF_SHORT,/* VCIII T-format 16-bit generic sample */
+ VC_IMAGE_TF_1BPP, /* VCIII T-format 1bpp black/white */
+ VC_IMAGE_OPENGL,
+ VC_IMAGE_YUV444I, /* VCIII-B0 HVS YUV 4:4:4 interleaved samples */
+ VC_IMAGE_YUV422PLANAR, /* Y, U, & V planes separately (VC_IMAGE_YUV422 has them interleaved on a per line basis) */
+ VC_IMAGE_ARGB8888, /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */
+ VC_IMAGE_XRGB8888, /* 32bpp with 8bit unused at MS byte, with R, G, B (LS byte) */
+
+ VC_IMAGE_YUV422YUYV, /* interleaved 8 bit samples of Y, U, Y, V */
+ VC_IMAGE_YUV422YVYU, /* interleaved 8 bit samples of Y, V, Y, U */
+ VC_IMAGE_YUV422UYVY, /* interleaved 8 bit samples of U, Y, V, Y */
+ VC_IMAGE_YUV422VYUY, /* interleaved 8 bit samples of V, Y, U, Y */
+
+ VC_IMAGE_RGBX32, /* 32bpp like RGBA32 but with unused alpha */
+ VC_IMAGE_RGBX8888, /* 32bpp, corresponding to RGBA with unused alpha */
+ VC_IMAGE_BGRX8888, /* 32bpp, corresponding to BGRA with unused alpha */
+
+ VC_IMAGE_YUV420SP, /* Y as a plane, then UV byte interleaved in plane with with same pitch, half height */
+
+ VC_IMAGE_YUV444PLANAR, /* Y, U, & V planes separately 4:4:4 */
+
+ VC_IMAGE_MAX, //bounds for error checking
+ VC_IMAGE_FORCE_ENUM_16BIT = 0xffff,
+} VC_IMAGE_TYPE_T;
+
+/**
+ * From https://github.com/raspberrypi/userland/blob/master/interface/vmcs_host/vc_vchi_dispmanx.h
+ */
+typedef enum {
+ DISPMANX_ELEMENT_CHANGE_LAYER = (1<<0),
+ DISPMANX_ELEMENT_CHANGE_OPACITY = (1<<1),
+ DISPMANX_ELEMENT_CHANGE_DEST_RECT = (1<<2),
+ DISPMANX_ELEMENT_CHANGE_SRC_RECT = (1<<3),
+ DISPMANX_ELEMENT_CHANGE_MASK_RESOURCE = (1<<4),
+ DISPMANX_ELEMENT_CHANGE_TRANSFORM = (1<<5)
+/**
+ * Not working /validated !
+ DISPMANX_ELEMENT_CHANGE_MIN = 0x00,
+ DISPMANX_ELEMENT_CHANGE_SOURCE = 0x01,
+ DISPMANX_ELEMENT_INSERT_ABOVE = 0x80,
+ DISPMANX_ELEMENT_CHANGE_FLAGS = 0x100,
+ DISPMANX_ELEMENT_CHANGE_NOTHING = 0x200,
+ DISPMANX_ELEMENT_CHANGE_ALPHA_FLAGS = 0x400,
+ DISPMANX_ELEMENT_CHANGE_PROTECTION = 0x800,
+ DISPMANX_ELEMENT_CHANGE_MAX = 0x1000
+ */
+} DISPMANX_ELEMENT_CHANGE_T;
+
+
+
extern void bcm_host_init(void);
extern void bcm_host_deinit(void);
@@ -171,15 +261,38 @@ extern int32_t graphics_get_display_size( const uint16_t display_number,
uint32_t *height);
extern DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open( uint32_t device );
+extern int vc_dispmanx_display_close( DISPMANX_DISPLAY_HANDLE_T display );
+
+extern DISPMANX_RESOURCE_HANDLE_T vc_dispmanx_resource_create(VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle);
+extern int vc_dispmanx_resource_write_data( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect );
+//extern int vc_dispmanx_resource_write_data_handle( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch,
+// VCHI_MEM_HANDLE_T handle, uint32_t offset, const VC_RECT_T * rect );
+extern int vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res );
+
+
+
extern DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority );
extern DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display,
int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src,
const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection,
VC_DISPMANX_ALPHA_T *alpha,
DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform );
+extern int vc_dispmanx_element_remove( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element );
+
extern int vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update );
+//New function added to VCHI to change attributes, set_opacity does not work there.
+extern int vc_dispmanx_element_change_attributes( DISPMANX_UPDATE_HANDLE_T update,
+ DISPMANX_ELEMENT_HANDLE_T element,
+ uint32_t change_flags,
+ int32_t layer,
+ uint8_t opacity,
+ const VC_RECT_T *dest_rect,
+ const VC_RECT_T *src_rect,
+ DISPMANX_RESOURCE_HANDLE_T mask,
+ DISPMANX_TRANSFORM_T transform );
+
#ifdef __cplusplus
}
#endif