From 66976571abed5f14db5de9975ce08d62cfecc2c8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Dec 2019 22:40:53 +0100 Subject: Bug 1408: NEWT DRM/GBM DisplayDriver: Add device locking/unlocking decoration for PointerIcon operations --- .../jogamp/newt/driver/egl/gbm/DisplayDriver.java | 44 +++++++++++++++++++--- .../jogamp/newt/driver/egl/gbm/ScreenDriver.java | 9 +++-- 2 files changed, 44 insertions(+), 9 deletions(-) (limited to 'src/newt/classes/jogamp') diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java index edc5fb532..bc177a8b3 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java @@ -100,8 +100,10 @@ public class DisplayDriver extends DisplayImpl { } else { defaultPointerIcon = null; } + if( DEBUG_POINTER_ICON ) { - System.err.println("Display.PointerIcon.createDefault: "+defaultPointerIcon); + System.err.println("Display.createNativeImpl: "+this); + System.err.println("Display.createNativeImpl: defaultPointerIcon "+defaultPointerIcon); } } @@ -124,17 +126,49 @@ public class DisplayDriver extends DisplayImpl { @Override protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { - return CreatePointerIcon(gbmHandle, pixels, width, height, hotX, hotY); + this.aDevice.lock(); + try { + return CreatePointerIcon(gbmHandle, pixels, width, height, hotX, hotY); + } finally { + this.aDevice.unlock(); + } } @Override protected final void destroyPointerIconImpl(final long displayHandle, final long piHandle) { - DestroyPointerIcon0(piHandle); + final AbstractGraphicsDevice d = this.aDevice; + if( null != d ) { + d.lock(); + try { + DestroyPointerIcon0(piHandle); + } finally { + d.unlock(); + } + } else { + DestroyPointerIcon0(piHandle); + } } //---------------------------------------------------------------------- // Internals only // + /* pp */ boolean setPointerIcon(final int crtc_id, final long piHandle, final boolean enable, final int x, final int y) { + this.aDevice.lock(); + try { + return SetPointerIcon0(DRMUtil.getDrmFd(), crtc_id, piHandle, enable, x, y); + } finally { + this.aDevice.unlock(); + } + } + /* pp */ boolean movePointerIcon(final int crtc_id, final int x, final int y) { + this.aDevice.lock(); + try { + return MovePointerIcon0(DRMUtil.getDrmFd(), crtc_id, x, y); + } finally { + this.aDevice.unlock(); + } + } + private static native boolean initIDs(); private static native void DispatchMessages0(); @@ -154,8 +188,8 @@ public class DisplayDriver extends DisplayImpl { private static native long CreatePointerIcon0(long gbmDevice, Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); private static native void DestroyPointerIcon0(long piHandle); - /* pp */ static native boolean SetPointerIcon0(int drmFd, int crtc_id, long piHandle, boolean enable, int x, int y); - /* pp */ static native boolean MovePointerIcon0(int drmFd, int crtc_id, int x, int y); + private static native boolean SetPointerIcon0(int drmFd, int crtc_id, long piHandle, boolean enable, int x, int y); + private static native boolean MovePointerIcon0(int drmFd, int crtc_id, int x, int y); /* pp */ static final boolean DEBUG_POINTER_ICON = Display.DEBUG_POINTER_ICON; /* pp */ PointerIconImpl defaultPointerIcon = null; diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java index 82f13f6d6..2faa8e54e 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java @@ -155,8 +155,9 @@ public class ScreenDriver extends ScreenImpl { System.err.println("Screen.PointerIcon.set.0: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> "+Display.toHexString(piHandle)); } if( 0 != activePointerIcon && activePointerIconVisible ) { + // disable active pointerIcon first System.err.println("Screen.PointerIcon.set.1"); - DisplayDriver.SetPointerIcon0(DRMUtil.getDrmFd(), crtc_ids[0], activePointerIcon, false, x, y); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon, false, x, y); } if( 0 == piHandle && null != defaultPointerIcon ) { System.err.println("Screen.PointerIcon.set.2"); @@ -164,7 +165,7 @@ public class ScreenDriver extends ScreenImpl { } if( 0 != piHandle ) { System.err.println("Screen.PointerIcon.set.3"); - DisplayDriver.SetPointerIcon0(DRMUtil.getDrmFd(), crtc_ids[0], piHandle, true, x, y); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], piHandle, true, x, y); activePointerIconVisible = true; } else { System.err.println("Screen.PointerIcon.set.4"); @@ -183,7 +184,7 @@ public class ScreenDriver extends ScreenImpl { } if( activePointerIconVisible != visible ) { if( 0 != activePointerIcon ) { - DisplayDriver.SetPointerIcon0(DRMUtil.getDrmFd(), crtc_ids[0], activePointerIcon, visible, x, y); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon, visible, x, y); } activePointerIconVisible = visible; } @@ -195,7 +196,7 @@ public class ScreenDriver extends ScreenImpl { System.err.println("Screen.PointerIcon.move: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"], "+x+"/"+y); } if( 0 != activePointerIcon && activePointerIconVisible ) { - DisplayDriver.MovePointerIcon0(DRMUtil.getDrmFd(), crtc_ids[0], x, y); + ((DisplayDriver)display).movePointerIcon(crtc_ids[0], x, y); } } } -- cgit v1.2.3