From: megacz Date: Fri, 30 Jan 2004 07:38:20 +0000 (+0000) Subject: 2003/09/27 06:42:27 X-Git-Tag: RC3~534 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=74872f23809fded481595225bd59115f521ca171;p=org.ibex.core.git 2003/09/27 06:42:27 darcs-hash:20040130073820-2ba56-ff97c93cd0bcb94e7d077c9c7116cd70f68735a0.gz --- diff --git a/src/org/xwt/plat/OpenGL.cc b/src/org/xwt/plat/OpenGL.cc index c7a1002..8200b16 100644 --- a/src/org/xwt/plat/OpenGL.cc +++ b/src/org/xwt/plat/OpenGL.cc @@ -96,17 +96,6 @@ void OpenGL$GLPixelBuffer::fillTrapezoid(jint x1, jint x2, jint y1, jint x3, jin glEnd(); } -void OpenGL$GLPixelBuffer::fillRect(jint x1, jint y1, jint x2, jint y2,jint color) { - activateContext(); - setColor(color); - glBegin(GL_QUADS); - glVertex3f(x1,y2,0.0f ); - glVertex3f(x2,y2,0.0f ); - glVertex3f(x2,y1,0.0f ); - glVertex3f(x1,y1,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) { diff --git a/src/org/xwt/plat/OpenGL.java b/src/org/xwt/plat/OpenGL.java index 9f6d669..510693a 100644 --- a/src/org/xwt/plat/OpenGL.java +++ b/src/org/xwt/plat/OpenGL.java @@ -74,7 +74,6 @@ abstract class OpenGL { public native void setClip(int x, int y, int x2, int y2); public native void resetClip(); - public native void fillRect(int x, int y, int x2, int y2, int color); 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) { diff --git a/src/org/xwt/plat/Win32.java b/src/org/xwt/plat/Win32.java index b57109c..f006190 100644 --- a/src/org/xwt/plat/Win32.java +++ b/src/org/xwt/plat/Win32.java @@ -269,6 +269,19 @@ public class Win32 extends GCJ { drawPicture(source, x, y, x + source.getWidth(), y + source.getHeight(), 0, 0, source.getWidth(), source.getHeight()); } + // FIXME: try to use os acceleration + public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) { + if (x1 == x3 && x2 == x4) { + fillRect(x1, y1, x4, y2, argb); + } else for(int y=y1; y _x2) { int _x0 = _x1; _x1 = _x2; _x2 = _x0; } + fillRect(_x1, _y1, _x2, _y2, argb); + } + } } } diff --git a/src/org/xwt/plat/X11.java b/src/org/xwt/plat/X11.java index 5f579e4..a8d948c 100644 --- a/src/org/xwt/plat/X11.java +++ b/src/org/xwt/plat/X11.java @@ -125,11 +125,10 @@ public class X11 extends POSIX { if (doublebuf != null) return; // no point in using a shared pixmap since we'll only write to this image once X11PixelBuffer b = new X11PixelBuffer(width, height, false); - b.drawPicture(this, 0, 0); + b.drawPicture(this, 0, 0, width, height, 0, 0, width, height); if (needsStipple) b.createStipple(this); doublebuf = b; } - } /** @@ -176,10 +175,6 @@ public class X11 extends POSIX { cliph = y2 - y; if (cliph < 0) cliph = 0; } - public void drawPicture(Picture source, int x, int y) { - drawPicture(source, x, y, x + source.getWidth(), y + source.getHeight(), 0, 0, source.getWidth(), source.getHeight()); - } - public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) { if (!(dx2 - dx1 != sx2 - sx1 || dy2 - dy1 != sy2 - sy1) && ((X11Picture)source).doublebuf != null) fastDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2); @@ -199,6 +194,19 @@ public class X11 extends POSIX { public native void fillRect(int x, int y, int x2, int y2, int color); public native void finalize(); + // FIXME: try to use os acceleration + public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) { + if (x1 == x3 && x2 == x4) { + fillRect(x1, y1, x4, y2, argb); + } else for(int y=y1; y _x2) { int _x0 = _x1; _x1 = _x2; _x2 = _x0; } + fillRect(_x1, _y1, _x2, _y2, argb); + } + } } } diff --git a/src/org/xwt/translators/SVG.java b/src/org/xwt/translators/SVG.java index 9abab1d..8c22dd0 100644 --- a/src/org/xwt/translators/SVG.java +++ b/src/org/xwt/translators/SVG.java @@ -2,8 +2,277 @@ package org.xwt.translators; import java.util.*; +// FIXME: need to support style sheets and the 'style=' attribute +// FIXME: need to convert markers into subboxes public class SVG { + /* + public static void parseNode(String name, String[] keys, Object[] vals, Template t) { + Hash h = new Hash(); + for(int i=0; iname property * / + Hashtable glyphByName = new Hashtable(); + + / ** linked list of glyphs, stored by the first character of their unicode property * / + Hashtable glyphByUnicode = new Hashtable(); + + // a Glyph in an VectorGraphics font + public static class Glyph { + + // FIXME: lang attribute + boolean isVerticallyOriented = false; + Template t = null; + Box b = null; + + float horiz_adv_x = 0; + float vert_origin_x = 0; + float vert_origin_y = 0; + float vert_adv_y = 0; + + String unicode = null; + + // forms the linked list in glyphByUnicode; glyphs appear in the order specified in the font + public Glyph next = null; + + Glyph(String name, String unicode, Template t, VectorGraphics.Font f) { + if (unicode != null) + if (f.glyphByUnicode.get(unicode.substring(0, 1)) == null) { + f.glyphByUnicode.put(unicode.substring(0, 1), this); + } else { + Glyph g; + for(g = (Glyph)f.glyphByUnicode.get(unicode.substring(0, 1)); g.next != null; g = g.next); + g.next = this; + } + if (name != null) f.glyphByUnicode.put(name, this); + this.unicode = unicode; + this.t = t; + horiz_adv_x = f.horiz_adv_x; + vert_origin_x = f.vert_origin_x; + vert_origin_y = f.vert_origin_y; + vert_adv_y = f.vert_adv_y; + } + public void render(DoubleBuffer buf, int x, int y, int fillcolor, int strokecolor, float scaleFactor) { + // FEATURE: make b double-buffered for increased performance + if (b == null) { + b = new Box(t, new org.xwt.util.Vec(), new org.xwt.util.Vec(), null, 0, 0); + b.put("absolute", Boolean.TRUE); + b.prerender(); + t = null; + } + // FIXME + b.put("width", new Integer(1000)); + b.put("height", new Integer(1000)); + b.fillcolor = fillcolor; + b.strokecolor = strokecolor; + + // we toss an extra flip on the ctm so that fonts stick "up" instead of down + b.render(0, 0, buf.getWidth(), buf.getHeight(), buf, + Affine.flip(false, true).multiply(Affine.scale(scaleFactor, scaleFactor).multiply(Affine.translate(x, y))).multiply(buf.a)); + } + } + } + */ + + /** Copied verbatim from the SVG specification */ public static Hashtable colors = new Hashtable(400); static {