diff options
author | Sven Gothel <[email protected]> | 2010-11-04 04:09:02 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-04 04:09:02 +0100 |
commit | a9e946d34bdf838de66e70112ca96dd122060327 (patch) | |
tree | f8cf73c52014c84f8fae658fe8b5cbc4579df210 /src | |
parent | ee0b89ccaa9e5587058f3764e52f3bcc205e862d (diff) |
NEWT DisplayImpl: Use ArrayList and index, no Iterator ; Misc cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java | 39 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/impl/WindowImpl.java | 28 |
2 files changed, 40 insertions, 27 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java index d4f391e6c..d22e9c7c4 100644 --- a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java @@ -34,13 +34,16 @@ package com.jogamp.newt.impl; -import com.jogamp.newt.*; -import javax.media.nativewindow.*; -import com.jogamp.newt.event.*; -import com.jogamp.newt.impl.event.*; +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.event.NEWTEvent; +import com.jogamp.newt.event.NEWTEventConsumer; +import com.jogamp.newt.impl.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; import com.jogamp.newt.util.MainThread; -import java.util.*; +import java.util.ArrayList; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowFactory; public abstract class DisplayImpl extends Display { public static final boolean DEBUG_TEST_EDT_MAINTHREAD = Debug.isPropertyDefined("newt.test.EDTMainThread", true); // JAU EDT Test .. @@ -306,7 +309,7 @@ public abstract class DisplayImpl extends Display { protected abstract void dispatchMessagesNative(); private Object eventsLock = new Object(); - private LinkedList/*<NEWTEvent>*/ events = new LinkedList(); + private ArrayList/*<NEWTEvent>*/ events = new ArrayList(); class DispatchMessagesRunnable implements Runnable { public void run() { @@ -320,20 +323,20 @@ public abstract class DisplayImpl extends Display { if(0==refCount) return; // no screens if(null==getGraphicsDevice()) return; // no native device - LinkedList/*<NEWTEvent>*/ _events = null; + ArrayList/*<NEWTEvent>*/ _events = null; - if(!events.isEmpty()) { + if(events.size()>0) { // swap events list to free ASAP synchronized(eventsLock) { - if(!events.isEmpty()) { + if(events.size()>0) { _events = events; - events = new LinkedList(); + events = new ArrayList(); } eventsLock.notifyAll(); } if( null != _events ) { - for (Iterator iter = _events.iterator(); iter.hasNext(); ) { - NEWTEventTask eventTask = (NEWTEventTask) iter.next(); + for (int i=0; i < _events.size(); i++) { + NEWTEventTask eventTask = (NEWTEventTask) _events.get(i); NEWTEvent event = eventTask.get(); Object source = event.getSource(); if(source instanceof NEWTEventConsumer) { @@ -349,14 +352,8 @@ public abstract class DisplayImpl extends Display { } } - // lock(); - try { - // System.err.println("Display.dispatchMessages() NATIVE "+this+" "+getThreadName()); - dispatchMessagesNative(); - } finally { - // unlock(); - // System.err.println("Display.dispatchMessages() X "+this+" "+getThreadName()); - } + // System.err.println("Display.dispatchMessages() NATIVE "+this+" "+getThreadName()); + dispatchMessagesNative(); } public void enqueueEvent(boolean wait, NEWTEvent e) { @@ -372,7 +369,7 @@ public abstract class DisplayImpl extends Display { NEWTEventTask eTask = new NEWTEventTask(e, wait?lock:null); synchronized(lock) { synchronized(eventsLock) { - events.addLast(eTask); + events.add(eTask); eventsLock.notifyAll(); } if( wait ) { diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java index dfa768147..d7504cfdf 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -34,19 +34,34 @@ package com.jogamp.newt.impl; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.event.*; - -import com.jogamp.common.util.*; -import javax.media.nativewindow.*; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.NEWTEvent; +import com.jogamp.newt.event.NEWTEventConsumer; +import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; import java.util.ArrayList; import java.lang.reflect.Method; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.DimensionReadOnly; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -362,12 +377,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod windowLock.lock(); - screen.getDisplay().getGraphicsDevice().lock(); + AbstractGraphicsDevice adevice = screen.getDisplay().getGraphicsDevice(); + adevice.lock(); try { res = lockSurfaceImpl(); } finally { if(!isNativeValid()) { - screen.getDisplay().getGraphicsDevice().unlock(); + adevice.unlock(); windowLock.unlock(); res = LOCK_SURFACE_NOT_READY; } |