summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java14
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java27
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java23
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java95
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java39
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java14
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java32
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java88
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java22
-rw-r--r--src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java15
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m7
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java143
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java20
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java63
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java17
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m38
-rw-r--r--src/newt/classes/com/jogamp/newt/Display.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java19
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java88
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java13
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/util/EDTUtil.java10
-rw-r--r--src/newt/classes/jogamp/newt/DefaultEDTUtil.java6
-rw-r--r--src/newt/classes/jogamp/newt/DisplayImpl.java54
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java150
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java40
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java2
-rw-r--r--src/newt/native/MacWindow.m59
-rw-r--r--src/newt/native/X11Window.c6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java)29
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java153
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java165
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java171
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java173
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java152
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java152
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java150
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java)68
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java89
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java102
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java101
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java94
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java306
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java93
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java111
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java8
68 files changed, 2791 insertions, 701 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java
index 7fdb93e9b..a00b19abc 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java
@@ -67,6 +67,7 @@ public class GLConfiguration extends ProcAddressConfiguration {
// Maps function names to the kind of buffer object it deals with
private Map<String, GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String, GLEmitter.BufferObjectKind>();
+ private Set<String> bufferObjectOnly = new HashSet<String>();
private GLEmitter emitter;
private Set<String> dropUniqVendorExtensions = new HashSet<String>();
@@ -106,6 +107,9 @@ public class GLConfiguration extends ProcAddressConfiguration {
glHeaders.add(sym);
} else if (cmd.equalsIgnoreCase("BufferObjectKind")) {
readBufferObjectKind(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("BufferObjectOnly")) {
+ String sym = readString("BufferObjectOnly", tok, filename, lineNo);
+ bufferObjectOnly.add(sym);
} else if (cmd.equalsIgnoreCase("DropUniqVendorExtensions")) {
String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo);
dropUniqVendorExtensions.add(sym);
@@ -127,10 +131,12 @@ public class GLConfiguration extends ProcAddressConfiguration {
kind = GLEmitter.BufferObjectKind.ARRAY;
} else if (kindString.equalsIgnoreCase("Element")) {
kind = GLEmitter.BufferObjectKind.ELEMENT;
+ } else if (kindString.equalsIgnoreCase("Indirect")) {
+ kind = GLEmitter.BufferObjectKind.INDIRECT;
} else {
throw new RuntimeException("Error parsing \"BufferObjectKind\" command at line " + lineNo
+ " in file \"" + filename + "\": illegal BufferObjectKind \""
- + kindString + "\", expected one of UnpackPixel, PackPixel, Array, or Element");
+ + kindString + "\", expected one of UnpackPixel, PackPixel, Array, Element or Indirect");
}
bufferObjectKinds.put(target, kind);
@@ -171,6 +177,8 @@ public class GLConfiguration extends ProcAddressConfiguration {
prologue = prologue + "ArrayVBO";
} else if (kind == GLEmitter.BufferObjectKind.ELEMENT) {
prologue = prologue + "ElementVBO";
+ } else if (kind == GLEmitter.BufferObjectKind.INDIRECT) {
+ prologue = prologue + "IndirectVBO";
} else {
throw new RuntimeException("Unknown BufferObjectKind " + kind);
}
@@ -335,6 +343,10 @@ public class GLConfiguration extends ProcAddressConfiguration {
public boolean isBufferObjectFunction(String name) {
return (getBufferObjectKind(name) != null);
}
+
+ public boolean isBufferObjectOnly(String name) {
+ return bufferObjectOnly.contains(name);
+ }
/** Parses any GL headers specified in the configuration file for
the purpose of being able to ignore an extension at a time. */
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
index 075c8bfd8..fa95049cc 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
@@ -74,7 +74,7 @@ public class GLEmitter extends ProcAddressEmitter {
// Buffer Object variants. Used as a Set rather than a Map.
private Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>();
- enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT}
+ enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT, INDIRECT}
@Override
public void beginEmission(GlueEmitterControls controls) throws IOException {
@@ -262,25 +262,31 @@ public class GLEmitter extends ProcAddressEmitter {
case (though we default to true currently). */
@Override
protected List<MethodBinding> expandMethodBinding(MethodBinding binding) {
- List<MethodBinding> bindings = super.expandMethodBinding(binding);
+ final GLConfiguration glConfig = getGLConfig();
+ final List<MethodBinding> bindings = super.expandMethodBinding(binding);
- if (!getGLConfig().isBufferObjectFunction(binding.getName())) {
+ if ( !glConfig.isBufferObjectFunction(binding.getName()) ) {
return bindings;
}
+ final boolean bufferObjectOnly = glConfig.isBufferObjectOnly(binding.getName());
- List<MethodBinding> newBindings = new ArrayList<MethodBinding>(bindings);
+ final List<MethodBinding> newBindings = new ArrayList<MethodBinding>();
// Need to expand each one of the generated bindings to take a
// Java long instead of a Buffer for each void* argument
- for (MethodBinding cur : bindings) {
-
+ // for (MethodBinding cur : bindings) {
+ int j=0;
+ while( j < bindings.size() ) {
+ final MethodBinding cur = bindings.get(j);
+
// Some of these routines (glBitmap) take strongly-typed
// primitive pointers as arguments which are expanded into
// non-void* arguments
// This test (rather than !signatureUsesNIO) is used to catch
// more unexpected situations
if (cur.signatureUsesJavaPrimitiveArrays()) {
+ j++;
continue;
}
@@ -300,9 +306,16 @@ public class GLEmitter extends ProcAddressEmitter {
// Now need to flag this MethodBinding so that we generate the
// correct flags in the emitters later
bufferObjectMethodBindings.put(result, result);
+
+ if( bufferObjectOnly ) {
+ bindings.remove(j);
+ } else {
+ j++;
+ }
}
+ bindings.addAll(newBindings);
- return newBindings;
+ return bindings;
}
@Override
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 023a8a1aa..6ef1e0805 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -181,15 +181,22 @@ public class GLRendererQuirks {
*/
public static final int NoFullFBOSupport = 11;
-
+ /**
+ * GLSL is not compliant or even not stable (crash)
+ * <ul>
+ * <li>OSX < 10.7.0 (?) - NVidia Driver. Bug 818 @ https://jogamp.org/bugzilla/.</li>
+ * </ul>
+ */
+ public static final int GLSLNonCompliant = 12;
+
/** Number of quirks known. */
- public static final int COUNT = 12;
+ public static final int COUNT = 13;
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
"GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
"NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext",
- "NoFullFBOSupport"
+ "NoFullFBOSupport", "GLSLNonCompliant"
};
private final int _bitmask;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index dc96cb5f2..111e2509e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -522,6 +522,10 @@ public class ImmModeSink {
gl.glDrawArrays(mode, 0, vElems);
}
} else {
+ // FIXME: Impl. VBO usage .. or unroll.
+ if( !gl.getContext().isCPUDataSourcingAvail() ) {
+ throw new GLException("CPU data sourcing n/a w/ "+gl.getContext());
+ }
final int type;
if(indices instanceof ByteBuffer) {
type = GL.GL_UNSIGNED_BYTE;
@@ -553,7 +557,7 @@ public class ImmModeSink {
}
}
} else {
- gl.glDrawElements(mode, idxLen, type, indices);
+ ((GL2ES1)gl).glDrawElements(mode, idxLen, type, indices);
// GL2: gl.glDrawRangeElements(mode, 0, idxLen-1, idxLen, type, indices);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java
index 8fc7916c7..a2b7ba343 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java
@@ -96,7 +96,28 @@ public class RandomTileRenderer extends TileRendererBase {
/**
* {@inheritDoc}
- * @throws IllegalStateException if image-size or tileRect has not been set
+ *
+ * <p>
+ * <i>end of tiling</i> is never reached w/ {@link RandomRileRenderer},
+ * i.e. method always returns false.
+ * </p>
+ */
+ @Override
+ public final boolean eot() { return false; }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Reset internal states of {@link RandomTileRenderer} are: <i>none</i>.
+ */
+ @Override
+ public final void reset() { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or
+ * {@link #setTileRect(int, int, int, int) tile-rect} has not been set.
*/
@Override
public final void beginTile(GL gl) throws IllegalStateException, GLException {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java
index f126eb7f5..deab8bc3e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java
@@ -101,7 +101,7 @@ public class TileRenderer extends TileRendererBase {
*/
public static final int TR_COLUMNS = 15;
/**
- * The current tile number. See {@link #getParam(int)}.
+ * The current tile number. Has value -1 if {@link #eot()}. See {@link #getParam(int)}.
*/
public static final int TR_CURRENT_TILE_NUM = 16;
/**
@@ -132,12 +132,13 @@ public class TileRenderer extends TileRendererBase {
private final Dimension tileSize = new Dimension(DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT);
private final Dimension tileSizeNB = new Dimension(DEFAULT_TILE_WIDTH - 2 * DEFAULT_TILE_BORDER, DEFAULT_TILE_HEIGHT - 2 * DEFAULT_TILE_BORDER);
- protected Dimension imageClippingDim = null; // not set - default
+ private boolean isInit = false;
+ private Dimension imageClippingDim = null; // not set - default
private int tileBorder = DEFAULT_TILE_BORDER;
private int rowOrder = TR_BOTTOM_TO_TOP;
private int rows;
private int columns;
- private int currentTile = -1;
+ private int currentTile = 0;
private int currentRow;
private int currentColumn;
private int offsetX;
@@ -158,13 +159,25 @@ public class TileRenderer extends TileRendererBase {
}
/**
+ * {@inheritDoc}
+ * <p>
+ * Implementation {@link #reset()} internal states.
+ * </p>
+ */
+ @Override
+ public final void setImageSize(int width, int height) {
+ super.setImageSize(width, height);
+ reset();
+ }
+
+ /**
* Clips the image-size this tile-renderer iterates through,
* which can be retrieved via {@link #getClippedImageSize()}.
* <p>
* Original image-size stored in this tile-renderer is unmodified.
* </p>
* <p>
- * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count.
+ * Implementation {@link #reset()} internal states.
* </p>
*
* @param width The image-clipping.width
@@ -178,7 +191,7 @@ public class TileRenderer extends TileRendererBase {
imageClippingDim.setWidth(width);
imageClippingDim.setHeight(height);
}
- setup();
+ reset();
}
/**
@@ -210,7 +223,7 @@ public class TileRenderer extends TileRendererBase {
* effective size of the tile depends on the border size, ie (
* width - 2*border ) * ( height - 2 * border )
* <p>
- * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count.
+ * Implementation {@link #reset()} internal states.
* </p>
*
* @param width
@@ -236,7 +249,7 @@ public class TileRenderer extends TileRendererBase {
tileSize.setHeight( height );
tileSizeNB.setWidth( width - 2 * border );
tileSizeNB.setHeight( height - 2 * border );
- setup();
+ reset();
}
/**
@@ -251,32 +264,43 @@ public class TileRenderer extends TileRendererBase {
}
/**
- * Sets up the number of rows and columns needed
+ * {@inheritDoc}
+ *
+ * Reset internal states of {@link TileRenderer} are:
+ * <ul>
+ * <li>{@link #TR_ROWS}</li>
+ * <li>{@link #TR_COLUMNS}</li>
+ * <li>{@link #TR_CURRENT_COLUMN}</li>
+ * <li>{@link #TR_CURRENT_ROW}</li>
+ * <li>{@link #TR_CURRENT_TILE_NUM}</li>
+ * <li>{@link #TR_CURRENT_TILE_X_POS}</li>
+ * <li>{@link #TR_CURRENT_TILE_Y_POS}</li>
+ * <li>{@link #TR_CURRENT_TILE_WIDTH}</li>
+ * <li>{@link #TR_CURRENT_TILE_HEIGHT}</li>
+ *</ul>
*/
- private final void setup() throws IllegalStateException {
+ @Override
+ public final void reset() {
final DimensionImmutable clippedImageSize = getClippedImageSize();
columns = ( clippedImageSize.getWidth() + tileSizeNB.getWidth() - 1 ) / tileSizeNB.getWidth();
rows = ( clippedImageSize.getHeight() + tileSizeNB.getHeight() - 1 ) / tileSizeNB.getHeight();
+ currentRow = 0;
+ currentColumn = 0;
currentTile = 0;
currentTileXPos = 0;
currentTileYPos = 0;
currentTileWidth = 0;
currentTileHeight = 0;
- currentRow = 0;
- currentColumn = 0;
assert columns >= 0;
assert rows >= 0;
+
+ beginCalled = false;
+ isInit = true;
}
/* pp */ final int getCurrentTile() { return currentTile; }
- /**
- * Returns <code>true</code> if all tiles have been rendered or {@link #setup()}
- * has not been called, otherwise <code>false</code>.
- */
- public final boolean eot() { return 0 > currentTile; }
-
@Override
public final int getParam(int pname) {
switch (pname) {
@@ -341,16 +365,41 @@ public class TileRenderer extends TileRendererBase {
return 0 < imageSize.getWidth() && 0 < imageSize.getHeight();
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * <i>end of tiling</i> is reached w/ {@link TileRenderer}, if at least one of the following is true:
+ * <ul>
+ * <li>all tiles have been rendered, i.e. {@link #TR_CURRENT_TILE_NUM} is -1</li>
+ * <li>no tiles to render, i.e. {@link #TR_COLUMNS} or {@link #TR_ROWS} is 0</li>
+ * </ul>
+ * </p>
+ */
+ @Override
+ public final boolean eot() {
+ if ( !isInit ) { // ensure at least one reset-call
+ reset();
+ }
+ return 0 > currentTile || 0 >= columns*rows;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or
+ * {@link #eot() end-of-tiling} has been reached.
+ */
@Override
public final void beginTile( GL gl ) throws IllegalStateException, GLException {
if( !isSetup() ) {
- throw new IllegalStateException("Image size has not been set");
+ throw new IllegalStateException("Image size has not been set: "+this);
}
- validateGL(gl);
- if (currentTile <= 0) {
- setup();
+ if ( eot() ) {
+ throw new IllegalStateException("EOT reached: "+this);
}
-
+ validateGL(gl);
+
/* which tile (by row and column) we're about to render */
if (rowOrder == TR_BOTTOM_TO_TOP) {
currentRow = currentTile / columns;
@@ -390,7 +439,7 @@ public class TileRenderer extends TileRendererBase {
gl.glViewport( 0, 0, tW, tH );
if( DEBUG ) {
- System.err.println("TileRenderer.begin.X: "+this.toString());
+ System.err.println("TileRenderer.begin: "+this.toString());
}
// Do not forget to issue:
diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
index f15c79f68..d6c36aa14 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
@@ -241,6 +241,7 @@ public abstract class TileRendererBase {
tileDetails(sb);
sb.append("], image[size "+imageSize+", buffer "+hashStr(imageBuffer)+"], glad["+
gladListenerCount+" listener, pre "+(null!=glEventListenerPre)+", post "+(null!=glEventListenerPost)+", preSwap "+gladRequiresPreSwap+"]");
+ sb.append(", isSetup "+isSetup());
return sb;
}
public String toString() {
@@ -284,7 +285,7 @@ public abstract class TileRendererBase {
* @param width The width of the final image
* @param height The height of the final image
*/
- public final void setImageSize(int width, int height) {
+ public void setImageSize(int width, int height) {
imageSize.setWidth(width);
imageSize.setHeight(height);
}
@@ -321,6 +322,27 @@ public abstract class TileRendererBase {
public abstract boolean isSetup();
/**
+ * Returns true if <i>end of tiling</i> has been reached, otherwise false.
+ * <p>
+ * <i>end of tiling</i> criteria is implementation specific and may never be reached.
+ * </p>
+ * <p>
+ * User needs to {@link #reset()} tiling after reaching <i>end of tiling</i>
+ * before calling {@link #beginTile(GL)} again.
+ * </p>
+ */
+ public abstract boolean eot();
+
+ /**
+ * Method resets implementation's internal state to <i>start of tiling</i>
+ * as required for {@link #beginTile(GL)} if {@link #eot() end of tiling} has been reached.
+ * <p>
+ * Implementation is a <i>nop</i> where {@link #eot() end of tiling} is never reached.
+ * </p>
+ */
+ public abstract void reset();
+
+ /**
* Begins rendering a tile.
* <p>
* This method modifies the viewport, see below.
@@ -351,10 +373,19 @@ public abstract class TileRendererBase {
* <p>
* User has to comply with the <a href="#glprequirement">GL profile requirement</a>.
* </p>
+ * <p>
+ * If {@link #eot() end of tiling} has been reached,
+ * user needs to {@link #reset()} tiling before calling this method.
+ * </p>
*
* @param gl The gl context
- * @throws IllegalStateException if image-size has not been set
+ * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} is undefined,
+ * an {@link #isSetup() implementation related setup} has not be performed
+ * or {@ link #eot()} has been reached. See implementing classes.
* @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used but <code>gl</code> instance is &lt; {@link GL2ES3}
+ * @see #isSetup()
+ * @see #eot()
+ * @see #reset()
*/
public abstract void beginTile(GL gl) throws IllegalStateException, GLException;
@@ -594,6 +625,12 @@ public abstract class TileRendererBase {
}
return;
}
+ if( eot() ) {
+ if( DEBUG ) {
+ System.err.println("TileRenderer.glel.display: EOT: "+TileRendererBase.this);
+ }
+ return;
+ }
final GL gl = drawable.getGL();
beginTile(gl);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
index 1f5bb6acc..9d2ef6572 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
@@ -28,7 +28,11 @@
package com.jogamp.opengl.util.awt;
import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.WritableRaster;
import java.nio.Buffer;
import java.nio.IntBuffer;
@@ -36,7 +40,6 @@ import javax.media.opengl.GL;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.util.GLPixelBuffer;
-import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
/**
* AWT {@link GLPixelBuffer} backed by an {@link BufferedImage} of type
@@ -51,6 +54,10 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
* <p>
* See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)} for {@link #allowRowStride} details.
* </p>
+ * <p>
+ * If using <code>allowRowStride == true</code>, user may needs to get the {@link #getAlignedImage(int, int) aligned image}
+ * since {@link #requiresNewBuffer(GL, int, int, int)} will allow different width in this case.
+ * </p>
*/
public class AWTGLPixelBuffer extends GLPixelBuffer {
public static final GLPixelAttributes awtPixelAttributesIntRGBA4 = new GLPixelAttributes(4, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE);
@@ -60,6 +67,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
public final BufferedImage image;
/**
+ *
* @param pixelAttributes the desired {@link GLPixelAttributes}
* @param width in pixels
* @param height in pixels
@@ -68,6 +76,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
* @param image the AWT image
* @param buffer the backing array
* @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}.
+ * If <code>true</code>, user shall decide whether to use a {@link #getAlignedImage(int, int) width-aligned image}.
*/
public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image,
Buffer buffer, boolean allowRowStride) {
@@ -81,6 +90,33 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
super.dispose();
}
+ /**
+ * Returns a width- and height-aligned image representation sharing data w/ {@link #image}.
+ * @param width
+ * @param height
+ * @return
+ * @throws IllegalArgumentException if requested size exceeds image size
+ */
+ public BufferedImage getAlignedImage(int width, int height) throws IllegalArgumentException {
+ if( width * height > image.getWidth() * image.getHeight() ) {
+ throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight());
+ }
+ if( width == image.getWidth() ) {
+ if( height == image.getHeight() ) {
+ return image;
+ }
+ return image.getSubimage(0, 0, width, height);
+ }
+ final ColorModel cm = image.getColorModel();
+ final WritableRaster raster = image.getRaster();
+ final DataBuffer dataBuffer = raster.getDataBuffer();
+ final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster.getSampleModel();
+ final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
+ width, height, width /* scanLineStride */, sppsm0.getBitMasks());
+ final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null);
+ return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null);
+ }
+
public StringBuilder toString(StringBuilder sb) {
sb = super.toString(sb);
sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]");
@@ -99,6 +135,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
/**
* @param allowRowStride If <code>true</code>, allow row-stride, otherwise not.
* See {@link #getAllowRowStride()} and {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}.
+ * If <code>true</code>, user shall decide whether to use a {@link AWTGLPixelBuffer#getAlignedImage(int, int) width-aligned image}.
*/
public AWTGLPixelBufferProvider(boolean allowRowStride) {
this.allowRowStride = allowRowStride;
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 2dca2a685..f4dbde6b2 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -1009,6 +1009,16 @@ public abstract class GLContext {
) ;
}
+ /**
+ * Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using a GPU buffer source (VBO),
+ * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}.
+ * <p>Includes [GL2ES1, GLES2] == [ GL4bc, GL3bc, GL2, GLES1, GL2ES1, GLES2 ].</p>
+ * <p>See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852 </p>
+ */
+ public final boolean isCPUDataSourcingAvail() {
+ return isGL2ES1() || isGLES2();
+ }
+
/**
* Indicates whether this GLContext's native profile does not implement a default <i>vertex array object</i> (VAO),
* starting w/ OpenGL 3.1 core and GLES3.
@@ -1078,11 +1088,11 @@ public abstract class GLContext {
}
/**
- * Indicates whether this GLContext is capable of GLES2. <p>Includes [ GLES3, GLES2 ].</p>
+ * Indicates whether this GLContext is capable of GLES2. <p>Includes [ GLES2 ].</p>
* @see GLProfile#isGLES2()
*/
public final boolean isGLES2() {
- return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ;
+ return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 2 ;
}
/**
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 1dde2cbb6..4a2edc56b 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -1098,9 +1098,9 @@ public class GLProfile {
return GLES1 == profile;
}
- /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES3, GLES2 ].</p> */
+ /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES2 ].</p> */
public final boolean isGLES2() {
- return GLES3 == profile || GLES2 == profile;
+ return GLES2 == profile;
}
/** Indicates whether this profile is capable of GLES3. <p>Includes [ GLES3 ].</p> */
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index f86a6a347..20dd802fb 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -837,20 +837,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
final Graphics2D g2d = (Graphics2D)graphics;
try {
printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight());
- try {
- final TileRenderer tileRenderer = printAWTTiles.renderer;
- if( DEBUG ) {
- System.err.println("AWT print.0: "+tileRenderer);
- }
- do {
- if( printGLAD != GLCanvas.this ) {
- tileRenderer.display();
- } else {
- Threading.invoke(true, displayOnEDTAction, getTreeLock());
+ final TileRenderer tileRenderer = printAWTTiles.renderer;
+ if( DEBUG ) {
+ System.err.println("AWT print.0: "+tileRenderer);
+ }
+ if( !tileRenderer.eot() ) {
+ try {
+ do {
+ if( printGLAD != GLCanvas.this ) {
+ tileRenderer.display();
+ } else {
+ Threading.invoke(true, displayOnEDTAction, getTreeLock());
+ }
+ } while ( !tileRenderer.eot() );
+ if( DEBUG ) {
+ System.err.println("AWT print.1: "+printAWTTiles);
}
- } while ( !tileRenderer.eot() );
- } finally {
- printAWTTiles.resetGraphics2D();
+ } finally {
+ tileRenderer.reset();
+ printAWTTiles.resetGraphics2D();
+ }
}
} catch (NoninvertibleTransformException nte) {
System.err.println("Catched: Inversion failed of: "+g2d.getTransform());
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 84d085f76..673f22aff 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -93,6 +93,7 @@ import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.nativewindow.awt.AWTPrintLifecycle;
import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
import com.jogamp.opengl.FBObject;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider;
import com.jogamp.opengl.util.GLDrawableUtil;
@@ -142,8 +143,19 @@ import com.jogamp.opengl.util.texture.TextureState;
<a name="fboGLSLVerticalFlip"><h5>FBO / GLSL Vertical Flip</h5></a>
The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target,
see {@link #setTextureUnit(int)} and {@link #getTextureUnit()}.
- If the application uses the same texture-unit, ensure it setup their texture properly, i.e. texture-unit bind, enable and then it's parameters,
- see {@link Texture#textureCallOrder Order of Texture Commands}.
+ <p>
+ The active and dedicated texture-unit's {@link GL#GL_TEXTURE_2D} state is preserved via {@link TextureState}.
+ See also {@link Texture#textureCallOrder Order of Texture Commands}.
+ </p>
+ <p>
+ The current gl-viewport is preserved.
+ </p>
+ <p>
+ <i>Warning (Bug 842)</i>: Certain GL states other than viewport and texture (see above)
+ influencing rendering, will also influence the GLSL vertical flip, e.g. {@link GL#glFrontFace(int) glFrontFace}({@link GL#GL_CCW}).
+ It is recommended to reset those states to default when leaving the {@link GLEventListener#display(GLAutoDrawable)} method!
+ We may change this behavior in the future, i.e. preserve all influencing states.
+ </p>
*/
@SuppressWarnings("serial")
@@ -167,12 +179,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true);
USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true);
- boolean enabled = false;
- final String sVal = System.getProperty("sun.java2d.opengl");
- if( null != sVal ) {
- enabled = Boolean.valueOf(sVal);
- }
- Debug.initSingleton();
+ boolean enabled = Debug.getBooleanProperty("sun.java2d.opengl", false);
java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true);
enabled = false;
@@ -639,17 +646,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
final Graphics2D g2d = (Graphics2D)graphics;
try {
printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight());
- try {
- final TileRenderer tileRenderer = printAWTTiles.renderer;
- do {
- if( printGLAD != GLJPanel.this ) {
- tileRenderer.display();
- } else {
- backend.doPlainPaint();
+ final TileRenderer tileRenderer = printAWTTiles.renderer;
+ if( DEBUG ) {
+ System.err.println("AWT print.0: "+tileRenderer);
+ }
+ if( !tileRenderer.eot() ) {
+ try {
+ do {
+ if( printGLAD != GLJPanel.this ) {
+ tileRenderer.display();
+ } else {
+ backend.doPlainPaint();
+ }
+ } while ( !tileRenderer.eot() );
+ if( DEBUG ) {
+ System.err.println("AWT print.1: "+printAWTTiles);
}
- } while ( !tileRenderer.eot() );
- } finally {
- printAWTTiles.resetGraphics2D();
+ } finally {
+ tileRenderer.reset();
+ printAWTTiles.resetGraphics2D();
+ }
}
} catch (NoninvertibleTransformException nte) {
System.err.println("Catched: Inversion failed of: "+g2d.getTransform());
@@ -1236,6 +1252,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final AWTGLPixelBufferProvider pixelBufferProvider;
private final boolean useSingletonBuffer;
private AWTGLPixelBuffer pixelBuffer;
+ private BufferedImage alignedImage;
// One of these is used to store the read back pixels before storing
// in the BufferedImage
@@ -1255,8 +1272,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) {
if(null == custom) {
- pixelBufferProvider = glp.isGL2ES3() ? getSingleAWTGLPixelBufferProvider() :
- new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ;
+ pixelBufferProvider = getSingleAWTGLPixelBufferProvider();
} else {
pixelBufferProvider = custom;
}
@@ -1290,7 +1306,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
flipVertical = offscreenDrawable.isGLOriented();
final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities();
offscreenIsFBO = chosenCaps.isFBO();
- if( USE_GLSL_TEXTURE_RASTERIZER && offscreenIsFBO && flipVertical && gl.isGL2ES2() ) {
+ final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant);
+ final boolean useGLSLFlip = flipVertical && offscreenIsFBO && gl.isGL2ES2() && USE_GLSL_TEXTURE_RASTERIZER && glslCompliant;
+ if( DEBUG ) {
+ System.err.println(getThreadName()+": OffscreenBackend.initialize: useGLSLFlip "+useGLSLFlip+
+ " [flip "+flipVertical+", isFBO "+offscreenIsFBO+", isGL2ES2 "+gl.isGL2ES2()+
+ ", noglsl "+!USE_GLSL_TEXTURE_RASTERIZER+", glslNonCompliant "+!glslCompliant+
+ ", isGL2ES2 " + gl.isGL2ES2()+"]");
+ }
+ if( useGLSLFlip ) {
final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode();
helper.setAutoSwapBufferMode(false);
final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable;
@@ -1382,6 +1406,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
pixelBuffer = null;
}
+ alignedImage = null;
}
@Override
@@ -1389,6 +1414,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if ( opaque != isOpaque() && !useSingletonBuffer ) {
pixelBuffer.dispose();
pixelBuffer = null;
+ alignedImage = null;
}
}
@@ -1423,6 +1449,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) {
pixelBuffer.dispose();
pixelBuffer = null;
+ alignedImage = null;
}
if ( null == pixelBuffer ) {
if (0 >= panelWidth || 0 >= panelHeight ) {
@@ -1439,6 +1466,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) {
throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName());
}
+ if( null == alignedImage || panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ) {
+ alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight);
+ if(DEBUG) {
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height);
+ }
+ }
final IntBuffer readBackInts;
if( !flipVertical || null != glslTextureRaster ) {
@@ -1475,7 +1508,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
psm.setAlignment(gl, alignment, alignment);
if(gl.isGL2ES3()) {
final GL2ES3 gl2es3 = gl.getGL2ES3();
- gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, pixelBuffer.width);
+ gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, panelWidth);
gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer());
}
@@ -1522,12 +1555,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// blitting Note that we could avoid this copy in the cases
// where !offscreenDrawable.isGLOriented(),
// but that's the software rendering path which is very slow anyway.
- final BufferedImage image = pixelBuffer.image;
+ final BufferedImage image = alignedImage;
final int[] src = readBackInts.array();
final int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
- final int incr = pixelBuffer.width;
+ final int incr = panelWidth;
int srcPos = 0;
- int destPos = (panelHeight - 1) * pixelBuffer.width;
+ int destPos = (panelHeight - 1) * panelWidth;
for (; destPos >= 0; srcPos += incr, destPos -= incr) {
System.arraycopy(src, srcPos, dest, destPos, incr);
}
@@ -1557,10 +1590,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
public void doPaintComponent(Graphics g) {
helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction);
- if ( null != pixelBuffer ) {
- final BufferedImage image = pixelBuffer.image;
+ if ( null != alignedImage ) {
// Draw resulting image in one shot
- g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); // Null ImageObserver since image data is ready.
+ g.drawImage(alignedImage, 0, 0, alignedImage.getWidth(), alignedImage.getHeight(), null); // Null ImageObserver since image data is ready.
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
index 890c82c90..f14d16ec4 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
@@ -102,6 +102,7 @@ public class GLBufferStateTracker {
setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0);
setBoundBufferObject(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
+ setBoundBufferObject(GL4.GL_DRAW_INDIRECT_BUFFER, 0);
}
public final void setBoundBufferObject(int target, int value) {
@@ -132,6 +133,7 @@ public class GLBufferStateTracker {
case GL.GL_ELEMENT_ARRAY_BUFFER: queryTarget = GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; break;
case GL2.GL_PIXEL_PACK_BUFFER: queryTarget = GL2.GL_PIXEL_PACK_BUFFER_BINDING; break;
case GL2.GL_PIXEL_UNPACK_BUFFER: queryTarget = GL2.GL_PIXEL_UNPACK_BUFFER_BINDING; break;
+ case GL4.GL_DRAW_INDIRECT_BUFFER: queryTarget = GL4.GL_DRAW_INDIRECT_BUFFER_BINDING; break;
default: gotQueryTarget = false; break;
}
if (gotQueryTarget) {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 77cbd0ed9..7f9f20a21 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1604,13 +1604,23 @@ public abstract class GLContextImpl extends GLContext {
quirks[i++] = quirk;
}
- final VersionNumber OSXVersion173 = new VersionNumber(1,7,3);
- if( Platform.getOSVersionNumber().compareTo(OSXVersion173) < 0 && isDriverNVIDIAGeForce ) {
- final int quirk = GLRendererQuirks.GLFlushBeforeRelease;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
+ if( isDriverNVIDIAGeForce ) {
+ final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush
+ if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) {
+ final int quirk = GLRendererQuirks.GLFlushBeforeRelease;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
+ }
+ quirks[i++] = quirk;
+ }
+ final VersionNumber osxVersionNVGLSLGood = new VersionNumber(10,7,0); // < OSX 10.7.0 w/ NV has instable GLSL
+ if( Platform.getOSVersionNumber().compareTo(osxVersionNVGLSLGood) < 0 ) {
+ final int quirk = GLRendererQuirks.GLSLNonCompliant;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
+ }
+ quirks[i++] = quirk;
}
- quirks[i++] = quirk;
}
} else if( Platform.getOSType() == Platform.OSType.WINDOWS ) {
//
diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
index 2b921f799..0600d99f5 100644
--- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
+++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
@@ -88,10 +88,14 @@ public class AWTTilePainter {
System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue());
}
final AffineTransform aTrans = g2d.getTransform();
- System.err.println(" type "+aTrans.getType());
- System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY());
- System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY());
- System.err.println(" mat "+aTrans);
+ if( null != aTrans ) {
+ System.err.println(" type "+aTrans.getType());
+ System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY());
+ System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY());
+ System.err.println(" mat "+aTrans);
+ } else {
+ System.err.println(" null transform");
+ }
}
/**
@@ -144,11 +148,6 @@ public class AWTTilePainter {
flipVertical = v;
}
- private static Rectangle getRoundedRect(Rectangle2D r) {
- if( null == r ) { return null; }
- return new Rectangle((int)Math.round(r.getX()), (int)Math.round(r.getY()),
- (int)Math.round(r.getWidth()), (int)Math.round(r.getHeight()));
- }
private static Rectangle2D getClipBounds2D(Graphics2D g) {
final Shape shape = g.getClip();
return null != shape ? shape.getBounds2D() : null;
@@ -188,6 +187,9 @@ public class AWTTilePainter {
public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) throws NoninvertibleTransformException {
this.g2d = g2d;
saveAT = g2d.getTransform();
+ if( null == saveAT ) {
+ saveAT = new AffineTransform(); // use identity
+ }
// We use double precision for scaling
//
// Setup original rectangles
@@ -201,7 +203,7 @@ public class AWTTilePainter {
{
final AffineTransform scaledATI;
{
- final AffineTransform scaledAT = g2d.getTransform();
+ final AffineTransform scaledAT = new AffineTransform(saveAT);
scaledAT.scale(scaleMatX, scaleMatY);
scaledATI = scaledAT.createInverse(); // -> NoninvertibleTransformException
}
@@ -214,8 +216,8 @@ public class AWTTilePainter {
dClipScaled = scaledATI.createTransformedShape(s0).getBounds2D(); // scaled out
}
}
- final Rectangle iClipScaled = getRoundedRect(dClipScaled);
- final Rectangle iImageSizeScaled = getRoundedRect(dImageSizeScaled);
+ final Rectangle iClipScaled = dClipScaled.getBounds();
+ final Rectangle iImageSizeScaled = dImageSizeScaled.getBounds();
renderer.setImageSize(iImageSizeScaled.width, iImageSizeScaled.height);
renderer.clipImageSize(iClipScaled.width, iClipScaled.height);
final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height);
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index e6334150b..0828d1dc3 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -745,7 +745,7 @@ public class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("NSOpenGLLayer.Attach: Re-Queue, drawableHandle "+toHexString(drawable.getHandle())+" - "+getThreadName());
}
- OSXUtil.RunLater(this, 1);
+ OSXUtil.RunLater(true /* onMain */, this, 1);
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index f028d7f9c..f196ebef1 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -38,6 +38,7 @@ import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLException;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.IOUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.opengl.util.TimeFrameI;
@@ -279,7 +280,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
System.err.println("initStream: p1 "+this);
}
- final String streamLocS=streamLoc.toString().replaceAll("%20", " ");
+ final String streamLocS=IOUtil.decodeFromURI(streamLoc.toString());
destroyAudioSink();
if( GLMediaPlayer.STREAM_ID_NONE == aid ) {
audioSink = AudioSinkFactory.createNull();
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index 2e924cbfb..5349745ea 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -40,6 +40,7 @@ import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2GL3;
import javax.media.opengl.GLArrayData;
+import javax.media.opengl.GLES2;
import javax.media.opengl.GLException;
import javax.media.opengl.GLRunnable2;
import javax.media.opengl.GLUniformData;
@@ -741,11 +742,17 @@ public class FixedFuncPipeline {
gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4);
}
}
- } else if( GL2ES1.GL_POINTS != mode ) {
- gl.glDrawElements(mode, count, type, indices);
} else {
- // FIXME GL_POINTS !
- gl.glDrawElements(mode, count, type, indices);
+ // FIXME: Impl. VBO usage .. or unroll (see above)!
+ if( !gl.getContext().isCPUDataSourcingAvail() ) {
+ throw new GLException("CPU data sourcing n/a w/ "+gl.getContext());
+ }
+ if( GL2ES1.GL_POINTS != mode ) {
+ ((GLES2)gl).glDrawElements(mode, count, type, indices);
+ } else {
+ // FIXME GL_POINTS !
+ ((GLES2)gl).glDrawElements(mode, count, type, indices);
+ }
}
}
public void glDrawElements(GL2ES2 gl, int mode, int count, int type, long indices_buffer_offset) {
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
index d15c8e038..75917d2dc 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
@@ -570,11 +570,12 @@ static const GLfloat gl_verts[] = {
CGRect lRect = [self frame];
Bool dedicatedFramePosSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & quirks );
Bool dedicatedFrameSizeSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & quirks );
- dedicatedFrameSet = dedicatedFramePosSet || dedicatedFrameSizeSet;
+ Bool dedicatedLayoutSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_LAYOUT & quirks );
+ dedicatedFrameSet = dedicatedFramePosSet || dedicatedFrameSizeSet || dedicatedLayoutSet;
dedicatedFrame = dFrame;
- DBG_PRINT("MyNSOpenGLLayer::setDedicatedFrame: Quirks [%d, pos %d, size %d], %p, texSize %dx%d, %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n",
- quirks, dedicatedFramePosSet, dedicatedFrameSizeSet, self, texWidth, texHeight,
+ DBG_PRINT("MyNSOpenGLLayer::setDedicatedFrame: Quirks [%d, pos %d, size %d, lout %d], %p, texSize %dx%d, %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n",
+ quirks, dedicatedFramePosSet, dedicatedFrameSizeSet, dedicatedLayoutSet, self, texWidth, texHeight,
lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height,
dFrame.origin.x, dFrame.origin.y, dFrame.size.width, dFrame.size.height);
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 5b5df7f68..6e198d961 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -37,14 +37,18 @@
package com.jogamp.nativewindow.awt;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import java.awt.Component;
import java.awt.Container;
+import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
import java.applet.Applet;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -61,7 +65,6 @@ 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 javax.swing.JRootPane;
import jogamp.nativewindow.SurfaceUpdatedHelper;
import jogamp.nativewindow.awt.AWTMisc;
@@ -76,10 +79,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
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();
+ protected final Component component;
+ private final AWTGraphicsConfiguration config; // control access due to delegation
+ private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
+ private final RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
+ private final JAWTComponentListener jawtComponentListener;
// lifetime: valid after lock but may change with each 1st lock, purges after invalidate
private boolean isApplet;
@@ -106,34 +110,110 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
if(! ( config instanceof AWTGraphicsConfiguration ) ) {
throw new NativeWindowException("Error: AbstractGraphicsConfiguration is not an AWTGraphicsConfiguration: "+config);
}
+ this.component = (Component)comp;
this.config = (AWTGraphicsConfiguration) config;
- init((Component)comp);
- }
-
- private void init(Component windowObject) throws NativeWindowException {
+ this.jawtComponentListener = new JAWTComponentListener();
+ this.component.addComponentListener(jawtComponentListener);
+ this.component.addHierarchyListener(jawtComponentListener);
invalidate();
- this.component = windowObject;
this.isApplet = false;
this.offscreenSurfaceLayer = 0;
- this.component.addComponentListener(new ComponentListener() {
+ }
+ private class JAWTComponentListener implements ComponentListener, HierarchyListener {
+ private boolean localVisibility = component.isVisible();
+ private boolean globalVisibility = localVisibility;
+ private boolean visibilityPropagation = false;
+
+ private String s(ComponentEvent e) {
+ return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+
+ " ** COMP "+e.getComponent()+Platform.getNewline()+
+ " ** SOURCE "+e.getSource()+Platform.getNewline()+
+ " ** THIS "+component;
+ }
+ private String s(HierarchyEvent e) {
+ return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+
+ " ** COMP "+e.getComponent()+Platform.getNewline()+
+ " ** SOURCE "+e.getSource()+Platform.getNewline()+
+ " ** CHANGED "+e.getChanged()+Platform.getNewline()+
+ " ** CHANGEDPARENT "+e.getChangedParent()+Platform.getNewline()+
+ " ** THIS "+component;
+ }
+
@Override
public void componentResized(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ if(DEBUG) {
+ System.err.println("JAWTWindow.componentResized: "+s(e));
+ }
+ layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility);
}
@Override
public void componentMoved(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ if(DEBUG) {
+ System.err.println("JAWTWindow.componentMoved: "+s(e));
+ }
+ layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility);
}
@Override
public void componentShown(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ if(DEBUG) {
+ System.err.println("JAWTWindow.componentShown: "+s(e));
+ }
+ layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility);
}
@Override
- public void componentHidden(ComponentEvent e) { }
- });
+ public void componentHidden(ComponentEvent e) {
+ if(DEBUG) {
+ System.err.println("JAWTWindow.componentHidden: "+s(e));
+ }
+ layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility);
+ }
+
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ final long bits = e.getChangeFlags();
+ final java.awt.Component changed = e.getChanged();
+ if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) {
+ final boolean displayable = changed.isDisplayable();
+ final boolean resetLocalVisibility = changed == component && !displayable && localVisibility != component.isVisible();
+ if( resetLocalVisibility ) {
+ // Reset components local state if detached from parent, i.e. 'removeNotify()'
+ visibilityPropagation = true;
+ if(DEBUG) {
+ System.err.println("JAWTWindow.hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+", "+s(e));
+ }
+ component.setVisible(localVisibility);
+ } else if(DEBUG) {
+ System.err.println("JAWTWindow.hierarchyChanged DISPLAYABILITY_CHANGED (x): displayable "+displayable+", "+s(e));
+ }
+ } else if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
+ final boolean showing = changed.isShowing();
+ final boolean propagateVisibility = changed != component && ( showing && localVisibility ) != component.isVisible();
+ if( propagateVisibility ) {
+ // Propagate parent's visibility
+ final boolean _visible = showing && localVisibility;
+ visibilityPropagation = true;
+ globalVisibility = showing;
+ if(DEBUG) {
+ System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+_visible+", "+s(e));
+ }
+ component.setVisible(_visible);
+ } else if( changed == component ) {
+ // Update component's local visibility state
+ if(!visibilityPropagation) {
+ localVisibility = showing;
+ }
+ visibilityPropagation = false;
+ if(DEBUG) {
+ System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e));
+ }
+ } else if(DEBUG) {
+ System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e));
+ }
+ }
+ }
}
protected synchronized void invalidate() {
@@ -248,14 +328,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
* Call this method if any parent or ancestor's layout has been changed,
* which could affects the layout of this surface.
* </p>
- * @see #isOffscreenLayerSurfaceEnabled()
+ * @see #isOffscreenLayerSurfaceEnabled()
* @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
*/
- protected void layoutSurfaceLayerImpl(long layerHandle) {}
+ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {}
- private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException {
+ private final void layoutSurfaceLayerIfEnabled(boolean visible) throws NativeWindowException {
if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) {
- layoutSurfaceLayerImpl(offscreenSurfaceLayer);
+ layoutSurfaceLayerImpl(offscreenSurfaceLayer, visible);
}
}
@@ -483,7 +563,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
surfaceLock.lock();
try {
invalidate();
- component = null; // don't dispose the AWT component, since we are merely an immutable uplink
} finally {
surfaceLock.unlock();
}
@@ -574,21 +653,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected abstract Point getLocationOnScreenNativeImpl(int x, int y);
protected static Component getLocationOnScreenNonBlocking(Point storage, Component comp) {
+ final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG
Component last = null;
while(null != comp) {
final int dx = comp.getX();
final int dy = comp.getY();
if( DEBUG ) {
- final java.awt.Insets ins = AWTMisc.getInsets(comp);
- System.err.print("LOS: "+storage+" + "+comp.getClass().getName()+"["+dx+"/"+dy+", vis "+comp.isVisible()+", ins "+ins+"] -> ");
+ final java.awt.Insets ins = AWTMisc.getInsets(comp, false);
+ if( null != ins ) {
+ insets.bottom += ins.bottom;
+ insets.top += ins.top;
+ insets.left += ins.left;
+ insets.right += ins.right;
+ }
+ System.err.print("LOS: "+storage+" + "+comp.getClass().getName()+"["+dx+"/"+dy+", vis "+comp.isVisible()+", ins "+ins+" -> "+insets+"] -> ");
}
storage.translate(dx, dy);
if( DEBUG ) {
System.err.println(storage);
}
last = comp;
- if( comp instanceof JRootPane ) {
- // LW JRootPane is considered a top-level component!
+ if( comp instanceof Window ) { // top-level heavy-weight ?
break;
}
comp = comp.getParent();
@@ -627,12 +712,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
", surfaceHandle "+toHexString(getSurfaceHandle())+
", bounds "+bounds+", insets "+insets
);
- if(null!=component) {
- sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- ", visible "+component.isVisible());
- } else {
- sb.append(", component NULL");
- }
+ sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+component.isVisible());
sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
",\n\tconfig "+getPrivateGraphicsConfiguration()+
",\n\tawtComponent "+getAWTComponent()+
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 611c13a22..23c48d20e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -82,8 +82,10 @@ public class AWTMisc {
* This is due to <i>experience</i> that <i>some</i> JRootPane's
* do not expose valid insets value.
* </p>
+ * @param topLevelOnly if true only returns insets of top-level components, i.e. Window and JRootPanel,
+ * otherwise for JComponent as well.
*/
- public static Insets getInsets(Component c) {
+ public static Insets getInsets(Component c, boolean topLevelOnly) {
if( c instanceof Window ) {
return ((Window)c).getInsets();
}
@@ -94,7 +96,7 @@ public class AWTMisc {
}
return ((JRootPane)c).getInsets();
}
- if( c instanceof JComponent ) {
+ if( !topLevelOnly && c instanceof JComponent ) {
return ((JComponent)c).getInsets();
}
return null;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index b20007d53..844b17469 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -152,7 +152,7 @@ public class JAWTUtil {
* CALayer position needs to be derived from AWT position
* in relation to super CALayer.
* <p>
- * AWT's super-calayer, i.e. the AWT's own component CALayer,
+ * AWT's super-calayer, i.e. the AWT top-container's CALayer,
* does not layout our root-calayer in respect to this component's
* position and size, at least when resizing programmatically.
* </p>
@@ -164,6 +164,24 @@ public class JAWTUtil {
* The super-calayer bounds exclude the frame's heavyweight border/insets.
* </p>
* <p>
+ * The super-calayer lies within the AWT top-container client space (content).
+ * </p>
+ * <p>
+ * Component's location in super-calayer:
+ * <pre>
+ p0 = c.locationOnScreen();
+ p0 -= c.getOutterComp.getPos();
+ p0 -= c.getOutterComp.getInsets();
+ * </pre>
+ * Where 'locationOnScreen()' is:
+ * <pre>
+ p0 = 0/0;
+ while( null != c ) {
+ p0 += c.getPos();
+ }
+ * </pre>
+ * </p>
+ * <p>
* This flags also sets {@link #JAWT_OSX_CALAYER_QUIRK_SIZE},
* i.e. they are related.
* </p>
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 0d81274ca..b712f6a1a 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -110,41 +110,58 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
// AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
// Determine p0: components location on screen w/o insets.
// CALayer position will be determined in native code.
- // See: {@link JAWTWindow#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
+ // See detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
final Point p0 = new Point();
final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
- final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
- if(null != ins) {
- p0.translate(-ins.left, -ins.top);
+ final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
+ final Point p1 = (Point)p0.cloneMutable();
+ p1.translate(-outterComp.getX(), -outterComp.getY());
+ if( null != outterInsets ) {
+ p1.translate(-outterInsets.left, -outterInsets.top);
}
+
if( DEBUG ) {
- final java.awt.Point wP0 = outterComp.getLocationOnScreen();
- System.err.println("JAWTWindow.attachSurfaceHandleImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds);
+ final java.awt.Point pA0 = component.getLocationOnScreen();
+ final Point pA1 = new Point(pA0.x, pA0.y);
+ pA1.translate(-outterComp.getX(), -outterComp.getY());
+ if( null != outterInsets ) {
+ pA1.translate(-outterInsets.left, -outterInsets.top);
+ }
+ System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
+ ", p0 "+p0+" -> "+p1+", bounds "+bounds);
}
- OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks());
+ OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks());
} } );
}
@Override
- protected void layoutSurfaceLayerImpl(long layerHandle) {
+ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {
final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks();
- if( 0 != caLayerQuirks ) {
- // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
- // Determine p0: components location on screen w/o insets.
- // CALayer position will be determined in native code.
- // See: {@link JAWTWindow#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
- final Point p0 = new Point();
- final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
- final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
- if( null != ins ) {
- p0.translate(-ins.left, -ins.top);
- }
- if( DEBUG ) {
- final java.awt.Point wP0 = outterComp.getLocationOnScreen();
- System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds);
+ // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
+ // Determine p0: components location on screen w/o insets.
+ // CALayer position will be determined in native code.
+ // See detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
+ final Point p0 = new Point();
+ final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
+ final Point p1 = (Point)p0.cloneMutable();
+ p1.translate(-outterComp.getX(), -outterComp.getY());
+ if( null != outterInsets ) {
+ p1.translate(-outterInsets.left, -outterInsets.top);
+ }
+
+ if( DEBUG ) {
+ final java.awt.Point pA0 = component.getLocationOnScreen();
+ final Point pA1 = new Point(pA0.x, pA0.y);
+ pA1.translate(-outterComp.getX(), -outterComp.getY());
+ if( null != outterInsets ) {
+ pA1.translate(-outterInsets.left, -outterInsets.top);
}
- OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), caLayerQuirks);
+ System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", quirks "+caLayerQuirks+", visible "+visible+
+ ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
+ ", p0 "+p0+" -> "+p1+", bounds "+bounds);
}
+ OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks);
}
@Override
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 2112131ed..dc32bd58c 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -186,15 +186,16 @@ public class OSXUtil implements ToolkitProperties {
*
* @param rootCALayer the root surface layer, maybe null.
* @param subCALayer the client surface layer, maybe null.
+ * @param visible TODO
* @param width the expected width
* @param height the expected height
* @param caLayerQuirks TODO
*/
- public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
+ public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final boolean visible, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
if( 0==rootCALayer && 0==subCALayer ) {
return;
}
- FixCALayerLayout0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks);
+ FixCALayerLayout0(rootCALayer, subCALayer, visible, x, y, width, height, caLayerQuirks);
}
/**
@@ -262,13 +263,13 @@ public class OSXUtil implements ToolkitProperties {
}
/**
- * Run later on current OSX thread.
- *
+ * Run later on ..
+ * @param onMain if true, run on main-thread, otherwise on the current OSX thread.
* @param runnable
* @param delay delay to run the runnable in milliseconds
*/
- public static void RunLater(Runnable runnable, int delay) {
- RunLater0(new RunnableTask( runnable, null, true, System.err ), delay);
+ public static void RunLater(boolean onMain, Runnable runnable, int delay) {
+ RunLater0(onMain, new RunnableTask( runnable, null, true, System.err ), delay);
}
private static Runnable _nop = new Runnable() { public void run() {}; };
@@ -358,11 +359,11 @@ public class OSXUtil implements ToolkitProperties {
private static native long GetNSWindow0(long nsView);
private static native long CreateCALayer0(int width, int height);
private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
- private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
+ private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, boolean visible, int x, int y, int width, int height, int caLayerQuirks);
private static native void RemoveCASublayer0(long rootCALayer, long subCALayer);
private static native void DestroyCALayer0(long caLayer);
private static native void RunOnMainThread0(Runnable runnable);
- private static native void RunLater0(Runnable runnable, int delay);
+ private static native void RunLater0(boolean onMain, Runnable runnable, int delay);
private static native boolean IsMainThread0();
private static native int GetScreenRefreshRate0(int scrn_idx);
}
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index e3844455a..6a7952eaf 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -336,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
@private
BOOL fixedFrameSet;
CGRect fixedFrame;
+ float visibleOpacity;
}
- (id)init;
#ifdef DBG_LIFECYCLE
@@ -346,7 +347,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
- (id<CAAction>)actionForKey:(NSString *)key ;
- (void)layoutSublayers;
- (void)setFrame:(CGRect) frame;
-- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force;
+- (void)fixCALayerLayout: (CALayer*) subLayer visible:(BOOL)visible x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force;
@end
@@ -358,6 +359,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
MyCALayer * o = [super init];
o->fixedFrameSet = 0;
o->fixedFrame = CGRectMake(0, 0, 0, 0);
+ o->visibleOpacity = 1.0;
DBG_PRINT("MyCALayer::init.X: new %p\n", o);
return o;
}
@@ -449,13 +451,26 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
}
}
-- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force
+- (void)fixCALayerLayout: (CALayer*) subLayer visible:(BOOL)visible x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force
{
int loutQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_LAYOUT & caLayerQuirks );
{
CALayer* superLayer = [self superlayer];
CGRect superFrame = [superLayer frame];
CGRect lFrame = [self frame];
+ if( visible ) {
+ // Opacity must be 0 to see through the disabled CALayer
+ [subLayer setOpacity: visibleOpacity];
+ [self setOpacity: visibleOpacity];
+ [self setHidden: NO];
+ [subLayer setHidden: NO];
+ } else {
+ [subLayer setHidden: YES];
+ [self setHidden: YES];
+ visibleOpacity = [self opacity];
+ [subLayer setOpacity: 0.0];
+ [self setOpacity: 0.0];
+ }
int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 );
int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height );
if( !posQuirk || loutQuirk ) {
@@ -596,7 +611,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
[subLayer setNeedsDisplayOnBoundsChange: YES];
if( 0 != caLayerQuirks ) {
- [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_TRUE];
+ [rootLayer fixCALayerLayout: subLayer visible:1 x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_TRUE];
}
[CATransaction commit];
@@ -612,7 +627,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
* Signature: (JJIII)V
*/
JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0
- (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jint caLayerQuirks)
+ (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jboolean visible, jint x, jint y, jint width, jint height, jint caLayerQuirks)
{
if( 0 != caLayerQuirks ) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -625,7 +640,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_FALSE];
+ [rootLayer fixCALayerLayout: subLayer visible:(BOOL)visible x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_FALSE];
[CATransaction commit];
@@ -837,10 +852,13 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Uns
static void RunOnThread (JNIEnv *env, jobject runnable, BOOL onMain, jint delayInMS)
{
- DBG_PRINT2( "RunOnThread0: isMainThread %d, NSApp %d, NSApp-isRunning %d, onMain %d, delay %dms\n",
- (int)([NSThread isMainThread]), (int)(NULL!=NSApp), (int)([NSApp isRunning]), (int)onMain, (int)delayInMS);
+ BOOL isMainThread = [NSThread isMainThread];
+ BOOL forkOnMain = onMain && ( NO == isMainThread || 0 < delayInMS );
+
+ DBG_PRINT2( "RunOnThread0: forkOnMain %d [onMain %d, delay %dms, isMainThread %d], NSApp %d, NSApp-isRunning %d\n",
+ (int)forkOnMain, (int)onMain, (int)delayInMS, (int)isMainThread, (int)(NULL!=NSApp), (int)([NSApp isRunning]));
- if ( !onMain || NO == [NSThread isMainThread] ) {
+ if ( forkOnMain ) {
jobject runnableObj = (*env)->NewGlobalRef(env, runnable);
JavaVM *jvmHandle = NULL;
@@ -892,10 +910,10 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0
* Signature: (ZLjava/lang/Runnable;I)V
*/
JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunLater0
- (JNIEnv *env, jclass unused, jobject runnable, jint delay)
+ (JNIEnv *env, jclass unused, jboolean onMain, jobject runnable, jint delay)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- RunOnThread (env, runnable, NO, delay);
+ RunOnThread (env, runnable, onMain ? YES : NO, delay);
[pool release];
}
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index c618405c2..382a5d583 100644
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -78,7 +78,7 @@ public abstract class Display {
* Stop the running EDT in case this display is destroyed already.<br>
* @return true if EDT has been stopped (destroyed but running), otherwise false.
*/
- public abstract boolean validateEDT();
+ public abstract boolean validateEDTStopped();
/**
* @return true if the native display handle is valid and ready to operate,
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index f63c03738..8a43ef153 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -351,10 +351,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
* @param newParent The new parent NativeWindow. If null, this Window becomes a top level window.
*
* @return The issued reparent action type (strategy) as defined in Window.ReparentAction
+ * @see #reparentWindow(NativeWindow, int, int, boolean)
*/
ReparentOperation reparentWindow(NativeWindow newParent);
- ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate);
+ /**
+ * Change this window's parent window.<br>
+ * <P>
+ * In case the old parent is not null and a Window,
+ * this window is removed from it's list of children.<br>
+ * In case the new parent is not null and a Window,
+ * this window is added to it's list of children.<br></P>
+ *
+ * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window.
+ * @param x new top-level position, use -1 for default position.
+ * @param y new top-level position, use -1 for default position.
+ * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is <code>false</code>.
+ *
+ * @return The issued reparent action type (strategy) as defined in Window.ReparentAction
+ * @see #reparentWindow(NativeWindow)
+ */
+ ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate);
/**
* Enable or disable fullscreen mode for this window.
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 55f5f0533..73b3bc368 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -272,10 +272,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF+", isParent "+isParent+", isFS "+isFullscreen);
}
if(isParent && !isFullscreen) {
- if(oldF == NewtCanvasAWT.this && newF == null) {
+ if(newF == NewtCanvasAWT.this) {
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.FocusProperty: AWT focus -> NEWT focus traversal");
+ }
+ requestFocusNEWTChild();
+ } else if(oldF == NewtCanvasAWT.this && newF == null) {
// focus traversal to NEWT - NOP
if(DEBUG) {
- System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus traversal");
+ System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus");
}
} else if(null != newF && newF != NewtCanvasAWT.this) {
// focus traversal to another AWT component
@@ -292,6 +297,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener();
private volatile KeyboardFocusManager keyboardFocusManager = null;
+ private final void requestFocusNEWTChild() {
+ if(null!=newtChild) {
+ newtChild.setFocusAction(null);
+ if(isOnscreen) {
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
+ }
+ newtChild.requestFocus();
+ newtChild.setFocusAction(focusAction);
+ }
+ }
+
/**
* Sets a new NEWT child, provoking reparenting.
* <p>
@@ -582,16 +598,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final Graphics2D g2d = (Graphics2D)graphics;
try {
printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight());
- try {
- final TileRenderer tileRenderer = printAWTTiles.renderer;
- if( DEBUG ) {
- System.err.println("AWT print.0: "+tileRenderer);
+ final TileRenderer tileRenderer = printAWTTiles.renderer;
+ if( DEBUG ) {
+ System.err.println("AWT print.0: "+tileRenderer);
+ }
+ if( !tileRenderer.eot() ) {
+ try {
+ do {
+ tileRenderer.display();
+ } while ( !tileRenderer.eot() );
+ if( DEBUG ) {
+ System.err.println("AWT print.1: "+printAWTTiles);
+ }
+ tileRenderer.reset();
+ } finally {
+ printAWTTiles.resetGraphics2D();
}
- do {
- tileRenderer.display();
- } while ( !tileRenderer.eot() );
- } finally {
- printAWTTiles.resetGraphics2D();
}
} catch (NoninvertibleTransformException nte) {
System.err.println("Catched: Inversion failed of: "+g2d.getTransform());
@@ -602,50 +624,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
}
- private final void requestFocusNEWTChild() {
- if(null!=newtChild) {
- newtChild.setFocusAction(null);
- if(isOnscreen) {
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- }
- newtChild.requestFocus();
- newtChild.setFocusAction(focusAction);
- }
- }
-
- @Override
- public void requestFocus() {
- super.requestFocus();
- requestFocusNEWTChild();
- }
-
- @Override
- public boolean requestFocus(boolean temporary) {
- final boolean res = super.requestFocus(temporary);
- if(res) {
- requestFocusNEWTChild();
- }
- return res;
- }
-
- @Override
- public boolean requestFocusInWindow() {
- final boolean res = super.requestFocusInWindow();
- if(res) {
- requestFocusNEWTChild();
- }
- return res;
- }
-
- @Override
- public boolean requestFocusInWindow(boolean temporary) {
- final boolean res = super.requestFocusInWindow(temporary);
- if(res) {
- requestFocusNEWTChild();
- }
- return res;
- }
-
private final boolean validateComponent(boolean attachNewtChild) {
if( Beans.isDesignTime() || !isDisplayable() ) {
return false;
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
index 83a129455..c7153840f 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
@@ -252,9 +252,9 @@ public class JOGLNewtApplet1Run extends Applet {
System.err.println("GLWindow: "+glWindow);
}
base.start();
- if( null != newtCanvasAWT &&
- newtCanvasAWT.isOffscreenLayerSurfaceEnabled() &&
- 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) {
+ if( null != newtCanvasAWT &&
+ newtCanvasAWT.isOffscreenLayerSurfaceEnabled() &&
+ 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) {
// force relayout
final int cW = newtCanvasAWT.getWidth();
final int cH = newtCanvasAWT.getHeight();
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
index 25ddfad48..1004adb8e 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -33,6 +33,7 @@ import java.security.PrivilegedAction;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode;
+import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
@@ -301,7 +302,17 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
if(null == glWindow.getParent()) {
glWindow.reparentWindow(awtParent);
} else {
- glWindow.reparentWindow(null);
+ final InsetsImmutable insets = glWindow.getInsets();
+ final int x, y;
+ if ( 0 >= insets.getTopHeight() ) {
+ // fail safe ..
+ x = 32;
+ y = 32;
+ } else {
+ x = insets.getLeftWidth();
+ y = insets.getTopHeight();
+ }
+ glWindow.reparentWindow(null, x, y, false /* forceDestroyCreate */);
glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE );
}
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 45ab2a44c..eace0f2af 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -390,8 +390,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
- public final ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) {
- return window.reparentWindow(newParent, forceDestroyCreate);
+ public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) {
+ return window.reparentWindow(newParent, x, y, forceDestroyCreate);
}
@Override
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index 47dfca0f3..2fa83e0e2 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -346,7 +346,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
{
final Display newtDisplay = newtChild.getScreen().getDisplay();
final EDTUtil edtUtil = new SWTEDTUtil(newtDisplay, getDisplay());
- edtUtil.restart();
+ edtUtil.start();
newtDisplay.setEDTUtil( edtUtil );
}
diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
index e86df2084..52ca95682 100644
--- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
@@ -65,10 +65,10 @@ public interface EDTUtil {
public void setPollPeriod(long ms);
/**
- * Starts or restarts the EDT.
+ * Starts the EDT after it's creation or after {@link #invokeStop(boolean, Runnable) stopping}.
* <p>
- * If the EDT is running, it must be stopped first via {@link #invokeStop(boolean, Runnable)}
- * and the caller should wait until it's stopped via {@link #waitUntilStopped()}.
+ * If the EDT is running, it must be {@link #invokeStop(boolean, Runnable) stopped} first
+ * and the caller should wait {@link #waitUntilStopped() until it's stopped}.
* </p>
*
* @return true if EDT has been successfully restarted, otherwise false
@@ -77,7 +77,7 @@ public interface EDTUtil {
* @see #invokeStop(boolean, java.lang.Runnable)
* @see #waitUntilStopped()
*/
- public boolean restart() throws IllegalStateException;
+ public boolean start() throws IllegalStateException;
/**
* Returns true if the current thread is the event dispatch thread (EDT).
@@ -130,7 +130,7 @@ public interface EDTUtil {
* <li>All previous queued tasks will be finished.</li>
* <li>No new tasks are allowed, an Exception is thrown.</li>
* <li>Can be issued from within EDT, ie from within an enqueued task.</li>
- * <li>{@link #restart()} may follow immediately, ie creating a new EDT</li>
+ * <li>{@link #start()} may follow immediately, ie creating a new EDT</li>
* </ul>
* </p>
* @return true if <code>task</code> has been executed or queued for later execution, otherwise false
diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
index 5794d4ae9..3d1037ad5 100644
--- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
@@ -77,7 +77,7 @@ public class DefaultEDTUtil implements EDTUtil {
}
@Override
- public final boolean restart() throws IllegalStateException {
+ public final boolean start() throws IllegalStateException {
synchronized(edtLock) {
if( edt.isRunning() ) {
throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", EDT "+edt.getName()+", isRunning "+edt.isRunning+", shouldStop "+edt.shouldStop);
@@ -135,6 +135,10 @@ public class DefaultEDTUtil implements EDTUtil {
@Override
public final boolean invokeStop(boolean wait, Runnable task) {
+ if(DEBUG) {
+ System.err.println(Thread.currentThread()+": Default-EDT.invokeStop wait "+wait);
+ Thread.dumpStack();
+ }
return invokeImpl(wait, task, true);
}
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index 8f792b23c..0f47c87a0 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -170,7 +170,7 @@ public abstract class DisplayImpl extends Display {
if(NewtFactory.useEDT()) {
def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable);
if(DEBUG) {
- System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName());
+ System.err.println("Display.createEDTUtil("+getFQName()+"): "+def.getClass().getName());
}
} else {
def = null;
@@ -181,21 +181,18 @@ public abstract class DisplayImpl extends Display {
@Override
public synchronized EDTUtil setEDTUtil(final EDTUtil usrEDTUtil) {
final EDTUtil oldEDTUtil = edtUtil;
- final EDTUtil newEDTUtil;
if( null != usrEDTUtil && usrEDTUtil == oldEDTUtil ) {
if( DEBUG ) {
System.err.println("Display.setEDTUtil: "+usrEDTUtil+" - keep!");
}
- newEDTUtil = oldEDTUtil;
- } else {
- if(DEBUG) {
- final String msg = ( null == usrEDTUtil ) ? "default" : "custom";
- System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil);
- }
- stopEDT( oldEDTUtil, null );
- newEDTUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil;
+ return oldEDTUtil;
+ }
+ if(DEBUG) {
+ final String msg = ( null == usrEDTUtil ) ? "default" : "custom";
+ System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil);
}
- edtUtil = newEDTUtil;
+ stopEDT( oldEDTUtil, null );
+ edtUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil;
return oldEDTUtil;
}
@@ -224,31 +221,30 @@ public abstract class DisplayImpl extends Display {
public void runOnEDTIfAvail(boolean wait, final Runnable task) {
final EDTUtil _edtUtil = edtUtil;
- if( null != _edtUtil && !_edtUtil.isCurrentThreadEDT() ) {
- if( !_edtUtil.isRunning() ) { // start EDT if not running yet
- synchronized( this ) {
- if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK
- _edtUtil.restart();
- if( DEBUG ) {
- System.err.println("Info: EDT started "+Thread.currentThread().getName()+", "+this);
- Thread.dumpStack();
- }
+ if( !_edtUtil.isRunning() ) { // start EDT if not running yet
+ synchronized( this ) {
+ if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK
+ if( DEBUG ) {
+ System.err.println("Info: EDT start "+Thread.currentThread().getName()+", "+this);
+ Thread.dumpStack();
}
+ _edtUtil.start();
}
}
- if( !_edtUtil.invoke(wait, task) ) {
- if( DEBUG ) {
- System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName());
- Thread.dumpStack();
- }
- task.run();
+ }
+ if( !_edtUtil.isCurrentThreadEDT() ) {
+ if( _edtUtil.invoke(wait, task) ) {
+ return; // done
+ }
+ if( DEBUG ) {
+ System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName());
+ Thread.dumpStack();
}
- } else {
- task.run();
}
+ task.run();
}
- public boolean validateEDT() {
+ public boolean validateEDTStopped() {
if( 0==refCount && null == aDevice ) {
final EDTUtil _edtUtil = edtUtil;
if( null != _edtUtil && _edtUtil.isRunning() ) {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index caa461e41..b7357863f 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -154,7 +154,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean fullscreen = false, brokenFocusChange = false;
private List<MonitorDevice> fullscreenMonitors = null;
private boolean fullscreenUseMainMonitor = true;
- private boolean fullscreenUseSpanningMode = true; // spanning mode: fake full screen, only on certain platforms
private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user)
private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets
@@ -273,7 +272,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
fullscreen = false;
fullscreenMonitors = null;
fullscreenUseMainMonitor = true;
- fullscreenUseSpanningMode = false;
hasFocus = false;
parentWindowHandle = 0;
}
@@ -416,7 +414,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if(postParentlockFocus) {
// harmonize focus behavior for all platforms: focus on creation
- requestFocusInt(isFullscreen() /* skipFocusAction */);
+ requestFocusInt(isFullscreen() /* skipFocusAction if fullscreen */);
((DisplayImpl) screen.getDisplay()).dispatchMessagesNative(); // status up2date
}
if(DEBUG_IMPLEMENTATION) {
@@ -1035,7 +1033,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
removeScreenReference();
Display dpy = screen.getDisplay();
if(null != dpy) {
- dpy.validateEDT();
+ dpy.validateEDTStopped();
}
// send synced destroyed notification
@@ -1051,7 +1049,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
fullscreen = false;
fullscreenMonitors = null;
fullscreenUseMainMonitor = true;
- fullscreenUseSpanningMode = false;
hasFocus = false;
parentWindowHandle = 0;
@@ -1115,12 +1112,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private class ReparentAction implements Runnable {
- NativeWindow newParentWindow;
+ final NativeWindow newParentWindow;
+ final int topLevelX, topLevelY;
boolean forceDestroyCreate;
ReparentOperation operation;
- private ReparentAction(NativeWindow newParentWindow, boolean forceDestroyCreate) {
+ private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, boolean forceDestroyCreate) {
this.newParentWindow = newParentWindow;
+ this.topLevelX = topLevelX;
+ this.topLevelY = topLevelY;
this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE;
this.operation = ReparentOperation.ACTION_INVALID; // ensure it's set
}
@@ -1147,10 +1147,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private void reparent() {
// mirror pos/size so native change notification can get overwritten
- int x = getX();
- int y = getY();
- int width = getWidth();
- int height = getHeight();
+ final int oldX = getX();
+ final int oldY = getY();
+ final int oldWidth = getWidth();
+ final int oldHeight = getHeight();
+ final int x, y;
+ int width = oldWidth;
+ int height = oldHeight;
boolean wasVisible;
final RecursiveLock _lock = windowLock;
@@ -1171,10 +1174,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
long newParentWindowHandle = 0 ;
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", "+x+"/"+y+" "+width+"x"+height);
+ System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate);
}
if(null!=newParentWindow) {
+ // REPARENT TO CHILD WINDOW
+
// reset position to 0/0 within parent space
x = 0;
y = 0;
@@ -1236,12 +1241,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
operation = ReparentOperation.ACTION_NOP;
}
} else {
- if( null != parentWindow ) {
+ // REPARENT TO TOP-LEVEL WINDOW
+ if( 0 <= topLevelX && 0 <= topLevelY ) {
+ x = topLevelX;
+ y = topLevelY;
+ } else if( null != parentWindow ) {
// child -> top
// put client to current parent+child position
final Point p = getLocationOnScreen(null);
x = p.getX();
y = p.getY();
+ } else {
+ x = oldX;
+ y = oldY;
}
// Case: Top Window
@@ -1267,18 +1279,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if ( ReparentOperation.ACTION_INVALID == operation ) {
throw new NativeWindowException("Internal Error: reparentAction not set");
}
-
+
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", pos/size "+x+"/"+y+" "+width+"x"+height+", visible "+wasVisible);
+ }
+
if( ReparentOperation.ACTION_NOP == operation ) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparent: NO CHANGE ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", visible "+wasVisible);
- }
return;
}
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", visible "+wasVisible);
- }
-
// rearrange window tree
if(null!=parentWindow && parentWindow instanceof Window) {
((Window)parentWindow).removeChild(WindowImpl.this);
@@ -1288,19 +1297,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
((Window)parentWindow).addChild(WindowImpl.this);
}
- if( ReparentOperation.ACTION_NATIVE_CREATION_PENDING == operation ) {
- // make size and position persistent for proper recreation
- definePosition(x, y);
- defineSize(width, height);
- return;
- }
-
if( ReparentOperation.ACTION_NATIVE_REPARENTING == operation ) {
final DisplayImpl display = (DisplayImpl) screen.getDisplay();
display.dispatchMessagesNative(); // status up2date
- if(wasVisible) {
- setVisibleImpl(false, x, y, width, height);
+ // TOP -> CLIENT: !visible first (fixes X11 unsuccessful return to parent window)
+ if( null != parentWindow && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) {
+ setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight);
WindowImpl.this.waitForVisible(false, false);
// FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible,
// even though we do exactly that (KDE+Composite)
@@ -1340,7 +1343,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW);
}
if(ok) {
- requestFocusInt(false /* skipFocusAction */);
+ ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW);
+ }
+ if(ok) {
+ requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */);
display.dispatchMessagesNative(); // status up2date
}
}
@@ -1361,10 +1367,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
destroy( wasVisible );
operation = ReparentOperation.ACTION_NATIVE_CREATION ;
}
+ } else {
+ // Case
+ // ACTION_NATIVE_CREATION
+ // ACTION_NATIVE_CREATION_PENDING;
+
+ // make size and position persistent for proper [re]creation
+ definePosition(x, y);
+ defineSize(width, height);
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight());
+ System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight());
}
} finally {
if(null!=lifecycleHook) {
@@ -1388,7 +1402,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparentWindow: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight());
+ System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight());
}
}
}
@@ -1399,9 +1413,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
_lock.lock();
try {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow));
+ System.err.println("Window.reparent: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow));
}
- setVisible(true); // native creation
+ setVisibleActionImpl(true); // native creation
+ requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */);
} finally {
_lock.unlock();
}
@@ -1411,11 +1426,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
@Override
public final ReparentOperation reparentWindow(NativeWindow newParent) {
- return reparentWindow(newParent, false);
+ return reparentWindow(newParent, -1, -1, false);
}
- public ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) {
- final ReparentAction reparentAction = new ReparentAction(newParent, forceDestroyCreate);
+ @Override
+ public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) {
+ final ReparentAction reparentAction = new ReparentAction(newParent, x, y, forceDestroyCreate);
runOnEDTIfAvail(true, reparentAction);
return reparentAction.getOp();
}
@@ -1803,7 +1819,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private void requestFocusInt(boolean skipFocusAction) {
if( skipFocusAction || !focusAction() ) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+ System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): skipFocusAction "+skipFocusAction+", focus "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
}
requestFocusImpl(true);
}
@@ -1903,6 +1919,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// set current state
WindowImpl.this.fullscreen = fullscreen;
+ final int oldX = getX();
+ final int oldY = getY();
+ final int oldWidth = getWidth();
+ final int oldHeight = getHeight();
+
int x,y,w,h;
final RectangleImmutable sviewport = screen.getViewport();
@@ -1920,23 +1941,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors);
if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) &&
( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) {
- fullscreenUseSpanningMode = true;
fs_span_flag = FLAG_IS_FULLSCREEN_SPAN;
} else {
- fullscreenUseSpanningMode = false;
fs_span_flag = 0;
}
- nfs_x = getX();
- nfs_y = getY();
- nfs_width = getWidth();
- nfs_height = getHeight();
+ nfs_x = oldX;
+ nfs_y = oldY;
+ nfs_width = oldWidth;
+ nfs_height = oldHeight;
x = viewport.getX();
y = viewport.getY();
w = viewport.getWidth();
h = viewport.getHeight();
} else {
fullscreenUseMainMonitor = true;
- fullscreenUseSpanningMode = false;
fullscreenMonitors = null;
fs_span_flag = 0;
viewport = null;
@@ -1962,16 +1980,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+
", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+
- ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName());
+ ", spanning "+(0!=fs_span_flag)+" @ "+Thread.currentThread().getName());
}
final DisplayImpl display = (DisplayImpl) screen.getDisplay();
display.dispatchMessagesNative(); // status up2date
final boolean wasVisible = isVisible();
-
+
// Lock parentWindow only during reparenting (attempt)
final NativeWindow parentWindowLocked;
if( null != parentWindow ) {
+ // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window)
+ if( !fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) {
+ setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight);
+ WindowImpl.this.waitForVisible(false, false);
+ // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible,
+ // even though we do exactly that (KDE+Composite)
+ try { Thread.sleep(100); } catch (InterruptedException e) { }
+ display.dispatchMessagesNative(); // status up2date
+ }
parentWindowLocked = parentWindow;
if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
@@ -1982,7 +2009,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
try {
reconfigureWindowImpl(x, y, w, h,
getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) |
- fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) );
+ fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) );
} finally {
if(null!=parentWindowLocked) {
parentWindowLocked.unlockSurface();
@@ -1992,11 +2019,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(wasVisible) {
setVisibleImpl(true, x, y, w, h);
- WindowImpl.this.waitForVisible(true, false);
- display.dispatchMessagesNative(); // status up2date
- WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW);
+ boolean ok = 0 <= WindowImpl.this.waitForVisible(true, false);
+ if(ok) {
+ ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW);
+ }
+ if(ok && !fullscreen) {
+ ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW);
+ }
+ if(ok) {
+ requestFocusInt(fullscreen /* skipFocusAction if fullscreen */);
+ display.dispatchMessagesNative(); // status up2date
+ }
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window fs done: " + WindowImpl.this);
+ System.err.println("Window fs done: ok " + ok + ", " + WindowImpl.this);
}
}
} finally {
@@ -2021,13 +2056,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
synchronized(fullScreenAction) {
fullscreenMonitors = monitors;
fullscreenUseMainMonitor = useMainMonitor;
- fullscreenUseSpanningMode = false;
if( fullScreenAction.init(fullscreen) ) {
if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) {
// enable fullscreen on offscreen instance
if(null != parentWindow) {
nfs_parent = parentWindow;
- reparentWindow(null, true);
+ reparentWindow(null, -1, -1, true /* forceDestroyCreate */);
} else {
throw new InternalError("Offscreen instance w/o parent unhandled");
}
@@ -2037,13 +2071,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(!fullScreenAction.fsOn() && null != nfs_parent) {
// disable fullscreen on offscreen instance
- reparentWindow(nfs_parent, true);
+ reparentWindow(nfs_parent, -1, -1, true /* forceDestroyCreate */);
nfs_parent = null;
}
-
- if( fullscreen && isVisible() ) { // force focus on fullscreen
- requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */);
- }
}
return this.fullscreen;
}
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
index 80c72c008..02f4be0cd 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
@@ -68,7 +68,7 @@ public class AWTEDTUtil implements EDTUtil {
}
@Override
- public final boolean restart() throws IllegalStateException {
+ public final boolean start() throws IllegalStateException {
synchronized(edtLock) {
if( nedt.isRunning() ) {
throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", on AWT-EDT "+EventQueue.isDispatchThread());
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 6aebf0410..08638d868 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -159,14 +159,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
protected void setTitleImpl(final String title) {
- OSXUtil.RunOnMainThread(false, new Runnable() {
- public void run() {
- setTitle0(getWindowHandle(), title);
- } } );
+ OSXUtil.RunOnMainThread(false, new Runnable() {
+ public void run() {
+ setTitle0(getWindowHandle(), title);
+ } } );
}
@Override
protected void requestFocusImpl(final boolean force) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+isOffscreenInstance);
+ }
if(!isOffscreenInstance) {
OSXUtil.RunOnMainThread(false, new Runnable() {
public void run() {
@@ -414,13 +417,15 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED;
keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode;
}
- /* {
+ /**
+ {
final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode);
System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+
", keyCode 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+
", keySymChar '"+keySymChar+"', 0x"+Integer.toHexString(keySymChar)+" -> 0x"+Integer.toHexString(keySym)+
", mods "+toHexString(modifiers)+
- ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode);
+ ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode+
+ ", nativeValid "+isNativeValid()+", isOffscreen "+isOffscreenInstance);
} */
// OSX delivery order is PRESSED (t0), RELEASED (t1) and TYPED (t2) -> NEWT order: PRESSED (t0) and RELEASED (t1)
@@ -452,27 +457,28 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
final PointImmutable pS, final int width, final int height,
final boolean fullscreen, final boolean visible, final boolean alwaysOnTop) {
+ final long parentWinHandle = getParentWindowHandle();
+ final long preWinHandle = getWindowHandle();
+
if(DEBUG_IMPLEMENTATION) {
System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+
": offscreen "+offscreenInstance+", recreate "+recreate+
", pS "+pS+", "+width+"x"+height+", fullscreen "+fullscreen+", visible "+visible+
- ", alwaysOnTop "+alwaysOnTop);
+ ", alwaysOnTop "+alwaysOnTop+", preWinHandle "+toHexString(preWinHandle)+", parentWin "+toHexString(parentWinHandle)+
+ ", surfaceHandle "+toHexString(surfaceHandle));
// Thread.dumpStack();
}
try {
- final long parentWin = getParentWindowHandle();
- if( 0 != getWindowHandle() ) {
- final long thisWin = getWindowHandle();
+ if( 0 != preWinHandle ) {
setWindowHandle(0);
-
if( 0 == surfaceHandle ) {
throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView");
}
OSXUtil.RunOnMainThread(false, new Runnable() {
public void run() {
- changeContentView0(parentWin, thisWin, 0);
- close0( thisWin );
+ changeContentView0(parentWinHandle, preWinHandle, 0);
+ close0( preWinHandle );
} } );
} else {
if( 0 != surfaceHandle ) {
@@ -494,13 +500,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
setWindowHandle( newWin );
final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance;
- // Non blocking initialization on main-thread!
- OSXUtil.RunOnMainThread(false, new Runnable() {
+ // Blocking initialization on main-thread!
+ OSXUtil.RunOnMainThread(true, new Runnable() {
public void run() {
- initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height,
+ initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height,
isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle);
if( offscreenInstance ) {
- orderOut0(0!=parentWin ? parentWin : newWin);
+ orderOut0(0!=parentWinHandle ? parentWinHandle : newWin);
} else {
setTitle0(newWin, getTitle());
setAlwaysOnTop0(getWindowHandle(), alwaysOnTop);
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index 4786ea04f..806dd270c 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -163,7 +163,7 @@ public class WindowDriver extends WindowImpl {
_y = y;
}
if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) {
- if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 != ( FLAG_IS_FULLSCREEN_SPAN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) {
+ if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) {
tempFSAlwaysOnTop = true;
flags |= FLAG_IS_ALWAYSONTOP;
if(DEBUG_IMPLEMENTATION) {
diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java
index d46562050..6024195e3 100644
--- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java
@@ -77,7 +77,7 @@ public class SWTEDTUtil implements EDTUtil {
}
@Override
- public final boolean restart() throws IllegalStateException {
+ public final boolean start() throws IllegalStateException {
final boolean swtDisposed = swtDisplay.isDisposed();
synchronized(edtLock) {
if( nedt.isRunning() ) {
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 1c7064a66..f8988cf15 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -764,27 +764,27 @@ NS_ENDHANDLER
// specify we want mouse-moved events
[myWindow setAcceptsMouseMovedEvents:YES];
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
// Set the content view
changeContentView(env, jthis, parentView, myWindow, myView, NO);
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
if(NULL!=parentWindow) {
[myWindow attachToParent: parentWindow];
}
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d, visible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible], visible);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d, visible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible], visible);
// Immediately re-position this window based on an upper-left coordinate system
setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO);
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
NS_DURING
// concurrent view rendering
@@ -793,8 +793,8 @@ NS_DURING
[myWindow setAllowsConcurrentViewDrawing: YES];
}
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
if ( [myView respondsToSelector:@selector(setCanDrawConcurrently:)] ) {
[myView setCanDrawConcurrently: YES];
@@ -802,16 +802,16 @@ NS_DURING
NS_HANDLER
NS_ENDHANDLER
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
// visible on front
if( visible ) {
[myWindow orderFront: myWindow];
}
- DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n",
- dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+ DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n",
+ dbgIdx++, myWindow, myView, [myWindow isVisible]);
// force surface creation
// [myView lockFocus];
@@ -831,16 +831,18 @@ NS_ENDHANDLER
// right mouse button down events
[myView setNextResponder: myWindow];
- DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n",
- (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView));
+ DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n",
+ dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
[myView setDestroyNotifySent: false];
setJavaWindowObject(env, jthis, myView, YES);
- DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n",
- (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView));
+ DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n",
+ dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
[pool release];
+ DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p\n",
+ (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
}
/**
@@ -857,14 +859,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0
NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window);
NewtView* mView = (NewtView *)[mWin contentView];
NSWindow* pWin = [mWin parentWindow];
- BOOL destroyNotifySent = (NULL != mView) ? [mView getDestroyNotifySent] : false;
+ BOOL destroyNotifySent, isNSView, isNewtView;
+ if( NULL != mView ) {
+ isNSView = [mView isKindOfClass:[NSView class]];
+ isNewtView = [mView isKindOfClass:[NewtView class]];
+ destroyNotifySent = isNewtView ? [mView getDestroyNotifySent] : false;
+ } else {
+ isNSView = false;
+ isNewtView = false;
+ destroyNotifySent = false;
+ }
- DBG_PRINT( "windowClose.0 - %p,%d, destroyNotifySent %d, view %p,%d, parent %p\n",
- mWin, getRetainCount(mWin), destroyNotifySent, mView, getRetainCount(mView), pWin);
+ DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], parent %p\n",
+ mWin, destroyNotifySent, mView, isNSView, isNewtView, pWin);
[mWin setRealized: NO];
- if(NULL!=mView) {
+ if( isNewtView ) {
// cleanup view
[mView setDestroyNotifySent: true];
setJavaWindowObject(env, NULL, mView, NO);
@@ -892,8 +903,7 @@ NS_ENDHANDLER
}
[mWin orderOut: mWin];
- DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n",
- mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin);
+ DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin);
// Only release window, if release is not yet in process.
// E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked.
@@ -953,7 +963,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0
#ifdef VERBOSE_ON
BOOL hasFocus = [mWin isKeyWindow];
#endif
-
DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus);
[mWin makeFirstResponder: nil];
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index e6e300d2e..f195c5616 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -817,11 +817,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo
if( TST_FLAG_IS_VISIBLE(flags) ) {
DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n");
XMapRaised(dpy, w);
+ XSync(dpy, False);
+ // WM may disregard pos/size XConfigureWindow requests for invisible windows!
+ DBG_PRINT( "X11: reconfigureWindow0 setPosSize.2 %d/%d %dx%d\n", x, y, width, height);
+ NewtWindows_setPosSize(dpy, w, x, y, width, height);
} else {
DBG_PRINT( "X11: reconfigureWindow0 VISIBLE OFF\n");
XUnmapWindow(dpy, w);
+ XSync(dpy, False);
}
- XSync(dpy, False);
}
if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) ||
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java
index cea104e2f..5335d858e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java
@@ -162,7 +162,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase {
}
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
- glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+ glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null));
frame1.setSize(frameSize0);
setupFrameAndShow(frame1, newtCanvasAWT1);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java
index 358e97622..fade6c33a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java
@@ -56,13 +56,9 @@ import java.awt.Button;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
-import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import org.junit.Assert;
@@ -80,7 +76,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestBug816OSXCALayerPosAWT extends UITestCase {
+public class TestBug816OSXCALayerPos01AWT extends UITestCase {
public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split };
static long duration = 1600; // ms
@@ -89,7 +85,6 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
static boolean forceES2 = false;
static boolean forceGL3 = false;
static int swapInterval = 1;
- static Thread awtEDT;
static java.awt.Dimension rwsize;
@BeforeClass
@@ -97,15 +92,6 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
width = 640;
height = 480;
rwsize = new Dimension(800, 600);
- try {
- EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- awtEDT = Thread.currentThread();
- } } );
- } catch (Exception e) {
- e.printStackTrace();
- Assert.assertNull(e);
- }
}
@AfterClass
@@ -149,7 +135,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
}
protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException {
- final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName());
+ final JFrame frame = new JFrame("Bug816: "+this.getTestMethodName());
Assert.assertNotNull(frame);
final Container framePane = frame.getContentPane();
@@ -473,8 +459,6 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
static int testNum = -1;
public static void main(String args[]) {
- boolean waitForKey = false;
-
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -497,13 +481,6 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
System.err.println("forceGL3 "+forceGL3);
System.err.println("swapInterval "+swapInterval);
- if(waitForKey) {
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- System.err.println("Press enter to continue");
- try {
- System.err.println(stdin.readLine());
- } catch (IOException e) { }
- }
- org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPosAWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos01AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java
new file mode 100644
index 000000000..073956459
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import javax.media.opengl.*;
+
+import com.jogamp.opengl.util.Animator;
+
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JFrame;
+import javax.swing.JRootPane;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug - Swing JFrame w/ 2 JRootPanes and 2 JSplitPanes
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * See also {@link com.jogamp.opengl.test.junit.jogl.demos.es2.awt.Bug816AppletOSXCALayerPos03b}
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos02AWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final JFrame frame = new JFrame("TestBug816OSXCALayerPos02AWT");
+ Assert.assertNotNull(frame);
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Build a GUI where the canvas 3D is located at top right of the frame
+ // and can be resized with split panes dividers
+ JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ true, new JScrollPane(), glCanvas1);
+ verticalSplitPane.setResizeWeight(0.5);
+ JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ true, new JScrollPane(), verticalSplitPane);
+ horizontalSplitPane.setResizeWeight(0.5);
+ JRootPane intermediateRootPane = new JRootPane();
+ intermediateRootPane.setContentPane(horizontalSplitPane);
+ frame.add(intermediateRootPane);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas1);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos02AWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java
new file mode 100644
index 000000000..3451b75cc
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java
@@ -0,0 +1,165 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+import java.awt.Checkbox;
+import java.awt.Frame;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * AWT Frame BorderLayout w/ Checkbox North, GLCanvas Center.
+ * <p>
+ * Checkbox toggles GLCanvas visibility state.
+ * </p>
+ * <p>
+ * Validates bugs:
+ * <ul>
+ * <li>Bug 816: OSX CALayer Positioning Bug</li>
+ * <li>Bug 729: OSX CALayer shall honor the Component's visibility state</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos03aAWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final Frame frame = new Frame("TestBug816OSXCALayerPos03aAWT");
+ Assert.assertNotNull(frame);
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Create a check box that hides / shows canvas
+ final Checkbox checkbox = new Checkbox("Visible canvas", true);
+ checkbox.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent ev) {
+ glCanvas1.setVisible(checkbox.getState());
+ System.out.println("Canvas visible: "+glCanvas1.isVisible());
+ if( glCanvas1.isVisible() ) {
+ frame.validate(); // take care of resized frame while hidden
+ }
+ }
+ });
+
+ // Build a GUI that displays canvas and check box
+ frame.setLayout(new BorderLayout());
+ frame.add(glCanvas1, BorderLayout.CENTER);
+ frame.add(checkbox, BorderLayout.NORTH);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas1);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos03aAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java
new file mode 100644
index 000000000..6f57f1e77
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java
@@ -0,0 +1,171 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+import java.awt.Checkbox;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.Panel;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * AWT Frame BorderLayout w/ Checkbox North, Panel.GLCanvas Center.
+ * <p>
+ * Checkbox toggles GLCanvas's parent panel's visibility state.
+ * </p>
+ * <p>
+ * Validates bugs:
+ * <ul>
+ * <li>Bug 816: OSX CALayer Positioning Bug</li>
+ * <li>Bug 729: OSX CALayer shall honor the Component's visibility state</li>
+ * <li>Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos03bAWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final Frame frame = new Frame("TestBug816OSXCALayerPos03bAWT");
+ Assert.assertNotNull(frame);
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+ // Put it in a panel
+ final Panel panel = new Panel(new GridLayout(1, 1));
+ panel.add(glCanvas1);
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Create a check box that hides / shows canvas
+ final Checkbox checkbox = new Checkbox("Visible canvas", true);
+ checkbox.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent ev) {
+ panel.setVisible(checkbox.getState());
+ System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]");
+ if( panel.isVisible() ) {
+ frame.validate(); // take care of resized frame while hidden
+ }
+ }
+ });
+
+ // Build a GUI that displays canvas and check box
+ frame.setLayout(new BorderLayout());
+ frame.add(panel, BorderLayout.CENTER);
+ frame.add(checkbox, BorderLayout.NORTH);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(panel);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos03bAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java
new file mode 100644
index 000000000..b06e9d970
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java
@@ -0,0 +1,173 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.GridLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * AWT JFrame BorderLayout w/ Checkbox North, JPanel.GLCanvas Center.
+ * <p>
+ * Checkbox toggles GLCanvas's parent jpanel's visibility state.
+ * </p>
+ * <p>
+ * Validates bugs:
+ * <ul>
+ * <li>Bug 816: OSX CALayer Positioning Bug</li>
+ * <li>Bug 729: OSX CALayer shall honor the Component's visibility state</li>
+ * <li>Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos03cAWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final JFrame frame = new JFrame("TestBug816OSXCALayerPos03cAWT");
+ Assert.assertNotNull(frame);
+ final Container framePane = frame.getContentPane();
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+ // Put it in a panel
+ final JPanel panel = new JPanel(new GridLayout(1, 1));
+ panel.add(glCanvas1);
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Create a check box that hides / shows canvas
+ final JCheckBox checkbox = new JCheckBox("Visible canvas", true);
+ checkbox.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent ev) {
+ panel.setVisible(checkbox.getSelectedObjects()!=null);
+ System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]");
+ if( panel.isVisible() ) {
+ frame.validate(); // take care of resized frame while hidden
+ }
+ }
+ });
+
+ // Build a GUI that displays canvas and check box
+ framePane.setLayout(new BorderLayout());
+ framePane.add(panel, BorderLayout.CENTER);
+ framePane.add(checkbox, BorderLayout.NORTH);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ framePane.remove(panel);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos03cAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java
new file mode 100644
index 000000000..b558b1680
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java
@@ -0,0 +1,152 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug - AWT Frame w/ (top-level) Dialog child containing the GLCanvas
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos04aAWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final Frame frame = new Frame("TestBug816OSXCALayerPos04aAWT");
+ Assert.assertNotNull(frame);
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Display the canvas 3D in a dialog child of a frame
+ frame.setSize(400, 400);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setLocation(100, 100);
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+
+ final Dialog dialog = new Dialog(frame, "Bug 816 AWT Top-Level Dialog");
+ dialog.setLayout(new BorderLayout());
+ dialog.add(glCanvas1, BorderLayout.CENTER);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ dialog.setLocation(200, 200);
+ dialog.setSize(width/2, height/2);
+ dialog.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas1);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos04aAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java
new file mode 100644
index 000000000..b502dbdae
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java
@@ -0,0 +1,152 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug - AWT JFrame w/ JDialog child containing the GLCanvas
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBug816OSXCALayerPos04bAWT extends UITestCase {
+ static long duration = 1600; // ms
+ static int width=640, height=480;
+
+ @Test
+ public void test() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+
+ final JFrame frame = new JFrame("TestBug816OSXCALayerPos04bAWT");
+ Assert.assertNotNull(frame);
+
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas1);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ final Animator animator = new Animator();
+ animator.add(glCanvas1);
+ QuitAdapter quitAdapter = new QuitAdapter();
+
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ // Display the canvas 3D in a dialog child of a frame
+ frame.setSize(400, 400);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setLocation(100, 100);
+ frame.setSize(width, height);
+ frame.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+
+ final JDialog dialog = new JDialog(frame, "Bug 816 AWT Top-Level JDialog");
+ dialog.setLayout(new BorderLayout());
+ dialog.add(glCanvas1, BorderLayout.CENTER);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ dialog.setLocation(200, 200);
+ dialog.setSize(width/2, height/2);
+ dialog.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ animator.setUpdateFPSFrames(60, System.err);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas1);
+
+ Assert.assertNotNull(animator);
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ }});
+ Assert.assertEquals(false, frame.isVisible());
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas1);
+ frame.dispose();
+ }});
+ }
+
+ static GLProfile getGLP() {
+ return GLProfile.getMaxProgrammableCore(true);
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+
+ org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos04bAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java
index 175b053d1..4cecd90a1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java
@@ -54,81 +54,81 @@ import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Bug816AppletGLCanvas01 extends Applet implements GLEventListener {
- public Bug816AppletGLCanvas01() {
- }
-
- public static JFrame frame;
- public static JPanel appletHolder;
- public static boolean isApplet = true;
-
- static public void main(String args[]) {
- Applet myApplet = null;
- isApplet = false;
-
- myApplet = new Bug816AppletGLCanvas01();
- appletStarter(myApplet, "Bug861AppletGLCanvasTest01", 800, 600);
- }
-
- static public void appletStarter(final Applet des, String frameName, int width, int height) {
- appletHolder = new JPanel();
- if (frame != null) {
- frame.dispose();
- frame = null;
+ public Bug816AppletGLCanvas01() {
+ }
+
+ public static JFrame frame;
+ public static JPanel appletHolder;
+ public static boolean isApplet = true;
+
+ static public void main(String args[]) {
+ Applet myApplet = null;
+ isApplet = false;
+
+ myApplet = new Bug816AppletGLCanvas01();
+ appletStarter(myApplet, "Bug861AppletGLCanvasTest01", 800, 600);
+ }
+
+ static public void appletStarter(final Applet des, String frameName, int width, int height) {
+ appletHolder = new JPanel();
+ if (frame != null) {
+ frame.dispose();
+ frame = null;
+ }
+ frame = new JFrame(frameName);
+ frame.setVisible(false);
+ frame.getContentPane().add(appletHolder);
+
+ appletHolder.setLayout(null);
+ des.setBounds(0, 0, width, height);
+ appletHolder.add(des);
+
+ frame.setVisible(true);
+ int frameBorderSize = appletHolder.getLocationOnScreen().x - frame.getLocationOnScreen().x;
+ int titleBarHeight = appletHolder.getLocationOnScreen().y - frame.getLocationOnScreen().y;
+ int frameWidth = width + 2 * frameBorderSize;
+ int frameHeight = height + titleBarHeight + frameBorderSize;
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(frameWidth, frameHeight);
+ frame.setVisible(true);
+ des.init();
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+
+ public void init() {
+ initOpenGLAWT();
+ }
+
+ public void initOpenGLAWT() {
+ setBackground(Color.gray);
+ setLayout(null);
+
+ GLProfile glp = GLProfile.getDefault();
+ GLCapabilities caps = new GLCapabilities(glp);
+ GLCanvas canvas = new GLCanvas((GLCapabilitiesImmutable) caps);
+ canvas.setBounds(50, 50, 200, 450);
+ canvas.addGLEventListener(this);
+ add(canvas);
+ }
+
+ public void init(GLAutoDrawable gLAutoDrawable) {
+ GL gl = gLAutoDrawable.getGL();
+ gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ gLAutoDrawable.swapBuffers();
+ }
+
+ public void dispose(GLAutoDrawable glad) {
+ }
+
+ public void display(GLAutoDrawable glad) {
+ }
+
+ public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) {
}
- frame = new JFrame(frameName);
- frame.setVisible(false);
- frame.getContentPane().add(appletHolder);
-
- appletHolder.setLayout(null);
- des.setBounds(0, 0, width, height);
- appletHolder.add(des);
-
- frame.setVisible(true);
- int frameBorderSize = appletHolder.getLocationOnScreen().x - frame.getLocationOnScreen().x;
- int titleBarHeight = appletHolder.getLocationOnScreen().y - frame.getLocationOnScreen().y;
- int frameWidth = width + 2 * frameBorderSize;
- int frameHeight = height + titleBarHeight + frameBorderSize;
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(frameWidth, frameHeight);
- frame.setVisible(true);
- des.init();
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
- }
-
- public void init() {
- initOpenGLAWT();
- }
-
- public void initOpenGLAWT() {
- setBackground(Color.gray);
- setLayout(null);
-
- GLProfile glp = GLProfile.getDefault();
- GLCapabilities caps = new GLCapabilities(glp);
- GLCanvas canvas = new GLCanvas((GLCapabilitiesImmutable) caps);
- canvas.setBounds(50, 50, 200, 450);
- canvas.addGLEventListener(this);
- add(canvas);
- }
-
- public void init(GLAutoDrawable gLAutoDrawable) {
- GL gl = gLAutoDrawable.getGL();
- gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gLAutoDrawable.swapBuffers();
- }
-
- public void dispose(GLAutoDrawable glad) {
- }
-
- public void display(GLAutoDrawable glad) {
- }
-
- public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) {
- }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java
index 9ae0a2bbd..3bbb423fd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java
@@ -28,8 +28,6 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
import java.applet.Applet;
-import java.util.ArrayList;
-import java.util.List;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.awt.GLCanvas;
@@ -48,38 +46,44 @@ import com.jogamp.opengl.util.Animator;
* </p>
*/
@SuppressWarnings("serial")
-public class Bug816AppletGLCanvas02 extends Applet {
- private List<GLAnimatorControl> animators = new ArrayList<GLAnimatorControl>(2);
+public class Bug816AppletGLCanvas02a extends Applet {
+ GLAnimatorControl animator;
+ boolean added = false;
- @Override
- public void init() {
- System.err.println("GearsApplet: init() - begin");
- new BoxLayout(this, BoxLayout.X_AXIS);
- setSize(600, 300);
- add(createCanvas());
- add(createCanvas());
- System.err.println("GearsApplet: init() - end");
- }
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator = new Animator();
+ new BoxLayout(this, BoxLayout.X_AXIS);
+ setSize(664, 364);
+ add(createCanvas());
+ add(createCanvas());
+ System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
- private GLCanvas createCanvas() {
- GLCanvas canvas = new GLCanvas();
- canvas.addGLEventListener(new GearsES2(1));
- canvas.setSize(300, 300);
- animators.add(new Animator(canvas));
- return canvas;
- }
+ private GLCanvas createCanvas() {
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(new GearsES2(1));
+ canvas.setSize(300, 300);
+ animator.add(canvas);
+ return canvas;
+ }
- @Override
- public void start() {
- for (GLAnimatorControl control : animators) {
- control.start();
- }
- }
+ String currentThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ @Override
+ public void start() {
+ System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.start();
+ animator.setUpdateFPSFrames(60, System.err);
+ System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
- @Override
- public void stop() {
- for (GLAnimatorControl control : animators) {
- control.stop();
- }
- }
+ @Override
+ public void stop() {
+ System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.stop();
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java
new file mode 100644
index 000000000..87a7ea4f5
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import java.applet.Applet;
+import java.awt.GridLayout;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.awt.GLCanvas;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug.
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * Test uses a grid layout within the Applet.
+ * </p>
+ */
+@SuppressWarnings("serial")
+public class Bug816AppletGLCanvas02b extends Applet {
+ GLAnimatorControl animator;
+ boolean added = false;
+
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator = new Animator();
+ this.setLayout(new GridLayout(1, 2));
+ setSize(664, 364);
+ add(createCanvas());
+ add(createCanvas());
+ System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ private GLCanvas createCanvas() {
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(new GearsES2(1));
+ canvas.setSize(300, 300);
+ animator.add(canvas);
+ return canvas;
+ }
+
+ String currentThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ @Override
+ public void start() {
+ System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.start();
+ animator.setUpdateFPSFrames(60, System.err);
+ System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ @Override
+ public void stop() {
+ System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.stop();
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java
new file mode 100644
index 000000000..a0ce938fe
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java
@@ -0,0 +1,102 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JRootPane;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug - AWT Applet w/ 1 JRootPane and 2 JSplitPanes
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * See also {@link com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT}
+ * </p>
+ * Bug persists in browser (Firefox, Safari) and not in appletviewer!
+ */
+@SuppressWarnings("serial")
+public class Bug816AppletOSXCALayerPos03a extends Applet {
+ GLAnimatorControl animator;
+ boolean added = false;
+
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ GLProfile glp = GLProfile.getDefault();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ animator = new Animator();
+ animator.add(glCanvas1);
+ setLayout(new BorderLayout());
+
+ // Build a GUI where the canvas 3D is located at top right of the frame
+ // and can be resized with split panes dividers
+ JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ true, new JScrollPane(), glCanvas1);
+ verticalSplitPane.setResizeWeight(0.5);
+ JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ true, new JScrollPane(), verticalSplitPane);
+ horizontalSplitPane.setResizeWeight(0.5);
+ JRootPane intermediateRootPane = new JRootPane();
+ intermediateRootPane.setContentPane(horizontalSplitPane);
+ add(intermediateRootPane, BorderLayout.CENTER);
+ System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ String currentThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ @Override
+ public void start() {
+ System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.start();
+ animator.setUpdateFPSFrames(60, System.err);
+ System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ @Override
+ public void stop() {
+ System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.stop();
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java
new file mode 100644
index 000000000..48dac25e8
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JApplet;
+import javax.swing.JRootPane;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug - Swing JApplet w/ 2 JRootPanes and 2 JSplitPanes
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * See also {@link com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT}
+ * </p>
+ * Bug persists in browser (Firefox, Safari) and not in appletviewer!
+ */
+@SuppressWarnings("serial")
+public class Bug816AppletOSXCALayerPos03b extends JApplet {
+ GLAnimatorControl animator;
+ boolean added = false;
+
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ GLProfile glp = GLProfile.getDefault();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final GLCanvas glCanvas1 = new GLCanvas(caps);
+ glCanvas1.addGLEventListener(new GearsES2(1));
+
+ animator = new Animator();
+ animator.add(glCanvas1);
+ setSize(640, 480);
+
+ // Build a GUI where the canvas 3D is located at top right of the frame
+ // and can be resized with split panes dividers
+ JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ true, new JScrollPane(), glCanvas1);
+ verticalSplitPane.setResizeWeight(0.5);
+ JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ true, new JScrollPane(), verticalSplitPane);
+ horizontalSplitPane.setResizeWeight(0.5);
+ JRootPane intermediateRootPane = new JRootPane();
+ intermediateRootPane.setContentPane(horizontalSplitPane);
+ intermediateRootPane.setSize(640, 480);
+ this.add(intermediateRootPane);
+ System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ String currentThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ @Override
+ public void start() {
+ System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.start();
+ animator.setUpdateFPSFrames(60, System.err);
+ System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ @Override
+ public void stop() {
+ System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ animator.stop();
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java
new file mode 100644
index 000000000..89e31cfe9
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import java.applet.Applet;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.BoxLayout;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 848: Applet on OSX w/ CALayer and 2 or more GLCanvas may 'crash'.
+ * <p>
+ * Test uses 2x3 GLCanvas in a box layout within the Applet.
+ * </p>
+ */
+@SuppressWarnings("serial")
+public class Bug848AppletGLCanvas01 extends Applet {
+ private List<GLAnimatorControl> animators = new ArrayList<GLAnimatorControl>(2);
+
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ new BoxLayout(this, BoxLayout.X_AXIS);
+ setSize(1024, 664);
+ add(createCanvas());
+ add(createCanvas());
+ add(createCanvas());
+ add(createCanvas());
+ add(createCanvas());
+ add(createCanvas());
+ System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ private GLCanvas createCanvas() {
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(new GearsES2(1));
+ canvas.setSize(300, 300);
+ animators.add(new Animator(canvas));
+ return canvas;
+ }
+
+ String currentThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ @Override
+ public void start() {
+ System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ for (GLAnimatorControl control : animators) {
+ control.start();
+ control.setUpdateFPSFrames(60, System.err);
+ }
+ System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ }
+
+ @Override
+ public void stop() {
+ System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName());
+ for (GLAnimatorControl control : animators) {
+ control.stop();
+ }
+ }
+}
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 3fc1eb61d..5d091bb6d 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
@@ -42,8 +42,6 @@ import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
@@ -51,17 +49,14 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-
import com.jogamp.opengl.util.Animator;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.PointImmutable;
import javax.media.nativewindow.util.DimensionImmutable;
-
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLProfile;
@@ -271,50 +266,8 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
}
});
- glWindow.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if( !e.isPrintableKey() || e.isAutoRepeat() ) {
- return;
- }
- if(e.getKeyChar()=='f') {
- quitAdapter.enable(false);
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setFullscreen(!glWindow.isFullscreen());
- System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- quitAdapter.clear();
- quitAdapter.enable(true);
- } }.start();
- } else if(e.getKeyChar()=='r') {
- quitAdapter.enable(false);
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to home");
- glWindow.reparentWindow(newtCanvasAWT.getNativeWindow());
- } else {
- final InsetsImmutable nInsets = glWindow.getInsets();
- java.awt.Insets aInsets = frame.getInsets();
- System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null);
- int dx, dy;
- if(nInsets.getTotalHeight()==0) {
- dx = aInsets.left;
- dy = aInsets.top;
- } else {
- dx = nInsets.getLeftWidth();
- dy = nInsets.getTopHeight();
- }
- glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy);
- }
- glWindow.requestFocus();
- quitAdapter.clear();
- quitAdapter.enable(true);
- }
- }
- });
-
+ glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter));
+
if( useAnimator ) {
animator.add(glWindow);
animator.start();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
index 37172822b..adc2b23ae 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
@@ -36,23 +36,18 @@ import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-
import com.jogamp.opengl.util.Animator;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2;
+import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.DimensionImmutable;
-
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLProfile;
@@ -119,50 +114,8 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase {
}
});
- glWindow.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if( !e.isPrintableKey() || e.isAutoRepeat() ) {
- return;
- }
- if(e.getKeyChar()=='f') {
- quitAdapter.enable(false);
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setFullscreen(!glWindow.isFullscreen());
- System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- quitAdapter.clear();
- quitAdapter.enable(true);
- } }.start();
- } else if(e.getKeyChar()=='r') {
- quitAdapter.enable(false);
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to home");
- glWindow.reparentWindow(newtCanvasAWT.getNativeWindow());
- } else {
- final InsetsImmutable nInsets = glWindow.getInsets();
- java.awt.Insets aInsets = frame.getInsets();
- System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null);
- int dx, dy;
- if(nInsets.getTotalHeight()==0) {
- dx = aInsets.left;
- dy = aInsets.top;
- } else {
- dx = nInsets.getLeftWidth();
- dy = nInsets.getTopHeight();
- }
- glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy);
- }
- glWindow.requestFocus();
- quitAdapter.clear();
- quitAdapter.enable(true);
- }
- }
- });
-
+ glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter));
+
if( useAnimator ) {
animator.add(glWindow);
animator.start();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
index b2f72b7c3..69879ddb2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
@@ -35,7 +35,6 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-import com.jogamp.opengl.test.junit.util.UITestCase.SnapshotGLEventListener;
import com.jogamp.opengl.util.Animator;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
index 74089c2fd..031d6a1c1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
@@ -97,11 +97,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
- System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse);
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
- System.err.println("INIT GL IS: " + gl.getClass().getName());
- System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
-
init(gl);
final Object upstreamWidget = drawable.getUpstreamWidget();
@@ -122,6 +117,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
+ System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse);
+ if(verbose) {
+ System.err.println("GearsES2 init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + gl.getContext().getGLDrawable().getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
gl.glEnable(GL2.GL_CULL_FACE);
gl.glEnable(GL2.GL_LIGHTING);
@@ -171,11 +174,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval);
}
- reshapeImpl(gl, x, y, width, height, width, height);
- }
-
- public void reshape(GL2 gl, int x, int y, int width, int height) {
- reshapeImpl(gl, x, y, width, height, width, height);
+ reshape(gl, x, y, width, height, width, height);
}
@Override
@@ -184,10 +183,10 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
int imageWidth, int imageHeight) {
final GL2 gl = tr.getAttachedDrawable().getGL().getGL2();
gl.setSwapInterval(0);
- reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
+ reshape(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
}
- void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) {
+ public void reshape(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) {
final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java
new file mode 100644
index 000000000..7e3d78b92
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java
@@ -0,0 +1,306 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
+
+import java.awt.Dimension;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.media.opengl.fixedfunc.GLLightingFunc;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+import javax.swing.JApplet;
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+/**
+ * Bug 818: OSX GLJPanel Crash
+ * <pre>
+ * - NVIDIA GeForce GT 330M
+ * - GL_VENDOR: "NVIDIA Corporation"
+ * - GL_RENDERER: "NVIDIA GeForce GT 330M OpenGL Engine"
+ * - GL_VERSION: "2.1 NVIDIA-8.12.47 310.40.00.05f01"
+ * - Mac OSX 10.6.8
+ * </pre>
+ */
+public class Bug818GLJPanelApplet extends JApplet {
+
+ private static final long serialVersionUID = 1L;
+
+ private Animator animatorCanvas;
+
+ private Animator animatorPanel;
+
+ public static JFrame frame;
+ public static JPanel appletHolder;
+ public static boolean isApplet = true;
+
+ static public void main(String args[]) {
+ isApplet = false;
+
+ final JApplet myApplet = new Bug818GLJPanelApplet();
+
+ appletHolder = new JPanel();
+
+ frame = new JFrame("Bug818GLJPanelApplet");
+ frame.getContentPane().add(myApplet);
+
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ myApplet.init();
+ frame.validate();
+ frame.pack();
+ frame.setVisible(true);
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ }
+
+ myApplet.start();
+ }
+
+
+ @Override
+ public void init() {
+
+ final JPanel panel = new JPanel();
+ setContentPane(panel);
+
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new JOGLQuad(true));
+ animatorCanvas = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
+
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.addGLEventListener(new JOGLQuad(false));
+ animatorPanel = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+
+ @Override
+ public void start() {
+
+ animatorCanvas.start();
+ animatorCanvas.setUpdateFPSFrames(60, System.err);
+ animatorPanel.start();
+ animatorPanel.setUpdateFPSFrames(60, System.err);
+ }
+
+ @Override
+ public void stop() {
+
+ animatorCanvas.stop();
+ animatorPanel.stop();
+ }
+
+ @Override
+ public void destroy() {}
+
+ /**
+ * Self-contained example (within a single class only to keep it simple) displaying a rotating quad
+ */
+ static class JOGLQuad implements GLEventListener {
+
+ private static final float[] VERTEX_DATA = {
+ -1.0f, 1.0f, 0.0f, // Top Left
+ 1.0f, 1.0f, 0.0f, // Top Right
+ 1.0f, -1.0f, 0.0f, // Bottom Right
+ -1.0f, -1.0f, 0.0f // Bottom Left
+ };
+
+ private static final float[] TEXCOORD_DATA = {
+ 0.0f, 1.0f, // Top Left
+ 1.0f, 1.0f, // Top Right
+ 1.0f, 0.0f, // Bottom Right
+ 0.0f, 0.0f // Bottom Left
+ };
+
+ private FloatBuffer vertexBuf;
+
+ private FloatBuffer texCoordBuf;
+
+ private int vertexVBO;
+
+ private int texCoordVBO;
+
+ private float rotateT = 0.0f;
+
+ private boolean canvas;
+
+ private Texture texture;
+
+ JOGLQuad(boolean canvas) {
+
+ this.canvas = canvas;
+
+ ByteBuffer bb = ByteBuffer.allocateDirect(VERTEX_DATA.length * 4);
+ bb.order(ByteOrder.nativeOrder());
+ vertexBuf = bb.asFloatBuffer();
+ vertexBuf.put(VERTEX_DATA);
+ vertexBuf.rewind();
+
+ bb = ByteBuffer.allocateDirect(TEXCOORD_DATA.length * 4);
+ bb.order(ByteOrder.nativeOrder());
+ texCoordBuf = bb.asFloatBuffer();
+ texCoordBuf.put(TEXCOORD_DATA);
+ texCoordBuf.rewind();
+ }
+
+ @Override
+ public void init(GLAutoDrawable glDrawable) {
+
+ final GL2 gl = glDrawable.getGL().getGL2();
+
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapabilitiesAndExtensionInfo */).toString());
+
+ gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glClearDepth(1.0f);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LEQUAL);
+ gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
+
+ int[] tmp = new int[2];
+ gl.glGenBuffers(tmp.length, tmp, 0);
+ vertexVBO = tmp[0];
+ texCoordVBO = tmp[1];
+
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, vertexVBO);
+ gl.glBufferData(GL2.GL_ARRAY_BUFFER, VERTEX_DATA.length * 4, vertexBuf, GL2.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, texCoordVBO);
+ gl.glBufferData(GL2.GL_ARRAY_BUFFER, TEXCOORD_DATA.length * 4, texCoordBuf, GL2.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
+
+ try {
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN_3-01-160x90-90pct-yuv444-base.jpg");
+ texture = TextureIO.newTexture(stream, true, TextureIO.JPG);
+ } catch (Exception exc) {
+ exc.printStackTrace(System.err);
+ }
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
+
+ final GL2 gl = drawable.getGL().getGL2();
+ int[] tmp = new int[] {vertexVBO, texCoordVBO};
+ gl.glGenBuffers(tmp.length, tmp, 0);
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) {
+
+ final GL2 gl = gLDrawable.getGL().getGL2();
+ final float aspect = (float) width / (float) height;
+ gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ gl.glLoadIdentity();
+ final float fh = 0.5f;
+ final float fw = fh * aspect;
+ gl.glFrustumf(-fw, fw, -fh, fh, 1.0f, 1000.0f);
+ gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ @Override
+ public void display(GLAutoDrawable gLDrawable) {
+
+ final GL2 gl = gLDrawable.getGL().getGL2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+
+ // rotate about the three axes
+ gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);
+
+ // set the color of the quad
+ if (canvas) {
+ gl.glColor3f(0.2f, 1.0f, 1.0f);
+ } else {
+ gl.glColor3f(1.0f, 0.2f, 0.2f);
+ }
+
+ if (texture != null) {
+ texture.bind(gl);
+ texture.enable(gl);
+ } else {
+ System.err.println("no texture");
+ }
+
+ // Draw A Quad
+ gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
+ gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, vertexVBO);
+ gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, texCoordVBO);
+ gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, 0);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
+ gl.glDrawArrays(GL2.GL_QUADS, 0, 4);
+ gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
+ gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
+
+ if (texture != null) {
+ texture.disable(gl);
+ }
+
+ // increasing rotation for the next iteration
+ rotateT += 0.2f;
+ }
+
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java
index c38140ce0..e0fabc3cc 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java
@@ -46,7 +46,6 @@ import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -67,11 +66,6 @@ import org.junit.runners.MethodSorters;
public class TestTiledRendering1GL2NEWT extends UITestCase {
static long duration = 500; // ms
- @Test
- public void test01() throws IOException {
- doTest();
- }
-
static class DrawableContext {
DrawableContext(GLDrawable d, GLContext glc) {
this.d = d;
@@ -102,7 +96,8 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
}
}
- void doTest() throws GLException, IOException {
+ @Test
+ public void test01() throws IOException {
GLProfile glp = GLProfile.getMaxFixedFunc(true);
GLCapabilities caps = new GLCapabilities(glp);
caps.setOnscreen(false);
@@ -132,15 +127,19 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
flipVertically[0] = false;
final Gears gears = new Gears();
+ gears.setVerbose(false);
gears.init(gl);
gears.addTileRendererNotify(renderer);
- do {
- renderer.beginTile(dc.glc.getGL().getGL2ES3());
- gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT));
+ while( !renderer.eot() ) {
+ renderer.beginTile(gl);
+ gears.reshape(gl,
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS),
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT),
+ renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT));
gears.display(gl);
- renderer.endTile(dc.glc.getGL().getGL2ES3());
- } while ( !renderer.eot() );
+ renderer.endTile(gl);
+ }
gears.removeTileRendererNotify(renderer);
destroyDrawableContext(dc);
@@ -160,6 +159,76 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
TextureIO.write(textureData, file);
}
+ @Test
+ public void test02_EOT_01() throws IOException {
+ GLProfile glp = GLProfile.getMaxFixedFunc(true);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+
+ final int maxTileSize = 256;
+ DrawableContext dc = createDrawableAndCurrentCtx(caps, maxTileSize, maxTileSize);
+ final GL2 gl = dc.glc.getGL().getGL2();
+
+ // Fix the image size for now
+ final int imageWidth = dc.d.getWidth() * 6;
+ final int imageHeight = dc.d.getHeight() * 4;
+
+ // Initialize the tile rendering library
+ final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer();
+ renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0);
+
+ IllegalStateException ise = null;
+ try {
+ renderer.beginTile(gl); // Image size has not been set
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: Image-size exception missing", ise);
+
+ renderer.setImageSize(imageWidth, imageHeight);
+
+ renderer.clipImageSize(0, 0);
+ try {
+ renderer.beginTile(gl); // EOT reached (1)
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: EOT (1) exception missing", ise);
+
+ renderer.clipImageSize(imageWidth, imageHeight); // back to full size
+
+ final Gears gears = new Gears();
+ gears.setVerbose(false);
+ gears.init(gl);
+
+ gears.addTileRendererNotify(renderer);
+ int numTiles = 0;
+ while( !renderer.eot() ) {
+ renderer.beginTile(gl);
+ gears.reshape(gl,
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS),
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT),
+ renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT));
+ gears.display(gl);
+ renderer.endTile(gl);
+ numTiles++;
+ }
+ try {
+ renderer.beginTile(gl); // EOT reached (2)
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: EOT (2) exception missing", ise);
+ gears.removeTileRendererNotify(renderer);
+
+ Assert.assertTrue("TileRenderer not rendered more than one tile but "+numTiles, numTiles > 1);
+
+ destroyDrawableContext(dc);
+ }
+
public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
index f0819a43d..74909dc8c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
@@ -215,9 +215,9 @@ public class TestTiledRendering2NEWT extends UITestCase {
};
renderer.setGLEventListener(preTileGLEL, null);
- do {
+ while ( !renderer.eot() ) {
renderer.display();
- } while ( !renderer.eot() );
+ }
renderer.detachAutoDrawable();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
index a3ea9ad3e..b007f57f3 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
@@ -208,7 +208,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
final EDTUtil edtUtil = display.getEDTUtil();
Assert.assertNotNull(edtUtil);
Assert.assertEquals(false,edtUtil.isRunning());
- edtUtil.restart();
+ edtUtil.start();
edtUtil.invoke(true, null);
Assert.assertEquals(true,edtUtil.isRunning());
edtUtil.invokeStop(true, null);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 9d08d8ff4..4bf1f95c3 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -35,33 +35,58 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
public class NewtAWTReparentingKeyAdapter extends KeyAdapter {
- Frame frame;
- NewtCanvasAWT newtCanvasAWT;
- GLWindow glWindow;
+ final Frame frame;
+ final NewtCanvasAWT newtCanvasAWT;
+ final GLWindow glWindow;
+ final QuitAdapter quitAdapter;
- public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow) {
+ public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) {
this.frame = frame;
this.newtCanvasAWT = newtCanvasAWT;
this.glWindow = glWindow;
+ this.quitAdapter = quitAdapter;
}
public void keyReleased(KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
return;
}
- if(e.getKeyChar()=='i') {
+ if( e.getKeySymbol() == KeyEvent.VK_I ) {
System.err.println(glWindow);
- } else if(e.getKeyChar()=='d') {
- glWindow.setUndecorated(!glWindow.isUndecorated());
- } else if(e.getKeyChar()=='f') {
- glWindow.setFullscreen(!glWindow.isFullscreen());
- } else if(e.getKeyChar()=='l') {
+ } else if( e.getKeySymbol() == KeyEvent.VK_L ) {
javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null);
javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
System.err.println("NewtCanvasAWT position: "+p0+", "+p1);
- } else if(e.getKeyChar()=='p') {
+ } else if( e.getKeySymbol() == KeyEvent.VK_D ) {
+ glWindow.setUndecorated(!glWindow.isUndecorated());
+ } else if( e.getKeySymbol() == KeyEvent.VK_S ) {
+ if(glWindow.getParent()==null) {
+ System.err.println("XXX glWin to 100/100");
+ glWindow.setPosition(100, 100);
+ } else {
+ System.err.println("XXX glWin to 0/0");
+ glWindow.setPosition(0, 0);
+ }
+ } else if( e.getKeySymbol() == KeyEvent.VK_F ) {
+ if( null != quitAdapter ) {
+ quitAdapter.enable(false);
+ }
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setExclusiveContextThread(t);
+ if( null != quitAdapter ) {
+ quitAdapter.clear();
+ quitAdapter.enable(true);
+ }
+ } }.start();
+ } else if( e.getKeySymbol() == KeyEvent.VK_P ) {
new Thread() {
public void run() {
if(glWindow.getAnimator().isPaused()) {
@@ -71,34 +96,44 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter {
}
}
}.run();
- } else if(e.getKeyChar()=='r') {
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to home");
- glWindow.reparentWindow(newtCanvasAWT.getNativeWindow());
- } else {
- final InsetsImmutable nInsets = glWindow.getInsets();
- java.awt.Insets aInsets = frame.getInsets();
- System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null);
- int dx, dy;
- if(nInsets.getTotalHeight()==0) {
- dx = aInsets.left;
- dy = aInsets.top;
- } else {
- dx = nInsets.getLeftWidth();
- dy = nInsets.getTopHeight();
- }
- glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy);
- }
- glWindow.requestFocus();
- } else if(e.getKeyChar()=='s') {
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to 100/100");
- glWindow.setPosition(100, 100);
- } else {
- System.err.println("XXX glWin to 0/0");
- glWindow.setPosition(0, 0);
+ } else if( e.getKeySymbol() == KeyEvent.VK_R ) {
+ if( null != quitAdapter ) {
+ quitAdapter.enable(false);
}
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ if(glWindow.getParent()==null) {
+ System.err.println("XXX glWin to HOME");
+ glWindow.reparentWindow(newtCanvasAWT.getNativeWindow());
+ } else {
+ if( null != frame ) {
+ final InsetsImmutable nInsets = glWindow.getInsets();
+ final java.awt.Insets aInsets = frame.getInsets();
+ int dx, dy;
+ if( nInsets.getTotalHeight()==0 ) {
+ dx = aInsets.left;
+ dy = aInsets.top;
+ } else {
+ dx = nInsets.getLeftWidth();
+ dy = nInsets.getTopHeight();
+ }
+ final int topLevelX = frame.getX()+frame.getWidth()+dx;
+ final int topLevelY = frame.getY()+dy;
+ System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets);
+ glWindow.reparentWindow(null, topLevelX, topLevelY, false);
+ } else {
+ System.err.println("XXX glWin to TOP.0");
+ glWindow.reparentWindow(null);
+ }
+ }
+ glWindow.requestFocus();
+ glWindow.setExclusiveContextThread(t);
+ if( null != quitAdapter ) {
+ quitAdapter.clear();
+ quitAdapter.enable(true);
+ }
+ } }.start();
}
}
} \ No newline at end of file
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
index 41a6b77fa..1f19241d8 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -379,7 +379,7 @@ public class TestParenting01NEWT extends UITestCase {
// glWindow2 -- child --> glWindow1: compatible
Assert.assertEquals(true, glWindow2.isVisible());
System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames());
- reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate);
+ reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate);
System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames());
Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction);
Assert.assertEquals(true, glWindow2.isVisible());
@@ -405,7 +405,7 @@ public class TestParenting01NEWT extends UITestCase {
// glWindow2 --> top
Assert.assertEquals(true, glWindow2.isVisible());
- reparentAction = glWindow2.reparentWindow(null, reparentRecreate);
+ reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate);
Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction);
Assert.assertEquals(true, glWindow2.isVisible());
Assert.assertEquals(true, glWindow2.isNativeValid());
@@ -567,7 +567,7 @@ public class TestParenting01NEWT extends UITestCase {
switch(state) {
case 0:
Assert.assertEquals(true, glWindow2.isVisible());
- reparentAction = glWindow2.reparentWindow(null, reparentRecreate);
+ reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate);
Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction);
Assert.assertEquals(true, glWindow2.isVisible());
Assert.assertEquals(true, glWindow2.isNativeValid());
@@ -582,7 +582,7 @@ public class TestParenting01NEWT extends UITestCase {
break;
case 1:
Assert.assertEquals(true, glWindow2.isVisible());
- reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate);
+ reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate);
Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction);
Assert.assertEquals(true, glWindow2.isVisible());
Assert.assertEquals(true, glWindow2.isNativeValid());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
index 60c2b702c..30ee0f129 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
@@ -88,7 +88,7 @@ public class TestParenting03AWT extends UITestCase {
GLEventListener demo1 = new GearsES2(1);
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
- glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+ glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null));
GLAnimatorControl animator1 = new Animator(glWindow1);
animator1.start();
@@ -104,7 +104,7 @@ public class TestParenting03AWT extends UITestCase {
GLEventListener demo2 = new GearsES2(1);
setDemoFields(demo2, glWindow2, false);
glWindow2.addGLEventListener(demo2);
- glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2));
+ glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2, null));
animator2 = new Animator(glWindow2);
animator2.start();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
index 58dafba15..ff540408a 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
@@ -147,7 +147,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
GLEventListener demo1 = new GearsES2(1);
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
- glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+ glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null));
glWindow1.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
@@ -249,7 +249,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
Assert.assertEquals(true, glWindow1FA.focusLost());
Thread.sleep(durationPerTest/numFocus);
- // direct AWT request focus
+ System.err.println("Test: Direct NewtCanvasAWT focus");
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
@@ -262,7 +262,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
Assert.assertEquals(true, bWestFA.focusLost());
Thread.sleep(durationPerTest/numFocus);
- // direct AWT request focus
+ System.err.println("Test: Direct AWT Button-West focus");
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
@@ -275,7 +275,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
Assert.assertEquals(true, glWindow1FA.focusLost());
Thread.sleep(durationPerTest/numFocus);
- // direct NEWT request focus
+ System.err.println("Test: Direct NEWT-Child request focus");
glWindow1.requestFocus();
Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA));
Assert.assertEquals(true, glWindow1FA.focusGained());