diff options
author | Sven Gothel <[email protected]> | 2012-09-28 18:52:31 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-09-28 18:52:31 +0200 |
commit | e4176f4e76f519b3599ad557210def3d35266e7b (patch) | |
tree | 1cb39ae2532b17ff5e1fd90a43198ce986878f26 /src/newt/classes/jogamp | |
parent | 54f79e402ddb87de9caa3297228cbd16c452cfb4 (diff) |
NativeWindow/X11 + NEWT/X11: Cache 'isXineramaEnabled()' to reduce X11 server roundtrips.
Diffstat (limited to 'src/newt/classes/jogamp')
3 files changed, 12 insertions, 7 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index bff050030..6e80e966a 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -85,8 +85,8 @@ public class DisplayDriver extends DisplayImpl { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { closeNativeImpl(); - throw e; - } + throw e; + } } protected void closeNativeImpl() { @@ -111,6 +111,9 @@ public class DisplayDriver extends DisplayImpl { protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } + /** Returns <code>null</code> if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ + protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } + //---------------------------------------------------------------------- // Internals only // @@ -131,6 +134,6 @@ public class DisplayDriver extends DisplayImpl { private long windowDeleteAtom; /** X11 Window java object property used on EDT */ - private long javaObjectAtom; + private long javaObjectAtom; } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index b09d98e06..7a3c718c0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -282,8 +282,10 @@ public class ScreenDriver extends ScreenImpl { } }; protected int validateScreenIndex(final int idx) { - if(getDisplay().isNativeValid()) { - return X11Util.XineramaIsEnabled((X11GraphicsDevice)getDisplay().getGraphicsDevice()) ? 0 : idx; + final DisplayDriver x11Display = (DisplayDriver) getDisplay(); + final Boolean r = x11Display.isXineramaEnabled(); + if( null != r ) { + return r.booleanValue() ? 0 : idx; } else { return runWithTempDisplayHandle( xineramaEnabledQueryWithTemp ).booleanValue() ? 0 : idx; } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index aea86a420..bde723634 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -74,7 +74,7 @@ public class WindowDriver extends WindowImpl { throw new RuntimeException("Error creating display(EDT): "+edtDevice.getConnection()); } renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true); - AbstractGraphicsScreen renderScreen = new X11GraphicsScreen((X11GraphicsDevice) renderDevice, screen.getIndex()); + final AbstractGraphicsScreen renderScreen = new X11GraphicsScreen(renderDevice, screen.getIndex()); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( @@ -300,5 +300,5 @@ public class WindowDriver extends WindowImpl { private static native void warpPointer0(long display, long windowHandle, int x, int y); private long windowHandleClose; - private AbstractGraphicsDevice renderDevice; + private X11GraphicsDevice renderDevice; } |