+++ /dev/null
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
-
-package org.xwt;
-import java.io.*;
-import java.util.*;
-import org.xwt.js.*;
-import org.xwt.util.*;
-
-/** A ByteStream encapsulates a <i>source</i> of a stream of bytes --
- * currently either a local file or a Base64-encoded XMLRPC/SOAP element */
-public class ByteStream extends JS.Obj {
-
- private byte[] bytes = null;
- private File file = null;
-
- private ByteStream() { setSeal(true); }
- ByteStream(String filename) { this(); this.file = new File(filename); }
- ByteStream(byte[] bytes) { this(); this.bytes = bytes; }
-
- public String toString() { return "ByteStream, source=" + (file == null ? "memory" : file.getAbsolutePath()); }
-
- public Object get(Object name) {
- if (name.equals("getUTF")) return getUTF;
- else if (name.equals("getDOM")) return getDOM;
- else if (name.equals("fileName")) return file == null ? null : file.getAbsolutePath();
- else return null;
- }
-
- private class XMLHelper extends XML {
- Vector obStack = new Vector();
-
- public XMLHelper() { super(BUFFER_SIZE); }
-
- public void startElement(XML.Element c) throws XML.SchemaException {
- JS o = new JS.Obj();
- o.put("$name", c.localName);
- for(int i=0; i<c.len; i++) o.put(c.keys[i], c.vals[i]);
- o.put("$numchildren", new Integer(0));
- obStack.addElement(o);
- }
-
- public void endElement(XML.Element c) throws XML.SchemaException {
- if (obStack.size() == 1) return;
- JS me = (JS)obStack.lastElement();
- obStack.setSize(obStack.size() - 1);
- JS parent = (JS)obStack.lastElement();
- int numchildren = ((Integer)parent.get("$numchildren")).intValue();
- parent.put("$numchildren", new Integer(numchildren + 1));
- parent.put(new Integer(numchildren), me);
- }
-
- public void characters(char[] ch, int start, int length) throws XML.SchemaException {
- String s = new String(ch, start, length);
- JS parent = (JS)obStack.lastElement();
- int numchildren = ((Integer)parent.get("$numchildren")).intValue();
- Object lastChild = parent.get(new Integer(numchildren - 1));
- if (lastChild instanceof String) {
- parent.put(new Integer(numchildren - 1), lastChild + s);
- } else {
- parent.put("$numchildren", new Integer(numchildren + 1));
- parent.put(new Integer(numchildren), s);
- }
- }
-
- public void whitespace(char[] ch, int start, int length) {}
-
- public JS doParse() throws JS.Exn {
- try {
- InputStream is = getInputStream();
- BufferedReader r = new BufferedReader(new InputStreamReader(is));
- parse(r);
- } catch (XML.XMLException e) {
- throw new JS.Exn("error parsing XML: " + e.toString());
- } catch (IOException e) {
- if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");
- if (Log.on) Log.log(ByteStream.class, e);
- throw new JS.Exn("error reading from ByteStream");
- }
- return obStack.size() >= 1 ? (JS)obStack.elementAt(0) : null;
- }
- }
-
- public InputStream getInputStream() throws IOException {
- return file == null ?
- (InputStream)(new ByteArrayInputStream(bytes)) :
- (InputStream)(new FileInputStream(file));
- }
-
- public void writeTo(OutputStream os) throws IOException {
- InputStream is = getInputStream();
- byte[] buf = new byte[1024];
- while(true) {
- int numread = is.read(buf, 0, 1024);
- if (numread == -1) break;
- if (Log.on) Log.log(this, "wrote " + numread + " bytes");
- os.write(buf, 0, numread);
- }
- os.flush();
-
- // we have to close this because flush() doesn't work on Win32-GCJ
- os.close();
- }
-
- private final JS.Callable getDOM = new JS.Callable() {
- public Object call(JS.Array args) throws JS.Exn {
- if (args.length() != 0) return null;
- return new XMLHelper().doParse();
- }
- };
-
- private final JS.Callable getUTF = new JS.Callable() {
- public Object call(JS.Array args) throws JS.Exn {
- if (args.length() != 0) return null;
- try {
- CharArrayWriter caw = new CharArrayWriter();
- InputStream is = getInputStream();
- BufferedReader r = new BufferedReader(new InputStreamReader(is));
- char[] buf = new char[1024];
- while(true) {
- int numread = r.read(buf, 0, 1024);
- if (numread == -1) break;
- caw.write(buf, 0, numread);
- }
- return caw.toString();
- } catch (IOException e) {
- if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");
- if (Log.on) Log.log(ByteStream.class, e);
- throw new JS.Exn("error while reading from ByteStream");
- }
- }
- };
-
-}
-
*
* <p>
* Implementations of the Platform class should return objects
- * supporting this interface from the _createDoubleBuffer()
+ * supporting this interface from the _createPixelBuffer()
* method. These implementations may choose to use off-screen video
* ram for this purpose (for example, a Pixmap on X11).
* </p>
*
* <p>
- * A note on coordinates: all members on DoubleBuffer specify
+ * A note on coordinates: all members on PixelBuffer specify
* coordinates in terms of x1,y1,x2,y2 even though the Box class
* represents regions internally as x,y,w,h.
* </p>
*/
-public abstract class DoubleBuffer {
+public abstract class PixelBuffer {
- /** Draw the region of source within (sx1, sy1, sx2, sy2) onto the region of this DoubleBuffer within (dx1, dy1, dx2, dy2), scaling as needed. */
+ /** Draw the region of source within (sx1, sy1, sx2, sy2) onto the region of this PixelBuffer within (dx1, dy1, dx2, dy2), scaling as needed. */
public abstract void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2);
- /** Draw source onto this DoubleBuffer at (x,y) */
+ /** Draw source onto this PixelBuffer at (x,y) */
public abstract void drawPicture(Picture source, int x, int y);
- /** Draw <tt>text</tt> in <tt>font</tt> and <tt>color</tt> on this DoubleBuffer, with the upper left corner of the text at (x, y) */
+ /** Draw <tt>text</tt> in <tt>font</tt> and <tt>color</tt> on this PixelBuffer, with the upper left corner of the text at (x, y) */
public abstract void drawString(String font, String text, int x, int y, int color);
/** Fill the region (x1, y1, x2, y2) with <tt>color</tt> (AARRGGBB format); the alpha channel component is ignored */
public abstract void fillRect(int x1, int y1, int x2, int y2, int color);
- /** Sets the clip region for this DoubleBuffer to (x,y,x2,y2) */
+ /** Sets the clip region for this PixelBuffer to (x,y,x2,y2) */
public abstract void setClip(int x, int y, int x2, int y2);
public abstract int getHeight();
/**
* <p>
* The in-memory representation of a PNG or GIF image. It is
- * read-only. It is usually passed to DoubleBuffer.drawPicture()
+ * read-only. It is usually passed to PixelBuffer.drawPicture()
* </p>
*
* <p>
protected void init() { }
protected void postInit() { }
- /** creates and returns a doublebuffer 'belonging' to <tt>owner</tt>; we need to associate DoubleBuffers to surfaces
+ /** creates and returns a doublebuffer 'belonging' to <tt>owner</tt>; we need to associate PixelBuffers to surfaces
* due to AWT 1.1 requirements (definately for Navigator, possibly also for MSJVM).
*/
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return null; }
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) { return null; }
/** creates and returns a new surface */
protected Surface _createSurface(Box b, boolean framed) { return null; }
public static int getScreenHeight() { return platform._getScreenHeight(); }
/** creates and returns a doublebuffer 'belonging' to <tt>owner</tt> */
- public static DoubleBuffer createDoubleBuffer(int w, int h, Surface s) { return platform._createDoubleBuffer(w, h, s); }
+ public static PixelBuffer createDoubleBuffer(int w, int h, Surface s) { return platform._createDoubleBuffer(w, h, s); }
/** creates and returns a picture */
public static Picture createPicture(int[] data, int w, int h) { return platform._createPicture(data, w, h); }
package org.xwt;
import java.io.*;
+import org.xwt.js.*;
+// FIXME: ByteStream fileName property
/** base class for XWT resources */
-public abstract class Res {
+public abstract class Res extends JS {
- public abstract InputStream getInputStream();
- public Res getSubResource(String key) { return Null.singleton; }
+ public String toString() { return "Resource, source=FIXME"; }
+
+ public final InputStream getInputStream() { return getInputStream(""); }
+
+ public Res graft(Object newResource) { throw new JS.Exn("cannot graft onto this resource"); }
+ public Object get(Object key) { return new Ref(this, key); }
+ public void put(Object key, Object val) { throw new JS.Exn("cannot put to a resource"); }
+ public Object[] keys() { throw new JS.Exn("cannot enumerate a resource"); }
+
+ public abstract InputStream getInputStream(String path) { return getInputStream(""); }
+ public abstract Res addExtension(String extension);
public static Res stringToRes(String url) {
if (url.indexOf('!') == -1)
throw new JS.Exn("invalid resource specifier");
}
- /** the invalid resource; only causes an error if you actually try to use it */
- public static class Null extends Res {
- Null() { }
- private static singleton = new Null();
- public InputStream getInputStream() throws JS.Exn { throw new JS.Exn("invalid resource"); }
- }
-
/** HTTP or HTTPS resource */
public static class HTTP extends Res {
private String url;
HTTP(String url) { this.url = url; }
- public InputStream getInputStream() { return new HTTP(url).GET(); }
- public Res getSubResource(String key) { return new HTTP(url + "/" + key); }
+ public InputStream getInputStream(String path) { return new HTTP(url + path).GET(); }
}
/** wrap a Res around a preexisting InputStream */
InputStream parent;
IS(InputStream parent) { this.parent = parent; }
public InputStream getInputStream() { return parent; }
+ public InputStream getInputStream(String path) {
+ if (!"".equals(path)) throw new JS.Exn("can't access subresources of IS");
+ return parent;
+ }
}
/** "unwrap" a Zip archive */
public static class Zip extends Res {
private Res parent;
- private String path = "";
- Zip(Res parent, String path) { this.parent = parent; this.path = path; }
- public InputStream getInputStream() {
+ Zip(Res parent) { this.parent = parent; }
+ public InputStream getInputStream(String path) {
ZipInputStream zis = new ZipInputStream(parent.getInputStream());
ZipEntry ze = zis.getNextEntry();
while(ze != null && !ze.getName().equals(path)) ze = zis.getNextEntry();
if (ze == null) throw new JS.Exn("zip file not found in archive");
return zis;
}
- public Res getSubResource(String key) { return new Zip(parent, path + '/' + key); }
}
+ /** what you get when you reference a subresource */
+ public static class Ref extends Res {
+ Res parent;
+ Object key;
+ Ref(Res parent, Object key) { this.parent = parent; this.key = key; }
+ public InputStream getInputStream(path) {
+ return parent.getInputStream("/" + key + path);
+ }
+ public Res graft(Object newResource) { return new Graft(parent, key, newResource); }
+ }
+
+ /** shadow resource which replaces the graft */
+ public static class Graft extends Res {
+ Res graftee;
+ Object replaced_key;
+ Object replaced_val;
+ Graft(Res graftee, Object key, Object val) {
+ this.graftee = graftee; replaced_key = key; replaced_val = val; }
+ public boolean equals(Object o) { return (this == o || graftee.equals(o)); }
+ public Object get(Object key) {
+ return replaced_key.equals(key) ? replaced_val : graftee.get(key);
+ }
+ }
+
+ /////////////// bytestream
+
+ public Object callMethod(Object method, Array args, boolean checkOnly) throws JS.Exn {
+ if (method.equals("getUTF")) {
+ if (checkOnly) return Boolean.TRUE;
+ if (args.length() != 0) return null;
+ try {
+ CharArrayWriter caw = new CharArrayWriter();
+ InputStream is = getInputStream();
+ BufferedReader r = new BufferedReader(new InputStreamReader(is));
+ char[] buf = new char[1024];
+ while(true) {
+ int numread = r.read(buf, 0, 1024);
+ if (numread == -1) break;
+ caw.write(buf, 0, numread);
+ }
+ return caw.toString();
+ } catch (IOException e) {
+ if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");
+ if (Log.on) Log.log(ByteStream.class, e);
+ throw new JS.Exn("error while reading from ByteStream");
+ }
+ } else if (name.equals("getDOM")) {
+ if (checkOnly) return Boolean.TRUE;
+ if (args.length() != 0) return null;
+ return new XMLHelper().doParse();
+ }
+ if (checkOnly) return Boolean.FALSE;
+ return null;
+ }
+
+ private class XMLHelper extends XML {
+ Vector obStack = new Vector();
+ public XMLHelper() { super(BUFFER_SIZE); }
+ public void startElement(XML.Element c) throws XML.SchemaException {
+ JS o = new JS.Obj();
+ o.put("$name", c.localName);
+ for(int i=0; i<c.len; i++) o.put(c.keys[i], c.vals[i]);
+ o.put("$numchildren", new Integer(0));
+ obStack.addElement(o);
+ }
+ public void endElement(XML.Element c) throws XML.SchemaException {
+ if (obStack.size() == 1) return;
+ JS me = (JS)obStack.lastElement();
+ obStack.setSize(obStack.size() - 1);
+ JS parent = (JS)obStack.lastElement();
+ int numchildren = ((Integer)parent.get("$numchildren")).intValue();
+ parent.put("$numchildren", new Integer(numchildren + 1));
+ parent.put(new Integer(numchildren), me);
+ }
+ public void characters(char[] ch, int start, int length) throws XML.SchemaException {
+ String s = new String(ch, start, length);
+ JS parent = (JS)obStack.lastElement();
+ int numchildren = ((Integer)parent.get("$numchildren")).intValue();
+ Object lastChild = parent.get(new Integer(numchildren - 1));
+ if (lastChild instanceof String) {
+ parent.put(new Integer(numchildren - 1), lastChild + s);
+ } else {
+ parent.put("$numchildren", new Integer(numchildren + 1));
+ parent.put(new Integer(numchildren), s);
+ }
+ }
+ public void whitespace(char[] ch, int start, int length) {}
+ public JS doParse() throws JS.Exn {
+ try {
+ InputStream is = getInputStream();
+ BufferedReader r = new BufferedReader(new InputStreamReader(is));
+ parse(r);
+ } catch (XML.XMLException e) {
+ throw new JS.Exn("error parsing XML: " + e.toString());
+ } catch (IOException e) {
+ if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");
+ if (Log.on) Log.log(ByteStream.class, e);
+ throw new JS.Exn("error reading from ByteStream");
+ }
+ return obStack.size() >= 1 ? (JS)obStack.elementAt(0) : null;
+ }
+ }
+
+ public void writeTo(OutputStream os) throws IOException {
+ InputStream is = getInputStream();
+ byte[] buf = new byte[1024];
+ while(true) {
+ int numread = is.read(buf, 0, 1024);
+ if (numread == -1) break;
+ if (Log.on) Log.log(this, "wrote " + numread + " bytes");
+ os.write(buf, 0, numread);
+ }
+ os.flush();
+
+ // we have to close this because flush() doesn't work on Win32-GCJ
+ os.close();
+ }
}
public abstract void setIcon(Picture i);
/** copies a region from the doublebuffer to this surface */
- public abstract void blit(DoubleBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2);
+ public abstract void blit(PixelBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2);
/** Destroy the surface */
public abstract void _dispose();
// Private Instance Data /////////////////////////////////////////////////////////////////////////////////////////////
/** The automatic double buffer for the root box */
- DoubleBuffer backbuffer = null;
+ PixelBuffer backbuffer = null;
/** Dirty regions on the backbuffer which need to be rebuilt using Box.render() */
private DirtyList backbufferDirtyRegions = new DirtyList();
static volatile boolean abort = false;
/** a solid red 10x10 double buffer */
- private DoubleBuffer showRenderBuf = null;
+ private PixelBuffer showRenderBuf = null;
/** a striped 100x100 double buffer */
- private DoubleBuffer showRenderBuf2 = null;
+ private PixelBuffer showRenderBuf2 = null;
/** true iff this window should be scarred */
private boolean scarred = true;
} while(abort);
// this is a bit dangerous since we're passing ourselves to another method before subclasses' ctors have run...
- backbuffer = Platform.createDoubleBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
+ backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
root.dirty();
Refresh();
if (Main.showRenders) {
if (showRenderBuf == null) {
- showRenderBuf = Platform.createDoubleBuffer(10, 10, this);
+ showRenderBuf = Platform.createPixelBuffer(10, 10, this);
showRenderBuf.fillRect(0, 0, 10, 10, 0x00FF0000);
- showRenderBuf2 = Platform.createDoubleBuffer(100, 100, this);
+ showRenderBuf2 = Platform.createPixelBuffer(100, 100, this);
for(int y1 = 0; y1<100; y1++)
for(int x1 = 0; x1<100; x1++)
if ((x1 + y1) % 5 == 0)
public class AWT extends JVM {
protected String getDescriptiveName() { return "Generic JDK 1.1+ with AWT"; }
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new AWTDoubleBuffer(w, h); }
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new AWTDoubleBuffer(w, h); }
protected Picture _createPicture(int[] b, int w, int h) { return new AWTPicture(b, w, h); }
protected int _getScreenWidth() { return Toolkit.getDefaultToolkit().getScreenSize().width; }
protected int _getScreenHeight() { return Toolkit.getDefaultToolkit().getScreenSize().height; }
}
}
- protected static class AWTDoubleBuffer extends DoubleBuffer {
+ protected static class AWTPixelBuffer extends DoubleBuffer {
protected Image i = null;
protected Graphics g = null;
/** JDK1.1 platforms require that a component be associated with each off-screen buffer */
static Component component = null;
- protected AWTDoubleBuffer() { }
- public AWTDoubleBuffer(int w, int h) {
- synchronized(AWTDoubleBuffer.class) {
+ protected AWTPixelBuffer() { }
+ public AWTPixelBuffer(int w, int h) {
+ synchronized(AWTPixelBuffer.class) {
if (component == null) {
component = new Frame();
component.setVisible(false);
protected static class AWTSurface extends Surface
implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, WindowListener {
- public void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
+ public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
if (ourGraphics == null) ourGraphics = window.getGraphics();
- ourGraphics.drawImage(((AWTDoubleBuffer)s).i, dx + insets.left, dy + insets.top, dx2 + insets.left, dy2 + insets.top,
+ ourGraphics.drawImage(((AWTPixelBuffer)s).i, dx + insets.left, dy + insets.top, dx2 + insets.left, dy2 + insets.top,
sx, sy, sx + (dx2 - dx), sy + (dy2 - dy), null);
}
#include <org/xwt/plat/Darwin.h>
#include <org/xwt/plat/Darwin$CarbonSurface.h>
#include <org/xwt/plat/Darwin$GLCarbonSurface.h>
-#include <org/xwt/plat/Darwin$GLCarbonDoubleBuffer.h>
+#include <org/xwt/plat/Darwin$GLCarbonPixelBuffer.h>
#include <org/xwt/plat/Darwin$CarbonMessage.h>
#include <org/xwt/plat/Darwin$CarbonOpenGL.h>
#include <org/xwt/plat/Darwin$FileDialogHelper.h>
checkStatus(rawSharedContext,"aglCreateContext");
}
-void Darwin$GLCarbonDoubleBuffer::natInit() {
+void Darwin$GLCarbonPixelBuffer::natInit() {
WindowClass wc = kPlainWindowClass;
WindowAttributes attr = 0;
WindowRef window;
rawCTX = (RawData*) ctx;
}
-void Darwin$GLCarbonDoubleBuffer::activateContext() {
+void Darwin$GLCarbonPixelBuffer::activateContext() {
AGLContext ctx = (AGLContext) rawCTX;
aglSetCurrentContext(ctx);
}
-void Darwin$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
+void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
WindowRef window = (WindowRef) rawWindowRef;
AGLContext ctx = (AGLContext) rawCTX;
aglDestroyContext(ctx);
DisposeWindow(window);
}
-void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
+void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
AGLContext ctx = (AGLContext) rawCTX;
int sx2 = sx1 + (dx2-dx1);
int sy2 = sy1 + (dy2-dy1);
public void _sizeChange(int w, int h) { SizeChange(w,h); }
/* Drawing stuff */
- public abstract void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
+ public abstract void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
public final void _dispose() { CarbonMessage.add(new CarbonMessage() { public void perform() { natDispose(); } }); }
public native void natDispose();
public void reshape(int w, int h) { }
}
- static class GLCarbonDoubleBuffer extends OpenGL.GLDoubleBuffer {
+ static class GLCarbonPixelBuffer extends OpenGL.GLDoubleBuffer {
RawData rawCTX;
RawData rawWindowRef;
int textureName;
if(!gl.rectangularTextures) n = OpenGL.roundToPowerOf2(n);
return Math.min(n,gl.maxAglSurfaceTexSize);
}
- public GLCarbonDoubleBuffer(int w, int h, final CarbonOpenGL gl) {
+ public GLCarbonPixelBuffer(int w, int h, final CarbonOpenGL gl) {
super(fixupDimension(gl,w),fixupDimension(gl,h));
this.gl = gl;
rectTexture = gl.hasRectangularTextures();
final Semaphore sem = new Semaphore();
- CarbonMessage.add(new CarbonMessage() { public void perform() { GLCarbonDoubleBuffer.this.natInit(); sem.release(); } });
+ CarbonMessage.add(new CarbonMessage() { public void perform() { GLCarbonPixelBuffer.this.natInit(); sem.release(); } });
sem.block();
}
public native void activateContext();
super.setSize(w,h);
}
- private native void natBlit(GLCarbonDoubleBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2);
- public synchronized void blit(DoubleBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2) {
- natBlit((GLCarbonDoubleBuffer)db,sx,sy,dx,dy,dx2,dy2);
+ 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) {
+ natBlit((GLCarbonPixelBuffer)db,sx,sy,dx,dy,dx2,dy2);
}
private native void natReshape(int w, int h);
public native void natDispose();
}
- /*private class QZCarbonDoubleBuffer extends DoubleBuffer {
+ /*private class QZCarbonPixelBuffer extends DoubleBuffer {
- public QZCarbonDoubleBuffer(int width, int height) {
+ public QZCarbonPixelBuffer(int width, int height) {
}
}
private class QZCarbonSurface extends CarbonSurface {
public QZCarbonSurface(Box root, boolean framed) {
super(b,root);
}
- public native void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
+ public native void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
}
private class QZCarbonPicture extends Picture {
}
}*/
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) {
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) {
if(openGL != null)
- return new GLCarbonDoubleBuffer(w,h,openGL);
+ return new GLCarbonPixelBuffer(w,h,openGL);
else
- return /*new QZCarbonDoubleBuffer(w,h)*/ null;
+ return /*new QZCarbonPixelBuffer(w,h)*/ null;
}
protected Surface _createSurface(Box b, boolean framed) {
if(openGL != null)
});
}
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Java2DoubleBuffer(w, h); }
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Java2DoubleBuffer(w, h); }
protected Surface _createSurface(final Box root, final boolean framed) {
return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
public Java2Surface(Box root, boolean framed) { super(root, framed); }
- public void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
+ public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
if (ourGraphics == null) {
ourGraphics = window.getGraphics();
// sometimes jdk1.4 doesn't set the clip properly when we're in the middle of a resize
ourGraphics.setClip(insets.left, insets.top, root.width + insets.left, root.height + insets.top);
}
- _doDrawImage(window.getGraphics(), ((AWTDoubleBuffer)s).i, dx + insets.left, dy + insets.top, dx2 + insets.left, dy2 + insets.top,
+ _doDrawImage(window.getGraphics(), ((AWTPixelBuffer)s).i, dx + insets.left, dy + insets.top, dx2 + insets.left, dy2 + insets.top,
sx, sy, sx + (dx2 - dx), sy + (dy2 - dy), null);
}
}
}
- protected static class Java2DoubleBuffer extends AWTDoubleBuffer {
+ protected static class Java2PixelBuffer extends AWTDoubleBuffer {
private static ColorModel cm = Toolkit.getDefaultToolkit().getColorModel();
private static Hashtable emptyHashtable = new Hashtable();
private static short[] sbank = null;
_doDrawImage(g, ((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
}
- public Java2DoubleBuffer(int w, int h) {
+ public Java2PixelBuffer(int w, int h) {
SampleModel sm = cm.createCompatibleSampleModel(w, h);
int numSamples = w * h * sm.getNumDataElements();
DataBuffer buf = null;
// IMPROVMENT: use alpha testing? might be faster
#include <org/xwt/plat/OpenGL.h>
-#include <org/xwt/plat/OpenGL$GLDoubleBuffer.h>
+#include <org/xwt/plat/OpenGL$GLPixelBuffer.h>
#include <org/xwt/plat/OpenGL$GLPicture.h>
#include <org/xwt/plat/OpenGL$RectGLPicture.h>
#include <org/xwt/plat/OpenGL$SquareGLPicture.h>
version = JvNewStringLatin1(s==0 ? "" : (char*)s);
}
-void OpenGL$GLDoubleBuffer::drawableInit(jint width, jint height) {
+void OpenGL$GLPixelBuffer::drawableInit(jint width, jint height) {
glClearColor (0.3f, 0.7f, 1.0f, 1.0f);
glClearDepth( 0.0f );
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
checkGLError();
}
-void OpenGL$GLDoubleBuffer::setColor(jint argb) {
+void OpenGL$GLPixelBuffer::setColor(jint argb) {
float alpha = ((argb >> 24) & 0xff) / 255.0;
float red = ((argb >> 16) & 0xff) / 255.0;
float green = ((argb >> 8) & 0xff) / 255.0;
glColor4f(red,green,blue,alpha);
}
-void OpenGL$GLDoubleBuffer::fillTrapezoid(jint x1, jint x2, jint y1, jint x3, jint x4, jint y2, jint color) {
+void OpenGL$GLPixelBuffer::fillTrapezoid(jint x1, jint x2, jint y1, jint x3, jint x4, jint y2, jint color) {
activateContext();
setColor(color);
glBegin(GL_QUADS);
glEnd();
}
-void OpenGL$GLDoubleBuffer::fillRect(jint x1, jint y1, jint x2, jint y2,jint color) {
+void OpenGL$GLPixelBuffer::fillRect(jint x1, jint y1, jint x2, jint y2,jint color) {
activateContext();
setColor(color);
glBegin(GL_QUADS);
glEnd();
}
-void OpenGL$GLDoubleBuffer::setClip(jint x1, jint y1, jint x2, jint y2) {
+void OpenGL$GLPixelBuffer::setClip(jint x1, jint y1, jint x2, jint y2) {
//fprintf(stderr,"setClip: %d %d %d %d\n",x1,y1,x2,y2);
if(x1==0 && y1==0 && x2==width && y2==height) {
if(glScissorEnabled) {
checkGLError();
}
-void OpenGL$GLDoubleBuffer::resetClip() {
+void OpenGL$GLPixelBuffer::resetClip() {
activateContext();
if(glScissorEnabled) {
glDisable(GL_SCISSOR_TEST);
public NotSupportedException(String s) { super(s); }
}
- public static abstract class GLDoubleBuffer extends DoubleBuffer {
+ public static abstract class GLPixelBuffer extends DoubleBuffer {
protected int width;
protected int height;
public int getWidth() { return width; }
private boolean glScissorEnabled = false;
- public GLDoubleBuffer(int width, int height) {
+ public GLPixelBuffer(int width, int height) {
this.width = width;
this.height = height;
}
#include <java/util/Hashtable.h>
#include <org/xwt/Box.h>
#include <org/xwt/Surface.h>
-#include <org/xwt/DoubleBuffer.h>
+#include <org/xwt/PixelBuffer.h>
#include <org/xwt/Picture.h>
#include <org/xwt/ByteStream.h>
#include <org/xwt/Platform.h>
#include <org/xwt/plat/Win32.h>
#include <org/xwt/plat/Win32$Win32Font.h>
#include <org/xwt/plat/Win32$Win32Surface.h>
-#include <org/xwt/plat/Win32$Win32DoubleBuffer.h>
+#include <org/xwt/plat/Win32$Win32PixelBuffer.h>
#include <org/xwt/plat/Win32$Win32Picture.h>
#include <org/xwt/util/Log.h>
#include <org/xwt/util/Semaphore.h>
}
-// Win32DoubleBuffer /////////////////////////////////////////////////////////////////////////
+// Win32PixelBuffer /////////////////////////////////////////////////////////////////////////
// This is a scratch area; when blitting a translucent image, we copy the underlying data here first.
// Since all drawing operations are single-threaded, it's safe to use a global here.
else \
StretchBlt(dest, dx1, dy1, dx2 - dx1, dy2 - dy1, src, sx1, sy1, sx2 - sx1, sy2 - sy1, op);
-void org::xwt::plat::Win32$Win32DoubleBuffer::drawPicture(org::xwt::Picture* source0,
+void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* source0,
jint dx1, jint dy1, jint dx2, jint dy2,
jint sx1, jint sy1, jint sx2, jint sy2) {
org::xwt::plat::Win32$Win32Picture* source = (org::xwt::plat::Win32$Win32Picture*)source0;
}
-void org::xwt::plat::Win32$Win32DoubleBuffer::drawString(jstring font, jstring text, jint x, jint y, jint color) {
+void org::xwt::plat::Win32$Win32PixelBuffer::drawString(jstring font, jstring text, jint x, jint y, jint color) {
org::xwt::plat::Win32$Win32Font* wf = org::xwt::plat::Win32::getFont(font);
SelectObject((HDC)hdc, (HFONT)(wf->hfont));
TextOut((HDC)hdc, x, y, buf, len);
}
-void org::xwt::plat::Win32$Win32DoubleBuffer::fillRect(jint x, jint y, jint x2, jint y2, jint color) {
+void org::xwt::plat::Win32$Win32PixelBuffer::fillRect(jint x, jint y, jint x2, jint y2, jint color) {
jint w = x2 - x;
jint h = y2 - y;
DeleteObject(brush);
}
-void org::xwt::plat::Win32$Win32Surface::blit(org::xwt::DoubleBuffer* s, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
+void org::xwt::plat::Win32$Win32Surface::blit(org::xwt::PixelBuffer* s, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
// we create the DC lazily to get around some strange race condition in WinXP
if (hdc == 0) hdc = (jint)GetDC((HWND)hwnd);
- BitBlt((HDC)hdc, dx, dy, dx2 - dx, dy2 - dy, (HDC)(((org::xwt::plat::Win32$Win32DoubleBuffer*)s)->hdc), sx, sy, SRCCOPY);
+ BitBlt((HDC)hdc, dx, dy, dx2 - dx, dy2 - dy, (HDC)(((org::xwt::plat::Win32$Win32PixelBuffer*)s)->hdc), sx, sy, SRCCOPY);
}
-void org::xwt::plat::Win32$Win32DoubleBuffer::natInit() {
+void org::xwt::plat::Win32$Win32PixelBuffer::natInit() {
hbitmap = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, w, h);
hdc = (jint)CreateCompatibleDC((HDC)org::xwt::plat::Win32::desktop_dc);
SetBkMode((HDC)hdc, TRANSPARENT);
SelectObject((HDC)hdc, (HBITMAP)hbitmap);
}
-void org::xwt::plat::Win32$Win32DoubleBuffer::setClip(jint x, jint y, jint x2, jint y2) {
+void org::xwt::plat::Win32$Win32PixelBuffer::setClip(jint x, jint y, jint x2, jint y2) {
clipx1 = x; clipx2 = x2; clipy1 = y; clipy2 = y2;
HRGN hrgn = CreateRectRgn(x, y, x2, y2);
SelectClipRgn((HDC)hdc, hrgn);
DeleteObject(hrgn);
}
-void org::xwt::plat::Win32$Win32DoubleBuffer::finalize() {
+void org::xwt::plat::Win32$Win32PixelBuffer::finalize() {
DeleteObject((void*)hdc);
DeleteObject((void*)hbitmap);
}
protected boolean _needsAutoClick() { return true; }
protected String getDescriptiveName() { return "GCJ Win32 Binary"; }
protected Surface _createSurface(Box b, boolean framed) { return new Win32Surface(b, framed); }
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Win32DoubleBuffer(w, h, (Win32Surface)owner); }
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Win32DoubleBuffer(w, h, (Win32Surface)owner); }
protected Picture _createPicture(int[] b, int w, int h) { return new Win32Picture(b, w, h); }
protected native int _getScreenWidth();
protected native int _getScreenHeight();
public native void setTitleBarText(String s);
public native void setIcon(Picture p);
public native void _dispose();
- public native void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
+ public native void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
}
}
- // Win32DoubleBuffer //////////////////////////////////////////////////////////////////////////
+ // Win32PixelBuffer //////////////////////////////////////////////////////////////////////////
- public static class Win32DoubleBuffer extends DoubleBuffer {
+ public static class Win32PixelBuffer extends DoubleBuffer {
int w = 0;
int h = 0;
public int getWidth() { return w; }
public native void natInit();
- public Win32DoubleBuffer(int w, int h, Win32Surface owner) {
+ public Win32PixelBuffer(int w, int h, Win32Surface owner) {
this.w = w;
this.h = h;
clipx2 = w;
#include <org/xwt/plat/X11.h>
#include <org/xwt/plat/X11$X11Surface.h>
#include <org/xwt/plat/X11$X11Picture.h>
-#include <org/xwt/plat/X11$X11DoubleBuffer.h>
+#include <org/xwt/plat/X11$X11PixelBuffer.h>
#include <org/xwt/util/Semaphore.h>
#include <org/xwt/Platform.h>
#include <java/lang/Long.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) < (b) ? (b) : (a))
-// X11DoubleBuffer //////////////////////////////////////////////////////////////////////
+// X11PixelBuffer //////////////////////////////////////////////////////////////////////
// ensures that the shared memory is at least size bytes; if not, allocates 3/2 * size
static void ensureShmSize(int size) {
}
}
-void org::xwt::plat::X11$X11DoubleBuffer::fastDrawPicture(org::xwt::Picture* s,
+void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s,
jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2) {
org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
XCopyArea(display, *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)), sx1, sy1, sx2 - sx1, sy2 - sy1, dx1, dy1);
}
-void org::xwt::plat::X11$X11DoubleBuffer::slowDrawPicture(org::xwt::Picture* s,
+void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2) {
org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
}
}
-void org::xwt::plat::X11$X11DoubleBuffer::finalize() {
+void org::xwt::plat::X11$X11PixelBuffer::finalize() {
if (shared_pixmap) {
XShmSegmentInfo *sinfo = (XShmSegmentInfo*)shm_segment;
XShmDetach(display, sinfo);
XFreeGC(display, *((GC*)clipped_gc));
}
-void org::xwt::plat::X11$X11DoubleBuffer::natInit() {
+void org::xwt::plat::X11$X11PixelBuffer::natInit() {
if (width == 0 || height == 0) return;
shared_pixmap &= shm_supported & shm_pixmaps_supported; // refuse to use shared pixmaps if we don't have shm
XChangeGC(display, (*((GC*)clipped_gc)), GCGraphicsExposures, &vm);
}
-void org::xwt::plat::X11$X11DoubleBuffer::createStipple(org::xwt::plat::X11$X11Picture* xpi) {
+void org::xwt::plat::X11$X11PixelBuffer::createStipple(org::xwt::plat::X11$X11Picture* xpi) {
stipple = (gnu::gcj::RawData*)malloc(sizeof(Pixmap));
(*((Pixmap*)stipple)) = XCreatePixmap(display, RootWindow(display, screen_num), width, height, 1);
XPutImage(display, (*((Pixmap*)stipple)), stipple_gc, &xi, 0, 0, 0, 0, width, height);
}
-void org::xwt::plat::X11$X11Surface::blit(org::xwt::DoubleBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
- org::xwt::plat::X11$X11DoubleBuffer *xdb = (org::xwt::plat::X11$X11DoubleBuffer*)db;
+void org::xwt::plat::X11$X11Surface::blit(org::xwt::PixelBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
+ org::xwt::plat::X11$X11PixelBuffer *xdb = (org::xwt::plat::X11$X11DoubleBuffer*)db;
XCopyArea(display, *((Pixmap*)xdb->pm), *((Window*)window), *((GC*)gc), sx, sy, dx2 - dx, dy2 - dy, dx, dy);
XFlush(display);
}
-void org::xwt::plat::X11$X11DoubleBuffer::fillRect (jint x, jint y, jint x2, jint y2, jint argb) {
+void org::xwt::plat::X11$X11PixelBuffer::fillRect (jint x, jint y, jint x2, jint y2, jint argb) {
jint w = x2 - x;
jint h = y2 - y;
XFillRectangle(display, (*((Pixmap*)pm)), (*((GC*)gc)), x, y, w, h);
}
-void org::xwt::plat::X11$X11DoubleBuffer::drawString(::java::lang::String* font, ::java::lang::String* text, jint x, jint y, jint argb) {
+void org::xwt::plat::X11$X11PixelBuffer::drawString(::java::lang::String* font, ::java::lang::String* text, jint x, jint y, jint argb) {
XRectangle rect;
rect.x = clipx, rect.y = clipy; rect.width = clipw; rect.height = cliph;
void org::xwt::plat::X11$X11Surface::setIcon(org::xwt::Picture* pic) {
org::xwt::plat::X11$X11Picture* p = ((org::xwt::plat::X11$X11Picture*)pic);
- org::xwt::plat::X11$X11DoubleBuffer* old_dbuf = p->doublebuf;
- p->buildDoubleBuffer(1);
+ org::xwt::plat::X11$X11PixelBuffer* old_dbuf = p->doublebuf;
+ p->buildPixelBuffer(1);
XWMHints xwmh;
memset(&xwmh, 0, sizeof(XWMHints));
xwmh.flags |= IconPixmapHint | IconMaskHint;
protected String[] _listFonts() { return fontList; }
protected Picture _createPicture(int[] data, int w, int h) { return new X11Picture(data, w, h); }
- protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new X11DoubleBuffer(w, h); }
+ protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new X11DoubleBuffer(w, h); }
protected Surface _createSurface(Box b, boolean framed) { return new X11Surface(b, framed); }
protected boolean _needsAutoClick() { return true; }
protected native int _getScreenWidth();
public native void syncCursor();
public native void _dispose();
public native void setLimits(int minw, int minh, int maxw, int maxh);
- public native void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
+ public native void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2);
public native void dispatchEvent(gnu.gcj.RawData ev);
public X11Surface(Box root, boolean framed) {
/**
* Implements a Picture. No special X11 structure is created
* unless the image has no alpha (in which case a
- * non-shared-pixmap DoubleBuffer is created), or all-or-nothing
- * alpha (in which case a non-shared-pixmap DoubleBuffer with a
+ * non-shared-pixmap PixelBuffer is created), or all-or-nothing
+ * alpha (in which case a non-shared-pixmap PixelBuffer with a
* stipple bitmap is created).
*/
public static class X11Picture extends Picture {
int width;
int height;
int[] data = null;
- public X11DoubleBuffer doublebuf = null;
+ public X11PixelBuffer doublebuf = null;
public int getWidth() { return width; }
public int getHeight() { return height; }
else if ((data[i] & 0xFF000000) != 0x00)
return;
- buildDoubleBuffer(needsStipple);
+ buildPixelBuffer(needsStipple);
}
- void buildDoubleBuffer(boolean needsStipple) {
+ void buildPixelBuffer(boolean needsStipple) {
if (doublebuf != null) return;
// no point in using a shared pixmap since we'll only write to this image once
- X11DoubleBuffer b = new X11DoubleBuffer(width, height, false);
+ X11PixelBuffer b = new X11DoubleBuffer(width, height, false);
b.drawPicture(this, 0, 0);
if (needsStipple) b.createStipple(this);
doublebuf = b;
}
/**
- * An X11DoubleBuffer is implemented as an X11 pixmap. "Normal"
- * DoubleBuffers will use XShm shared pixmaps if
- * available. X11DoubleBuffers created to accelerate Pictures
+ * An X11PixelBuffer is implemented as an X11 pixmap. "Normal"
+ * PixelBuffers will use XShm shared pixmaps if
+ * available. X11PixelBuffers created to accelerate Pictures
* with all-or-nothing alpha will not use shared pixmaps, however
* (since they are only written to once.
*/
- public static class X11DoubleBuffer extends DoubleBuffer {
+ public static class X11PixelBuffer extends DoubleBuffer {
int clipx, clipy, clipw, cliph;
int width;
int height;
- /** DoubleBuffers of X11Pictures can have stipples -- the stipple of the Picture */
+ /** PixelBuffers of X11Pictures can have stipples -- the stipple of the Picture */
RawData stipple = null;
- /** Sets the DoubleBuffer's internal stipple to the alpha==0x00 regions of xpi */
+ /** Sets the PixelBuffer's internal stipple to the alpha==0x00 regions of xpi */
public native void createStipple(X11Picture xpi);
RawData pm; // Pixmap (if any) representing this Picture
RawData gc; // Graphics Context on pm (never changes, so it's fast)
RawData clipped_gc; // Graphics Context on pm, use this one if you need a clip/stipple
- /** DoubleBuffer mode */
- public X11DoubleBuffer(int w, int h) { this(w, h, true); }
- public X11DoubleBuffer(int w, int h, boolean shared_pixmap) {
+ /** PixelBuffer mode */
+ public X11PixelBuffer(int w, int h) { this(w, h, true); }
+ public X11PixelBuffer(int w, int h, boolean shared_pixmap) {
width = clipw = w;
height = cliph = h;
clipx = clipy = 0;