aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-02-13 18:12:27 +0100
committerSven Gothel <[email protected]>2014-02-13 18:12:27 +0100
commit8be9d9b5bd71854f4da15294b47125a8a4975e31 (patch)
treeac9a240fe7b2b2183017aa8775a8b2ed3d4b4f3f /src
parent325986eb0b14e90d9ef35cbb0ca57c9c91df4827 (diff)
SurfaceUpdatedListener: Order methods in impl. Class; SurfaceUpdatedListener: Mark methods final, use volatile 'isEmpty' to bail out early @ surfaceUpdated.
Diffstat (limited to 'src')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java44
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java25
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java40
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java43
4 files changed, 76 insertions, 76 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index a57dafc92..20ab7a2ee 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -438,30 +438,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
//
- // SurfaceUpdateListener
- //
-
- @Override
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
- }
-
- @Override
- public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
- }
-
- @Override
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
- }
-
- @Override
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
- surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
- }
-
- //
// NativeSurface
//
@@ -572,6 +548,26 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
@Override
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+ surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
+ }
+
+ @Override
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
+ }
+
+ @Override
public long getSurfaceHandle() {
return drawable;
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java
index 1e83232bb..0b033955e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java
@@ -36,22 +36,23 @@ import javax.media.nativewindow.SurfaceUpdatedListener;
public class SurfaceUpdatedHelper implements SurfaceUpdatedListener {
private final Object surfaceUpdatedListenersLock = new Object();
private final ArrayList<SurfaceUpdatedListener> surfaceUpdatedListeners = new ArrayList<SurfaceUpdatedListener>();
+ private volatile boolean isEmpty = true;
//
// Management Utils
//
- public int size() { return surfaceUpdatedListeners.size(); }
- public SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); }
+ public final int size() { return surfaceUpdatedListeners.size(); }
+ public final SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); }
//
// Implementation of NativeSurface SurfaceUpdatedListener methods
//
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
addSurfaceUpdatedListener(-1, l);
}
- public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)
+ public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)
throws IndexOutOfBoundsException
{
if(l == null) {
@@ -62,23 +63,29 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener {
index = surfaceUpdatedListeners.size();
}
surfaceUpdatedListeners.add(index, l);
+ isEmpty = false;
}
}
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ public final boolean removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
if (l == null) {
- return;
+ return false;
}
synchronized(surfaceUpdatedListenersLock) {
- surfaceUpdatedListeners.remove(l);
+ final boolean res = surfaceUpdatedListeners.remove(l);
+ isEmpty = 0 == surfaceUpdatedListeners.size();
+ return res;
}
}
@Override
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ if( isEmpty ) {
+ return;
+ }
synchronized(surfaceUpdatedListenersLock) {
for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) {
- SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i);
+ final SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i);
l.surfaceUpdated(updater, ns, when);
}
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index ca8ab6733..4b740927b 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -683,21 +683,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
- public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.removeSurfaceUpdatedListener(l);
- }
-
- @Override
- public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.addSurfaceUpdatedListener(l);
- }
-
- @Override
- public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
- window.addSurfaceUpdatedListener(index, l);
- }
-
- @Override
public void sendWindowEvent(int eventType) {
window.sendWindowEvent(eventType);
}
@@ -851,6 +836,26 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
+ public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.removeSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.addSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+ window.addSurfaceUpdatedListener(index, l);
+ }
+
+ @Override
+ public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ window.surfaceUpdated(updater, ns, when);
+ }
+
+ @Override
public final long getWindowHandle() {
return window.getWindowHandle();
@@ -877,11 +882,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
return window.getScreenIndex();
}
- @Override
- public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
- window.surfaceUpdated(updater, ns, when);
- }
-
/**
* A most simple JOGL AWT test entry
*/
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 1e2291c8f..7f7cb61a9 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -811,6 +811,26 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
@Override
+ public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+ surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
+ }
+
+ @Override
+ public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
+ }
+
+ @Override
+ public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
+ }
+
+ @Override
public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config.getNativeGraphicsConfiguration();
}
@@ -2507,29 +2527,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
//
- // SurfaceUpdatedListener Support
- //
- @Override
- public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
- }
-
- @Override
- public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
- }
-
- @Override
- public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
- }
-
- @Override
- public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
- surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
- }
-
- //
// MouseListener/Event Support
//