From 006acbb9463af33a8b45aa0b3a298604eba72d82 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 21 Jun 2008 02:33:51 +0000 Subject: 2nd big refactoring. Goals are orthogonal components for: - OS Windowing system - NEWT, X11, Windows, MacOsX - GL Windowing GLUE - EGL, GLX, WGL, CGL - GL profiles - core and util packages - generate all Java components from any platform All above goals are achieved. TODO: - Native compilation fix and test - Check/Fix Win32, MacOSX and the mobile devices - .. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1665 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../opengl/impl/macosx/awt/MacOSXJAWTWindow.java | 103 +++++++++++++++++++-- 1 file changed, 93 insertions(+), 10 deletions(-) (limited to 'src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java') diff --git a/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java b/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java index 5f676a138..44a34b98d 100644 --- a/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java +++ b/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java @@ -41,28 +41,111 @@ package com.sun.opengl.impl.macosx.awt; import com.sun.opengl.impl.macosx.*; import com.sun.opengl.impl.awt.*; +import com.sun.opengl.impl.*; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import javax.media.opengl.*; -import com.sun.opengl.impl.*; +import java.security.*; public class MacOSXJAWTWindow extends JAWTWindow { - // Variables for lockSurface/unlockSurface - //private JAWT_DrawingSurface ds; - //private JAWT_DrawingSurfaceInfo dsi; - //private JAWT_MacOSXDrawingSurfaceInfo x11dsi; - public MacOSXJAWTWindow(Object comp) { super(comp); } - public int lockSurface() throws NativeWindowException { - super.lockSurface(); - return 0; + protected void initNative() throws NativeWindowException { } - public void unlockSurface() { + public int lockSurface() throws NativeWindowException { + int ret = super.lockSurface(); + if(NativeWindow.LOCK_SUCCESS != ret) { + return ret; + } + ds = JAWT.getJAWT().GetDrawingSurface(component); + if (ds == null) { + // Widget not yet realized + return NativeWindow.LOCK_SURFACE_NOT_READY; + } + int res = ds.Lock(); + if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { + throw new GLException("Unable to lock surface"); + } + // See whether the surface changed and if so destroy the old + // OpenGL context so it will be recreated (NOTE: removeNotify + // should handle this case, but it may be possible that race + // conditions can cause this code to be triggered -- should test + // more) + if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) { + ret = NativeWindow.LOCK_SURFACE_CHANGED; + } + if (firstLock) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + dsi = ds.GetDrawingSurfaceInfo(); + return null; + } + }); + } else { + dsi = ds.GetDrawingSurfaceInfo(); + } + if (dsi == null) { + // Widget not yet realized + ds.Unlock(); + JAWT.getJAWT().FreeDrawingSurface(ds); + ds = null; + 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; + return NativeWindow.LOCK_SURFACE_NOT_READY; + } + drawable = macosxdsi.cocoaViewRef(); + // FIXME: Are the followup abstractions available ? would it be usefull ? + display = 0; + visualID = 0; + screen= 0; + screenIndex = 0; + + if (drawable == 0) { + // Widget not yet realized + ds.FreeDrawingSurfaceInfo(dsi); + ds.Unlock(); + JAWT.getJAWT().FreeDrawingSurface(ds); + ds = null; + dsi = null; + macosxdsi = null; + return NativeWindow.LOCK_SURFACE_NOT_READY; + } + return ret; + } + + public void unlockSurface() throws GLException { + if(!isSurfaceLocked()) return; + 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 JAWT_DrawingSurfaceInfo dsi; + private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; + + // Workaround for instance of 4796548 + private boolean firstLock = true; + } -- cgit v1.2.3