X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fgraphics%2FSurface.java;h=b27fa615b9f39e5800684fdbd41e860d60044f32;hp=7658ec50794e540e25673911556a3bae7ac7e189;hb=51935331706d01844ed596f0c7a77e2ff86d381e;hpb=297fdbde87e6db4732448a0950d1141c7265c169 diff --git a/src/org/ibex/graphics/Surface.java b/src/org/ibex/graphics/Surface.java index 7658ec5..b27fa61 100644 --- a/src/org/ibex/graphics/Surface.java +++ b/src/org/ibex/graphics/Surface.java @@ -7,8 +7,7 @@ package org.ibex.graphics; import org.ibex.js.*; import org.ibex.util.*; import org.ibex.plat.*; - -import org.ibex.core.*; // FIXME +import org.ibex.core.*; /** * A Surface, as described in the Ibex Reference. @@ -23,7 +22,7 @@ public abstract class Surface implements Callable { private static final JS T = JSU.T; private static final JS F = JSU.F; - /** all instances of Surface which need to be refreshed by the Scheduler */ + /** all instances of Surface which need to be refreshed by the Platform.Scheduler */ public static Vec allSurfaces = new Vec(); /** When set to true, render() should abort as soon as possible and restart the rendering process */ @@ -97,7 +96,7 @@ public abstract class Surface implements Callable { if (button == 1) new Message("_Press1", T, root); else if (button == 2) new Message("_Press2", T, root); else if (button == 3) { - Scheduler.add(new Callable() { public Object run(Object o) throws JSExn { + Platform.Scheduler.add(new Callable() { public Object run(Object o) throws JSExn { Platform.clipboardReadEnabled = true; try { root.putAndTriggerTraps(JSU.S("_Press3"), T); @@ -136,7 +135,7 @@ public abstract class Surface implements Callable { } private final static JS MOVE = JSU.S("_Move"); - /** we enqueue ourselves in the Scheduler when we have a Move message to deal with */ + /** we enqueue ourselves in the Platform.Scheduler when we have a Move message to deal with */ private Callable mover = new Callable() { public Object run(Object o) { if (mousex == newmousex && mousey == newmousey) return null; @@ -159,7 +158,7 @@ public abstract class Surface implements Callable { protected final void Move(final int newmousex, final int newmousey) { this.newmousex = newmousex; this.newmousey = newmousey; - Scheduler.add(mover); + Platform.Scheduler.add(mover); } protected final void HScroll(int pixels) { new Message("_HScroll", JSU.N(pixels), root); } @@ -174,14 +173,15 @@ public abstract class Surface implements Callable { pendingHeight = height; syncRootBoxToSurface = true; abort = true; - Scheduler.renderAll(); + Refresh(); } // FEATURE: can we avoid creating objects here? protected final void PosChange(final int x, final int y) { - Scheduler.add(new Callable() { public Object run(Object o) throws JSExn { - root.x = x; - root.y = y; + Platform.Scheduler.add(new Callable() { public Object run(Object o) throws JSExn { + // FIXME + //root.x = x; + //root.y = y; root.putAndTriggerTrapsAndCatchExceptions(JSU.S("PosChange"), T); return null; }}); @@ -197,8 +197,8 @@ public abstract class Surface implements Callable { protected final void Focused(boolean b) { new Message("Focused", b ? T : F, root); } private boolean scheduled = false; - public void Refresh() { if (!scheduled) Scheduler.add(this); scheduled = true; } - public Object run(Object o) { scheduled = false; Scheduler.renderAll(); return null; } + public void Refresh() { if (!scheduled) Platform.Scheduler.add(this); scheduled = true; } + public Object run(Object o) { scheduled = false; Platform.Scheduler.renderAll(); return null; } public final void setMaximized(boolean b) { if (b != maximized) _setMaximized(maximized = b); } public final void setMinimized(boolean b) { if (b != minimized) _setMinimized(minimized = b); } @@ -259,7 +259,6 @@ public abstract class Surface implements Callable { // make sure the root is properly sized do { abort = false; - root.pack(); if (syncRootBoxToSurface) { root.setWidth(root.minwidth, pendingWidth); root.setHeight(root.minheight, pendingHeight); @@ -281,6 +280,7 @@ public abstract class Surface implements Callable { } while(abort); int[][] dirt = dirtyRegions.flush(); + /* for(int i = 0; dirt != null && i < dirt.length; i++) { if (dirt[i] == null) continue; int x = dirt[i][0], y = dirt[i][1], w = dirt[i][2], h = dirt[i][3]; @@ -289,9 +289,12 @@ public abstract class Surface implements Callable { if (x+w > root.width) w = root.width - x; 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.getPixelBuffer(), identity); - getPixelBuffer().drawPicture(scarImage, 0, root.height - scarImage.height, x, y, x+w, y+h); + */ + // FIXME: set clip to -- x, y, x + w, y + h, + System.out.println("paint"); + root.render(this.getPixelBuffer(), identity, null); + /* + //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 @@ -303,6 +306,7 @@ public abstract class Surface implements Callable { return; } } + */ unrendered = false; } @@ -318,7 +322,7 @@ public abstract class Surface implements Callable { this.boxContainingMouse = boxContainingMouse; this.name = name; this.value = value; - Scheduler.add(this); + Platform.Scheduler.add(this); } public Object run(Object o) throws JSExn { @@ -360,21 +364,30 @@ public abstract class Surface implements Callable { DirtyList screenDirtyRegions = new DirtyList(); public PixelBuffer getPixelBuffer() { return this; } + public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int argb) { + backbuffer.fillTriangle(x1, y1, x2, y2, x3, y3, argb); + } + public void drawPicture(Picture p, Affine a, Mesh h) { + throw new Error("drawPicture() not implemented"); + } + public void drawGlyph(Font.Glyph source,Affine a,Mesh h,int rgb,int bg) { + //screenDirtyRegions.dirty(cx1, cy1, cx2 - cx1, cy2 - cy1); + backbuffer.drawGlyph(source, a, h, rgb, bg); + } + /* 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, int bc) { - screenDirtyRegions.dirty(cx1, cy1, cx2 - cx1, cy2 - cy1); - backbuffer.drawGlyph(source, dx, dy, cx1, cy1, cx2, cy2, argb, bc); } - - public void stroke(Polygon p, int color) { + */ + public void stroke(Mesh p, int color) { // FIXME } - public void fill(Polygon p, Paint paint) { + public void fill(Mesh p, Paint paint) { // FIXME } @@ -413,8 +426,9 @@ public abstract class Surface implements Callable { // 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(); + //screenDirtyRegions.dirty(x, y, w, h); + //Refresh(); + blit(x,y,w,h); } public void dirty(int x, int y, int w, int h) {