diff options
author | Sven Gothel <[email protected]> | 2011-09-06 07:14:08 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-06 07:14:08 +0200 |
commit | 1b3411d8099761e6fec2d2edfa9b86b33d9b2c8a (patch) | |
tree | 7cd35d337972a7bc1bcea8c6c23cd019a581fbb1 /src/newt/classes | |
parent | 086ea0a1abeb625f900edbf8513e3f1358b72f8e (diff) |
NEWT: Sync User-Lifecycle
Sync User-Lifecycle:
Display, Screen: createNative(), destroy(), isNativeValid()
sync on instance (used by multiple threads)
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/DisplayImpl.java | 2 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/ScreenImpl.java | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 4154059e2..26c437b4d 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -335,7 +335,7 @@ public abstract class DisplayImpl extends Display { return aDevice; } - public final boolean isNativeValid() { + public synchronized final boolean isNativeValid() { return null != aDevice; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 59d46a662..ec955ead6 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -169,10 +169,15 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")"); } t0 = System.currentTimeMillis(); - display.addReference(); - createNativeImpl(); - if(null == aScreen) { - throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); + display.createNative(); // 1st display: trigger creation w/o incr ref count (hold native dispatching) + try { + createNativeImpl(); + if(null == aScreen) { + throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); + } + initScreenModeStatus(); + } finally { + display.addReference(); // 1st display: allow native dispatching } if(DEBUG) { System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+")"); @@ -181,7 +186,8 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { screensActive++; } } - initScreenModeStatus(); + ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); + sms.addListener(this); } public synchronized final void destroy() { @@ -263,7 +269,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return aScreen; } - public final boolean isNativeValid() { + public synchronized final boolean isNativeValid() { return null != aScreen; } @@ -447,8 +453,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return false; } - private void initScreenModeStatus() { - // JAU: FIXME: Add return .. + private ScreenModeStatus initScreenModeStatus() { ScreenModeStatus sms; ScreenModeStatus.lockScreenModeStatus(); try { @@ -481,10 +486,10 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { } ScreenModeStatus.mapScreenModeStatus(this.getFQName(), sms); } - sms.addListener(this); } finally { ScreenModeStatus.unlockScreenModeStatus(); } + return sms; } /** ignores bpp < 15 */ |