aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-27 11:59:06 +0200
committerSven Gothel <[email protected]>2011-09-27 11:59:06 +0200
commitdf85f0dfafc09e147f9d422adf5ee8eabf67977b (patch)
tree2cfa489bc37a8195e0742d8ce48d0d7b2ba468fb /src
parente5ab975727134d8249277f4df707b2b14a7788f3 (diff)
Adapt to GlueGen's Lock ChangeSet: e4baba27507ce78e64a150ec6f69fb96f5721a34 ; Use generics
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java26
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java17
-rw-r--r--src/jogl/classes/jogamp/opengl/GLPbufferImpl.java7
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java11
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java7
7 files changed, 40 insertions, 40 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
index 9c77a0508..93b75e70b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
@@ -54,21 +54,21 @@ import javax.media.opengl.GLAutoDrawable;
class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
// For efficient rendering of Swing components, in particular when
// they overlap one another
- private List lightweights = new ArrayList();
- private Map repaintManagers = new IdentityHashMap();
- private Map dirtyRegions = new IdentityHashMap();
+ private List<JComponent> lightweights = new ArrayList<JComponent>();
+ private Map<RepaintManager,RepaintManager> repaintManagers = new IdentityHashMap<RepaintManager,RepaintManager>();
+ private Map<JComponent,Rectangle> dirtyRegions = new IdentityHashMap<JComponent,Rectangle>();
- public void display(ArrayList drawables,
+ public void display(ArrayList<GLAutoDrawable> drawables,
boolean ignoreExceptions,
boolean printExceptions) {
for (int i=0; i<drawables.size(); i++) {
- GLAutoDrawable drawable = (GLAutoDrawable) drawables.get(i);
+ GLAutoDrawable drawable = drawables.get(i);
if (drawable instanceof JComponent) {
// Lightweight components need a more efficient drawing
// scheme than simply forcing repainting of each one in
// turn since drawing one can force another one to be
// drawn in turn
- lightweights.add(drawable);
+ lightweights.add((JComponent)drawable);
} else {
try {
drawable.display();
@@ -98,8 +98,8 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
// the Swing widgets we're animating
private Runnable drawWithRepaintManagerRunnable = new Runnable() {
public void run() {
- for (Iterator iter = lightweights.iterator(); iter.hasNext(); ) {
- JComponent comp = (JComponent) iter.next();
+ for (Iterator<JComponent> iter = lightweights.iterator(); iter.hasNext(); ) {
+ JComponent comp = iter.next();
RepaintManager rm = RepaintManager.currentManager(comp);
rm.markCompletelyDirty(comp);
repaintManagers.put(rm, rm);
@@ -148,16 +148,16 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
}
// Dirty any needed regions on non-optimizable components
- for (Iterator iter = dirtyRegions.keySet().iterator(); iter.hasNext(); ) {
- JComponent comp = (JComponent) iter.next();
- Rectangle rect = (Rectangle) dirtyRegions.get(comp);
+ for (Iterator<JComponent> iter = dirtyRegions.keySet().iterator(); iter.hasNext(); ) {
+ JComponent comp = iter.next();
+ Rectangle rect = dirtyRegions.get(comp);
RepaintManager rm = RepaintManager.currentManager(comp);
rm.addDirtyRegion(comp, rect.x, rect.y, rect.width, rect.height);
}
// Draw all dirty regions
- for (Iterator iter = repaintManagers.keySet().iterator(); iter.hasNext(); ) {
- ((RepaintManager) iter.next()).paintDirtyRegions();
+ for (Iterator<RepaintManager> iter = repaintManagers.keySet().iterator(); iter.hasNext(); ) {
+ iter.next().paintDirtyRegions();
}
dirtyRegions.clear();
repaintManagers.clear();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index a6ba74665..e84a9bf78 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl.util;
+import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import jogamp.opengl.Debug;
import jogamp.opengl.FPSCounterImpl;
@@ -35,7 +36,6 @@ import jogamp.opengl.FPSCounterImpl;
import java.io.PrintStream;
import java.util.ArrayList;
-import javax.media.opengl.FPSCounter;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLProfile;
@@ -55,11 +55,11 @@ public abstract class AnimatorBase implements GLAnimatorControl {
private static int animatorCount = 0;
public interface AnimatorImpl {
- void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions);
+ void display(ArrayList<GLAutoDrawable> drawables, boolean ignoreExceptions, boolean printExceptions);
boolean skipWaitForCompletion(Thread thread);
}
- protected ArrayList/*<GLAutoDrawable>*/ drawables = new ArrayList();
+ protected ArrayList<GLAutoDrawable> drawables = new ArrayList<GLAutoDrawable>();
protected boolean drawablesEmpty;
protected AnimatorImpl impl;
protected String baseName;
@@ -67,7 +67,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
protected boolean ignoreExceptions;
protected boolean printExceptions;
protected FPSCounterImpl fpsCounter = new FPSCounterImpl();
- protected RecursiveLock stateSync = new RecursiveLock();
+ protected RecursiveLock stateSync = LockFactory.createRecursiveLock();
/** Creates a new, empty Animator. */
public AnimatorBase() {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
index d3f9cdeeb..bad268f70 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
@@ -41,11 +41,11 @@ import javax.media.opengl.GLAutoDrawable;
up this behavior if desired. */
class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl {
- public void display(ArrayList drawables,
+ public void display(ArrayList<GLAutoDrawable> drawables,
boolean ignoreExceptions,
boolean printExceptions) {
for (int i=0; i<drawables.size(); i++) {
- GLAutoDrawable drawable = (GLAutoDrawable) drawables.get(i);
+ GLAutoDrawable drawable = drawables.get(i);
try {
drawable.display();
} catch (RuntimeException e) {
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 03dfc55b5..48c1c5411 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -90,6 +90,7 @@ import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.opengl.JoglVersion;
+import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import jogamp.opengl.Debug;
import jogamp.opengl.GLContextImpl;
@@ -134,6 +135,7 @@ import jogamp.opengl.ThreadingImpl;
* </ul>
*/
+@SuppressWarnings("serial")
public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol {
private static final boolean DEBUG;
@@ -498,7 +500,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
}
- RecursiveLock drawableSync = new RecursiveLock();
+ RecursiveLock drawableSync = LockFactory.createRecursiveLock();
/** Overridden to track when this component is added to a container.
Subclasses which override this method must call
@@ -507,6 +509,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
<B>Overrides:</B>
<DL><DD><CODE>addNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
+ @SuppressWarnings("deprecation")
@Override
public void addNotify() {
if(DEBUG) {
@@ -593,6 +596,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
about this.</p>
<B>Overrides:</B>
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
+ @SuppressWarnings("deprecation")
@Override
public void removeNotify() {
if(DEBUG) {
@@ -628,6 +632,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
<B>Overrides:</B>
<DL><DD><CODE>reshape</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
+ @SuppressWarnings("deprecation")
@Override
public void reshape(int x, int y, int width, int height) {
super.reshape(x, y, width, height);
@@ -935,10 +940,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private void disableBackgroundErase() {
if (!disableBackgroundEraseInitialized) {
try {
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
- Class clazz = getToolkit().getClass();
+ Class<?> clazz = getToolkit().getClass();
while (clazz != null && disableBackgroundEraseMethod == null) {
try {
disableBackgroundEraseMethod =
@@ -1006,7 +1011,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
chooser, aScreen);
} else {
try {
- final ArrayList bucket = new ArrayList(1);
+ final ArrayList<AWTGraphicsConfiguration> bucket = new ArrayList<AWTGraphicsConfiguration>(1);
EventQueue.invokeAndWait(new Runnable() {
public void run() {
AWTGraphicsConfiguration c = (AWTGraphicsConfiguration)
@@ -1016,7 +1021,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
bucket.add(c);
}
});
- config = ( bucket.size() > 0 ) ? (AWTGraphicsConfiguration)bucket.get(0) : null ;
+ config = ( bucket.size() > 0 ) ? bucket.get(0) : null ;
} catch (InvocationTargetException e) {
throw new GLException(e.getTargetException());
} catch (InterruptedException e) {
@@ -1042,7 +1047,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
GLProfile.initSingleton(false);
GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
+ List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null);
for(int i=0; i<availCaps.size(); i++) {
System.err.println(availCaps.get(i));
}
diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
index 1d52bedbb..d667fa53a 100644
--- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
@@ -40,6 +40,7 @@
package jogamp.opengl;
+import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GL;
@@ -255,7 +256,7 @@ public class GLPbufferImpl implements GLPbuffer {
return pbufferDrawable.getGLProfile();
}
- private RecursiveLock recurLock = new RecursiveLock();
+ private RecursiveLock recurLock = LockFactory.createRecursiveLock();
public int lockSurface() throws GLException {
recurLock.lock();
@@ -270,10 +271,6 @@ public class GLPbufferImpl implements GLPbuffer {
return recurLock.isLocked();
}
- public Throwable getLockedStack() {
- return recurLock.getLockedStack();
- }
-
public int getFloatingPointMode() {
if (floatMode == 0) {
throw new GLException("Pbuffer not initialized, or floating-point support not requested");
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index 038580ce0..e34476228 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -28,10 +28,11 @@
package javax.media.nativewindow;
+import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
public abstract class ProxySurface implements NativeSurface {
- protected RecursiveLock surfaceLock = new RecursiveLock();
+ protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
protected AbstractGraphicsConfiguration config;
protected long displayHandle;
protected int height;
@@ -86,7 +87,7 @@ public abstract class ProxySurface implements NativeSurface {
public int lockSurface() throws NativeWindowException {
surfaceLock.lock();
- int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
+ int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
@@ -111,7 +112,7 @@ public abstract class ProxySurface implements NativeSurface {
public final void unlockSurface() {
surfaceLock.validateLocked();
- if (surfaceLock.getRecursionCount() == 0) {
+ if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
try {
unlockSurfaceImpl();
@@ -142,9 +143,5 @@ public abstract class ProxySurface implements NativeSurface {
return surfaceLock.getOwner();
}
- public final int getSurfaceRecursionCount() {
- return surfaceLock.getRecursionCount();
- }
-
public abstract String toString();
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 65fb31d72..2c80392ad 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -37,6 +37,7 @@
package jogamp.nativewindow.jawt;
+import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import java.awt.Component;
@@ -112,13 +113,13 @@ public abstract class JAWTWindow implements NativeWindow {
// NativeSurface
//
- private RecursiveLock surfaceLock = new RecursiveLock();
+ private RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
protected abstract int lockSurfaceImpl() throws NativeWindowException;
public final int lockSurface() throws NativeWindowException {
surfaceLock.lock();
- int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
+ int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
@@ -145,7 +146,7 @@ public abstract class JAWTWindow implements NativeWindow {
public final void unlockSurface() {
surfaceLock.validateLocked();
- if (surfaceLock.getRecursionCount() == 0) {
+ if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
try {
unlockSurfaceImpl();