2003/11/17 10:18:32
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:44 +0000 (07:41 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:44 +0000 (07:41 +0000)
darcs-hash:20040130074144-2ba56-d00b265b1c09f697204132c3cbeb7dfac7dbedaf.gz

src/org/xwt/Font.java
src/org/xwt/Main.java
src/org/xwt/Platform.java
src/org/xwt/Template.java
src/org/xwt/XWT.java
src/org/xwt/plat/Java2.java

index 19c1a5c..c9f7566 100644 (file)
@@ -63,7 +63,7 @@ public class Font {
             if (g.p == null) {
                 glyphsToBeRendered.prepend(g);
                 encounteredUnrenderedGlyph = true;
-            } else {
+            } else if (!encounteredUnrenderedGlyph) {
                 if (pb != null && g.p != null)
                     pb.drawPictureAlphaOnly(g.p, x + width, y + g.font.max_ascent - g.baseline, cx1, cy1, cx2, cy2, textcolor);
                 width += g.advance;
@@ -78,7 +78,11 @@ public class Font {
             }
             callback.perform();
         }});
-        if (!latinCharsPreloaded) for(int i=32; i<128; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+        if (!latinCharsPreloaded) {
+            for(int i=48; i<57; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+            for(int i=32; i<47; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+            for(int i=57; i<128; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
+        }
         if (!latinCharsPreloaded || encounteredUnrenderedGlyph) Scheduler.add(glyphRenderingTask);
         latinCharsPreloaded = true;
         return ((((long)width) << 32) | (long)(height & 0xffffffffL));
index b725805..09f1b31 100644 (file)
@@ -84,7 +84,7 @@ public class Main {
             Picture.fromRes((Res)Main.builtin.get("org/xwt/builtin/scar.png"),
                         new Scheduler.Task() { public void perform() {
                             scarImage = scarHolder.picture;
-                            Template.getTemplate(((Res)final_rr.get(initialTemplate))).apply(new BoxTree(), xwt);
+                            Template.getTemplate(((Res)final_rr.get(initialTemplate))).apply(new Box(), xwt);
                         } });
 
         new Thread() { public void run() { Scheduler.init(); } }.start();
index 00b00d2..efc2731 100644 (file)
@@ -69,6 +69,7 @@ public class Platform {
             // Disable 2d hardware acceleration on Jaguar
             if (os_name.equals("Mac OS X") && os_version.startsWith("10.2")) System.setProperty("com.apple.hwaccel", "false");
             */
+            System.setProperty("com.apple.hwaccel", "true");
 
             if (platform_class != null) {
                 platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance();
index bd57bf9..d633f48 100644 (file)
@@ -120,7 +120,7 @@ public class Template {
 
         PerInstantiationJSScope pis = new PerInstantiationJSScope(b, xwt, parentPis, staticJSScope);
         for (int i=0; children != null && i<children.size(); i++) {
-            Box kid = new BoxTree();
+            Box kid = new Box();
             ((Template)children.elementAt(i)).apply(kid, xwt, pis);
             b.putAndTriggerJSTraps(JS.N(b.numchildren), kid);
         }
index 45144cd..fec4565 100644 (file)
@@ -37,7 +37,7 @@ public final class XWT extends JSCallable {
         case "string": return xwtString;
         case "date": return METHOD;
         case "origin": return Main.origin;
-        case "box": return new BoxTree();
+        case "box": return new Box();
         case "log": return new Sub("log");
         case "ui": return new Sub("ui");
         case "thread": return new Sub("thread");
index d2785a9..f478b58 100644 (file)
@@ -173,11 +173,26 @@ public class Java2 extends AWT {
         private static int[] ibank = null;
         private static byte[] bbank = null;
         private static int bank_start = 0;
+        private WritableRaster raster = null;
+        private SampleModel sm = null;
+        private DataBuffer buf = null;
+
+        public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+            AWTPicture src = (AWTPicture)source;
+            Graphics2D g2 = (Graphics2D)i.getGraphics();
+            g2.setComposite(AlphaComposite.DstOut);
+            g2.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
+            g2.drawImage(src.i, dx, dy, null);
+            g2.setComposite(AlphaComposite.DstOver);
+            g2.setColor(new Color((rgb & 0x00FF0000) >> 16, (rgb & 0x0000FF00) >> 8, (rgb & 0x000000FF)));
+            g2.fillRect(dx, dy, cx2 - dx, cy2 - dy);
+            g2.drawImage(i, 0, 0, null);
+            g2.setClip(0, 0, i.getWidth(null), i.getHeight(null));
+        }
 
         public Java2PixelBuffer(int w, int h) {
-            SampleModel sm = cm.createCompatibleSampleModel(w, h);
+            sm = cm.createCompatibleSampleModel(w, h);
             int numSamples = w * h * sm.getNumDataElements();
-            DataBuffer buf = null;
             if (sm.getDataType() == DataBuffer.TYPE_USHORT) {
                 if (sbank == null || numSamples > 512 * 512 / 3) {
                     buf = new DataBufferUShort(numSamples);
@@ -212,7 +227,8 @@ public class Java2 extends AWT {
                     bank_start += numSamples;
                 }
             }
-            i = new BufferedImage(cm, Raster.createWritableRaster(sm, buf, null), false,  emptyHashtable);
+            raster = Raster.createWritableRaster(sm, buf, null);
+            i = new BufferedImage(cm, raster, false,  emptyHashtable);
             g = i.getGraphics();
         }
     }