From: megacz Date: Fri, 30 Jan 2004 07:44:20 +0000 (+0000) Subject: 2004/01/13 10:27:46 X-Git-Tag: RC3~179 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=75b9e1e72f6067e59a1e5312c91d20d05ec8a927 2004/01/13 10:27:46 darcs-hash:20040130074420-2ba56-8fe661b8a8707a217b6768f3ecc48e156481c944.gz --- diff --git a/src/org/xwt/HTTP.java b/src/org/xwt/HTTP.java index 9190f8f..d94edc6 100644 --- a/src/org/xwt/HTTP.java +++ b/src/org/xwt/HTTP.java @@ -339,7 +339,7 @@ public class HTTP { OUTER: do { if (pi != null) { for(int i=0; i startargs + 1 ? args[startargs + 1] : "main"; initialTemplateName = initialTemplateName.replace('.', '/'); + initialTemplateName += ".xwt"; origin = args[startargs]; Stream rr; @@ -77,12 +78,12 @@ public class Main { if (Log.on) Log.info(Main.class, "loading xwar"); final XWT xwt = new XWT(rr); - final Stream final_rr = rr; + final JS final_rr = (JS)xwt.get(""); scarImage = Picture.load((Stream)Main.builtin.get("org/xwt/builtin/scar.png"), - new Scheduler.Task() { public void perform() throws JSExn { - Template.getTemplate(((Stream)final_rr.get(initialTemplate))).apply(new Box(), xwt); + new Scheduler.Task() { public void perform() throws Exception { + new Template(Stream.getInputStream(final_rr.get(initialTemplate)), xwt).apply(new Box()); } }); Scheduler.init(); diff --git a/src/org/xwt/Picture.java b/src/org/xwt/Picture.java index 4cbd299..4a8289d 100644 --- a/src/org/xwt/Picture.java +++ b/src/org/xwt/Picture.java @@ -17,40 +17,32 @@ import org.xwt.translators.*; public class Picture { public Picture() { this.res = null; } - public Picture(Stream r) { this.res = r; } + public Picture(JS r) { this.res = r; } private static Cache cache = new Cache(100); ///< Picture, keyed by the Stream that loaded them - public Stream res = null; ///< the resource we were loaded from + public JS res = null; ///< the resource we were loaded from public int width = -1; ///< the width of the image public int height = -1; ///< the height of the image public int[] data = null; ///< argb samples public boolean isLoaded = false; ///< true iff the image is fully loaded /** turns a resource into a Picture.Source and passes it to the callback */ - public static Picture load(final Stream r, final Scheduler.Task callback) { + public static Picture load(JS rr, final Scheduler.Task callback) { + final JS r = rr; Picture ret = (Picture)cache.get(r); if (ret == null) cache.put(r, ret = Platform.createPicture(r)); final Picture p = ret; if (!ret.isLoaded && callback != null) new java.lang.Thread() { public void run() { // get the InputStream for the image + Log.info(Picture.class, "r is a " + r.getClass().getName()); InputStream in = null; try { - in = r.getInputStream(); + in = (r instanceof XWT.Blessing) ? ((XWT.Blessing)r).getImage() : Stream.getInputStream(r); } catch (IOException e) { - in = null; - if (r instanceof Stream.Ref) { - // add extensions to the resource, looking for the image - Stream.Ref ref = (Stream.Ref)r; - Stream newr; - - String[] exts = new String[] { ".png", ".jpeg", ".gif" }; - for (int i=0; i < exts.length && in == null; i++) { - newr = ref.addExtension(exts[i]); - try { in = newr.getInputStream(); } - catch (IOException f) { in = null; } - } - } + Log.error(Picture.class, r); + } catch (JSExn e) { + Log.error(Picture.class, r); } // could not find image diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java index 2e086da..e364a50 100644 --- a/src/org/xwt/Platform.java +++ b/src/org/xwt/Platform.java @@ -5,6 +5,7 @@ import java.lang.reflect.*; import java.net.*; import java.io.*; import java.util.*; +import org.xwt.js.*; import org.xwt.util.*; /** @@ -104,17 +105,16 @@ public abstract class Platform { protected void postInit() { } protected Surface _createSurface(Box b, boolean framed) { return null; } - protected Picture _createPicture(Stream r) { return null; } + protected Picture _createPicture(JS r) { return null; } protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return null; } protected Font.Glyph _createGlyph(org.xwt.Font f, char c) { return new DefaultGlyph(f, c); } public static PixelBuffer createPixelBuffer(int w, int h, Surface s) { return platform._createPixelBuffer(w, h, s); } - public static Picture createPicture(Stream r) { return platform._createPicture(r); } + public static Picture createPicture(JS r) { return platform._createPicture(r); } public static Font.Glyph createGlyph(org.xwt.Font f, char c) { return platform._createGlyph(f, c); } public static Surface createSurface(Box b, boolean framed, boolean refreshable) { Surface ret = platform._createSurface(b, framed); ret.setInvisible(false); - ret.setLimits(b.minwidth, b.minheight, b.maxwidth, b.maxheight); if (refreshable) { Surface.allSurfaces.addElement(ret); ret.dirty(0, 0, b.width, b.height); diff --git a/src/org/xwt/Scheduler.java b/src/org/xwt/Scheduler.java index 4dc85bf..58b6a8b 100644 --- a/src/org/xwt/Scheduler.java +++ b/src/org/xwt/Scheduler.java @@ -8,8 +8,6 @@ import org.xwt.util.*; /** Implements cooperative multitasking */ public class Scheduler { - // FIXME: prepending events messes with keysate -- make a "no re-ordering" invariant? - // Public API Exposed to org.xwt ///////////////////////////////////////////////// private static Scheduler singleton; @@ -18,9 +16,6 @@ public class Scheduler { /** adds a task to the back of the queue */ public static void add(Task t) { singleton.runnable.append(t); } - /** adds a task to the front of the queue (guaranteed to run next) */ - public static void addAtFront(Task t) { singleton.runnable.prepend(t); } - public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); } private static Task currentTask = null; @@ -71,7 +66,7 @@ public class Scheduler { synchronized(this) { for(int i=0; i