X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FDarwin.java;h=a3e4141e34b19c6e2942b4f1f063f8f524db15ac;hb=745fb6aad79e10eb8c402b8fa6a591769c0fcdfb;hp=0812a3d0c1c860da364f3a0d29032e30312776ce;hpb=d9fdc968988212807221d0d71d2fb6dc19cb87a3;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java index 0812a3d..a3e4141 100644 --- a/src/org/xwt/plat/Darwin.java +++ b/src/org/xwt/plat/Darwin.java @@ -47,7 +47,6 @@ public class Darwin extends POSIX { public Semaphore sem = new Semaphore(); public String fileName; public String saveName; - public RawData rawUPP; } private native void natFileDialog(FileDialogHelper helper, String suggestedFileName, boolean write); protected String _fileDialog(final String fn, final boolean w) { @@ -93,13 +92,10 @@ public class Darwin extends POSIX { throw new Error("No OpenGL support"); } natInit(); - new Thread() { - public void run() { - runApplicationEventLoop(); - } - }.start(); } + public void _running() { runApplicationEventLoop(); } + private final class CarbonOpenGL extends OpenGL { public RawData rawPixelFormat; public RawData rawSharedContext; @@ -132,8 +128,11 @@ public class Darwin extends POSIX { static abstract class CarbonSurface extends Surface.DoubleBufferedSurface { RawData rawWindowRef; - RawData rawEventHandlerUPP; int modifiers; + int winWidth; + int winHeight; + + boolean pendingResize; private native void natSetInvisible(boolean i); public void setInvisible(final boolean i) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetInvisible(i); } }); } @@ -172,9 +171,7 @@ public class Darwin extends POSIX { final int n_ = n; CarbonMessage.add(new CarbonMessage() { public void perform() { natSyncCursor(n_); } }); } - - public void _sizeChange(int w, int h) { SizeChange(w,h); } - + /* Drawing stuff */ public abstract void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2); @@ -190,7 +187,10 @@ public class Darwin extends POSIX { sem.block(); } - public void reshape(int w, int h) { } + public void needsReshape() { } + protected static native void blitLock(); + protected static native void blitUnlock(); + protected static native void blitWait(); } static class GLCarbonPixelBuffer extends OpenGL.GLPixelBuffer { @@ -226,9 +226,11 @@ public class Darwin extends POSIX { static class GLCarbonSurface extends CarbonSurface { RawData rawCTX; CarbonOpenGL gl; - boolean sizeChange; - + boolean needsReshape; + private final native void natInit(); + private final native void flush(); + private final native void clear(); public GLCarbonSurface(Box root, boolean framed, CarbonOpenGL gl) { super(root,framed); @@ -241,26 +243,39 @@ public class Darwin extends POSIX { mxh = Math.min(mxh,gl.maxSurfaceHeight); super.setLimits(mnw,mnh,mxw,mxh); } - public void _sizeChange(int w, int h) { - sizeChange = true; - super._sizeChange(w,h); - } public void setSize(int w, int h) { - sizeChange = true; w = Math.min(w,gl.maxSurfaceWidth); h = Math.min(h,gl.maxSurfaceWidth); super.setSize(w,h); } private native void natBlit(GLCarbonPixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2); - public synchronized void blit(PixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2) { + public void blit(PixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2) { natBlit((GLCarbonPixelBuffer)db,sx,sy,dx,dy,dx2,dy2); } - private native void natReshape(int w, int h); - public synchronized void reshape(int w, int h) { natReshape(w,h); } + // The blit_lock ensures the window size does not change through the entire blit operation. + public void render_() { + blitLock(); + while(pendingResize) blitWait(); + if(needsReshape) { + needsReshape = false; + + reshape(winWidth,winHeight); + clear(); + Dirty(0,0,getWidth(),getHeight()); + } + super.render_(); + flush(); + blitUnlock(); + } + + private native void reshape(int w, int h); + // blit_lock is assumed to be held + public void needsReshape() { needsReshape = true; } + public native void natDispose(); } @@ -307,6 +322,12 @@ public class Darwin extends POSIX { else return /*new QZCarbonPicture(data,w,h);*/ null; } + protected Picture _createAlphaOnlyPicture(byte[] data, int w, int h) { + if(openGL != null) + return openGL.createAlphaOnlyPicture(data,w,h); + else + return super.createAlphaOnlyPicture(data,w,h); + } /* A message that is sent through the carbon event queue */ private static abstract class CarbonMessage {