diff options
author | Sven Gothel <[email protected]> | 2015-08-31 08:41:07 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-08-31 08:41:07 +0200 |
commit | cf9e2f2cb8ead7efd7751dcbfaecb36ed06cf9d6 (patch) | |
tree | 5b0879c7146983221074ed9c687be2fba7db779d /src/nativewindow/classes | |
parent | cc00d9b6c5a5c6b71ba14311fc6b17ce932d9a1e (diff) |
Bug 1210 - Use manual impl. XRenderFindVisualFormat instead of buggy generated version
- XRenderDirectFormat XVisual2XRenderMask(..):
- Move from JOGL's X11GLXGraphicsConfiguration -> Nativewindow X11GraphicsConfiguration
- Always use manual impl. of XRenderFindVisualFormat
Additionally:
- Add X11GraphicsConfiguration.XVisualInfo2X11Capabilities(..)
allowing to properly setup the resulting Capabilities instance
as used in X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(..)
- XVisualInfo:
- Add 'String toString()'
- 'XVisualInfo create(XVisualInfo s)' uses source buffer size!
- XGetVisualInfo: Use returned buffer-capacity/count for element-size
and also bail out if count<=0
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java | 43 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java | 12 |
2 files changed, 50 insertions, 5 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java index 04619962d..bcb9741d6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java @@ -33,10 +33,15 @@ package com.jogamp.nativewindow.x11; +import com.jogamp.common.util.Bitfield; import com.jogamp.nativewindow.CapabilitiesImmutable; import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import jogamp.nativewindow.x11.X11Capabilities; +import jogamp.nativewindow.x11.X11Lib; +import jogamp.nativewindow.x11.XRenderDirectFormat; +import jogamp.nativewindow.x11.XRenderPictFormat; import jogamp.nativewindow.x11.XVisualInfo; /** Encapsulates a graphics configuration, or OpenGL pixel format, on @@ -48,6 +53,44 @@ import jogamp.nativewindow.x11.XVisualInfo; public class X11GraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { private XVisualInfo info; + // FBConfig + + protected static XRenderDirectFormat XVisual2XRenderMask(final long dpy, final long visual) { + final XRenderPictFormat xRenderPictFormat = XRenderPictFormat.create(); + return XVisual2XRenderMask(dpy, visual, xRenderPictFormat); + } + protected static XRenderDirectFormat XVisual2XRenderMask(final long dpy, final long visual, final XRenderPictFormat dest) { + if( !X11Lib.XRenderFindVisualFormat(dpy, visual, dest) ) { + return null; + } else { + return dest.getDirect(); + } + } + + public static X11Capabilities XVisualInfo2X11Capabilities(final X11GraphicsDevice device, final XVisualInfo info) { + final long display = device.getHandle(); + final X11Capabilities res = new X11Capabilities(info); + + final XRenderDirectFormat xrmask = ( null != info ) ? XVisual2XRenderMask( display, info.getVisual() ) : null ; + final int alphaMask = ( null != xrmask ) ? xrmask.getAlphaMask() : 0; + if( 0 < alphaMask ) { + res.setBackgroundOpaque(false); + res.setTransparentRedValue(xrmask.getRedMask()); + res.setTransparentGreenValue(xrmask.getGreenMask()); + res.setTransparentBlueValue(xrmask.getBlueMask()); + res.setTransparentAlphaValue(alphaMask); + } else { + res.setBackgroundOpaque(true); + } + // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples) + res.setRedBits (Bitfield.Util.bitCount((int)info.getRed_mask())); + res.setGreenBits (Bitfield.Util.bitCount((int)info.getGreen_mask())); + res.setBlueBits (Bitfield.Util.bitCount((int)info.getBlue_mask())); + res.setAlphaBits (Bitfield.Util.bitCount(alphaMask)); + + return res; + } + public X11GraphicsConfiguration(final X11GraphicsScreen screen, final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested, final XVisualInfo info) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index f8a11f91e..4257376a0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -42,6 +42,7 @@ import com.jogamp.nativewindow.NativeWindowException; import com.jogamp.nativewindow.VisualIDHolder; import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory { @@ -59,15 +60,17 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor if(!(screen instanceof X11GraphicsScreen)) { throw new NativeWindowException("Only valid X11GraphicsScreen are allowed"); } - final X11Capabilities x11CapsChosen; + final XVisualInfo x11VisualInfo; if(VisualIDHolder.VID_UNDEFINED == nativeVisualID) { - x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, capsChosen)); + x11VisualInfo = getXVisualInfo(screen, capsChosen); } else { - x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, nativeVisualID)); + x11VisualInfo = getXVisualInfo(screen, nativeVisualID); } + + final X11Capabilities x11CapsChosen = X11GraphicsConfiguration.XVisualInfo2X11Capabilities((X11GraphicsDevice)screen.getDevice(), x11VisualInfo); final AbstractGraphicsConfiguration res = new X11GraphicsConfiguration((X11GraphicsScreen)screen, x11CapsChosen, capsRequested, x11CapsChosen.getXVisualInfo()); if(DEBUG) { - System.err.println("X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(visualID 0x"+Integer.toHexString(nativeVisualID)+", "+screen+","+capsChosen+"): "+res); + System.err.println("X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(visualID 0x"+Integer.toHexString(nativeVisualID)+", "+x11VisualInfo+", "+screen+","+capsChosen+"): "+res); } return res; } @@ -85,7 +88,6 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor if(xvis==null || num[0]<1) { return null; } - return XVisualInfo.create(xvis[0]); } |