JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
AbstractGraphicsDevice.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2024 JogAmp Community. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 *
37 * Sun gratefully acknowledges that this software was originally authored
38 * and developed by Kenneth Bradley Russell and Christopher John Kline.
39 */
40
41package com.jogamp.nativewindow;
42
43import jogamp.nativewindow.Debug;
44
45/** A interface describing a graphics device in a
46 toolkit-independent manner.
47 */
48public interface AbstractGraphicsDevice extends Cloneable {
49 public static final boolean DEBUG = Debug.debug("GraphicsDevice");
50
51 /** Dummy connection value for a default connection where no native support for multiple devices is available */
52 public static String DEFAULT_CONNECTION = "decon";
53
54 /** Dummy connection value for an external connection where no native support for multiple devices is available */
55 public static String EXTERNAL_CONNECTION = "excon";
56
57 /** Default unit id for the 1st device: 0 */
58 public static int DEFAULT_UNIT = 0;
59
60 public Object clone();
61
62 /**
63 * Returns the type of the underlying subsystem, ie
64 * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
65 */
66 public String getType();
67
68 /**
69 * Returns the semantic GraphicsDevice connection.<br>
70 * On platforms supporting remote devices, eg via tcp/ip network,
71 * the implementation shall return a unique name for each remote address.
72 * <p>
73 * For {@link com.jogamp.nativewindow.x11.X11GraphicsDevice X11GraphicsDevice},
74 * the connection string should be as the follows
75 * <ul>
76 * <li><code>:0.0</code> for a local connection</li>
77 * <li><code>remote.host.net:0.0</code> for a remote connection</li>
78 * </ul>
79 * </p>
80 * To support multiple local device, see {@link #getUnitID()}.
81 */
82 public String getConnection();
83
84 /**
85 * Returns the graphics device <code>unit ID</code>.<br>
86 * The <code>unit ID</code> support multiple graphics device configurations
87 * on a local machine.<br>
88 * To support remote device, see {@link #getConnection()}.
89 * @return
90 */
91 public int getUnitID();
92
93 /**
94 * Returns a unique ID object of this device using {@link #getType() type},
95 * {@link #getConnection() connection} and {@link #getUnitID() unitID} as it's key components.
96 * <p>
97 * The unique ID does not reflect the instance of the device, hence the handle is not included.
98 * The unique ID may be used as a key for semantic device mapping.
99 * </p>
100 * <p>
101 * The returned string object reference is unique using {@link String#intern()}
102 * and hence can be used as a key itself.
103 * </p>
104 */
105 public String getUniqueID();
106
107 /**
108 * Returns the native handle of the underlying native device,
109 * if such thing exist.
110 */
111 public long getHandle();
112
113 /**
114 * Optionally locking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#lock()}.
115 * The lock implementation must be recursive.
116 */
117 public void lock();
118
119 /**
120 * Optionally unlocking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#unlock()}.
121 * The lock implementation must be recursive.
122 *
123 * @throws RuntimeException in case the lock is not acquired by this thread.
124 */
125 public void unlock();
126
127 /**
128 * @throws RuntimeException if current thread does not hold the lock
129 */
130 public void validateLocked() throws RuntimeException;
131
132 /**
133 * Optionally [re]opening the device if handle is <code>null</code>.
134 * <p>
135 * The default implementation is a <code>NOP</code>.
136 * </p>
137 * <p>
138 * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
139 * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
140 * issue the native open operation in case handle is <code>null</code>.
141 * </p>
142 *
143 * @return true if the handle was <code>null</code> and opening was successful, otherwise false.
144 */
145 public boolean open();
146
147 /**
148 * Optionally closing the device if handle is not <code>null</code>.
149 * <p>
150 * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to <code>null</code>.
151 * </p>
152 * <p>
153 * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
154 * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
155 * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}.
156 * </p>
157 *
158 * @return true if the handle was not <code>null</code> and closing was successful, otherwise false.
159 */
160 public boolean close();
161
162 /**
163 * @return <code>true</code> if instance owns the handle to issue {@link #close()}, otherwise <code>false</code>.
164 */
165 public boolean isHandleOwner();
166
167 public void clearHandleOwner();
168}
A interface describing a graphics device in a toolkit-independent manner.
boolean close()
Optionally closing the device if handle is not null.
void lock()
Optionally locking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#lock().
void unlock()
Optionally unlocking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#unlock().
String getType()
Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory....
String getUniqueID()
Returns a unique ID object of this device using type, connection and unitID as it's key components.
long getHandle()
Returns the native handle of the underlying native device, if such thing exist.
boolean open()
Optionally [re]opening the device if handle is null.
int getUnitID()
Returns the graphics device unit ID.
static int DEFAULT_UNIT
Default unit id for the 1st device: 0.
static String EXTERNAL_CONNECTION
Dummy connection value for an external connection where no native support for multiple devices is ava...
String getConnection()
Returns the semantic GraphicsDevice connection.
static String DEFAULT_CONNECTION
Dummy connection value for a default connection where no native support for multiple devices is avail...