summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java65
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java7
4 files changed, 81 insertions, 19 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 3d907a86f..d0a4b7e98 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -54,6 +54,8 @@ import jogamp.newt.awt.NewtFactoryAWT;
import jogamp.newt.awt.event.AWTParentWindowAdapter;
import jogamp.newt.driver.DriverClearFocus;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
import com.jogamp.nativewindow.awt.JAWTWindow;
import com.jogamp.newt.Display;
@@ -561,7 +563,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
if(DEBUG) {
// if ( isShowing() == false ) -> Container was not visible yet.
// if ( isShowing() == true ) -> Container is already visible.
- System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+
+ System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+Thread.currentThread().getName()+": win "+newtWinHandleToHexString(newtChild)+
", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+
", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+
", cont "+AWTMisc.getContainer(this));
@@ -575,9 +577,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final int w = getWidth();
final int h = getHeight();
System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h);
+ newtChild.setVisible(false);
newtChild.setSize(w, h);
newtChild.reparentWindow(jawtWindow);
newtChild.addSurfaceUpdatedListener(jawtWindow);
+ if( Platform.OSType.MACOS == Platform.getOSType() && jawtWindow.isOffscreenLayerSurfaceEnabled() ) {
+ AWTEDTExecutor.singleton.invoke(false, forceRelayout);
+ }
newtChild.setVisible(true);
configureNewtChild(true);
newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
@@ -589,6 +595,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this);
}
}
+ private final Runnable forceRelayout = new Runnable() {
+ public void run() {
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.forceRelayout.0");
+ }
+ // Hack to force proper native AWT layout incl. CALayer components on OSX
+ final java.awt.Component component = NewtCanvasAWT.this;
+ final int cW = component.getWidth();
+ final int cH = component.getHeight();
+ component.setSize(cW+1, cH+1);
+ component.setSize(cW, cH);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.forceRelayout.X");
+ }
+ } };
private final void detachNewtChild(java.awt.Container cont) {
if( null == newtChild || null == jawtWindow || !newtChildAttached ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 49f1940dc..5e523c780 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -37,6 +37,7 @@ import java.nio.FloatBuffer;
import javax.media.nativewindow.NativeWindow;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -267,6 +268,10 @@ public class GearsES2 implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
+ GLAnimatorControl anim = drawable.getAnimator();
+ if( verbose && ( null == anim || !anim.isAnimating() ) ) {
+ System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
+ }
// Turn the gears' teeth
if(doRotate) {
angle += 2.0f;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
index 64151362b..78ee2f6b5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
@@ -47,6 +47,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter;
import java.awt.BorderLayout;
import java.awt.Button;
+import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
@@ -65,7 +66,13 @@ import org.junit.Test;
public class TestGearsES2AWT extends UITestCase {
public enum FrameLayout { None, TextOnBottom, BorderCenterSurrounded, DoubleBorderCenterSurrounded };
+ public enum ResizeBy { Component, Frame };
+
+ static long duration = 500; // ms
static int width, height;
+ static FrameLayout frameLayout = FrameLayout.None;
+ static ResizeBy resizeBy = ResizeBy.Component;
+
static boolean forceES2 = false;
static boolean forceGL3 = false;
static boolean shallUseOffscreenFBOLayer = false;
@@ -79,7 +86,7 @@ public class TestGearsES2AWT extends UITestCase {
static boolean exclusiveContext = false;
static boolean useAnimator = true;
static Thread awtEDT;
- static Dimension rwsize = null;
+ static java.awt.Dimension rwsize = null;
@BeforeClass
public static void initClass() {
@@ -100,13 +107,13 @@ public class TestGearsES2AWT extends UITestCase {
public static void releaseClass() {
}
- static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final Dimension new_sz) {
+ static void setComponentSize(final Frame frame, final Component comp, final java.awt.Dimension new_sz) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- glc.setMinimumSize(new_sz);
- glc.setPreferredSize(new_sz);
- glc.setSize(new_sz);
+ comp.setMinimumSize(new_sz);
+ comp.setPreferredSize(new_sz);
+ comp.setSize(new_sz);
if( null != frame ) {
frame.pack();
}
@@ -116,14 +123,39 @@ public class TestGearsES2AWT extends UITestCase {
Assume.assumeNoException( throwable );
}
}
+ static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) {
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(new_sz);
+ if( frameLayout ) {
+ frame.validate();
+ }
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ static void setSize(final ResizeBy resizeBy, final Frame frame, final boolean frameLayout, final Component comp, final java.awt.Dimension new_sz) {
+ switch( resizeBy ) {
+ case Component:
+ setComponentSize(frameLayout ? frame : null, comp, new_sz);
+ break;
+ case Frame:
+ setFrameSize(frame, frameLayout, new_sz);
+ break;
+ }
+ }
- protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException {
+ protected void runTestGL(GLCapabilities caps, final ResizeBy resizeBy, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException {
final Frame frame = new Frame("GearsES2 AWT Test");
Assert.assertNotNull(frame);
final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
- setGLCanvasSize(null, glCanvas, new Dimension(width, height));
+ setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height));
switch( frameLayout) {
case None:
@@ -179,8 +211,12 @@ public class TestGearsES2AWT extends UITestCase {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- frame.pack();
- frame.setVisible(true);
+ if( ResizeBy.Frame == resizeBy ) {
+ frame.validate();
+ } else {
+ frame.pack();
+ }
+ frame.setVisible(true);
}});
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
@@ -197,7 +233,7 @@ public class TestGearsES2AWT extends UITestCase {
if( null != rwsize ) {
Thread.sleep(500); // 500ms delay
- setGLCanvasSize(frame, glCanvas, rwsize);
+ setSize(resizeBy, frame, true, glCanvas, rwsize);
System.err.println("window resize pos/siz: "+glCanvas.getX()+"/"+glCanvas.getY()+" "+glCanvas.getWidth()+"x"+glCanvas.getHeight());
}
@@ -263,12 +299,9 @@ public class TestGearsES2AWT extends UITestCase {
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
}
- runTestGL(caps, frameLayout);
+ runTestGL(caps, resizeBy, frameLayout);
}
- static long duration = 500; // ms
- static FrameLayout frameLayout = FrameLayout.None;
-
public static void main(String args[]) {
boolean waitForKey = false;
int rw=-1, rh=-1;
@@ -288,6 +321,9 @@ public class TestGearsES2AWT extends UITestCase {
} else if(args[i].equals("-layout")) {
i++;
frameLayout = FrameLayout.valueOf(args[i]);
+ } else if(args[i].equals("-resizeBy")) {
+ i++;
+ resizeBy = ResizeBy.valueOf(args[i]);
} else if(args[i].equals("-es2")) {
forceES2 = true;
} else if(args[i].equals("-gl3")) {
@@ -326,6 +362,7 @@ public class TestGearsES2AWT extends UITestCase {
System.err.println("resize "+rwsize);
System.err.println("frameLayout "+frameLayout);
+ System.err.println("resizeBy "+resizeBy);
System.err.println("forceES2 "+forceES2);
System.err.println("forceGL3 "+forceGL3);
System.err.println("swapInterval "+swapInterval);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
index 38eb80be8..3cf8290c7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
@@ -80,7 +80,9 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
static int screenIdx = 0;
static PointImmutable wpos;
static DimensionImmutable wsize, rwsize = null;
-
+ static FrameLayout frameLayout = FrameLayout.None;
+ static ResizeBy resizeBy = ResizeBy.Component;
+
static long duration = 500; // ms
static boolean opaque = true;
static int forceAlpha = -1;
@@ -401,9 +403,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
runTestGL(caps, resizeBy, frameLayout);
}
- static FrameLayout frameLayout = FrameLayout.None;
- static ResizeBy resizeBy = ResizeBy.Component;
-
public static void main(String args[]) throws IOException {
mainRun = true;