public int maxwidth = Integer.MAX_VALUE;
public int minheight = 0;
public int maxheight = Integer.MAX_VALUE;
+ public int minwidth() { return minwidth; }
+ public int minheight() { return minheight; }
+ public int maxwidth() { return maxwidth; }
+ public int maxheight() { return maxheight; }
private short rows = 1;
private short cols = 0;
private short rowspan = 1;
public interface PixelBuffer {
public abstract void drawLine(int x1, int y1, int x2, int y2, int color);
public abstract void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
+ public abstract void drawPicture(Picture p, int x, int y, int x1, int y1, int w, int h); // names may be wrong
public abstract void drawGlyph(Font.Glyph source, int dx1, int dy1, int cx1, int cy1, int cx2, int cy2, int rgb, int bg);
public abstract void stroke(Polygon p, int color);
public abstract void fill(Polygon p, Paint paint);
float y1 = p.y[p.edges[i]];\r
float x2 = p.x[p.edges[i]+1];\r
float y2 = p.y[p.edges[i]+1];\r
- buf.drawLine((int)Math.floor(x1), (int)Math.floor(y1), (int)Math.ceil(x2), (int)Math.ceil(y2), 1, color, false);\r
+ buf.drawLine((int)Math.floor(x1), (int)Math.floor(y1), (int)Math.ceil(x2), (int)Math.ceil(y2), color);\r
}\r
}\r
\r
}
}
- public void dirty(int x, int y, int w, int h) {
- dirtyRegions.dirty(x, y, w, h);
- Refresh();
- }
+ // This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not
+ public void Dirty(int x, int y, int w, int h) { dirty(x,y,w,h); }
+ public void dirty(int x, int y, int w, int h) { dirtyRegions.dirty(x, y, w, h); Refresh(); }
public static Surface fromBox(Box b) {
// FIXME use a hash table here
if (y+h > root.height) h = root.height - y;
if (w <= 0 || h <= 0) continue;
- root.render(0, 0, x, y, x + w, y + h, this, identity);
- drawPicture(scarImage, 0, root.height - scarImage.height, x, y, x+w, y+h);
+ root.render(0, 0, x, y, x + w, y + h, this.getPixelBuffer(), identity);
+ getPixelBuffer().drawPicture(scarImage, 0, root.height - scarImage.height, x, y, x+w, y+h);
if (abort) {
// x,y,w,h is only partially reconstructed, so we must be careful not to re-blit it
// Default PixelBuffer implementation /////////////////////////////////////////////////////////
- public static abstract class DoubleBufferedSurface extends Surface {
+ public static abstract class DoubleBufferedSurface extends Surface implements PixelBuffer {
public DoubleBufferedSurface(Box root) { super(root); }
PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
DirtyList screenDirtyRegions = new DirtyList();
+ public PixelBuffer getPixelBuffer() { return this; }
public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
screenDirtyRegions.dirty(cx1, cy1, cx2 - cx1, cy2 - cy1);
backbuffer.drawPicture(source, dx, dy, cx1, cy1, cx2, cy2);
}
- public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int argb) {
+ public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int argb, int bc) {
screenDirtyRegions.dirty(cx1, cy1, cx2 - cx1, cy2 - cy1);
- backbuffer.drawGlyph(source, dx, dy, cx1, cy1, cx2, cy2, argb);
+ backbuffer.drawGlyph(source, dx, dy, cx1, cy1, cx2, cy2, argb, bc);
+ }
+
+ public void stroke(Polygon p, int color) {
+ // FIXME
+ }
+
+ public void fill(Polygon p, Paint paint) {
+ // FIXME
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2, int color) {
+ screenDirtyRegions.dirty(x1, y1, x2, y2);
+ backbuffer.drawLine(x1, y1, x2, y2, color);
}
+ public abstract void _fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color) {
+ // we don't dirty trapezoid-fills since it's faster to just do them directly than to copy from the backbuffer
screenDirtyRegions.dirty(Math.min(x1, x3), y1, Math.max(x2, x4) - Math.min(x1, x3), y2 - y1);
backbuffer.fillTrapezoid(x1, x2, y1, x3, x4, y2, color);
+ //_fillTrapezoid(x1, x2, y1, x3, x4, y2, color);
}
public void render() {
}
}
- /** This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not */
+ // This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not
public final void Dirty(int x, int y, int w, int h) {
screenDirtyRegions.dirty(x, y, w, h);
Scheduler.renderAll();
super.dirty(x, y, w, h);
}
- /** copies a region from the doublebuffer to this surface */
+ // copies a region from the doublebuffer to this surface
public abstract void blit(PixelBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2);
-
+ protected void blit(int x, int y, int w, int h) {
+ blit(backbuffer, x, y, x, y, w + x, h + y);
+ }
}
}
protected org.ibex.graphics.Font.Glyph _createGlyph(org.ibex.graphics.Font f, char c) { return new AWTGlyph(f, c); }
protected static class AWTGlyph extends org.ibex.graphics.Font.Glyph {
private Image i = null;
+ private Image i2 = null;
private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
// this doesn't work on Win32 because the JVM is broken
}
}
- protected static class AWTPixelBuffer extends PixelBuffer {
+ protected static class AWTPixelBuffer implements PixelBuffer {
protected Image i = null;
protected Graphics g = null;
-
+ protected AWTSurface surface = null;
+
/** JDK1.1 platforms require that a component be associated with each off-screen buffer */
static Component component = null;
- protected AWTPixelBuffer() { }
+ public AWTPixelBuffer(Image i) { this.i = i; }
+ public AWTPixelBuffer(AWTSurface s) { this.surface = s; }
public AWTPixelBuffer(int w, int h) {
synchronized(AWTPixelBuffer.class) {
if (component == null) {
}
}
i = component.createImage(w, h);
- g = i.getGraphics();
+ }
+ Graphics getGraphics() {
+ if (surface != null) return surface.getGraphics();
+ if (g != null) return g;
+ if (i != null) { g = i.getGraphics(); return g; }
+ return null;
}
- public int getHeight() { return i == null ? 0 : i.getHeight(null); }
- public int getWidth() { return i == null ? 0 : i.getWidth(null); }
-
public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
((AWTPicture)source).init();
+ Graphics g = getGraphics();
g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
g.drawImage(((AWTPicture)source).i, dx, dy, null);
- g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
+ if (i != null) g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
}
- /** implemented with java.awt 1.1's setXORMode() */
- public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
-
- // XOR the target region
- g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
- g.setColor(new java.awt.Color(0x0, 0x0, 0x0));
- g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
-
- // blacken the area we want the glyph to cover
- g.setPaintMode();
- g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
- g.drawImage(((AWTGlyph)source).getImage(), dx, dy, null);
- g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
+ public void drawLine(int x1, int y1, int x2, int y2, int rgb) {
+ Graphics g = getGraphics();
+ ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setColor(new java.awt.Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+ g.drawLine(x1, y1, x2, y2);
+ }
- // XOR back, turning black into the chosen rgb color
- g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
- g.setColor(new java.awt.Color(0x0, 0x0, 0x0));
- g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+ public void stroke(org.ibex.graphics.Polygon p, int color) { p.stroke(this, color); }
+ public void fill(org.ibex.graphics.Polygon p, org.ibex.graphics.Paint paint) { p.fill(this, paint); }
- // restore the graphics context
- g.setPaintMode();
+ private static int[] xa = new int[4];
+ private static int[] ya = new int[4];
+ public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) {
+ Graphics g = getGraphics();
+ ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ g.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
+ xa[0]=x1;
+ xa[1]=x2;
+ xa[2]=x4;
+ xa[3]=x3;
+ ya[0]=y1;
+ ya[1]=y1;
+ ya[2]=y2;
+ ya[3]=y2;
+ g.fillPolygon(xa, ya, 4);
}
- // FIXME: try to use os acceleration
- public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) {
+ // this doens't seem to work on Windows
+ public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2,
+ int rgb, int argb) {
+ Image i = ((AWTGlyph)source).getImage();
+ if (((AWTGlyph)source).i2 == null)
+ ((AWTGlyph)source).i2 = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_ARGB);
+ Image i2 = ((AWTGlyph)source).i2;
+ Graphics g2 = i2.getGraphics();
+ g2.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
+ g2.fillRect(0, 0, i2.getWidth(null), i2.getHeight(null));
+ g2.drawImage(i, 0, 0, null);
+ Graphics g = getGraphics();
+ g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
+ g.drawImage(i2, dx, dy, i2.getWidth(null), i2.getHeight(null), null);
g.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
- if (x1 == x3 && x2 == x4) {
- g.fillRect(x1, y1, x4 - x1, y2 - y1);
- } else for(int y=y1; y<y2; y++) {
- int _x1 = (int)Math.floor((y - y1) * (x3 - x1) / (y2 - y1) + x1);
- int _y1 = (int)Math.floor(y);
- int _x2 = (int)Math.ceil((y - y1) * (x4 - x2) / (y2 - y1) + x2);
- int _y2 = (int)Math.floor(y) + 1;
- if (_x1 > _x2) { int _x0 = _x1; _x1 = _x2; _x2 = _x0; }
- g.fillRect(_x1, _y1, _x2 - _x1, _y2 - _y1);
- }
+ g.fillRect(cx1, cy1, dx - cx1, cy2 - cy1);
+ g.fillRect(cx1, cy1, cx2 - cx1, dy - cy1);
+ g.fillRect(dx+i2.getWidth(null), cy1, cx2 - (dx+i2.getWidth(null)), cy2 - cy1);
+ g.fillRect(cx1, dy+i2.getHeight(null), cx2 - cx1, cy2 - (dy+i2.getHeight(null)));
+ g.setClip(0, 0, 1000, 1000);
}
}
protected static class AWTSurface extends Surface.DoubleBufferedSurface
implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, WindowListener {
- public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
- insets = (frame == null ? window : frame).getInsets();
- window.getGraphics().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);
- }
-
- /** if (component instanceof Frame) then frame == window else frame == null */
+ protected AWTPixelBuffer pb = null;
+ private Graphics g = null;
Frame frame = null;
Window window = null;
+
+ public void blit(PixelBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2) {
+ getGraphics().drawImage(((AWTPixelBuffer)source).i, sx, sy, sx+(dx2-dx), sy+(dy2-dy), dx, dy, dx2, dy2, null);
+ }
/** our component's insets */
protected Insets insets = new Insets(0, 0, 0, 0);
-
- /** some JDKs let us recycle a single Dimension object when calling getSize() */
- Dimension singleSize = new Dimension();
-
+ Graphics getGraphics() { if (g==null) g=window==null ? frame.getGraphics() : window.getGraphics(); return g; }
+ public void _fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color) {
+ if (pb ==null) pb = new AWTPixelBuffer(this);
+ pb.fillTrapezoid(x1, x2, y1, x3, x4, y2, color);
+ }
+ //public PixelBuffer getPixelBuffer() { return pb != null ? pb : (pb = new AWTPixelBuffer(this)); }
+ public void setMinimumSize(int minx, int miny, boolean resizable) { if (frame != null) frame.setResizable(resizable); }
public void toBack() { if (window != null) window.toBack(); }
public void toFront() { if (window != null) window.toFront(); }
public void setLocation() { window.setLocation(root.x, root.y); }
public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
- public void _setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
+ public void _setSize(int width, int height) {
+ g = null;
+ window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
public void setInvisible(boolean b) { window.setVisible(!b); }
protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
protected void _setMaximized(boolean b) {
}
window.setLocation(new Point(0, 0));
window.setSize(Toolkit.getDefaultToolkit().getScreenSize());
+ g = null;
}
class InnerFrame extends Frame {
public InnerFrame() throws java.lang.UnsupportedOperationException { }
- public Dimension getMinimumSize() {
- return new Dimension(root == null ? 0 : root.minwidth, root == null ? 0 : root.minheight); }
+ public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
public void update(Graphics gr) { paint(gr); }
public void paint(Graphics gr) {
+ // Mac OS X Jdk1.4 Bug: after a componentResized(), you must wait for the paint() before you redraw
Rectangle r = gr.getClipBounds();
// ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
componentResized(window.getWidth() - insets.left - insets.right,
window.getHeight() - insets.top - insets.bottom);
- Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+ //Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+ g = gr;
+ blit(r.x - insets.left, r.y - insets.top, r.width, r.height);
+ g.setClip(0, 0, getWidth(), getHeight());
}
}
class InnerWindow extends Window {
public InnerWindow() throws java.lang.UnsupportedOperationException { super(new Frame()); }
- public Dimension getMinimumSize() {
- return new Dimension(root == null ? 0 : root.minwidth, root == null ? 0 : root.minheight); }
+ public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
public void update(Graphics gr) { paint(gr); }
public void paint(Graphics gr) {
+ g = null;
Rectangle r = gr.getClipBounds();
Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
}
}
- public void setMinimumSize(int minx, int miny, boolean resizable) { if (frame != null) frame.setResizable(resizable); }
-
private int oldfill = 0x0;
public void render() {
// useful optimizatin;
componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
}
- public void componentResized(int newwidth, int newheight) { SizeChange(newwidth, newheight); }
+ public void componentResized(int newwidth, int newheight) {
+ SizeChange(newwidth, newheight);
+ //if (newwidth > root.width) Dirty(root.width, 0, newwidth-root.width, newheight);
+ //if (newheight > root.height) Dirty(0, root.height, newwidth, newheight-root.height);
+ }
public void keyTyped(KeyEvent k) { }
public void keyPressed(KeyEvent k) { KeyPressed(translateKey(k)); }
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2003 Adam Megacz, see the COPYING file for licensing [LGPL]
// Authors: Brian Alliet and Evan Jones
#ifndef __APPLE_CC__
#define FSF_GCC
#include <org/ibex/plat/Darwin.h>
#include <org/ibex/plat/Darwin$CarbonSurface.h>
+#include <org/ibex/plat/Darwin$GLCarbonSurface$GLCarbonSurfacePixelBuffer.h>
#include <org/ibex/plat/Darwin$GLCarbonSurface.h>
#include <org/ibex/plat/Darwin$GLCarbonPixelBuffer.h>
#include <org/ibex/plat/Darwin$CarbonMessage.h>
Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData;
Rect rect;
WC(GetRegionBounds)(inClientPaintRgn, &rect);
- surface->Dirty(rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top);
+ surface->dirty(rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top);
return noErr;
}
WindowAttributes attr = kWindowStandardHandlerAttribute|
(framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute : 0);
OSStatus r;
- rect.top = rect.left = 0;
- rect.bottom = rect.right = 10;
- winWidth = winHeight = 10;
+ rect.top = rect.left = 100;
+ rect.bottom = rect.right = 200;
+ winWidth = winHeight = 100;
r = WC(CreateNewWindow)(wc, attr, &rect, &window);
checkStatus(r,"CreateNewWindow");
WC(aglSetCurrentContext)(ctx);
}
+void Darwin$GLCarbonSurface$GLCarbonSurfacePixelBuffer::activateContext() {
+ // hooray for Brian's forward-thinking design abstractions, because I have no idea what the fuck this does, but it works
+ AGLContext ctx = (AGLContext) rawCTX;
+ WC(aglSetCurrentContext)(ctx);
+}
+
void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
WindowRef window = (WindowRef) rawWindowRef;
AGLContext ctx = (AGLContext) rawCTX;
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL]
// Authors: Brian Alliet and Evan Jones
package org.ibex.plat;
protected native void activateSharedContext();
}
- static abstract class CarbonSurface extends Surface.DoubleBufferedSurface {
+ static abstract class CarbonSurface extends Surface {
RawData rawWindowRef;
int modifiers;
int winWidth;
private native void natInit();
private static native void natCleanup(RawData rawWindowRef, RawData rawCTX);
-
private static final int fixupDimension(CarbonOpenGL gl, int n) {
if(!gl.rectangularTextures) n = OpenGL.roundToPowerOf2(n);
return Math.min(n,gl.maxAglSurfaceTexSize);
private final native void natInit();
private final native void flush();
private final native void clear();
+
+ private PixelBuffer pb;
+ public PixelBuffer getPixelBuffer() { return pb; }
+
+ static class GLCarbonSurfacePixelBuffer extends GLCarbonPixelBuffer {
+ RawData rawCTX;
+ public native void activateContext();
+ public GLCarbonSurfacePixelBuffer(RawData rawCTX, CarbonOpenGL gl) {
+ super(500, 500, gl);
+ this.rawCTX = rawCTX;
+ }
+ }
public GLCarbonSurface(Box root, boolean framed, CarbonOpenGL gl) {
super(root,framed);
this.gl = gl;
natInit();
+ pb = new GLCarbonSurfacePixelBuffer(rawCTX, gl);
}
public void setLimits(int mnw,int mnh, int mxw, int mxh) {
reshape(winWidth,winHeight);
clear();
- Dirty(0,0,winWidth,winHeight);
+ dirty(0,0,winWidth,winHeight);
}
super.render();
flush();
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
+import java.awt.geom.*;
import java.net.*;
import java.util.*;
import org.ibex.util.*;
public static class Java2Surface extends AWTSurface {
public Java2Surface(Box root, boolean framed) { super(root, framed); }
-
protected void _setMinimized(boolean b) {
if (frame == null) Log.info(this, "JDK 1.2 can only minimize frames, not windows");
else if (b) frame.setState(java.awt.Frame.ICONIFIED);
private SampleModel sm = null;
private DataBuffer buf = null;
- // this doens't seem to work on Windows
- public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
- Image i2 = ((AWTGlyph)source).getImage();
- Graphics2D g2 = (Graphics2D)i.getGraphics();
- g2.setComposite(AlphaComposite.DstOut);
- g2.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
- g2.drawImage(i2, dx, dy, null);
- g2.setComposite(AlphaComposite.DstOver);
- g2.setColor(new java.awt.Color((rgb & 0x00FF0000) >> 16, (rgb & 0x0000FF00) >> 8, (rgb & 0x000000FF)));
- g2.fillRect(dx, dy, cx2 - dx, cy2 - dy);
- g2.drawImage(i2, 0, 0, null);
- g2.setClip(0, 0, i.getWidth(null), i.getHeight(null));
+ private static int[] xs = new int[65535];
+ private static int[] ys = new int[65535];
+ private static GeneralPath gp = new GeneralPath();
+
+ public void fill(org.ibex.graphics.Polygon p, org.ibex.graphics.Paint paint) { fillStroke(p, paint, true, false); }
+ public void stroke(org.ibex.graphics.Polygon p, org.ibex.graphics.Paint paint) { fillStroke(p, paint, false, true); }
+ public void fillStroke(org.ibex.graphics.Polygon p, org.ibex.graphics.Paint paint, boolean fill, boolean stroke) {
+ if (g == null) g = getGraphics();
+ ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ int argb = ((org.ibex.graphics.Paint.SingleColorPaint)paint).color;
+ g.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
+ gp.reset();
+ gp.setWindingRule(GeneralPath.WIND_EVEN_ODD);
+ for(int j=0; j<p.numcontours; j++) {
+ if (p.contours[j+1] <= p.contours[j]) continue;
+ gp.moveTo(p.x[p.contours[j]], p.y[p.contours[j]]);
+ for(int i=p.contours[j]+1; i<p.contours[j+1]; i++) gp.lineTo(p.x[i], p.y[i]);
+ gp.closePath();
+ }
+ if (fill) ((Graphics2D)g).fill(gp);
+ if (stroke) ((Graphics2D)g).draw(gp);
}
public Java2PixelBuffer(int w, int h) {
protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
public Java4() {
java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
-
+ /*
// Properties for Apple JDK 1.4
System.setProperty("apple.awt.showGrowBox", "false");
System.setProperty("apple.awt.graphics.EnableLazyDrawing", "40");
System.setProperty("apple.awt.graphics.EnableLazyDrawing", "true");
System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
+ */
}
protected Surface __createSurface(final Box root, final boolean framed) { return new Java4Surface(root, framed); }
public static class Java4Surface extends Java2Surface implements WindowStateListener, MouseWheelListener {
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2003 Adam Megacz, see the COPYING file for licensing [LGPL]
// Author: Brian Alliet
// IMPROVMENT: use alpha testing? might be faster
#include <org/ibex/plat/OpenGL.h>
+#include <org/ibex/graphics/PixelBuffer.h>
+#include <org/ibex/graphics/Polygon.h>
#include <org/ibex/plat/OpenGL$GLPixelBuffer.h>
#include <org/ibex/plat/OpenGL$GLPicture.h>
#include <org/ibex/plat/OpenGL$RectGLPicture.h>
} glEnd();
}
+void OpenGL$GLPixelBuffer::natFill(org::ibex::graphics::Polygon* p, jint argb) {
+ activateContext();
+ setColor(argb);
+ for(jint contour=0; contour < p->numcontours; contour++) {
+ glBegin(GL_POLYGON); {
+ for(jint i = elements(p->contours)[contour]; i < elements(p->contours)[contour+1]; i++) {
+ glVertex3f(elements(p->x)[i], elements(p->y)[i], 0.0f );
+ } glEnd();
+ }
+ }
+}
+
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) {
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL]
// Author: Brian Alliet
package org.ibex.plat;
public NotSupportedException(String s) { super(s); }
}
- public static abstract class GLPixelBuffer extends PixelBuffer {
+ public static abstract class GLPixelBuffer implements PixelBuffer {
protected int width;
protected int height;
public int getWidth() { return width; }
private boolean glScissorEnabled = false;
+ // FIXME: HUGE HACK!
+ public GLPixelBuffer() { width = 500; height = 500; }
+
public GLPixelBuffer(int width, int height) {
this.width = width;
this.height = height;
public native void setClip(int x, int y, int x2, int y2);
public native void resetClip();
public native void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
-
- public void drawString(String font, String text, int x, int y, int color) {
- //System.out.println("drawString(): " + text);
+ public void drawLine(int x1, int y1, int x2, int y2, int color) {
+ // FIXME
+ fillTrapezoid(x1, x1, y1, x2, x2, y2, color);
}
- public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+ public void stroke(Polygon p, int color) { p.stroke(this, color); }
+ public native void natFill(Polygon p, int color);
+ public void fill(Polygon p, Paint paint) { natFill(p, ((Paint.SingleColorPaint)paint).color); }
+
+ public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy,
+ int cx1, int cy1, int cx2, int cy2, int rgb, int pc) {
drawPicture_(((org.ibex.plat.Platform.DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb);
}
public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
String os_name = System.getProperty("os.name", "");
String os_version = System.getProperty("os.version", "");
String platform_class = null;
-
+
if (vendor.startsWith("Free Software Foundation")) {
if (os_name.startsWith("Window")) platform_class = "Win32";
else if (os_name.startsWith("Linux")) platform_class = "Linux";
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
#include "GCJ.cc"
// we have to do this because the jpeg libraries use the symbol 'INT32'
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL]
package org.ibex.plat;
import org.ibex.util.*;
HTTP.Proxy ret = new HTTP.Proxy();
if (container[2] != null) {
- // FIXME!!!
+ // FIXME
//ret.proxyAutoConfigFunction = HTTP.Proxy.getProxyAutoConfigFunction(container[2]);
if (ret.proxyAutoConfigFunction != null) return ret;
}
// Win32Surface ////////////////////////////////////////////////////////////////////////////
- public static class Win32Surface extends Surface.DoubleBufferedSurface {
+ public static class Win32Surface extends Surface {
+
+ public PixelBuffer getPixelBuffer() { return null; } // FIXME
+ // hack
+ String cursor;
+
/** used to block while waiting for the message pump thread to create a hwnd for us */
public Semaphore hwndCreated = new Semaphore();
// Win32PixelBuffer //////////////////////////////////////////////////////////////////////////
- public static class Win32PixelBuffer extends PixelBuffer {
+ public static class Win32PixelBuffer implements PixelBuffer {
+ public void drawLine(int x1, int y1, int x2, int y2, int color) { }
+ public void drawGlyph(Font.Glyph source, int dx1, int dy1, int cx1, int cy1, int cx2, int cy2, int rgb, int pc){}
+ public void stroke(Polygon p, int color){}
+ public void fill(Polygon p, Paint paint){}
int w = 0;
int h = 0;
((Win32Picture)source).init();
drawPicture(source, dx, dy, cx1, cy1, cx2, cy2, 0, false);
}
- public void drawGlyph(org.ibex.graphics.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+ public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
Win32Picture p = ((Win32Picture)((Platform.DefaultGlyph)source).getPicture());
p.init();
drawPicture(p, dx, dy, cx1, cy1, cx2, cy2, rgb, true);
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
+// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
+// see below for copyright information on the second portion of this file
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL]
package org.ibex.plat;
import gnu.gcj.RawData;
// X11Surface /////////////////////////////////////////////////////
+
/** Implements a Surface as an X11 Window */
- public static class X11Surface extends Surface.DoubleBufferedSurface {
+ public static class X11Surface extends Surface {
+ public PixelBuffer getPixelBuffer() { return null; } // FIXME
+
gnu.gcj.RawData window;
gnu.gcj.RawData gc;
boolean framed = false;
* with all-or-nothing alpha will not use shared pixmaps, however
* (since they are only written to once.
*/
- public static class X11PixelBuffer extends PixelBuffer {
+ public static class X11PixelBuffer implements PixelBuffer {
+
+ public void drawLine(int x1, int y1, int x2, int y2, int color) { }
+ public void drawGlyph(Font.Glyph source, int dx1, int dy1, int cx1, int cy1, int cx2, int cy2, int rgb, int pc){}
+ public void stroke(Polygon p, int color){}
+ public void fill(Polygon p, Paint paint){}
int clipx, clipy, clipw, cliph;
int width;