diff options
author | Kevin Rushforth <[email protected]> | 2007-05-16 22:34:12 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2007-05-16 22:34:12 +0000 |
commit | cb471feee88597a77b715a9039ef6f62ef9fd664 (patch) | |
tree | 15edaad8562be73a4375c5fc1236a48fed89c11e /src/classes | |
parent | cf929de6a881ab72b03b99690feec23a8e0413d5 (diff) |
Source code changes for issue 491: Refactor platform-specific classes to use non-overlapping class names
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@842 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 2 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/NativeConfigTemplate3D.java | 108 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/NativePipeline.java | 32 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/NativeScreenInfo.java | 69 | ||||
-rw-r--r-- | src/classes/win32/javax/media/j3d/Win32NativeConfigTemplate3D.java (renamed from src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java) | 44 | ||||
-rw-r--r-- | src/classes/win32/javax/media/j3d/Win32NativeScreenInfo.java (renamed from src/classes/win32/javax/media/j3d/NativeScreenInfo.java) | 17 | ||||
-rw-r--r-- | src/classes/x11/javax/media/j3d/X11NativeConfigTemplate3D.java (renamed from src/classes/x11/javax/media/j3d/NativeConfigTemplate3D.java) | 68 | ||||
-rw-r--r-- | src/classes/x11/javax/media/j3d/X11NativeScreenInfo.java (renamed from src/classes/x11/javax/media/j3d/NativeScreenInfo.java) | 19 |
8 files changed, 270 insertions, 89 deletions
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index c503697..f1f1687 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -1253,7 +1253,7 @@ class MasterControl { * Returns whether we are running on Windows * TODO: most code that cares about this should move into the pipeline */ - final boolean isWindows() { + static final boolean isWindows() { return isWindowsOs; } diff --git a/src/classes/share/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/share/javax/media/j3d/NativeConfigTemplate3D.java new file mode 100644 index 0000000..d16c0a2 --- /dev/null +++ b/src/classes/share/javax/media/j3d/NativeConfigTemplate3D.java @@ -0,0 +1,108 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.awt.GraphicsConfiguration; + +/** + * Native config template class. A singleton instance of the appropriate + * concrete subclass is created by a factory method using reflection. + */ +abstract class NativeConfigTemplate3D { + // These definitions are used by both the X11 and Win32 subclasses + final static int RED_SIZE = 0; + final static int GREEN_SIZE = 1; + final static int BLUE_SIZE = 2; + final static int ALPHA_SIZE = 3; + final static int ACCUM_BUFFER = 4; + final static int DEPTH_SIZE = 5; + final static int DOUBLEBUFFER = 6; + final static int STEREO = 7; + final static int ANTIALIASING = 8; + final static int STENCIL_SIZE = 9; + final static int NUM_ITEMS = 10; + + private static final String x11ClassName = "javax.media.j3d.X11NativeConfigTemplate3D"; + private static final String win32ClassName = "javax.media.j3d.Win32NativeConfigTemplate3D"; + + // The singleton instance of this class + private static NativeConfigTemplate3D nativeConfigTemplate3D = null; + + protected NativeConfigTemplate3D() { + } + + // This method is called exactly once by the initialization method of + // the NativePipeline class + synchronized static void createNativeConfigTemplate3D() { + String className; + if (MasterControl.isWindows()) { + className = win32ClassName; + } else { + className = x11ClassName; + } + + final String templateClassName = className; + nativeConfigTemplate3D = (NativeConfigTemplate3D) + java.security.AccessController.doPrivileged(new + java.security.PrivilegedAction() { + public Object run() { + try { + Class templateClass = Class.forName(templateClassName); + return templateClass.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + } + + static NativeConfigTemplate3D getNativeConfigTemplate3D() { + return nativeConfigTemplate3D; + } + + + /* + * Chooses the best FBConfig for Java 3D apps. + */ + abstract GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D template, + GraphicsConfiguration[] gc); + + /* + * Determine if a given GraphicsConfiguration object can be used + * by Java 3D. + */ + abstract boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D template, + GraphicsConfiguration gc); + + + // Return whether stereo is available. + abstract boolean hasStereo(Canvas3D c3d); + + // Return the stencil of this canvas. + abstract int getStencilSize(Canvas3D c3d); + + // Return whether a double buffer is available. + abstract boolean hasDoubleBuffer(Canvas3D c3d); + + // Return whether scene antialiasing is available. + abstract boolean hasSceneAntialiasingAccum(Canvas3D c3d); + + + // Return whether scene antialiasing is available. + abstract boolean hasSceneAntialiasingMultisample(Canvas3D c3d); + + // Ensure that the native libraries are loaded + static { + VirtualUniverse.loadLibraries(); + } +} diff --git a/src/classes/share/javax/media/j3d/NativePipeline.java b/src/classes/share/javax/media/j3d/NativePipeline.java index d8341df..0ac3b73 100644 --- a/src/classes/share/javax/media/j3d/NativePipeline.java +++ b/src/classes/share/javax/media/j3d/NativePipeline.java @@ -43,13 +43,6 @@ class NativePipeline extends Pipeline { private boolean cgLibraryAvailable = false; private boolean glslLibraryAvailable = false; - /** - * The platform dependent template. Since there is no - * template-specific instance data in the NativeConfigTemplate3D - * class, we can create one statically. - */ - private static NativeConfigTemplate3D nativeTemplate = new NativeConfigTemplate3D(); - // Flag indicating that the ogl-chk library has been loaded private static boolean oglChkLibraryLoaded = false; @@ -86,7 +79,7 @@ class NativePipeline extends Pipeline { */ void initialize(Pipeline.Type pipelineType) { super.initialize(pipelineType); - + // This works around a native load library bug try { java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); @@ -106,6 +99,11 @@ class NativePipeline extends Pipeline { default: assert false; // Should never get here } + + // Create the singleton, OS-dependent NativeConfigTemplate3D and + // NativeScreenInfo objects. + NativeConfigTemplate3D.createNativeConfigTemplate3D(); + NativeScreenInfo.createNativeScreenInfo(); } /** @@ -3263,42 +3261,42 @@ class NativePipeline extends Pipeline { // Get best graphics config from pipeline GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct, GraphicsConfiguration[] gc) { - return nativeTemplate.getBestConfiguration(gct, gc); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().getBestConfiguration(gct, gc); } // Determine whether specified graphics config is supported by pipeline boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D gct, GraphicsConfiguration gc) { - return nativeTemplate.isGraphicsConfigSupported(gct, gc); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().isGraphicsConfigSupported(gct, gc); } // Methods to get actual capabilities from Canvas3D boolean hasDoubleBuffer(Canvas3D cv) { - return nativeTemplate.hasDoubleBuffer(cv); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().hasDoubleBuffer(cv); } boolean hasStereo(Canvas3D cv) { - return nativeTemplate.hasStereo(cv); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().hasStereo(cv); } int getStencilSize(Canvas3D cv) { - return nativeTemplate.getStencilSize(cv); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().getStencilSize(cv); } boolean hasSceneAntialiasingMultisample(Canvas3D cv) { - return nativeTemplate.hasSceneAntialiasingMultisample(cv); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().hasSceneAntialiasingMultisample(cv); } boolean hasSceneAntialiasingAccum(Canvas3D cv) { - return nativeTemplate.hasSceneAntialiasingAccum(cv); + return NativeConfigTemplate3D.getNativeConfigTemplate3D().hasSceneAntialiasingAccum(cv); } // Methods to get native WS display and screen long getDisplay() { - return NativeScreenInfo.getDisplay(); + return NativeScreenInfo.getNativeScreenInfo().getDisplay(); } int getScreen(GraphicsDevice graphicsDevice) { - return NativeScreenInfo.getScreen(graphicsDevice); + return NativeScreenInfo.getNativeScreenInfo().getScreen(graphicsDevice); } // --------------------------------------------------------------------- diff --git a/src/classes/share/javax/media/j3d/NativeScreenInfo.java b/src/classes/share/javax/media/j3d/NativeScreenInfo.java new file mode 100644 index 0000000..94502f4 --- /dev/null +++ b/src/classes/share/javax/media/j3d/NativeScreenInfo.java @@ -0,0 +1,69 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.awt.GraphicsDevice; + +/** + * Native screen info class. A singleton instance of the appropriate + * concrete subclass is created by a factory method using reflection. + */ +abstract class NativeScreenInfo { + private static final String x11ClassName = "javax.media.j3d.X11NativeScreenInfo"; + private static final String win32ClassName = "javax.media.j3d.Win32NativeScreenInfo"; + + // The singleton instance of this class + private static NativeScreenInfo nativeScreenInfo = null; + + protected NativeScreenInfo() { + } + + // This method is called exactly once by the initialization method of + // the NativePipeline class + synchronized static void createNativeScreenInfo() { + String className; + if (MasterControl.isWindows()) { + className = win32ClassName; + } else { + className = x11ClassName; + } + + final String scrInfoClassName = className; + nativeScreenInfo = (NativeScreenInfo) + java.security.AccessController.doPrivileged(new + java.security.PrivilegedAction() { + public Object run() { + try { + Class scrInfoClass = Class.forName(scrInfoClassName); + return scrInfoClass.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + } + + static NativeScreenInfo getNativeScreenInfo() { + return nativeScreenInfo; + } + + /** + * Get the display handle + */ + abstract long getDisplay(); + + /** + * Get the screen number for the given graphics device + */ + abstract int getScreen(GraphicsDevice graphicsDevice); +} diff --git a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/win32/javax/media/j3d/Win32NativeConfigTemplate3D.java index f91986a..10edfd1 100644 --- a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/win32/javax/media/j3d/Win32NativeConfigTemplate3D.java @@ -18,25 +18,16 @@ import sun.awt.Win32GraphicsDevice; import sun.awt.Win32GraphicsConfig; import java.awt.GraphicsConfigTemplate; -class NativeConfigTemplate3D { +/** + * Native config template class. A singleton instance of this class is + * created by a factory method in the base class using reflection. + */ +class Win32NativeConfigTemplate3D extends NativeConfigTemplate3D { private final static boolean debug = false; - NativeConfigTemplate3D() { + Win32NativeConfigTemplate3D() { } - // This definition should match those in solaris NativeConfigTemplate3D.java - final static int RED_SIZE = 0; - final static int GREEN_SIZE = 1; - final static int BLUE_SIZE = 2; - final static int ALPHA_SIZE = 3; - final static int ACCUM_BUFFER = 4; - final static int DEPTH_SIZE = 5; - final static int DOUBLEBUFFER = 6; - final static int STEREO = 7; - final static int ANTIALIASING = 8; - final static int STENCIL_SIZE = 9; - final static int NUM_ITEMS = 10; - /** * selects the proper visual */ @@ -45,7 +36,7 @@ class NativeConfigTemplate3D { // Native method to free an PixelFormatInfo struct. This is static since it // may need to be called to clean up the Canvas3D graphicsConfigTable after the - // NativeConfigTemplate3D has been disposed of. + // Win32NativeConfigTemplate3D has been disposed of. static native void freePixelFormatInfo(long pFormatInfo); // Native methods to return whether a particular attribute is available @@ -58,6 +49,7 @@ class NativeConfigTemplate3D { /** * Chooses the best PixelFormat for Java 3D apps. */ + @Override GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D template, GraphicsConfiguration[] gc) { @@ -69,7 +61,7 @@ class NativeConfigTemplate3D { do so in J3D 1.4. System.out.println("getBestConfiguration : Checking WGL ARB support\n"); - if (!NativeScreenInfo.isWglARB()) { + if (!Win32NativeScreenInfo.isWglARB()) { Thread.dumpStack(); System.out.println("getBestConfiguration : WGL ARB support fail\n"); return null; @@ -89,10 +81,10 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); attrList[STENCIL_SIZE] = template.getStencilSize(); - // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // System.out.println("Win32NativeConfigTemplate3D : getStencilSize " + // attrList[STENCIL_SIZE]); - int screen = NativeScreenInfo.getScreen(gd); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); long[] pFormatInfo = new long[1]; @@ -139,6 +131,7 @@ class NativeConfigTemplate3D { * Determine if a given GraphicsConfiguration object can be used * by Java 3D. */ + @Override boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D template, GraphicsConfiguration gc) { @@ -149,7 +142,7 @@ class NativeConfigTemplate3D { do so in J3D 1.4. System.out.println("isGraphicsConfigSupported : Checking WGL ARB support\n"); - if (!NativeScreenInfo.isWglARB()) { + if (!Win32NativeScreenInfo.isWglARB()) { Thread.dumpStack(); System.out.println("isGraphicsConfigSupported : WGL ARB support fail\n"); return false; @@ -169,10 +162,10 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); attrList[STENCIL_SIZE] = template.getStencilSize(); - // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // System.out.println("Win32NativeConfigTemplate3D : getStencilSize " + // attrList[STENCIL_SIZE]); - int screen = NativeScreenInfo.getScreen(gd); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); long[] pFormatInfo = new long[1]; @@ -192,32 +185,37 @@ class NativeConfigTemplate3D { // Return whether stereo is available. + @Override boolean hasStereo(Canvas3D c3d) { return isStereoAvailable(c3d.fbConfig, c3d.offScreen); } // Return the stencil of this canvas. + @Override int getStencilSize(Canvas3D c3d) { return getStencilSize(c3d.fbConfig, c3d.offScreen); } // Return whether a double buffer is available. + @Override boolean hasDoubleBuffer(Canvas3D c3d) { return isDoubleBufferAvailable(c3d.fbConfig, c3d.offScreen); } // Return whether scene antialiasing is available. + @Override boolean hasSceneAntialiasingAccum(Canvas3D c3d) { return isSceneAntialiasingAccumAvailable(c3d.fbConfig, c3d.offScreen); } // Return whether scene antialiasing is available. + @Override boolean hasSceneAntialiasingMultisample(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; Win32GraphicsDevice gd = (Win32GraphicsDevice)((Win32GraphicsConfig)gc).getDevice(); - int screen = NativeScreenInfo.getScreen(gd); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); /* Fix to issue 77 */ return isSceneAntialiasingMultisampleAvailable(c3d.fbConfig, c3d.offScreen, screen); } diff --git a/src/classes/win32/javax/media/j3d/NativeScreenInfo.java b/src/classes/win32/javax/media/j3d/Win32NativeScreenInfo.java index 61066b9..0a6a105 100644 --- a/src/classes/win32/javax/media/j3d/NativeScreenInfo.java +++ b/src/classes/win32/javax/media/j3d/Win32NativeScreenInfo.java @@ -15,7 +15,11 @@ package javax.media.j3d; import java.awt.GraphicsDevice; import sun.awt.Win32GraphicsDevice; -class NativeScreenInfo { +/** + * Native screen info class. A singleton instance of this class is created by + * a factory method in the base class using reflection. + */ +class Win32NativeScreenInfo extends NativeScreenInfo { private static final long display = 0; // unused for Win32 private static boolean wglARBChecked = false; @@ -23,8 +27,7 @@ class NativeScreenInfo { private static native boolean queryWglARB(); - private NativeScreenInfo() { - throw new AssertionError("constructor should never be called"); + Win32NativeScreenInfo() { } // This method will return true if wglGetExtensionsStringARB is supported, @@ -39,16 +42,18 @@ class NativeScreenInfo { return isWglARB; } - static long getDisplay() { + @Override + long getDisplay() { return display; } - static int getScreen(GraphicsDevice graphicsDevice) { + @Override + int getScreen(GraphicsDevice graphicsDevice) { return ((Win32GraphicsDevice)graphicsDevice).getScreen(); } // Ensure that the native libraries are loaded static { - VirtualUniverse.loadLibraries(); + VirtualUniverse.loadLibraries(); } } diff --git a/src/classes/x11/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/x11/javax/media/j3d/X11NativeConfigTemplate3D.java index d1d2000..8a46d3b 100644 --- a/src/classes/x11/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/x11/javax/media/j3d/X11NativeConfigTemplate3D.java @@ -19,25 +19,16 @@ import java.awt.Rectangle; import sun.awt.X11GraphicsDevice; import sun.awt.X11GraphicsConfig; -class NativeConfigTemplate3D { +/** + * Native config template class. A singleton instance of this class is + * created by a factory method in the base class using reflection. + */ +class X11NativeConfigTemplate3D extends NativeConfigTemplate3D { private final static boolean debug = false; - NativeConfigTemplate3D() { + X11NativeConfigTemplate3D() { } - // These definitions should match those in win32 NativeConfigTemplate3D.java - final static int RED_SIZE = 0; - final static int GREEN_SIZE = 1; - final static int BLUE_SIZE = 2; - final static int ALPHA_SIZE = 3; - final static int ACCUM_BUFFER = 4; - final static int DEPTH_SIZE = 5; - final static int DOUBLEBUFFER = 6; - final static int STEREO = 7; - final static int ANTIALIASING = 8; - final static int STENCIL_SIZE = 9; - final static int NUM_ITEMS = 10; - // Native method to get an OpenGL visual id and a pointer to the // GLXFBConfig structure list itself. native int chooseOglVisual(long display, int screen, @@ -45,7 +36,7 @@ class NativeConfigTemplate3D { // Native method to free an GLXFBConfig struct. This is static since it // may need to be called to clean up the Canvas3D graphicsConfigTable - // after the NativeConfigTemplate3D has been disposed of. + // after the X11NativeConfigTemplate3D has been disposed of. static native void freeFBConfig(long fbConfig); // Native methods to return whether a particular attribute is available @@ -58,21 +49,22 @@ class NativeConfigTemplate3D { /* * Chooses the best FBConfig for Java 3D apps. */ + @Override GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D template, GraphicsConfiguration[] gc) { X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc[0]).getDevice(); - if (!NativeScreenInfo.isGLX13()) { + if (!X11NativeScreenInfo.isGLX13()) { return null; } - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); if (debug) { - System.out.println(" NativeConfigTemplate3D: using device " + gd); + System.out.println(" X11NativeConfigTemplate3D: using device " + gd); System.out.println(" display " + display + " screen " + screen); System.out.println(" configuration count: " + gc.length); for (int i = 0 ; i < gc.length ; i++) { @@ -109,7 +101,7 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); attrList[STENCIL_SIZE] = template.getStencilSize(); - // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // System.out.println("X11NativeConfigTemplate3D : getStencilSize " + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; @@ -162,18 +154,19 @@ class NativeConfigTemplate3D { * Determine if a given GraphicsConfiguration object can be used * by Java 3D. */ + @Override boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D template, GraphicsConfiguration gc) { X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - if (!NativeScreenInfo.isGLX13()) { + if (!X11NativeScreenInfo.isGLX13()) { return false; } - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int[] attrList; // holds the list of attributes to be tramslated // for glxChooseVisual call @@ -190,7 +183,7 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); attrList[STENCIL_SIZE] = template.getStencilSize(); - // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // System.out.println("X11NativeConfigTemplate3D : getStencilSize " + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; @@ -204,56 +197,60 @@ class NativeConfigTemplate3D { // Return whether stereo is available. + @Override boolean hasStereo(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int vid = ((X11GraphicsConfig)gc).getVisual(); return isStereoAvailable(display, screen, vid); } // Return the stencil of this canvas. + @Override int getStencilSize(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int vid = ((X11GraphicsConfig)gc).getVisual(); return getStencilSize(display, screen, vid); } // Return whether a double buffer is available. + @Override boolean hasDoubleBuffer(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int vid = ((X11GraphicsConfig)gc).getVisual(); return isDoubleBufferAvailable(display, screen, vid); } // Return whether scene antialiasing is available. + @Override boolean hasSceneAntialiasingAccum(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int vid = ((X11GraphicsConfig)gc).getVisual(); return isSceneAntialiasingAccumAvailable(display, screen, vid); @@ -261,14 +258,15 @@ class NativeConfigTemplate3D { // Return whether scene antialiasing is available. + @Override boolean hasSceneAntialiasingMultisample(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); - long display = NativeScreenInfo.getDisplay(); - int screen = NativeScreenInfo.getScreen(gd); + long display = NativeScreenInfo.getNativeScreenInfo().getDisplay(); + int screen = NativeScreenInfo.getNativeScreenInfo().getScreen(gd); int vid = ((X11GraphicsConfig)gc).getVisual(); return isSceneAntialiasingMultisampleAvailable(display, screen, vid); diff --git a/src/classes/x11/javax/media/j3d/NativeScreenInfo.java b/src/classes/x11/javax/media/j3d/X11NativeScreenInfo.java index c352467..bb19002 100644 --- a/src/classes/x11/javax/media/j3d/NativeScreenInfo.java +++ b/src/classes/x11/javax/media/j3d/X11NativeScreenInfo.java @@ -15,7 +15,11 @@ package javax.media.j3d; import java.awt.GraphicsDevice; import sun.awt.X11GraphicsDevice; -class NativeScreenInfo { +/** + * Native screen info class. A singleton instance of this class is created by + * a factory method in the base class using reflection. + */ +class X11NativeScreenInfo extends NativeScreenInfo { private static long display = 0; private static boolean glxChecked = false; private static boolean isGLX13; @@ -23,8 +27,7 @@ class NativeScreenInfo { private static native long openDisplay(); private static native boolean queryGLX13(long display); - private NativeScreenInfo() { - throw new AssertionError("constructor should never be called"); + X11NativeScreenInfo() { } // Fix for issue 20. @@ -36,7 +39,7 @@ class NativeScreenInfo { getStaticDisplay(); // Query for glx1.3 support. - isGLX13 = queryGLX13(getDisplay()); + isGLX13 = queryGLX13(getStaticDisplay()); glxChecked = true; } @@ -50,18 +53,20 @@ class NativeScreenInfo { return display; } - static long getDisplay() { + @Override + long getDisplay() { // Open a new static display connection if one is not already opened return getStaticDisplay(); } - static int getScreen(GraphicsDevice graphicsDevice) { + @Override + int getScreen(GraphicsDevice graphicsDevice) { // Get the screen number return ((X11GraphicsDevice)graphicsDevice).getScreen(); } // Ensure that the native libraries are loaded static { - VirtualUniverse.loadLibraries(); + VirtualUniverse.loadLibraries(); } } |