aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-03-19 00:32:21 +0000
committerSven Gothel <[email protected]>2010-04-19 00:55:58 +0200
commitccad31d01fc1385bd09029f825a4a7ad8c305b4f (patch)
treedc55858007eb53ed18341ff42c0e1c4baa232b9b /src
parent90a29aef20d5be1b35c42f30a9a8bd3202a21fc2 (diff)
Movement of Capabilities class and chooseCapabilities functionality into NativeWindowFactory introduced an undesirable dependence between the windowing toolkit, which can be replaced via NativeWindowFactory, and the library which implements the selection algorithm, for example OpenGL. This would prevent, for example, an easy SWT port of JOGL.
To fix this, refactored chooseCapabilities into new GraphicsConfigurationFactory, the default implementation of which is currently a no-op on X11 platforms, and which is provided by JOGL in a toolkit-agnostic manner via GLX. Refactored OpenGL portions of Capabilities class back into GLCapabilities. Reintroduced GLCapabilitiesChooser interface for compatibility and to avoid having to import javax.media.nativewindow classes in most user code. Fixed problem in GLProfile where failures to load native libraries were being squelched. Reorganized build to have all outputs under build/ directory. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1884 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
new file mode 100644
index 0000000..1643c30
--- /dev/null
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.sun.nativewindow.impl.x11;
+
+import javax.media.nativewindow.*;
+import com.sun.nativewindow.impl.*;
+
+public class X11NativeWindowFactory extends NativeWindowFactoryImpl {
+ // On X11 platforms we need to do some locking; this basic
+ // implementation should suffice for some simple window toolkits
+ private ToolkitLock toolkitLock = new ToolkitLock() {
+ private Thread owner;
+ private int recursionCount;
+
+ public synchronized void lock() {
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return;
+ }
+ while (owner != null) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ owner = cur;
+ }
+
+ public synchronized void unlock() {
+ if (owner != Thread.currentThread()) {
+ throw new RuntimeException("Not owner");
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ }
+ };
+
+ public ToolkitLock getToolkitLock() {
+ return toolkitLock;
+ }
+}