diff options
author | Sven Gothel <[email protected]> | 2010-05-27 14:25:37 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-05-27 14:25:37 +0200 |
commit | 944bef5e70e0e8fe85a147fa7304c35f18d1957b (patch) | |
tree | 3279a9cae1258bf102716bf6d4f49883bd14f67f | |
parent | 6e599a2696f878786783e0fea17534e67655a5c9 (diff) |
Fix NativeWindow JAWT Code Generation and Bounds Access
- Restructure: JAWT gluegen, use common jawt-common.cfg
- Fix: Use proper capacity for GetDrawingSurface and GetDrawingSurfaceInfo
- Fix: JAWTWindow maintains AWT bounds
- Fix: JAWTWindow locking/unlocking decoupled with abstract implementation,
which allows clear code and simpler unlock code.
-rw-r--r-- | make/build-nativewindow.xml | 4 | ||||
-rw-r--r-- | make/config/nativewindow/jawt-common.cfg | 26 | ||||
-rw-r--r-- | make/config/nativewindow/jawt-macosx.cfg | 18 | ||||
-rw-r--r-- | make/config/nativewindow/jawt-win32.cfg | 17 | ||||
-rw-r--r-- | make/config/nativewindow/jawt-x11.cfg | 17 | ||||
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java | 26 | ||||
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java | 56 | ||||
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java | 59 | ||||
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java | 57 | ||||
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java | 59 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java (renamed from src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java) | 0 |
11 files changed, 177 insertions, 162 deletions
diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index b087a5ba7..861dc00c5 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -73,7 +73,7 @@ <!-- partitioning --> <property name="java.part.core" - value="javax/media/nativewindow/*, javax/media/nativewindow/egl/*, javax/media/nativewindow/macosx/*, javax/media/nativewindow/windows/*, com/jogamp/nativewindow/impl/*, com/jogamp/nativewindow/impl/jvm/*"/> + value="javax/media/nativewindow/*, javax/media/nativewindow/egl/*, javax/media/nativewindow/macosx/*, javax/media/nativewindow/windows/*, com/jogamp/nativewindow/util/*, com/jogamp/nativewindow/impl/*, com/jogamp/nativewindow/impl/jvm/*"/> <property name="java.part.awt" value="javax/media/nativewindow/awt/*, com/jogamp/nativewindow/impl/jawt/**, com/jogamp/nativewindow/impl/**/awt/**"/> @@ -155,7 +155,7 @@ <property name="javadoc.packagenames" value="${javadoc.spec.packagenames}" /> - <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},com.jogamp.nativewindow.impl.*,com.sun.gluegen,com.jogamp.gluegen.runtime" /> + <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},com.jogamp.nativewindow.util.*,com.jogamp.nativewindow.impl.*,com.sun.gluegen,com.jogamp.gluegen.runtime" /> <property name="javadoc.bottom" value="Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="http://jcp.org/en/jsr/detail?id=231">license terms</a>." /> </target> diff --git a/make/config/nativewindow/jawt-common.cfg b/make/config/nativewindow/jawt-common.cfg new file mode 100644 index 000000000..4ed0a88f1 --- /dev/null +++ b/make/config/nativewindow/jawt-common.cfg @@ -0,0 +1,26 @@ +# Common JAWT config file +Style AllStatic +Package com.jogamp.nativewindow.impl.jawt +JavaClass JAWTFactory +JavaOutputDir gensrc/classes +#NativeOutputDir gensrc/native/<PLATFORM> + +HierarchicalNativeOutput false + +Opaque boolean jboolean +Opaque long struct jawt_DrawingSurface* + +ReturnValueCapacity GetDrawingSurface sizeof(JAWT_DrawingSurface) +ReturnValueCapacity GetDrawingSurfaceInfo sizeof(JAWT_DrawingSurfaceInfo) + +IgnoreField JAWT GetComponent +IgnoreField JAWT_DrawingSurfaceInfo platformInfo + +IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java + +CustomCCode #include <jawt.h> + +import java.security.* +import com.jogamp.nativewindow.impl.jawt.* + +IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg index dea1a27b7..e018af0dc 100644 --- a/make/config/nativewindow/jawt-macosx.cfg +++ b/make/config/nativewindow/jawt-macosx.cfg @@ -1,30 +1,14 @@ # This .cfg file is used to generate the interface to the JAWT, which # is used by the MacOSXOnscreenGLContext. -Style AllStatic -Package com.jogamp.nativewindow.impl.jawt -JavaClass JAWTFactory -JavaOutputDir gensrc/classes +Include jawt-common.cfg NativeOutputDir gensrc/native/MacOSX -HierarchicalNativeOutput false - -Opaque boolean jboolean Opaque long void * Opaque long NSView * -IgnoreField JAWT GetComponent -IgnoreField JAWT_DrawingSurfaceInfo platformInfo - -IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java - CustomCCode #include <inttypes.h> -CustomCCode #include <jawt.h> CustomCCode #include </usr/include/machine/types.h> -import java.security.* -import com.jogamp.nativewindow.impl.jawt.* StructPackage JAWT_MacOSXDrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.macosx EmitStruct JAWT_MacOSXDrawingSurfaceInfo Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo - -IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java diff --git a/make/config/nativewindow/jawt-win32.cfg b/make/config/nativewindow/jawt-win32.cfg index af0c7ce29..00b3a3322 100644 --- a/make/config/nativewindow/jawt-win32.cfg +++ b/make/config/nativewindow/jawt-win32.cfg @@ -1,30 +1,15 @@ # This .cfg file is used to generate the interface to the JAWT, which # is used by the WindowsOnscreenGLContext. -Style AllStatic -Package com.jogamp.nativewindow.impl.jawt -JavaClass JAWTFactory -JavaOutputDir gensrc/classes +Include jawt-common.cfg NativeOutputDir gensrc/native/Windows -HierarchicalNativeOutput false - -Opaque boolean jboolean Opaque long HDC -IgnoreField JAWT GetComponent -IgnoreField JAWT_DrawingSurfaceInfo platformInfo IgnoreField JAWT_Win32DrawingSurfaceInfo null IgnoreField JAWT_Win32DrawingSurfaceInfo hpalette -IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java - -CustomCCode #include <jawt.h> Include ../intptr.cfg -import java.security.* -import com.jogamp.nativewindow.impl.jawt.* StructPackage JAWT_Win32DrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.windows EmitStruct JAWT_Win32DrawingSurfaceInfo Implements JAWT_Win32DrawingSurfaceInfo JAWT_PlatformInfo - -IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java diff --git a/make/config/nativewindow/jawt-x11.cfg b/make/config/nativewindow/jawt-x11.cfg index ccfe009dd..4e7ed267b 100644 --- a/make/config/nativewindow/jawt-x11.cfg +++ b/make/config/nativewindow/jawt-x11.cfg @@ -1,30 +1,15 @@ # This .cfg file is used to generate the interface to the JAWT, which # is used by the X11OnscreenGLContext. -Style AllStatic -Package com.jogamp.nativewindow.impl.jawt -JavaClass JAWTFactory -JavaOutputDir gensrc/classes +Include jawt-common.cfg NativeOutputDir gensrc/native/X11 -HierarchicalNativeOutput false - -Opaque boolean jboolean Opaque long Drawable Opaque long Display * -IgnoreField JAWT GetComponent -IgnoreField JAWT_DrawingSurfaceInfo platformInfo IgnoreField JAWT_X11DrawingSurfaceInfo GetAWTColor -IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java - CustomCCode #include <inttypes.h> -CustomCCode #include <jawt.h> -import java.security.* -import com.jogamp.nativewindow.impl.jawt.* StructPackage JAWT_X11DrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.x11 EmitStruct JAWT_X11DrawingSurfaceInfo Implements JAWT_X11DrawingSurfaceInfo JAWT_PlatformInfo - -IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java index d0529878f..68e61cd85 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java @@ -37,6 +37,7 @@ package com.jogamp.nativewindow.impl.jawt; import com.jogamp.nativewindow.impl.*; +import com.jogamp.nativewindow.util.Rectangle; import java.awt.Component; import java.awt.Window; @@ -60,6 +61,7 @@ public abstract class JAWTWindow implements NativeWindow { // lifetime: valid after lock, forever until invalidate protected long drawable; + protected Rectangle bounds; public JAWTWindow(Object comp, AbstractGraphicsConfiguration config) { if (config == null) { @@ -80,6 +82,7 @@ public abstract class JAWTWindow implements NativeWindow { public synchronized void invalidate() { component = null; drawable= 0; + bounds = new Rectangle(); } public synchronized void destroy() { @@ -91,9 +94,18 @@ public abstract class JAWTWindow implements NativeWindow { invalidate(); } + protected void updateBounds(JAWT_Rectangle jawtBounds) { + bounds.setX(jawtBounds.getX()); + bounds.setY(jawtBounds.getY()); + bounds.setWidth(jawtBounds.getWidth()); + bounds.setHeight(jawtBounds.getHeight()); + } + private volatile Exception lockedStack = null; - public synchronized int lockSurface() throws NativeWindowException { + protected abstract int lockSurfaceImpl() throws NativeWindowException; + + public final synchronized int lockSurface() throws NativeWindowException { // We have to be the owner of the JAWT ToolkitLock 'lock' to benefit from it's // recursive and blocking lock capabitlites. // Otherwise a followup ToolkitLock would deadlock, @@ -107,15 +119,18 @@ public abstract class JAWTWindow implements NativeWindow { } lockedStack = new Exception("JAWT Surface previously locked by "+Thread.currentThread().getName()); - return LOCK_SUCCESS; + return lockSurfaceImpl(); } + protected abstract void unlockSurfaceImpl() throws NativeWindowException; + public synchronized void unlockSurface() { if (null!=lockedStack) { lockedStack = null; } else { throw new NativeWindowException("JAWT Surface not locked"); } + unlockSurfaceImpl(); NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } @@ -165,12 +180,16 @@ public abstract class JAWTWindow implements NativeWindow { return component.getHeight(); } + /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ + public Rectangle getBounds() { return bounds; } + public String toString() { StringBuffer sb = new StringBuffer(); sb.append("JAWT-Window["+ "windowHandle 0x"+Long.toHexString(getWindowHandle())+ - ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())); + ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ + ", bounds "+bounds); if(null!=component) { sb.append(", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); @@ -183,4 +202,5 @@ public abstract class JAWTWindow implements NativeWindow { return sb.toString(); } + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java index 967d43d60..ed932ff91 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java @@ -57,20 +57,18 @@ public class MacOSXJAWTWindow extends JAWTWindow { protected void initNative() throws NativeWindowException { } - public int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(NativeWindow.LOCK_SUCCESS != ret) { - return ret; - } + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -92,56 +90,44 @@ public class MacOSXJAWTWindow extends JAWTWindow { dsi = ds.GetDrawingSurfaceInfo(); } if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } firstLock = false; macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo(); if (macosxdsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } drawable = macosxdsi.getCocoaViewRef(); if (drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - macosxdsi = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } return ret; } - public void unlockSurface() throws NativeWindowException { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); + protected void unlockSurfaceImpl() throws NativeWindowException { + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; macosxdsi = null; - super.unlockSurface(); } // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java index 7d680dfa0..c3b3682fd 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java @@ -61,12 +61,8 @@ public class WindowsJAWTWindow extends JAWTWindow { windowHandle = 0; } - public int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(LOCK_SUCCESS != ret) { - return ret; - } - + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; long startTime; if (PROFILING) { startTime = System.currentTimeMillis(); @@ -74,12 +70,13 @@ public class WindowsJAWTWindow extends JAWTWindow { ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -92,36 +89,21 @@ public class WindowsJAWTWindow extends JAWTWindow { } dsi = ds.GetDrawingSurfaceInfo(); if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo(); if (win32dsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } windowHandle = win32dsi.getHandle(); drawable = win32dsi.getHdc(); if (windowHandle == 0 || drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - win32dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } if (PROFILING) { long endTime = System.currentTimeMillis(); @@ -136,21 +118,23 @@ public class WindowsJAWTWindow extends JAWTWindow { return ret; } - public void unlockSurface() { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); - } + protected void unlockSurfaceImpl() throws NativeWindowException { long startTime = 0; if (PROFILING) { startTime = System.currentTimeMillis(); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); + } ds = null; dsi = null; win32dsi = null; - super.unlockSurface(); if (PROFILING) { long endTime = System.currentTimeMillis(); profilingUnlockSurfaceTime += (endTime - startTime); @@ -169,6 +153,7 @@ public class WindowsJAWTWindow extends JAWTWindow { // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_Win32DrawingSurfaceInfo win32dsi; private long profilingLockSurfaceTime = 0; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java index 77bf93204..f7151d9f1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java @@ -69,20 +69,18 @@ public class X11JAWTWindow extends JAWTWindow { } } - public synchronized int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(LOCK_SUCCESS != ret) { - return ret; - } + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -95,55 +93,42 @@ public class X11JAWTWindow extends JAWTWindow { } dsi = ds.GetDrawingSurfaceInfo(); if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo(); if (x11dsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } drawable = x11dsi.getDrawable(); if (drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - x11dsi = null; - drawable = 0; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } return ret; } - public synchronized void unlockSurface() { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); + protected void unlockSurfaceImpl() throws NativeWindowException { + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; x11dsi = null; - super.unlockSurface(); } // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_X11DrawingSurfaceInfo x11dsi; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java new file mode 100644 index 000000000..9f487f847 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2010, Sven Gothel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Sven Gothel nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 Sven Gothel 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. + */ + +package com.jogamp.nativewindow.util; + +public class Rectangle { + int x; + int y; + int width; + int height; + + public Rectangle() { + this(0, 0, 0, 0); + } + + public Rectangle(int x, int y, int width, int height) { + this.x=x; + this.y=y; + this.width=width; + this.height=height; + } + public int getX() { return x; } + public int getY() { return y; } + public int getWidth() { return width; } + public int getHeight() { return height; } + public void setX(int x) { this.x = x; } + public void setY(int y) { this.y = y; } + public void setWidth(int width) { this.width = width; } + public void setHeight(int height) { this.height = height; } + + public String toString() { + return new String("Rect["+x+"/"+y+" "+width+"x"+height+"]"); + } +} + diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java b/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java index e0f86b1a9..e0f86b1a9 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java |