All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.media.nativewindow.AbstractGraphicsDevice Maven / Gradle / Ivy

There is a newer version: 2.3.2
Show newest version
/*
 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
 * Copyright (c) 2010 JogAmp Community. 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.
 * 
 * You acknowledge that this software is not designed or intended for use
 * in the design, construction, operation or maintenance of any nuclear
 * facility.
 * 
 * Sun gratefully acknowledges that this software was originally authored
 * and developed by Kenneth Bradley Russell and Christopher John Kline.
 */

package javax.media.nativewindow;

import jogamp.nativewindow.Debug;

/** A interface describing a graphics device in a
    toolkit-independent manner.
 */
public interface AbstractGraphicsDevice extends Cloneable {
    public static final boolean DEBUG = Debug.debug("GraphicsDevice");
    
    /** Dummy connection value for a default connection where no native support for multiple devices is available */
    public static String DEFAULT_CONNECTION = "decon";

    /** Dummy connection value for an external connection where no native support for multiple devices is available */
    public static String EXTERNAL_CONNECTION = "excon";

    /** Default unit id for the 1st device: 0 */
    public static int DEFAULT_UNIT = 0;

    public Object clone();
    
    /**
     * Returns the type of the underlying subsystem, ie
     * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
     */
    public String getType();

    /**
     * Returns the semantic GraphicsDevice connection.
* On platforms supporting remote devices, eg via tcp/ip network, * the implementation shall return a unique name for each remote address.
* On X11 for example, the connection string should be as the following example.
*
    *
  • :0.0 for a local connection
  • *
  • remote.host.net:0.0 for a remote connection
  • *
* * To support multiple local device, see {@link #getUnitID()}. */ public String getConnection(); /** * Returns the graphics device unit ID.
* The unit ID support multiple graphics device configurations * on a local machine.
* To support remote device, see {@link #getConnection()}. * @return */ public int getUnitID(); /** * Returns a unique ID object of this device using {@link #getType() type}, * {@link #getConnection() connection} and {@link #getUnitID() unitID} as it's key components. *

* The unique ID does not reflect the instance of the device, hence the handle is not included. * The unique ID may be used as a key for semantic device mapping. *

*

* The returned string object reference is unique using {@link String#intern()} * and hence can be used as a key itself. *

*/ public String getUniqueID(); /** * Returns the native handle of the underlying native device, * if such thing exist. */ public long getHandle(); /** * Optionally locking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#lock()}. * The lock implementation must be recursive. */ public void lock(); /** * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#unlock()}. * The lock implementation must be recursive. * * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); /** * @throws RuntimeException if current thread does not hold the lock */ public void validateLocked() throws RuntimeException; /** * Optionally [re]opening the device if handle is null. *

* The default implementation is a NOP. *

*

* Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native open operation in case handle is null. *

* * @return true if the handle was null and opening was successful, otherwise false. */ public boolean open(); /** * Optionally closing the device if handle is not null. *

* The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null. *

*

* Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}. *

* * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); /** * @return true if instance owns the handle to issue {@link #close()}, otherwise false. */ public boolean isHandleOwner(); public void clearHandleOwner(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy