X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FDarwin.java;h=211c88cb3f35d1d2aa638d847cfd3233db4c08c6;hb=d5ed44dae8660a62e24b4e7d535f3ee8f8e791ed;hp=a3e4141e34b19c6e2942b4f1f063f8f524db15ac;hpb=745fb6aad79e10eb8c402b8fa6a591769c0fcdfb;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java index a3e4141..211c88c 100644 --- a/src/org/xwt/plat/Darwin.java +++ b/src/org/xwt/plat/Darwin.java @@ -1,10 +1,11 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [LGPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL] // Authors: Brian Alliet and Evan Jones package org.xwt.plat; import gnu.gcj.RawData; import org.xwt.util.*; +import org.xwt.js.*; import org.xwt.*; import java.util.*; @@ -77,24 +78,27 @@ public class Darwin extends POSIX { private static native final boolean isJaguar(); - // Called by main thread after initialization, this is the event handler - protected native void runApplicationEventLoop(); - - public void init() { - super.init(); + public void postInit() { jaguar = isJaguar(); try { openGL = new CarbonOpenGL(); openGL.init(); } catch(OpenGL.NotSupportedException e) { - Log.log(this,"WARNING: OpenGL support not available: " + e); + Log.info(this,"WARNING: OpenGL support not available: " + e); // FEATURE: fall back to quartz 2d throw new Error("No OpenGL support"); } natInit(); } - public void _running() { runApplicationEventLoop(); } + protected Scheduler _getScheduler() { return new DarwinScheduler(); } + protected native void runApplicationEventLoop(); + private class DarwinScheduler extends org.xwt.Scheduler { + public void run() { + new Thread() { public void run() { defaultRun(); } }.start(); + runApplicationEventLoop(); + } + } private final class CarbonOpenGL extends OpenGL { public RawData rawPixelFormat; @@ -119,7 +123,7 @@ public class Darwin extends POSIX { maxAglSurfaceTexSize = rectangularTextures ? maxRectTexSize : maxTexSize; if(renderer.startsWith("ATI Radeon 7500")) { maxAglSurfaceTexSize = Math.min(rectangularTextures ? 1600 : 1024,maxAglSurfaceTexSize); - Log.log(this,"Working around Radeon 7500 bug: maxAglSurfaceTexSize: " + maxAglSurfaceTexSize); + Log.info(this,"Working around Radeon 7500 bug: maxAglSurfaceTexSize: " + maxAglSurfaceTexSize); } maxSurfaceWidth = maxSurfaceHeight = maxAglSurfaceTexSize; } @@ -145,7 +149,7 @@ public class Darwin extends POSIX { private native void natSetTitleBarText(String s); public void setTitleBarText(final String s) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetTitleBarText(s); } }); } private native void natSetSize(int w, int h); - public void setSize(final int w, final int h) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetSize(w,h); } }); } + public void _setSize(final int w, final int h) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetSize(w,h); } }); } private native void natSetLocation(); public void setLocation() { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetLocation(); } }); } private native void natToFront(); @@ -244,10 +248,10 @@ public class Darwin extends POSIX { super.setLimits(mnw,mnh,mxw,mxh); } - public void setSize(int w, int h) { + public void _setSize(int w, int h) { w = Math.min(w,gl.maxSurfaceWidth); h = Math.min(h,gl.maxSurfaceWidth); - super.setSize(w,h); + super._setSize(w,h); } private native void natBlit(GLCarbonPixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2); @@ -257,19 +261,23 @@ public class Darwin extends POSIX { // The blit_lock ensures the window size does not change through the entire blit operation. - public void render_() { + public void render() { + /* blitLock(); while(pendingResize) blitWait(); + */ if(needsReshape) { needsReshape = false; reshape(winWidth,winHeight); clear(); - Dirty(0,0,getWidth(),getHeight()); + Dirty(0,0,winWidth,winHeight); } - super.render_(); + super.render(); flush(); + /* blitUnlock(); + */ } private native void reshape(int w, int h); @@ -316,17 +324,17 @@ public class Darwin extends POSIX { else return /*new QZCarbonSufrace(b,framed)*/ null; } - protected Picture _createPicture(int[] data, int w, int h) { + protected Picture _createPicture(JS r) { if(openGL != null) - return openGL.createPicture(data,w,h); + return openGL._createPicture(r, true); else return /*new QZCarbonPicture(data,w,h);*/ null; } - protected Picture _createAlphaOnlyPicture(byte[] data, int w, int h) { + protected org.xwt.Font.Glyph _createGlyph(org.xwt.Font f, char c) { if(openGL != null) - return openGL.createAlphaOnlyPicture(data,w,h); + return openGL._createGlyph(f, c); else - return super.createAlphaOnlyPicture(data,w,h); + return super.createGlyph(f, c); } /* A message that is sent through the carbon event queue */