- Removed Display reusage by unique TLS key: type + name, instead use user-responsibility or Destroy-When-Unused (usage reference count).
- Removed X11 Display TLS pool usage
- Display creation means i, incl the later native one (X11).
- Added reference counting as follows: - Display's refCount: number it is referenced by Screen: display.addReference()/display.removeReference()
- Screen's refCount: number it is referenced by Window: screen.addReference()/screen.removeReference()
- Lazy creation using refcount 0 -> 1 All resources are created when they are needed. This also removes redundant native Display/Screen objects, ie in case of [AWT] reparenting.
- Default lifecycle is user-responsibility, ie no Destroy-When-Unused, where Window may be destroyed unrecoverable, which removes the Screen reference only.
- If using optional Destroy-When-Unused a Window may be destroyed unrecoverable, which removes the Screen reference: Screen.removeReference(); IF Screen.refCount == 0 THEN Screen.destroy(); Display.removeReference(); IF Display.refCount == 0 THEN Display.destroy();
- Use Destroy-When-Unused lifecycle for all automatic created Display/Screen instances (GLWindow, NewtCanvasAWT,..)
- Display/Screen destroy/create cycles valid, ie you can reuse destroyed Display/Screen's
- EDTUtil: - Created right away. - Started always via invoke, if not running.
- DefaultEDTUtil: - Simplified locking a bit locking on: - edtLock for start/stop - edtTasks for tasks queue - invoke-wait doubles check shouldStop - invoke-wait 'waiting' outside of edtLock
+++
NEWT: Cleanup
- Window.destroy/invalidate: deep -> unrecoverable
- Window.isNativeWindowValid() -> Window.isNativeValid() to unify with Display/Screen
- Window.isDestroyed() -> Window.isValid() to unify and simplify logic. Returns false if destroy(true) has been called.
- NewtFactory.wrapDisplay(.. handle) -> NewtFactory.createDisplay(.. handle), since it actually creates a compatible display.
+++
NativeWindow X11Util: Added non TLS createDisplay()/closeDisplay()
NEWT: Changed Lifecycle of Display/Screen (part 2)
Window Reparenting (unification): On the fly Display/Screen creation resides in NewtFactory. Reparenting logic within Window. Handles all reparenting cases now: ACTION_NONE, ACTION_SOFT_REPARENTING, ACTION_NATIVE_REPARENTING, ACTION_NATIVE_CREATION
- out.println -> err.println
++++
- Bumbed windows bat scripts to 1.6.0_21 and ant 1.8.1 - Debug: /RecursiveToolkitLock.java TO is 300s for now, while not finished. -
+++
Needs more testing. Deadlocks: AWT/NEWT parenting.
NEWT: Changed Lifecycle of Display/Screen (part 3)
- Fix DefaultEDTUtil deadlocks: Minimize locking! - invoke: - Check isCurrentThreadEDT() before locking edtLock - Check isRunning() redundant, since we start it beforehand
- EventDispatchThread.run(): - Relax definition of EDTUtil::waitUntilIdle(), ie method may return while last task is being executed (see below). - Execute task outside of edtTasks lock.
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.
EDTUtil: - Added documentation to EDTUtil interface - Removed 'stop()', introduced 'invokeStop(Runnable)', allowing proper shutdown with a final task (see doc). - Fix (c) header, since it is a new file, changed to interface with df161c9fcc1bc90d03e374e0eb8148424d4c5577
DefaultEDTUtil: - Move EDT scope volatile states (shouldStop, edtTasks) into inner class EventDispatchThread (the actual EDT). Fetching those outer instance values from within the inner EDT instance results in 'old values', ie this memory didn't get updates/synced.
- Give the thread a proper name: <invocation-thread-name>-<custom-name>-EDT-<start-sequence-number> This allows easy identification of the EDT incl. indication of the 'start' sequence number.
- Added fail-fast Exceptions in case of a stopped EDT with remaining tasks. This should validate/test the runtime behavior.
- Ensure isRunning(), invokeStop(..) and waitUntilStopped() only returns after the last task has been executed.
- invokeImpl/EDT.run: Complete task-lock coverage incl. wait case. - The final task is blocked until the wait() state in invokeImpl is reached. - EDT executes the final task and notifies the lock owner - then exist - invokeImpl leaves the wait state. - See EDTUtil API doc ..
NEWT: Fix Display/Window/Screen OO Identity, Reparenting and requestFocus
NativeWindow: Interface NativeWindow changes: - Remove 'throws' qualifier in lockSurface(), since it is not - Adding convenient 'one call' isSurfaceLockedByOtherThread() - Adding getSurfaceLockOwner()
NEWT Window/GLWindow:
- Unclutter Window/GLWindow relationship - save Window's indentity GLWindow's role is a GLAutoDrawable implementation aggregating (maybe even compositioning) a Window.
The previous implementation just derived from the Window implementation, overwriting methods and fields - impossible to ensure sanity / completness. It was also not ensured that the added functionality of GLWindow (setVisible, destroy, ..) has been issued in case of handling the aggregated Window alone (window callbacks, ..).
To solve this issue in a 1st attempt without changing the GLWindow API, Window is just an interface, being implemented by their specializations, hence sanity is intrinsic.
GLWindow's added functionality is ensured by a Window.LifecycleHook interfaced implementation, registered at the aggregated Window.
- Screen and Window are interfaces now (new files)
- Display is an abstract class.
- Their (abstract) implementations resides in impl/<BaseName>Impl
- GLWindow implements Window as well
- Remove Screen reference handled by setScreen(Screen) method.
- Lock native parentWindow if used (createNative/reparenting)
- Move lockSurface/unlockSurface from unchecked override pattern to an callback style using abstract methods lockSurfaceImpl/...
- Sorting all methods to semantic sections, abstract, superinterface, ..
- Reparenting: Handling different reparenting situations: - Unchanged - No change - Native Reparenting - Compatible Display/Screen, try native reparenting - Native (Re)Creation - Use destroy/create pattern - Native Creation Pending - Create later
- setUndecorated() calls reconfigure Window now, ie tries to change the window actually
- Don't issue 'requestFocus()' directly from the native implementation anymore, call it from the Java code.
- Window/GLWindow/NewtFactory: Constructor simplification Avoid explosion of constructor overloading, ie removing the 'undecorated' variant, since this is redundant due to the 'setUndecorated(boolean)' method.