diff options
-rw-r--r-- | make/build-test.xml | 4 | ||||
-rwxr-xr-x | make/scripts/run-test-until-crash.sh | 2 | ||||
-rwxr-xr-x | make/scripts/test-fat-jars.sh | 2 | ||||
-rwxr-xr-x | make/scripts/tests-win.bat | 4 | ||||
-rwxr-xr-x | make/scripts/tests-x64-dbg.bat | 14 | ||||
-rwxr-xr-x | make/scripts/tests-x64.bat | 11 | ||||
-rw-r--r-- | make/scripts/tests.sh | 5 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java | 12 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java | 103 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 12 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java | 12 |
11 files changed, 154 insertions, 27 deletions
diff --git a/make/build-test.xml b/make/build-test.xml index bda7576c3..ade3ab8af 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -42,8 +42,8 @@ <property name="test.archive.name" value="${archive.name}-test-results-${build.node.name}"/> <!-- not required: java.base/java.lang=ALL-UNNAMED --> - <!-- required for AWT: java.desktop/sun.awt=ALL-UNNAMED java.desktop/sun.java2d=ALL-UNNAMED --> - <condition property="jvmarg.modules" value="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED"> + <!-- required for AWT: java.desktop/sun.awt=ALL-UNNAMED java.desktop/sun.awt.windows=ALL-UNNAMED java.desktop/sun.java2d=ALL-UNNAMED --> + <condition property="jvmarg.modules" value="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED"> <isset property="minJava17"/> </condition> <condition property="jvmarg.modules" value="--illegal-access=warn"> diff --git a/make/scripts/run-test-until-crash.sh b/make/scripts/run-test-until-crash.sh index 5b11a77e2..80f3e0609 100755 --- a/make/scripts/run-test-until-crash.sh +++ b/make/scripts/run-test-until-crash.sh @@ -29,7 +29,7 @@ do_test() { -cp ${TST_CLASSPATH} \ -Djunit.run.arg0=dummy -Djunit.run.arg1=dummy -Djnlp.no.jvm.data.model.set=true \ -Djava.library.path=../../gluegen/${build_dir_base}/obj:${build_dir}/nativewindow/obj:${build_dir}/jogl/obj:${build_dir}/newt/obj:${build_dir}/test/build/obj \ - --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED \ + --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED \ org.junit.runner.JUnitCore ${test_class} \ && OK=0 diff --git a/make/scripts/test-fat-jars.sh b/make/scripts/test-fat-jars.sh index 865aad7fd..a3bd91dff 100755 --- a/make/scripts/test-fat-jars.sh +++ b/make/scripts/test-fat-jars.sh @@ -9,7 +9,7 @@ folder=${version} MOSX=0 uname -a | grep -i Darwin && MOSX=1 -MODULE_ARGS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED" +MODULE_ARGS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED" # D_ARGS="-Djogl.debug.GLMediaPlayer" USE_CLASSPATH=jogamp-fat.jar:jogl-demos.jar diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 49495f636..e518aadf1 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -10,7 +10,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* @@ -31,7 +31,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimat REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasResize01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelReadd01Bug1310AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelReadd01Bug1310AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestGLCanvasSWTNewtCanvasSWTPosInTabs %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 14a8e85ac..25cfc5761 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -4,6 +4,12 @@ set TMP=\\jordan\data\Incoming\windows\temp REM set TEMP=C:\Documents and Settings\jogamp\temp
REM set TMP=C:\Documents and Settings\jogamp\temp
+set LIBGL_DEBUG=verbose
+set MESA_DEBUG=true
+set LIBGL_ALWAYS_SOFTWARE=true
+REM set INTEL_DEBUG="buf bat"
+REM set INTEL_STRICT_CONFORMANCE=1
+
set BLD_SUB=build-win64
set J2RE_HOME=c:\jdk-17
set JAVA_HOME=c:\jdk-17
@@ -72,7 +78,7 @@ REM set D_ARGS="-Djogl.gljpanel.noverticalflip" REM set D_ARGS="-Dnewt.debug=all"
REM set D_ARGS="-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.JAWT"
-set D_ARGS="-Djogl.debug.GLJPanel" "-Dnativewindow.debug.JAWT"
+REM set D_ARGS="-Djogl.debug.GLJPanel" "-Dnativewindow.debug.JAWT"
REM set D_ARGS="-Dnativewindow.debug.SWT" "-Dnewt.debug.Window" "-Djogl.debug.GLCanvas"
REM set D_ARGS="-Dnativewindow.debug.JFX" "-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window.KeyEvent"
@@ -100,8 +106,10 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2 REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m"
REM set MODULE_ARGS=--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
-set MODULE_ARGS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
-set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %MODULE_ARGS%
+set MODULE_ARGS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
+
+REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %MODULE_ARGS%
+set X_ARGS="-Dsun.java2d.noddraw=true" %MODULE_ARGS%
scripts\tests-win.bat %*
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index a9b6580ef..728dd6ba2 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -4,6 +4,12 @@ set J2RE_HOME=c:\jdk-17 set JAVA_HOME=c:\jdk-17
set ANT_PATH=C:\apache-ant-1.10.5
+REM set LIBGL_DEBUG=verbose
+REM set MESA_DEBUG=true
+set LIBGL_ALWAYS_SOFTWARE=true
+REM set INTEL_DEBUG="buf bat"
+REM set INTEL_STRICT_CONFORMANCE=1
+
REM set TEMP=C:\Documents and Settings\jogamp\temp
REM set TMP=C:\Documents and Settings\jogamp\temp
REM set TEMP=C:\Users\jogamp\temp\no-exec
@@ -25,8 +31,9 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_D echo CP_ALL %CP_ALL%
REM set MODULE_ARGS=--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
-set MODULE_ARGS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
-set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %MODULE_ARGS%
+set MODULE_ARGS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED
+REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %MODULE_ARGS%
+set X_ARGS="-Dsun.java2d.noddraw=true" %MODULE_ARGS%
scripts\tests-win.bat %*
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5b3152e40..20dc8e4e4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { # MODULE_ARGS="--illegal-access=warn" # MODULE_ARGS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED" - MODULE_ARGS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED" + MODULE_ARGS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.java2d=ALL-UNNAMED" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" @@ -926,9 +926,10 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestBug1431NewtCanvasAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* # # JavaFX (testjfx) diff --git a/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java index 735a2a21c..97a3321d5 100644 --- a/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java @@ -86,6 +86,8 @@ import com.jogamp.opengl.GLSharedContextSetter; import com.jogamp.opengl.Threading; import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.Platform; +import com.jogamp.common.os.Platform.OSType; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; @@ -169,6 +171,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private static final boolean DEBUG = Debug.debug("GLCanvas"); + private static JAWTUtil.BackgroundEraseControl backgroundEraseControl = new JAWTUtil.BackgroundEraseControl(); + private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access @@ -589,7 +593,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing */ // before native peer is valid: X11 - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS != Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } final GraphicsDevice awtDevice; if(null==awtDeviceReq) { @@ -614,7 +620,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing super.addNotify(); // after native peer is valid: Windows - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS == Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } createJAWTDrawableAndContext(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 86de6e30d..f3c3da286 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -109,7 +109,7 @@ public class JAWTUtil { // default initialization to null, false Method awtLockMID; Method awtUnlockMID; - Method disableBackgroundEraseMID; + Method stkDisableBackgroundEraseMID; boolean ok; } private static class GraphicsDeviceData { @@ -117,7 +117,6 @@ public class JAWTUtil { // default initialization to null, false Method getScaleFactorMID; Method getCGDisplayIDMIDOnOSX; - boolean ok; } /** @@ -381,8 +380,8 @@ public class JAWTUtil { d.awtLockMID.setAccessible(true); d.awtUnlockMID = sunToolkitClass.getDeclaredMethod("awtUnlock"); d.awtUnlockMID.setAccessible(true); - d.disableBackgroundEraseMID = sunToolkitClass.getDeclaredMethod("disableBackgroundErase", java.awt.Component.class); - d.disableBackgroundEraseMID.setAccessible(true); + d.stkDisableBackgroundEraseMID = sunToolkitClass.getDeclaredMethod("disableBackgroundErase", java.awt.Component.class); + d.stkDisableBackgroundEraseMID.setAccessible(true); d.ok=true; } catch (final Exception e) { // Either not a Sun JDK or the interfaces have changed since [Java 1.4.2 / 1.5 -> Java 11] @@ -394,7 +393,7 @@ public class JAWTUtil { }}); }}); stkAWTLockMID = std.awtLockMID; stkAWTUnlockMID = std.awtUnlockMID; - stkDisableBackgroundEraseMID = std.disableBackgroundEraseMID; + stkDisableBackgroundEraseMID = std.stkDisableBackgroundEraseMID; boolean _hasSunToolkitAWTLock = false; if ( std.ok ) { try { @@ -489,7 +488,7 @@ public class JAWTUtil { } if (DEBUG) { - System.err.println("JAWTUtil: Has sun.awt.SunToolkit: awtLock/awtUnlock " + hasSTKAWTLock + ", disableBackgroundErase "+(null!=stkDisableBackgroundEraseMID)); + System.err.println("JAWTUtil: Has sun.awt.SunToolkit: awtLock/awtUnlock " + hasSTKAWTLock + ", stkDisableBackgroundErase "+(null!=stkDisableBackgroundEraseMID)); System.err.println("JAWTUtil: Has Java2D " + j2dExist); System.err.println("JAWTUtil: Is headless " + headlessMode); final int hints = ( null != desktophints ) ? desktophints.size() : 0 ; @@ -604,19 +603,27 @@ public class JAWTUtil { * @param component * @return {@code true} if available and successful, otherwise {@code false} */ - public static boolean disableBackgroundErase(final java.awt.Component component) { + public static boolean disableBackgroundEraseSTK(final java.awt.Component component) { if( null != stkDisableBackgroundEraseMID ) { try { stkDisableBackgroundEraseMID.invoke(component.getToolkit(), component); + if( DEBUG ) { + System.err.println(getThreadName()+dbe_msg+" OK"); + } return true; } catch (final Exception e) { if( DEBUG ) { - ExceptionUtils.dumpThrowable("JAWTUtil", e); + System.err.println(getThreadName()+dbe_msg+" failed, error "+e); + ExceptionUtils.dumpThrowable(dbe_msg, e); } } } + if( DEBUG ) { + System.err.println(getThreadName()+dbe_msg+" failed, no method"); + } return false; } + private static final String dbe_msg = ": java.awt.Component: STK disableBackgroundErase"; /** * Queries the Monitor's display ID of the given device @@ -800,5 +807,85 @@ public class JAWTUtil { return NativeWindowFactory.createScreen(adevice, AWTGraphicsScreen.findScreenIndex(awtComp.getGraphicsConfiguration().getDevice())); } + + /** + * Disables the AWT's erasing of this Canvas's background on Windows in Java SE 6. + * <p> + * Utilize this class as a static instance within your AWT Canvas override. + * </p> + * <p> + * Implementation also calls {@link JAWTUtil#disableBackgroundEraseSTK(java.awt.Component)} just in case. + * </p> + * <p> + * This internal API is not available in previous releases, + * but the system property {@code -Dsun.awt.noerasebackground=true} + * can be specified to get similar results globally in previous releases. + * </p> + */ + public static class BackgroundEraseControl { + private boolean disableBackgroundEraseInitialized = false; + private Method disableBackgroundEraseMethod = null; + private static final String msg = ": java.awt.Canvas: TK disableBackgroundErase"; + + /** + * Disables the AWT's erasing of this Canvas's background on Windows in Java SE 6. + * <p> + * Method also calls {@link JAWTUtil#disableBackgroundEraseSTK(java.awt.Component)} just in case. + * </p> + */ + public boolean disable(final java.awt.Canvas canvas) { + if (!disableBackgroundEraseInitialized) { + try { + SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + Class<?> clazz = canvas.getToolkit().getClass(); + while (clazz != null && disableBackgroundEraseMethod == null) { + try { + disableBackgroundEraseMethod = + clazz.getDeclaredMethod("disableBackgroundErase", + new Class[] { java.awt.Canvas.class }); + disableBackgroundEraseMethod.setAccessible(true); + } catch (final Exception e) { + clazz = clazz.getSuperclass(); + } + } + } catch (final Exception e) { + } + return null; + } + }); + } catch (final Exception e) { + } + disableBackgroundEraseInitialized = true; + if(DEBUG) { + System.err.println(getThreadName()+msg+" method found: "+ + (null!=disableBackgroundEraseMethod)); + } + } + boolean res = false; + if (disableBackgroundEraseMethod != null) { + Throwable t=null; + try { + disableBackgroundEraseMethod.invoke(canvas.getToolkit(), new Object[] { canvas }); + res = true; + } catch (final Exception e) { + t = e; + } + if(DEBUG) { + System.err.println(getThreadName()+msg+" res "+res+", error: "+t); + if( null != t ) { + ExceptionUtils.dumpThrowable(msg, t); + } + } + } else if(DEBUG) { + System.err.println(getThreadName()+msg+" failed, no method"); + } + JAWTUtil.disableBackgroundEraseSTK(canvas); + return res; + } + } + } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 783bc6857..fc885e591 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -69,6 +69,8 @@ import jogamp.newt.driver.DriverClearFocus; import jogamp.opengl.awt.AWTTilePainter; import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.os.Platform; +import com.jogamp.common.os.Platform.OSType; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTPrintLifecycle; @@ -100,6 +102,8 @@ import com.jogamp.opengl.util.TileRenderer; public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder, WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { public static final boolean DEBUG = Debug.debug("Window"); + private static JAWTUtil.BackgroundEraseControl backgroundEraseControl = new JAWTUtil.BackgroundEraseControl(); + private final Object sync = new Object(); private volatile JAWTWindow jawtWindow = null; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private boolean isApplet = false; @@ -589,7 +593,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder * This code order also allows recreation, ie re-adding the GLCanvas. */ // before native peer is valid: X11 - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS != Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } // Query AWT GraphicsDevice from parent tree, default final GraphicsConfiguration gc = super.getGraphicsConfiguration(); @@ -607,7 +613,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder super.addNotify(); // after native peer is valid: Windows - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS == Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } synchronized(sync) { determineIfApplet(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index b81bd7544..11eb1dba0 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -39,6 +39,8 @@ import java.awt.Graphics; import java.awt.GraphicsDevice; import java.awt.GraphicsConfiguration; +import com.jogamp.common.os.Platform; +import com.jogamp.common.os.Platform.OSType; import com.jogamp.nativewindow.AbstractGraphicsDevice; import com.jogamp.nativewindow.AbstractGraphicsScreen; import com.jogamp.nativewindow.CapabilitiesChooser; @@ -59,6 +61,8 @@ import jogamp.nativewindow.jawt.JAWTUtil; @SuppressWarnings("serial") public class AWTCanvas extends Canvas { + private static JAWTUtil.BackgroundEraseControl backgroundEraseControl = new JAWTUtil.BackgroundEraseControl(); + private final WindowDriver driver; private final CapabilitiesImmutable capabilities; private final CapabilitiesChooser chooser; @@ -121,7 +125,9 @@ public class AWTCanvas extends Canvas { public void addNotify() { // before native peer is valid: X11 - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS != Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } /** * 'super.addNotify()' determines the GraphicsConfiguration, @@ -146,7 +152,9 @@ public class AWTCanvas extends Canvas { super.addNotify(); // after native peer is valid: Windows - JAWTUtil.disableBackgroundErase(this); + if( OSType.WINDOWS == Platform.getOSType() ) { + backgroundEraseControl.disable(this); + } { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); |