aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-07-22 04:16:55 +0200
committerSven Gothel <[email protected]>2012-07-22 04:16:55 +0200
commit4b5a0f6557d7152ec770bc13ad3c494449de0529 (patch)
tree12fc93f9e7f34b61c1d5748f0e6a1cd85fc6125b /src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java
parentadc9522ccaff74eb779d4d33905d76d52acb36bb (diff)
Fix Bug 606 - New AWT threading implementation breaks .. ; Fix GLAutoDrawable multi-threading w/ proper pattern (hope so)
Considering code changes and remarks: 3ed491213f8f7f05d7b9866b50d764370d8ff5f6 1a91ec5c8b6fd9d9db7bc115569c369fe7b38e9b 3334a924309a9361a448d69bc707d4cce416b430 4f27bcecf7484dc041551f52a5c49e2884cb3867 It seems necessary to have - recursive locking employed for all semantic actions which changes drawable & context (and the Window resource) - to avoid deadlock, we have to ensure the locked code segment will not spawn off to another thread, or a thread holds the lock, spawns of an action requiring the lock. .. sure - other read-only methods (flags, ..) shall at least utilize a safe local copy of a volatile field if further use to produce the result is necessary. - flags like sendReshape require to be volatile to guarantee it's being processed Patch impacts: AWT/SWT GLCanvas, GLAutoDrawableBase [and it's specializations] and hopefully closes any loopholes of missing a cache hit, etc. If you review this and find optimizations, i.e. removing a lock due to semantics etc, don't hold back and discuss it, please.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java
index 1f6166719..76959f3f4 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java
@@ -67,18 +67,18 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase {
}
//
- // make protected methods accessible
+ // expose default methods
//
- public void defaultWindowRepaintOp() {
+ public final void windowRepaintOp() {
super.defaultWindowRepaintOp();
}
- public void defaultWindowResizedOp() {
+ public final void windowResizedOp() {
super.defaultWindowResizedOp();
}
- public void defaultWindowDestroyNotifyOp() {
+ public final void windowDestroyNotifyOp() {
super.defaultWindowDestroyNotifyOp();
}
@@ -90,6 +90,9 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase {
private final Object upstreamWidget;
@Override
+ protected final RecursiveLock getLock() { return lock; }
+
+ @Override
public final Object getUpstreamWidget() {
return upstreamWidget;
}
@@ -97,39 +100,21 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase {
/**
* {@inheritDoc}
* <p>
- * This implementation calls {@link #defaultDestroyOp()}.
+ * This implementation calls {@link #defaultDestroy()}.
* </p>
* <p>
* User still needs to destroy the upstream window, which details are hidden from this aspect.
+ * This can be performed by overriding {@link #destroyImplInLock()}.
* </p>
*/
@Override
- public void destroy() {
- lock.lock();
- try {
- defaultDestroyOp();
- } finally {
- lock.unlock();
- }
+ public final void destroy() {
+ defaultDestroy();
}
@Override
public void display() {
- if( sendDestroy ) {
- sendDestroy=false;
- destroy();
- return;
- }
-
- lock.lock(); // sync: context/drawable could been recreated/destroyed while animating
- try {
- if( null != drawable && drawable.isRealized() && null != context ) {
- // surface is locked/unlocked implicit by context's makeCurrent/release
- helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction);
- }
- } finally {
- lock.unlock();
- }
+ defaultDisplay();
}
//
@@ -145,4 +130,9 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase {
public final void setRealized(boolean realized) {
}
+ @Override
+ public final void swapBuffers() throws GLException {
+ defaultSwapBuffers();
+ }
+
}