summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-07-08 04:35:04 +0200
committerSven Gothel <[email protected]>2019-07-08 04:35:04 +0200
commit7fc01d666ae35bd789232b18f8d3f2df7146e4d3 (patch)
treecf4c208114cd9066af340da0f3932b58e66d5af8 /src/newt/classes
parentf006cb6a0794c0d4fdfc59ded579fc3d91551d0b (diff)
NEWT WindowImpl.doPointerEvent: Use native short[] for pNames
and not int[], this avoid copying in case given pNames are normalized. This is benecifical for X11, Windows and the upcoming iOS touch/pointer support.
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java25
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java2
3 files changed, 13 insertions, 16 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 5f03189ac..b2e727355 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -558,7 +558,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private final PointerState1 pState1 = new PointerState1();
/** Pointer names -> pointer ID (consecutive index, starting w/ 0) */
- private final ArrayHashSet<Integer> pName2pID = new ArrayHashSet<Integer>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR);
+ private final ArrayHashSet<Short> pName2pID = new ArrayHashSet<Short>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR);
private boolean defaultGestureHandlerEnabled = true;
private DoubleTapScrollGesture gesture2PtrTouchScroll = null;
@@ -3464,36 +3464,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
*/
public final void doPointerEvent(final boolean enqueue, final boolean wait,
final PointerType[] pTypes, final short eventType, final int modifiers,
- final int actionIdx, final boolean normalPNames, final int[] pNames,
+ final int actionIdx, final boolean normalPNames, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure,
final float maxPressure, final float[] rotationXYZ, final float rotationScale) {
final int pCount = pNames.length;
- final short[] pIDs = new short[pCount];
- for(int i=0; i<pCount; i++) {
- if( !normalPNames ) {
+ final short[] pIDs = normalPNames ? pNames : new short[pCount];
+ if( !normalPNames ) {
+ for(int i=0; i<pCount; i++) {
// hash map int name -> short idx
final int sz0 = pName2pID.size();
- final Integer pNameI1 = pName2pID.getOrAdd(Integer.valueOf(pNames[i]));
- final short pID = (short)pName2pID.indexOf(pNameI1);
+ final Short pNameS1 = pName2pID.getOrAdd(Short.valueOf(pNames[i]));
+ final short pID = (short)pName2pID.indexOf(pNameS1);
pIDs[i] = pID;
if(DEBUG_MOUSE_EVENT) {
final int sz1 = pName2pID.size();
if( sz0 != sz1 ) {
- System.err.println("PointerName2ID[sz "+sz1+"]: Map "+pNameI1+" == "+pID);
+ System.err.println("PointerName2ID[sz "+sz1+"]: Map "+pNameS1+" == "+pID);
}
}
if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) {
- pName2pID.remove(pNameI1);
+ pName2pID.remove(pNameS1);
if(DEBUG_MOUSE_EVENT) {
- System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Unmap "+pNameI1+" == "+pID);
+ System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Unmap "+pNameS1+" == "+pID);
}
}
- } else {
- // simple type cast
- pIDs[i] = (short)pNames[i];
}
}
- final short button = 0 < pCount ? (short) ( pIDs[0] + 1 ) : (short)0;
+ final short button = 0 < pCount ? (short) ( pIDs[actionIdx] + 1 ) : (short)0;
doPointerEvent(enqueue, wait, pTypes, eventType, modifiers, actionIdx, pIDs, button,
pX, pY, pPressure, maxPressure, rotationXYZ, rotationScale);
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index af5dad3ac..020fe599b 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -334,7 +334,7 @@ public class WindowDriver extends WindowImpl {
* </p>
*/
public final void sendTouchScreenEvent(final short eventType, final int modifiers,
- final int pActionIdx, final int[] pNames,
+ final int pActionIdx, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure, final float maxPressure) {
final int pCount = pNames.length;
final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount];
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index afd10f54b..5adbba185 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -407,7 +407,7 @@ public class WindowDriver extends WindowImpl {
}
public final void sendTouchScreenEvent(final short eventType, final int modifiers,
- final int pActionIdx, final int[] pNames,
+ final int pActionIdx, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure, final float maxPressure) {
final int pCount = pNames.length;
final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount];