From 34fffab0bb25bbf8a4cd2bf372e018748982b9bc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 23 Sep 2010 14:53:25 +0200 Subject: NEWT: Animator API Change - Changed Lifecycle of Display/Screen (part 4) Change GLAutoDrawable interface: setAnimator(Thread) -> setAnimator(GLAnimatorControl) to minimize the setAnimator(..) calls and to allow fine grained control over the animation, ie in case of reparenting where the animation shall pause while changing the window(s). Introducing GLAnimatorControl interface: - abstract class AnimatorBase implements GLAnimatorControl - class Animator extends AnimatorBase - class FPSAnimator extends AnimatorBase This also changes FPSAnimator, since it is no more derived from Animator, use it's superclass or superinterface instead. +++ - Fix GLJPanel.paintComponent(): Don't issue reshape/display in case an external animator thread is animating. - Fix: Documentation [API] --- .../com/jogamp/opengl/impl/GLRunnableTask.java | 41 +++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/impl/GLRunnableTask.java') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLRunnableTask.java b/src/jogl/classes/com/jogamp/opengl/impl/GLRunnableTask.java index ea1e63b8b..a2a6939cd 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLRunnableTask.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLRunnableTask.java @@ -38,27 +38,52 @@ import javax.media.opengl.GLAutoDrawable; public class GLRunnableTask implements GLRunnable { GLRunnable runnable; Object notifyObject; + boolean catchExceptions; + boolean isExecuted; Throwable runnableException; - public GLRunnableTask(GLRunnable runnable, Object notifyObject) { + public GLRunnableTask(GLRunnable runnable, Object notifyObject, boolean catchExceptions) { this.runnable = runnable ; this.notifyObject = notifyObject ; + this.catchExceptions = catchExceptions; + isExecuted = false; } public void run(GLAutoDrawable drawable) { - try { - runnable.run(drawable); - } catch (Throwable t) { - runnableException = t; - } - if(null != notifyObject) { + if(null == notifyObject) { + try { + runnable.run(drawable); + } catch (Throwable t) { + runnableException = t; + if(catchExceptions) { + runnableException.printStackTrace(); + } else { + throw new RuntimeException(runnableException); + } + } finally { + isExecuted=true; + } + } else { synchronized (notifyObject) { - notifyObject.notifyAll(); + try { + runnable.run(drawable); + } catch (Throwable t) { + runnableException = t; + if(catchExceptions) { + runnableException.printStackTrace(); + } else { + throw new RuntimeException(runnableException); + } + } finally { + isExecuted=true; + notifyObject.notifyAll(); + } } } } + public boolean isExecuted() { return isExecuted; } public Throwable getThrowable() { return runnableException; } } -- cgit v1.2.3