aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-01-19 13:36:23 -0800
committerSven Gothel <[email protected]>2012-01-19 13:36:23 -0800
commit9844190b0a7a3b1504266f81bcba973a9b0ac06c (patch)
treecbd696365d27cac76afe052c1cea66ce5c3d9075 /src/jogl/classes/com/jogamp
parent4635eb9f78456f14376ae524c8aee74019f770c5 (diff)
parent6fecbcd14c069193aefa2e580aaa53de5265fce3 (diff)
Merge pull request #43 from krisher/master
Fixed SWT threading policy violation when using worker mode for JOGL threading.
Diffstat (limited to 'src/jogl/classes/com/jogamp')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index ef1c3fbeb..c982ce16d 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -57,6 +57,7 @@ import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
@@ -186,6 +187,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
};
/**
+ * Storage for the client area rectangle so that it may be accessed from outside of the SWT thread.
+ */
+ private volatile Rectangle clientArea;
+
+ /**
* Creates a new SWT GLCanvas.
*
* @param parent
@@ -212,6 +218,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
SWTAccessor.setRealized(this, true);
+ clientArea = GLCanvas.this.getClientArea();
+
/* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite) */
device = SWTAccessor.getDevice(this);
/* Native handle for the control, used to associate with GLContext */
@@ -247,6 +255,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
addControlListener(new ControlAdapter() {
@Override
public void controlResized(final ControlEvent arg0) {
+ clientArea = GLCanvas.this.getClientArea();
/* Mark for OpenGL reshape next time the control is painted */
sendReshape = true;
}
@@ -381,7 +390,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
public int getHeight() {
- return getClientArea().height;
+ final Rectangle clientArea = this.clientArea;
+ if (clientArea == null) return 0;
+ return clientArea.height;
}
public NativeSurface getNativeSurface() {
@@ -395,7 +406,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
public int getWidth() {
- return getClientArea().width;
+ final Rectangle clientArea = this.clientArea;
+ if (clientArea == null) return 0;
+ return clientArea.width;
}
public boolean isRealized() {