aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-05 06:31:08 +0200
committerSven Gothel <[email protected]>2012-10-05 06:31:08 +0200
commita3cb6bb14f410f67fccf5ccd4cd7ecc66f448389 (patch)
tree74e127fac791c5ece7e69c04f6fc5ea9e32087aa /src/jogl
parent8f6233f11693f5e079cfeb6706fe2c37b5b9a6c2 (diff)
Fix Bug 572 (2nd time): GLCanvas.validateGLDrawable() @ display() and reshape() ; GLCanvas.reshape() only if drawble valid ; GLCanvas.validateGLDrawable() also test isDisplayable() ; Fix size validation ; resizeOffscreenDrawable(..) don't validate 'safe' size 1x1
- GLCanvas.validateGLDrawable() @ display() and reshape() To help users using GLCanvas w/ having a realized GLCanvas/Drawable, validateGLDrawable() is also called at reshape(). This shall ensure a valid drawable after even a non AWT-EDT issued first setVisible(). - GLCanvas.reshape() only if drawble valid Otherwise offscreen reshape attempts would happen even on unrealized drawable, which is not necessary. - GLCanvas.validateGLDrawable() also test isDisplayable() To make sure the native peer is valid, also test isDisplayable() - Fix size validation Since we have experienced odd size like 0 x -41 test each component, i.e. 0 < width && 0 < height. This is done through all JOGL/NEWT components. - resizeOffscreenDrawable(..) don't validate 'safe' size 1x1 In case method is called w/ odd size, i.e. 0 x -41, the safe size 1x1 is used. However, we cannot validate this size. Dump WARNING if odd size is detected.
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java60
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java11
3 files changed, 40 insertions, 33 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index 06114431a..24971ff97 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -389,7 +389,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
return false;
}
final Rectangle nClientArea = clientArea;
- if(0 == nClientArea.width * nClientArea.height) {
+ if(0 >= nClientArea.width || 0 >= nClientArea.height) {
return false;
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 335322be9..4bdae7135 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -440,6 +440,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
@Override
public void display() {
+ if( !validateGLDrawable() ) {
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet");
+ }
+ return; // not yet available ..
+ }
Threading.invoke(true, displayOnEDTAction, getTreeLock());
awtWindowClosingProtocol.addClosingListenerOneShot();
}
@@ -489,7 +495,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
(int) ((getHeight() + bounds.getHeight()) / 2));
return;
}
- if( ! this.helper.isAnimatorAnimating() ) {
+ if( ! this.helper.isExternalAnimatorAnimating() ) {
display();
}
}
@@ -570,30 +576,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
if( _drawable.isRealized() ) {
return true;
}
- if (!Beans.isDesignTime() &&
- 0 < _drawable.getWidth() * _drawable.getHeight() ) {
- // make sure drawable realization happens on AWT EDT, due to AWTTree lock
- AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction);
- if( _drawable.isRealized() ) {
- sendReshape=true; // ensure a reshape is being send ..
- if(DEBUG) {
- System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString());
- Thread.dumpStack();
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if (!Beans.isDesignTime() && isDisplayable() &&
+ 0 < _drawable.getWidth() && 0 < _drawable.getHeight() ) {
+ // make sure drawable realization happens on AWT EDT, due to AWTTree lock
+ AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction);
+ if( _drawable.isRealized() ) {
+ sendReshape=true; // ensure a reshape is being send ..
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString());
+ Thread.dumpStack();
+ }
+ return true;
}
- return true;
}
+ } finally {
+ _lock.unlock();
}
}
return false;
}
- private Runnable setRealizedOnEDTAction = new Runnable() {
- @Override
- public void run() {
- final GLDrawable _drawable = drawable;
- if ( null != _drawable && 0 < _drawable.getWidth() * _drawable.getHeight() ) {
- _drawable.setRealized(true);
- }
- } };
+ private Runnable setRealizedOnEDTAction = new Runnable() { public void run() { drawable.setRealized(true); } };
/** <p>Overridden to track when this component is removed from a
container. Subclasses which override this method must call
@@ -640,11 +645,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape
super.reshape(x, y, width, height);
- GLDrawableImpl _drawable = drawable;
- if( null != _drawable ) {
- if(DEBUG) {
- System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle()));
- }
+ if(DEBUG) {
+ System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle()));
+ // Thread.dumpStack();
+ }
+ if( validateGLDrawable() ) {
+ final GLDrawableImpl _drawable = drawable;
if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) {
final RecursiveLock _lock = lock;
_lock.lock();
@@ -984,11 +990,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
final RecursiveLock _lock = lock;
_lock.lock();
try {
- if( validateGLDrawable() ) {
- helper.invokeGL(drawable, context, displayAction, initAction);
- } else if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet");
- }
+ helper.invokeGL(drawable, context, displayAction, initAction);
} finally {
_lock.unlock();
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 13c387231..d4ff9702c 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -241,9 +241,14 @@ public class GLDrawableHelper {
if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
throw new NativeWindowException("Could not lock surface of drawable: "+drawable);
}
+ boolean validateSize = true;
try {
- if(0>=newWidth) { newWidth = 1; }
- if(0>=newHeight) { newHeight = 1; }
+ if(DEBUG && ( 0>=newWidth || 0>=newHeight) ) {
+ System.err.println("WARNING: Odd size detected: "+newWidth+"x"+newHeight+", using safe size 1x1. Drawable "+drawable);
+ Thread.dumpStack();
+ }
+ if(0>=newWidth) { newWidth = 1; validateSize=false; }
+ if(0>=newHeight) { newHeight = 1; validateSize=false; }
// propagate new size
if(ns instanceof ProxySurface) {
final ProxySurface ps = (ProxySurface) ns;
@@ -266,7 +271,7 @@ public class GLDrawableHelper {
} finally {
ns.unlockSurface();
}
- if(drawable.getWidth() != newWidth || drawable.getHeight() != newHeight) {
+ if( validateSize && ( drawable.getWidth() != newWidth || drawable.getHeight() != newHeight ) ) {
throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable);
}
return drawable;