summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/swt
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/swt')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java134
1 files changed, 67 insertions, 67 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index ff764d849..33941a407 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -102,11 +102,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
/* GL Stuff */
private final RecursiveLock lock = LockFactory.createRecursiveLock();
private final GLDrawableHelper helper = new GLDrawableHelper();
-
+
private final GLContext shareWith;
private final GLCapabilitiesImmutable capsRequested;
- private final GLCapabilitiesChooser capsChooser;
-
+ private final GLCapabilitiesChooser capsChooser;
+
private volatile Rectangle clientArea;
private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access
private volatile GLContextImpl context;
@@ -156,7 +156,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public void run() {
final RecursiveLock _lock = lock;
_lock.lock();
- try {
+ try {
if( !GLCanvas.this.isDisposed() ) {
helper.invokeGL(drawable, context, displayAction, initAction);
}
@@ -215,7 +215,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
gle.printStackTrace();
}
}
- context = null;
+ context = null;
}
if ( null != drawable ) {
drawable.setRealized(false);
@@ -261,11 +261,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
};
-
- /**
- * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)}
+
+ /**
+ * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)}
* on the SWT thread.
- *
+ *
* @param parent
* Required (non-null) parent Composite.
* @param style
@@ -284,7 +284,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
*/
public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps,
final GLCapabilitiesChooser chooser, final GLContext shareWith) {
- final GLCanvas[] res = new GLCanvas[] { null };
+ final GLCanvas[] res = new GLCanvas[] { null };
parent.getDisplay().syncExec(new Runnable() {
public void run() {
res[0] = new GLCanvas( parent, style, caps, chooser, shareWith );
@@ -319,22 +319,22 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
GLProfile.initSingleton(); // ensure JOGL is completly initialized
SWTAccessor.setRealized(this, true);
-
+
clientArea = GLCanvas.this.getClientArea();
- /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite).
+ /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite).
* Note: SWT is owner of the native handle, hence closing operation will be a NOP. */
final AbstractGraphicsDevice swtDevice = SWTAccessor.getDevice(this);
-
+
useX11GTK = SWTAccessor.useX11GTK();
if(useX11GTK) {
- // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering
+ // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering
final long x11DeviceHandle = X11Util.openDisplay(swtDevice.getConnection());
if( 0 == x11DeviceHandle ) {
throw new RuntimeException("Error creating display(EDT): "+swtDevice.getConnection());
}
final AbstractGraphicsDevice x11Device = new X11GraphicsDevice(x11DeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */);
- screen = SWTAccessor.getScreen(x11Device, -1 /* default */);
+ screen = SWTAccessor.getScreen(x11Device, -1 /* default */);
} else {
screen = SWTAccessor.getScreen(swtDevice, -1 /* default */);
}
@@ -343,7 +343,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
if(null == capsReqUser) {
capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice()));
}
-
+
this.capsRequested = capsReqUser;
this.capsChooser = capsChooser;
this.shareWith = shareWith;
@@ -353,7 +353,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
x11Window = 0;
drawable = null;
context = null;
-
+
final Listener listener = new Listener () {
@Override
public void handleEvent (Event event) {
@@ -374,7 +374,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
addListener (SWT.Paint, listener);
addListener (SWT.Dispose, listener);
}
-
+
private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() {
@Override
public final void create(ProxySurface s) { /* nop */ }
@@ -401,11 +401,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
protected final void updateSizeCheck() {
final Rectangle oClientArea = clientArea;
final Rectangle nClientArea = GLCanvas.this.getClientArea();
- if ( nClientArea != null &&
+ if ( nClientArea != null &&
( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height )
) {
clientArea = nClientArea; // write back new value
-
+
final GLDrawableImpl _drawable = drawable;
final boolean drawableOK = null != _drawable && _drawable.isRealized();
if(DEBUG) {
@@ -419,14 +419,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
try {
final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, nClientArea.width, nClientArea.height);
if(_drawable != _drawableNew) {
- // write back
+ // write back
drawable = _drawableNew;
}
} finally {
_lock.unlock();
}
- }
- }
+ }
+ }
if(0 != x11Window) {
SWTAccessor.resizeX11Window(screen.getDevice(), clientArea, x11Window);
} else if(0 != gdkWindow) {
@@ -435,36 +435,36 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock
}
}
-
+
private boolean isValidAndVisibleOnEDTActionResult;
private final Runnable isValidAndVisibleOnEDTAction = new Runnable() {
@Override
- public void run() {
+ public void run() {
isValidAndVisibleOnEDTActionResult = !GLCanvas.this.isDisposed() && GLCanvas.this.isVisible();
} };
-
+
private final boolean isValidAndVisibleOnEDT() {
synchronized(isValidAndVisibleOnEDTAction) {
runOnEDTIfAvail(true, isValidAndVisibleOnEDTAction);
return isValidAndVisibleOnEDTActionResult;
}
}
-
+
/** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */
protected final boolean validateDrawableAndContextWithCheck() {
if( !isValidAndVisibleOnEDT() ) {
return false;
}
- return validateDrawableAndContextPostCheck();
+ return validateDrawableAndContextPostCheck();
}
-
+
/** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */
protected final boolean validateDrawableAndContextPostCheck() {
final Rectangle nClientArea = clientArea;
if(0 >= nClientArea.width || 0 >= nClientArea.height) {
return false;
}
-
+
final boolean res;
final RecursiveLock _lock = lock;
_lock.lock();
@@ -480,18 +480,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
} finally {
_lock.unlock();
- }
-
+ }
+
if(res) {
sendReshape = true;
if(DEBUG) {
System.err.println("SWT GLCanvas realized! "+this+", "+drawable);
// Thread.dumpStack();
- }
+ }
}
- return res;
+ return res;
}
-
+
private final void createDrawableAndContext() {
final AbstractGraphicsDevice device = screen.getDevice();
device.open();
@@ -503,14 +503,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED);
if(DEBUG) {
System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg);
- }
+ }
if (null == cfg) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
final int visualID = cfg.getVisualID(VIDType.NATIVE);
if( VisualIDHolder.VID_UNDEFINED != visualID ) {
// gdkWindow = SWTAccessor.createCompatibleGDKChildWindow(this, visualID, clientArea.width, clientArea.height);
- // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow);
+ // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow);
x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height);
nativeWindowHandle = x11Window;
} else {
@@ -520,16 +520,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
nativeWindowHandle = SWTAccessor.getWindowHandle(this);
}
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile());
-
+
// Create a NativeWindow proxy for the SWT canvas
- ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle,
+ ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle,
capsRequested, capsChooser, swtCanvasUpStreamHook);
// Associate a GL surface with the proxy
drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface);
context = (GLContextImpl) drawable.createContext(shareWith);
- context.setContextCreationFlags(additionalCtxCreationFlags);
+ context.setContextCreationFlags(additionalCtxCreationFlags);
}
-
+
@Override
public void update() {
// don't paint background etc .. nop avoids flickering
@@ -543,13 +543,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
if(r && 0 != gdkWindow) {
SWTGTKUtil.focusGDKWindow(gdkWindow);
}
- return r;
+ return r;
} */
-
+
@Override
public void dispose() {
runInGLThread(disposeOnEDTGLAction);
- super.dispose();
+ super.dispose();
}
private final void displayIfNoAnimatorNoCheck() {
@@ -557,14 +557,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
final boolean drawableOK = null != drawable && drawable.isRealized();
if( drawableOK || validateDrawableAndContextPostCheck() ) {
runInGLThread(makeCurrentAndDisplayOnGLAction);
- }
+ }
}
}
-
+
//
// GL[Auto]Drawable
//
-
+
@Override
public void display() {
final boolean drawableOK = null != drawable && drawable.isRealized();
@@ -577,7 +577,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public final Object getUpstreamWidget() {
return this;
}
-
+
@Override
public int getWidth() {
return clientArea.width;
@@ -593,7 +593,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
final GLDrawable _drawable = drawable;
return null != _drawable ? _drawable.isGLOriented() : true;
}
-
+
@Override
public void addGLEventListener(final GLEventListener listener) {
helper.addGLEventListener(listener);
@@ -608,29 +608,29 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public int getGLEventListenerCount() {
return helper.getGLEventListenerCount();
}
-
+
@Override
public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException {
return helper.getGLEventListener(index);
}
-
+
@Override
public boolean getGLEventListenerInitState(GLEventListener listener) {
return helper.getGLEventListenerInitState(listener);
}
-
+
@Override
public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) {
helper.setGLEventListenerInitState(listener, initialized);
}
-
+
@Override
public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) {
final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove);
runInGLThread(r);
return r.listener;
}
-
+
@Override
public GLEventListener removeGLEventListener(final GLEventListener listener) {
return helper.removeGLEventListener(listener);
@@ -673,7 +673,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public final GLDrawable getDelegatedDrawable() {
return drawable;
}
-
+
@Override
public GLContext getContext() {
return null != drawable ? context : null;
@@ -694,12 +694,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public boolean invoke(final boolean wait, final GLRunnable runnable) {
return helper.invoke(this, wait, runnable);
}
-
+
@Override
public boolean invoke(final boolean wait, final List<GLRunnable> runnables) {
return helper.invoke(this, wait, runnables);
}
-
+
@Override
public void setAnimator(final GLAnimatorControl arg0) throws GLException {
helper.setAnimator(arg0);
@@ -714,7 +714,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) {
final RecursiveLock _lock = lock;
_lock.lock();
- try {
+ try {
final GLContext oldCtx = context;
GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags);
context=(GLContextImpl)newCtx;
@@ -761,7 +761,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
@Override
public GLCapabilitiesImmutable getChosenGLCapabilities() {
- final GLDrawable _drawable = drawable;
+ final GLDrawable _drawable = drawable;
return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getChosenGLCapabilities() : null;
}
@@ -771,7 +771,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* @return Non-null GLCapabilities.
*/
public GLCapabilitiesImmutable getRequestedGLCapabilities() {
- final GLDrawable _drawable = drawable;
+ final GLDrawable _drawable = drawable;
return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities() : null;
}
@@ -788,7 +788,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
@Override
public long getHandle() {
- final GLDrawable _drawable = drawable;
+ final GLDrawable _drawable = drawable;
return (_drawable != null) ? _drawable.getHandle() : 0;
}
@@ -827,12 +827,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* <ul>
* <!--li>Use {@link Threading#invokeOnOpenGLThread(boolean, Runnable)}</li-->
* <li>Current thread</li>
- * </ul></li>
+ * </ul></li>
* </ul>
- * The current thread seems to be valid for all platforms,
+ * The current thread seems to be valid for all platforms,
* since no SWT lifecycle tasks are being performed w/ this call.
* Only GL task, which are independent from the SWT threading model.
- *
+ *
* @see Platform#AWT_AVAILABLE
* @see Platform#getOSType()
*/
@@ -854,8 +854,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
} */
action.run();
}
-
- private void runOnEDTIfAvail(boolean wait, final Runnable action) {
+
+ private void runOnEDTIfAvail(boolean wait, final Runnable action) {
final Display d = isDisposed() ? null : getDisplay();
if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) {
action.run();
@@ -879,7 +879,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
",\n\tDrawable size "+dw+"x"+dh+
",\n\tSWT size "+getWidth()+"x"+getHeight()+"]";
}
-
+
public static void main(final String[] args) {
System.err.println(VersionUtil.getPlatformInfo());
System.err.println(GlueGenVersion.getInstance());