aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2011-11-09 07:42:20 +0100
committerSven Gothel <sgothel@jausoft.com>2011-11-09 07:42:20 +0100
commit46542168d64b37f544f61802693f15b59b224e4e (patch)
tree292a62903a27ef00cef92faca19d323f914bce28 /src/newt/classes/jogamp
parentf51e3dad6c4bd1f6d0001cecf6a0f692400ed602 (diff)
OS X Layered View: Part5 NEWT/AWT Interaction ; Fix NSOpenGLLayer pos ; Cleanup
Better JAWT* name for offscreen layer surface: - MacOSXCGLDrawableFactory, JAWTUtil, JAWTWindow, MacOSXJAWTWindow - FIXME: Need to get rid of the cached JAWT instance, in case we like to have dual usage of offscreenLayerSurface and onscreen. This would be done implicit by using NEWT .. hence low prio. AWTGraphicsConfiguration: - Fix create(): Use capsRequested for AWT aligned caps if capsChosen is null. (was capsChosen .. which is null) - Add updateGraphicsConfiguration() which allows to update the AWTGraphicsConfiguration. NewtFactoryAWT: - Add updateGraphicsConfiguration() .. entrypoint for AWTGraphicsConfiguration.updateGraphicsConfiguration() NSOpenGLLayer Impl: - For 'some reason' the layer's position is initially negative, fix it @ 1st 'draw' - Re-add CVDisplayLink OpenGL setting .. for what it's worth .. I don't know JAWTWindow: - Remove test setting: Only enable offscreenLayerSurface for applets if avail. (New unit test enables it seperatly) NewtCanvasAWT: - If NEWT child is offscreen, attach AWTMouseAdapter and AWTKeyAdapter to route these AWT input events to NEWT. - Don't loose-focus if NEWT child is offscreen. - Impl. NativeSurfaceHolder, NativeWindowHolder - NativeWindow is created at construction and it's GraphicsConfiguration updated at addNotify(..). - At addNotify/reparent: try harder to determine proper NEWT child size: - use preferred size if set - use minimum size if set - subtract insets from container size OffscreenWindow/WindowImpl: - Allow setSize() .. currently NOP for offscreen. - WindowImpl: Commented out recreate case for offscreen-setSize .. TEST: com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT Passed tests: - GLCanvas - NewtCanvasAWT/OffscreenWindow
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/OffscreenWindow.java7
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java49
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java16
3 files changed, 52 insertions, 20 deletions
diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java
index a7a930691..d6402c6bb 100644
--- a/src/newt/classes/jogamp/newt/OffscreenWindow.java
+++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java
@@ -86,13 +86,6 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
}
@Override
- public void setSize(int width, int height) {
- if(!isNativeValid()) {
- super.setSize(width, height);
- }
- }
-
- @Override
public void setPosition(int x, int y) {
// nop
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 919c32f13..823868f2b 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -308,6 +308,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return isNativeValid() ;
}
+ private void recreate(boolean skipCreate) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Window.recreate() START ("+getThreadName()+", "+this+")");
+ }
+ if(!isNativeValid()) {
+ throw new InternalError("XXX");
+ }
+ ScreenImpl retainedScreen = screen;
+ retainedScreen.addReference(); // +1 - retain over destroy
+ destroy();
+ setScreen(retainedScreen);
+ retainedScreen.removeReference(); // -1 - release
+ if(!skipCreate) {
+ setVisible(true); // native creation
+ }
+ }
+
+ private void setScreen(ScreenImpl newScreen) { // never null !
+ removeScreenReference();
+ screen = newScreen;
+ screen.addReference();
+ screenReferenceAdded = false;
+ }
+
private void removeScreenReference() {
if(screenReferenceAdded) {
// be nice, probably already called recursive via
@@ -821,6 +845,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void setSize(int width, int height) {
+ /** FIXME: freezes due to many resize events by eg AWT
+ if( isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen() ) {
+ recreate(true); // skip create, create is done here ..
+ }
+ */
runOnEDTIfAvail(true, new SetSizeActionImpl(width, height));
}
@@ -927,7 +956,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private ReparentActionImpl(NativeWindow newParentWindow, boolean forceDestroyCreate) {
this.newParentWindow = newParentWindow;
- this.forceDestroyCreate = forceDestroyCreate;
+ this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE;
this.reparentAction = -1; // ensure it's set
}
@@ -935,13 +964,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return reparentAction;
}
- private void setScreen(ScreenImpl newScreen) { // never null !
- WindowImpl.this.removeScreenReference();
- screen = newScreen;
- screen.addReference();
- screenReferenceAdded = false;
- }
-
public final void run() {
boolean animatorPaused = false;
if(null!=lifecycleHook) {
@@ -973,7 +995,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
long newParentWindowHandle = 0 ;
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.reparent: START ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", DEBUG_TEST_REPARENT_INCOMPATIBLE "+DEBUG_TEST_REPARENT_INCOMPATIBLE+" "+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+", "+x+"/"+y+" "+width+"x"+height);
}
if(null!=lifecycleHook) {
@@ -1024,8 +1046,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
} else {
reparentAction = ACTION_NATIVE_CREATION_PENDING;
}
- } else if ( DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ||
- !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) {
+ } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) {
// Destroy this window, may create a new compatible Screen/Display,
// and mark it for creation.
destroy();
@@ -1056,7 +1077,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if( 0 == parentWindowHandle ) {
// Already Top Window
reparentAction = ACTION_UNCHANGED;
- } else if( !isNativeValid() || DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) {
+ } else if( !isNativeValid() || forceDestroyCreate ) {
// Destroy this window and mark it for [pending] creation.
destroy();
if( 0<width*height ) {
@@ -1219,6 +1240,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public int reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) {
+ if(isNativeValid()) {
+ // force recreation if offscreen, since it may become onscreen
+ forceDestroyCreate |= !getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+ }
ReparentActionImpl reparentAction = new ReparentActionImpl(newParent, forceDestroyCreate);
runOnEDTIfAvail(true, reparentAction);
return reparentAction.getStrategy();
diff --git a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
index aa98d3a37..1d11887fb 100644
--- a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
+++ b/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
@@ -34,6 +34,8 @@ import javax.media.nativewindow.*;
import javax.media.nativewindow.awt.*;
import com.jogamp.newt.NewtFactory;
+
+import jogamp.nativewindow.jawt.JAWTWindow;
import jogamp.newt.Debug;
public class NewtFactoryAWT extends NewtFactory {
@@ -62,12 +64,24 @@ public class NewtFactoryAWT extends NewtFactory {
}
public static NativeWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) {
- DefaultGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, capsRequested, capsRequested);
+ AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested);
NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
if(DEBUG_IMPLEMENTATION) {
System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+awtNative);
}
return awtNative;
}
+
+ public static void updateGraphicsConfiguration(NativeWindow nw, java.awt.Component awtComp) {
+ if(! ( nw instanceof JAWTWindow ) ) {
+ throw new NativeWindowException("Not an AWT NativeWindow: "+nw);
+ }
+ final AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) nw.getGraphicsConfiguration();
+ awtConfig.updateGraphicsConfiguration(awtComp);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: "+awtComp+" -> "+nw);
+ }
+ }
+
}