summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-06 07:27:29 +0100
committerSven Gothel <[email protected]>2012-03-06 07:27:29 +0100
commit28ca3652c7c3c73cc3c41ad84b3f1efdad98add5 (patch)
tree20c687ec4b4ef1be7ff3548c96e1913889e3be8b /src/nativewindow/classes/jogamp
parent9124f3fade3f923b581c6e7b871d049b431bbd78 (diff)
NativeWindow public-spec to public-impl reorg (javax.media.nativewindow.<impl> -> com.jogamp.nativewindow.<impl>) 1/2
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java43
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java84
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java74
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTToolkitLock.java54
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java489
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java265
6 files changed, 0 insertions, 1009 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java b/src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java
deleted file mode 100644
index ee3ab73ba..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright 2011 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:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.nativewindow;
-
-import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.CapabilitiesImmutable;
-import javax.media.nativewindow.DefaultGraphicsConfiguration;
-
-public class MutableGraphicsConfiguration extends DefaultGraphicsConfiguration {
- public MutableGraphicsConfiguration(AbstractGraphicsScreen screen,
- CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
- super(screen, capsChosen, capsRequested);
- }
-
- public void setChosenCapabilities(CapabilitiesImmutable caps) {
- super.setChosenCapabilities(caps);
- }
-}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
deleted file mode 100644
index 20d3ad6dc..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Copyright 2012 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:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package jogamp.nativewindow;
-
-/**
- * Specifies query to the native capabilities identification.
- * Semantics may differ depending on the native windowing system,
- * see {@link #getVisualID(int)}.
- */
-public interface NativeVisualID {
-
- public enum NVIDType {
- GEN_ID(0), NATIVE_ID(1),
- EGL_ConfigID(2), EGL_NativeVisualID(3), X11_XVisualID(4), X11_FBConfigID(5), WIN32_PFDID(6);
-
- public final int id;
-
- NVIDType(int id){
- this.id = id;
- }
- }
-
- /**
- * Returns the native identification of the given <code>type</code>.
- * <p>
- * Depending on the native windowing system, this might be
- * <ul>
- * <li>X11
- * <ul>
- * <li>GEN_ID: X11_XVisualID</li>
- * <li>NATIVE_ID: X11_XVisualID</li>
- * <li>X11_XVisualID</li>
- * </ul></li>
- * <li>X11/GL
- * <ul>
- * <li>GEN_ID: X11_XVisualID</li>
- * <li>NATIVE_ID: X11_XVisualID</li>
- * <li>X11_XVisualID</li>
- * <li>X11FBConfigID</li>
- * </ul></li>
- * <li>Windows/GL
- * <ul>
- * <li>GEN_ID: WIN32_PFDID</li>
- * <li>NATIVE_ID: WIN32_PFDID</li>
- * <li>WIN32_PFDID</li>
- * </ul></li>
- * <li>EGL/GL
- * <ul>
- * <li>GEN_ID: EGL_ConfigID</li>
- * <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li>
- * <li>EGL_ConfigID</li>
- * <li>EGL_NativeVisualID</li>
- * </ul></li>
- * </ul>
- * </p>
- */
- int getVisualID(NVIDType type);
-}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
deleted file mode 100644
index 074fab563..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright 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:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package jogamp.nativewindow;
-
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
-import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.SurfaceChangeable;
-
-
-public class WrappedSurface extends ProxySurface implements SurfaceChangeable {
- protected long surfaceHandle;
-
- public WrappedSurface(AbstractGraphicsConfiguration cfg) {
- this(cfg, 0);
- }
-
- public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle) {
- super(cfg);
- surfaceHandle=handle;
- }
-
- protected final void invalidateImpl() {
- surfaceHandle = 0;
- }
-
- public long getSurfaceHandle() {
- return surfaceHandle;
- }
-
- public void setSurfaceHandle(long surfaceHandle) {
- this.surfaceHandle=surfaceHandle;
- }
-
- protected int lockSurfaceImpl() {
- return LOCK_SUCCESS;
- }
-
- protected void unlockSurfaceImpl() {
- }
-
- public String toString() {
- return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+
- ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) +
- ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) +
- ", size " + getWidth() + "x" + getHeight() +
- ", surfaceLock "+surfaceLock+"]";
- }
-}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTToolkitLock.java
deleted file mode 100644
index 37e34c01c..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTToolkitLock.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 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:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.nativewindow.jawt;
-
-import javax.media.nativewindow.ToolkitLock;
-
-/**
- * Implementing a singleton global recursive {@link javax.media.nativewindow.ToolkitLock}
- * utilizing JAWT's AWT lock via {@link JAWTUtil#lockToolkit()}.
- * <br>
- * This strategy should only be used if AWT is using the underlying native windowing toolkit
- * in a not intrinsic thread safe manner, e.g. under X11 where no XInitThreads() call
- * is issued before any other X11 usage. This is the current situation for e.g. Webstart or Applets.
- */
-public class JAWTToolkitLock implements ToolkitLock {
-
- /** Singleton via {@link JAWTUtil#getJAWTToolkitLock()} */
- protected JAWTToolkitLock() {}
-
- public final void lock() {
- if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.lock()"); }
- JAWTUtil.lockToolkit();
- }
-
- public final void unlock() {
- if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.unlock()"); }
- JAWTUtil.unlockToolkit();
- }
-}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
deleted file mode 100644
index 863b336fc..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- */
-
-package jogamp.nativewindow.jawt;
-
-import com.jogamp.common.util.locks.LockFactory;
-import com.jogamp.common.util.locks.RecursiveLock;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.applet.Applet;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.NativeWindow;
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.OffscreenLayerOption;
-import javax.media.nativewindow.OffscreenLayerSurface;
-import javax.media.nativewindow.SurfaceUpdatedListener;
-import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
-import javax.media.nativewindow.util.Insets;
-import javax.media.nativewindow.util.InsetsImmutable;
-import javax.media.nativewindow.util.Point;
-import javax.media.nativewindow.util.Rectangle;
-import javax.media.nativewindow.util.RectangleImmutable;
-
-import jogamp.nativewindow.SurfaceUpdatedHelper;
-
-public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption {
- protected static final boolean DEBUG = JAWTUtil.DEBUG;
-
- // user properties
- protected boolean shallUseOffscreenLayer = false;
-
- // lifetime: forever
- protected Component component;
- private AWTGraphicsConfiguration config; // control access due to delegation
- private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
- private RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
-
- // lifetime: valid after lock but may change with each 1st lock, purges after invalidate
- private boolean isApplet;
- private JAWT jawt;
- private boolean isOffscreenLayerSurface;
- protected long drawable;
- protected Rectangle bounds;
- protected Insets insets;
-
- private long drawable_old;
-
- /**
- * Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)}
- * via this platform's specialization (X11, OSX, Windows, ..).
- *
- * @param comp
- * @param config
- */
- protected JAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
- if (config == null) {
- throw new NativeWindowException("Error: AbstractGraphicsConfiguration is null");
- }
- if(! ( config instanceof AWTGraphicsConfiguration ) ) {
- throw new NativeWindowException("Error: AbstractGraphicsConfiguration is not an AWTGraphicsConfiguration: "+config);
- }
- this.config = (AWTGraphicsConfiguration) config;
- init((Component)comp);
- }
-
- private void init(Component windowObject) throws NativeWindowException {
- invalidate();
- this.component = windowObject;
- this.isApplet = false;
- }
-
- public void setShallUseOffscreenLayer(boolean v) {
- shallUseOffscreenLayer = v;
- }
-
- public final boolean getShallUseOffscreenLayer() {
- return shallUseOffscreenLayer;
- }
-
- public final boolean isOffscreenLayerSurfaceEnabled() {
- return isOffscreenLayerSurface;
- }
-
- protected synchronized void invalidate() {
- invalidateNative();
- jawt = null;
- isOffscreenLayerSurface = false;
- drawable= 0;
- drawable_old = 0;
- bounds = new Rectangle();
- insets = new Insets();
- }
- protected abstract void invalidateNative();
-
- protected final void updateBounds(JAWT_Rectangle jawtBounds) {
- bounds.setX(jawtBounds.getX());
- bounds.setY(jawtBounds.getY());
- bounds.setWidth(jawtBounds.getWidth());
- bounds.setHeight(jawtBounds.getHeight());
-
- if(component instanceof Container) {
- java.awt.Insets contInsets = ((Container)component).getInsets();
- insets.setLeftWidth(contInsets.left);
- insets.setRightWidth(contInsets.right);
- insets.setTopHeight(contInsets.top);
- insets.setBottomHeight(contInsets.bottom);
- }
- }
-
- /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
- public final RectangleImmutable getBounds() { return bounds; }
-
- public final InsetsImmutable getInsets() { return insets; }
-
- public final Component getAWTComponent() {
- return component;
- }
-
- /**
- * Returns true if the AWT component is parented to an {@link java.applet.Applet},
- * otherwise false. This information is valid only after {@link #lockSurface()}.
- */
- public final boolean isApplet() {
- return isApplet;
- }
-
- /** Returns the underlying JAWT instance created @ {@link #lockSurface()}. */
- public final JAWT getJAWT() {
- return jawt;
- }
-
- /**
- * {@inheritDoc}
- */
- public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException {
- if( !isOffscreenLayerSurfaceEnabled() ) {
- throw new NativeWindowException("Not an offscreen layer surface");
- }
- int lockRes = lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
- throw new NativeWindowException("Could not lock (offscreen layer): "+this);
- }
- try {
- if(DEBUG) {
- System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
- }
- attachSurfaceLayerImpl(layerHandle);
- } finally {
- unlockSurface();
- }
- }
- protected abstract void attachSurfaceLayerImpl(final long layerHandle);
-
- /**
- * {@inheritDoc}
- */
- public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {
- if( !isOffscreenLayerSurfaceEnabled() ) {
- throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface");
- }
- int lockRes = lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
- throw new NativeWindowException("Could not lock (offscreen layer): "+this);
- }
- try {
- if(DEBUG) {
- System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
- }
- detachSurfaceLayerImpl(layerHandle);
- } finally {
- unlockSurface();
- }
- }
- protected abstract void detachSurfaceLayerImpl(final long layerHandle);
-
- //
- // SurfaceUpdateListener
- //
-
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
- }
-
- public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
- surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
- }
-
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
- }
-
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
- surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
- }
-
- //
- // NativeSurface
- //
-
- private void determineIfApplet() {
- Component c = component;
- while(!isApplet && null != c) {
- isApplet = c instanceof Applet;
- c = c.getParent();
- }
- }
-
- /**
- * If JAWT offscreen layer is supported,
- * implementation shall respect {@link #getShallUseOffscreenLayer()}
- * and may respect {@link #isApplet()}.
- *
- * @return The JAWT instance reflecting offscreen layer support, etc.
- *
- * @throws NativeWindowException
- */
- protected abstract JAWT fetchJAWTImpl() throws NativeWindowException;
- protected abstract int lockSurfaceImpl() throws NativeWindowException;
-
- protected void dumpJAWTInfo() {
- if(null != jawt) {
- System.err.println("JAWT version: 0x"+Integer.toHexString(jawt.getCachedVersion())+
- ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(jawt)+
- ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets);
- } else {
- System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets);
- }
- // Thread.dumpStack();
- }
-
- public final int lockSurface() throws NativeWindowException {
- surfaceLock.lock();
- int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
-
- if ( LOCK_SURFACE_NOT_READY == res ) {
- determineIfApplet();
- try {
- final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
- adevice.lock();
- try {
- jawt = fetchJAWTImpl();
- isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt);
- res = lockSurfaceImpl();
- if(LOCK_SUCCESS == res && drawable_old != drawable) {
- res = LOCK_SURFACE_CHANGED;
- if(DEBUG) {
- System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable));
- // Thread.dumpStack();
- }
- }
- } finally {
- if (LOCK_SURFACE_NOT_READY >= res) {
- adevice.unlock();
- }
- }
- } finally {
- if (LOCK_SURFACE_NOT_READY >= res) {
- surfaceLock.unlock();
- }
- }
- }
- return res;
- }
-
- protected abstract void unlockSurfaceImpl() throws NativeWindowException;
-
- public final void unlockSurface() {
- surfaceLock.validateLocked();
- drawable_old = drawable;
-
- if (surfaceLock.getHoldCount() == 1) {
- final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
- try {
- unlockSurfaceImpl();
- } finally {
- adevice.unlock();
- }
- }
- surfaceLock.unlock();
- }
-
- public final boolean isSurfaceLockedByOtherThread() {
- return surfaceLock.isLockedByOtherThread();
- }
-
- public final boolean isSurfaceLocked() {
- return surfaceLock.isLocked();
- }
-
- public final Thread getSurfaceLockOwner() {
- return surfaceLock.getOwner();
- }
-
- public boolean surfaceSwap() {
- return false;
- }
-
- public long getSurfaceHandle() {
- return drawable;
- }
-
- public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() {
- return config;
- }
-
- public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
- return config.getNativeGraphicsConfiguration();
- }
-
- public final long getDisplayHandle() {
- return getGraphicsConfiguration().getScreen().getDevice().getHandle();
- }
-
- public final int getScreenIndex() {
- return getGraphicsConfiguration().getScreen().getIndex();
- }
-
- public int getWidth() {
- return component.getWidth();
- }
-
- public int getHeight() {
- return component.getHeight();
- }
-
- //
- // NativeWindow
- //
-
- public synchronized void destroy() {
- invalidate();
- component = null; // don't dispose the AWT component, since we are merely an immutable uplink
- }
-
- public final NativeWindow getParent() {
- return null;
- }
-
- public long getWindowHandle() {
- return drawable;
- }
-
- public final int getX() {
- return component.getX();
- }
-
- public final int getY() {
- return component.getY();
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * This JAWT default implementation is currently still using
- * a blocking implementation. It first attempts to retrieve the location
- * via a native implementation. If this fails, it tries the blocking AWT implementation.
- * If the latter fails due to an external AWT tree-lock, the non block
- * implementation {@link #getLocationOnScreenNonBlocking(Point, Component)} is being used.
- * The latter simply traverse up to the AWT component tree and sums the rel. position.
- * We have to determine whether the latter is good enough for all cases,
- * currently only OS X utilizes the non blocking method per default.
- * </p>
- */
- public Point getLocationOnScreen(Point storage) {
- Point los = getLocationOnScreenNative(storage);
- if(null == los) {
- if(!Thread.holdsLock(component.getTreeLock())) {
- // avoid deadlock ..
- if(DEBUG) {
- System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock: "+this);
- Thread.dumpStack();
- }
- return getLocationOnScreenNonBlocking(storage, component);
- }
- java.awt.Point awtLOS = component.getLocationOnScreen();
- if(null!=storage) {
- los = storage.translate(awtLOS.x, awtLOS.y);
- } else {
- los = new Point(awtLOS.x, awtLOS.y);
- }
- }
- return los;
- }
-
- protected Point getLocationOnScreenNative(Point storage) {
- int lockRes = lockSurface();
- if(LOCK_SURFACE_NOT_READY == lockRes) {
- if(DEBUG) {
- System.err.println("Warning: JAWT Lock couldn't be acquired: "+this);
- Thread.dumpStack();
- }
- return null;
- }
- try {
- Point d = getLocationOnScreenNativeImpl(0, 0);
- if(null!=d) {
- if(null!=storage) {
- storage.translate(d.getX(),d.getY());
- return storage;
- }
- }
- return d;
- } finally {
- unlockSurface();
- }
- }
- protected abstract Point getLocationOnScreenNativeImpl(int x, int y);
-
- protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) {
- int x = 0;
- int y = 0;
- while(null != comp) {
- x += comp.getX();
- y += comp.getY();
- comp = comp.getParent();
- }
- if(null!=storage) {
- storage.translate(x, y);
- return storage;
- }
- return new Point(x, y);
- }
-
- public boolean hasFocus() {
- return component.hasFocus();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
-
- sb.append("JAWT-Window["+
- "windowHandle 0x"+Long.toHexString(getWindowHandle())+
- ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+
- ", bounds "+bounds+", insets "+insets+
- ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface);
- if(null!=component) {
- sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- ", visible "+component.isVisible());
- } else {
- sb.append(", component NULL");
- }
- sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
- ",\n\tconfig "+getPrivateGraphicsConfiguration()+
- ",\n\tawtComponent "+getAWTComponent()+
- ",\n\tsurfaceLock "+surfaceLock+"]");
-
- return sb.toString();
- }
-
-}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java
deleted file mode 100644
index aab1556da..000000000
--- a/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * Copyright 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:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.nativewindow.swt;
-
-import com.jogamp.common.os.Platform;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.eclipse.swt.graphics.GCData;
-import org.eclipse.swt.widgets.Control;
-
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.windows.WindowsGraphicsDevice;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
-import com.jogamp.common.util.ReflectionUtil;
-import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
-
-import jogamp.nativewindow.macosx.OSXUtil;
-
-public class SWTAccessor {
- static final Field swt_control_handle;
- static final boolean swt_uses_long_handles;
-
- // X11/GTK, Windows/GDI, ..
- static final String str_handle = "handle";
-
- // OSX/Cocoa
- static final String str_view = "view"; // OSX
- static final String str_id = "id"; // OSX
- // static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView";
-
- static final Method swt_control_internal_new_GC;
- static final Method swt_control_internal_dispose_GC;
- static final String str_internal_new_GC = "internal_new_GC";
- static final String str_internal_dispose_GC = "internal_dispose_GC";
-
- static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS";
- static final Class<?> OS_gtk_class;
- static final Method OS_gtk_widget_realize;
- static final Method OS_gtk_widget_unrealize;
- static final Method OS_GTK_WIDGET_WINDOW;
- static final Method OS_gdk_x11_drawable_get_xdisplay;
- static final Method OS_gdk_x11_drawable_get_xid;
- static final String str_gtk_widget_realize = "gtk_widget_realize";
- static final String str_gtk_widget_unrealize = "gtk_widget_unrealize";
- static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW";
- static final String str_gdk_x11_drawable_get_xdisplay = "gdk_x11_drawable_get_xdisplay";
- static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid";
-
- static {
- Field f = null;
-
- if(NativeWindowFactory.TYPE_MACOSX != NativeWindowFactory.getNativeWindowType(false) ) {
- try {
- f = Control.class.getField(str_handle);
- } catch (Exception ex) {
- throw new NativeWindowException(ex);
- }
- }
- swt_control_handle = f; // maybe null !
-
- boolean ulh;
- if (null != swt_control_handle) {
- ulh = swt_control_handle.getGenericType().toString().equals(long.class.toString());
- } else {
- ulh = Platform.is64Bit();
- }
- swt_uses_long_handles = ulh;
- // System.err.println("SWT long handles: " + swt_uses_long_handles);
- // System.err.println("Platform 64bit: "+Platform.is64Bit());
-
- Method m=null;
- try {
- m = ReflectionUtil.getMethod(Control.class, str_internal_new_GC, new Class[] { GCData.class });
- } catch (Exception ex) {
- throw new NativeWindowException(ex);
- }
- swt_control_internal_new_GC = m;
-
- try {
- if(swt_uses_long_handles) {
- m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { long.class, GCData.class });
- } else {
- m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { int.class, GCData.class });
- }
- } catch (NoSuchMethodException ex) {
- throw new NativeWindowException(ex);
- }
- swt_control_internal_dispose_GC = m;
-
- Class<?> c=null;
- Method m1=null, m2=null, m3=null, m4=null, m5=null;
- Class<?> handleType = swt_uses_long_handles ? long.class : int.class ;
- if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false) ) {
- try {
- c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader());
- m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType);
- m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType);
- m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType);
- m4 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType);
- m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType);
- } catch (Exception ex) { throw new NativeWindowException(ex); }
- }
- OS_gtk_class = c;
- OS_gtk_widget_realize = m1;
- OS_gtk_widget_unrealize = m2;
- OS_GTK_WIDGET_WINDOW = m3;
- OS_gdk_x11_drawable_get_xdisplay = m4;
- OS_gdk_x11_drawable_get_xid = m5;
- }
-
- static Object getIntOrLong(long arg) {
- if(swt_uses_long_handles) {
- return new Long(arg);
- }
- return new Integer((int) arg);
- }
-
- static void callStaticMethodL2V(Method m, long arg) {
- ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) });
- }
-
- static long callStaticMethodL2L(Method m, long arg) {
- Object o = ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) });
- if(o instanceof Number) {
- return ((Number)o).longValue();
- } else {
- throw new InternalError("SWT method "+m.getName()+" didn't return int or long but "+o.getClass());
- }
- }
-
- public static boolean isUsingLongHandles() {
- return swt_uses_long_handles;
- }
-
- public static long getHandle(Control swtControl) {
- long h = 0;
- if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) {
- try {
- Field fView = Control.class.getField(str_view);
- Object view = fView.get(swtControl);
- Field fId = view.getClass().getField(str_id);
- return fId.getLong(view);
- } catch (Exception ex) {
- throw new NativeWindowException(ex);
- }
- }
-
- try {
- h = swt_control_handle.getLong(swtControl);
- } catch (Exception ex) {
- throw new NativeWindowException(ex);
- }
- return h;
- }
-
- public static void setRealized(final Control swtControl, final boolean realize) {
- final long handle = getHandle(swtControl);
-
- if(null != OS_gtk_class) {
- invoke(true, new Runnable() {
- public void run() {
- if(realize) {
- callStaticMethodL2V(OS_gtk_widget_realize, handle);
- } else {
- callStaticMethodL2V(OS_gtk_widget_unrealize, handle);
- }
- }
- });
- }
- }
-
- public static AbstractGraphicsDevice getDevice(Control swtControl) {
- long handle = getHandle(swtControl);
- if( null != OS_gtk_class ) {
- long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle);
- long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle);
- // FIXME: May think about creating a private non-shared X11 Display handle, like we use to for AWT
- // to avoid locking problems !
- return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false);
- }
- if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ) {
- return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- }
- if( NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) {
- return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
- }
- throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));
- }
-
- public static long getWindowHandle(Control swtControl) {
- long handle = getHandle(swtControl);
- if( null != OS_gtk_class ) {
- long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle);
- return callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, widgedHandle);
- }
- if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ||
- NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) {
- return handle;
- }
- throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));
- }
-
- public static long newGC(final Control swtControl, final GCData gcData) {
- final Object[] o = new Object[1];
- invoke(true, new Runnable() {
- public void run() {
- o[0] = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData });
- }
- });
- if(o[0] instanceof Number) {
- return ((Number)o[0]).longValue();
- } else {
- throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass());
- }
- }
-
- public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) {
- invoke(true, new Runnable() {
- public void run() {
- if(swt_uses_long_handles) {
- ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Long(gc), gcData });
- } else {
- ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Integer((int)gc), gcData });
- }
- }
- });
- }
-
- public static void invoke(boolean wait, Runnable runnable) {
- if(Platform.OS_TYPE == Platform.OSType.MACOS) {
- OSXUtil.RunOnMainThread(wait, runnable);
- } else {
- runnable.run();
- }
- }
-
-}