-// 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.*;
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) {
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);
- // FIXME: We need to fallback to Quartz2D
+ Log.info(this,"WARNING: OpenGL support not available: " + e);
+ // FEATURE: fall back to quartz 2d
throw new Error("No OpenGL support");
}
natInit();
- new Thread() {
- public void run() {
- runApplicationEventLoop();
- }
- }.start();
+ }
+
+ 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 {
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;
}
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); } }); }
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();
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);
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 {
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);
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;
+ 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);
- 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,winWidth,winHeight);
+ }
+ 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();
}
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 org.xwt.Font.Glyph _createGlyph(org.xwt.Font f, char c) {
+ if(openGL != null)
+ return openGL._createGlyph(f, c);
+ else
+ return super.createGlyph(f, c);
+ }
/* A message that is sent through the carbon event queue */
private static abstract class CarbonMessage {