From 51ad6992e068f25d86d2c9e085bd7ec6f49d2432 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 10 Nov 2011 04:45:25 +0100 Subject: NEWT/WindowImpl: Generalize recreation @ setSize() for offscreen surface In case of offscreen surfaces (pbuffer, ..) we have to go through a whole destroy/setSize/create cycle. --- src/newt/classes/jogamp/newt/WindowImpl.java | 107 ++++++++++++++------------- 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'src/newt') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 1ce02c8e4..2d32414fc 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -691,6 +691,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return screen; } + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); + } final void setVisibleActionImpl(boolean visible) { boolean nativeWindowCreated = false; boolean madeVisible = false; @@ -749,8 +752,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( nativeWindowCreated || madeVisible ) { sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } - } - + } private class VisibleAction implements Runnable { boolean visible; @@ -761,8 +763,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final void run() { setVisibleActionImpl(visible); } - } - + } public void setVisible(boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); @@ -771,64 +772,64 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(true, new VisibleAction(visible)); } - protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); + final void setSizeActionImpl(int width, int height) { + windowLock.lock(); + screen.addReference(); // recreate case + try { + int visibleAction = 0; // 1 invisible, 2 visible (create) + if ( !fullscreen && ( width != WindowImpl.this.width || WindowImpl.this.height != height ) ) { + final boolean recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate); + } + if(recreate) { + // will trigger visibleAction:=2 -> create if wasVisible + final boolean wasVisible = WindowImpl.this.visible; + destroyAction.run(); + WindowImpl.this.visible = wasVisible; + } + if ( isNativeValid() && 0>=width*height && visible ) { + visibleAction=1; // invisible + WindowImpl.this.width = 0; + WindowImpl.this.height = 0; + } else if ( !isNativeValid() && 0 "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible; - System.err.println(msg); - } - if ( isNativeValid() && 0>=width*height && visible ) { - visibleAction=1; // invisible - WindowImpl.this.width = 0; - WindowImpl.this.height = 0; - } else if ( !isNativeValid() && 0