X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FSurface.java;h=c30a34b7681f97beb30988c47606f0ea044f09bc;hb=20c80526fbef20ad0b6f1cd67805871c10616bea;hp=8b888e7fc974a09a4fbb4b3000856dd080e5c959;hpb=a05013dcf876e6b0a5002b25661ba40fbe9616aa;p=org.ibex.core.git diff --git a/src/org/xwt/Surface.java b/src/org/xwt/Surface.java index 8b888e7..c30a34b 100644 --- a/src/org/xwt/Surface.java +++ b/src/org/xwt/Surface.java @@ -73,13 +73,21 @@ public abstract class Surface extends PixelBuffer { public abstract void setInvisible(boolean b); ///< If b, make window invisible; otherwise, make it non-invisible. protected abstract void _setMaximized(boolean b); ///< If b, maximize the surface; otherwise, un-maximize it. protected abstract void _setMinimized(boolean b); ///< If b, minimize the surface; otherwise, un-minimize it. - protected abstract void setSize(int width, int height); ///< Sets the surface's width and height. public abstract void setLocation(); ///< Set the surface's x/y position to that of the root box public abstract void setTitleBarText(String s); ///< Sets the surface's title bar text, if applicable public abstract void setIcon(Picture i); ///< Sets the surface's title bar text, if applicable public abstract void _dispose(); ///< Destroy the surface public void setLimits(int min_width, int min_height, int max_width, int max_height) { } + protected abstract void _setSize(int width, int height); ///< Sets the surface's width and height. + protected final void setSize(int width, int height) { + if (root.width != width || root.height != height) { + root.dirty(0, root.height - Main.scarImage.getHeight(), Main.scarImage.getWidth(), Main.scarImage.getHeight()); + root.width = Math.max(Main.scarImage.getWidth(), width); + root.height = Math.max(Main.scarImage.getHeight(), height); + } + _setSize(root.width, root.height); + } // Helper methods for subclasses //////////////////////////////////////////////////////////// @@ -223,15 +231,16 @@ public abstract class Surface extends PixelBuffer { Message.Q.add(new Message() { public void perform() { if (width == root.width && height == root.height) return; root.needs_reflow = true; - root.reflow(width, height); + do { abort = false; root.reflow(width, height); } while(abort); }}); abort = true; } protected final void PosChange(final int x, final int y) { Message.Q.add(new Message() { public void perform() { - root.put("x", new Integer(x)); - root.put("y", new Integer(y)); + root.x = x; + root.y = y; + root.put("PosChange", Boolean.TRUE); }}); } @@ -247,13 +256,6 @@ public abstract class Surface extends PixelBuffer { // Other Methods /////////////////////////////////////////////////////////////////////////////// - /** wrapper for setSize() which makes sure to dirty the place where the scar used to be */ - void setSize() { - root.width = Math.max(root.width, 10); - root.height = Math.max(root.height, 10); - setSize(root.width, root.height); - } - /** Indicates that the Surface is no longer needed */ public final void dispose(boolean quitIfAllSurfacesGone) { if (Log.on) Log.log(this, "disposing " + this); @@ -284,6 +286,8 @@ public abstract class Surface extends PixelBuffer { Refresh(); } + private static VectorGraphics.Affine identity = VectorGraphics.Affine.identity(); + /** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */ public synchronized void render() { @@ -291,6 +295,7 @@ public abstract class Surface extends PixelBuffer { do { abort = false; root.reflow(); + setSize(root.width, root.height); // update mouseinside and trigger Enter/Leave as a result of box size/position changes String oldcursor = cursor; cursor = "default"; @@ -309,7 +314,10 @@ public abstract class Surface extends PixelBuffer { if (y+h > root.height) h = root.height - y; if (w <= 0 || h <= 0) continue; - root.render(0, 0, x, y, w, h, this); + root.render(0, 0, x, y, w, h, this, identity); + drawPicture(Main.scarImage, + 0, root.height - Main.scarImage.getHeight(), + x, y, w, h); if (abort) { @@ -326,7 +334,6 @@ public abstract class Surface extends PixelBuffer { return; } } - } // FEATURE: reinstate recycler @@ -357,18 +364,25 @@ public abstract class Surface extends PixelBuffer { PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this); DirtyList screenDirtyRegions = new DirtyList(); - public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) { - screenDirtyRegions.dirty(dx1, dy1, dx2 - dx1, dy2 - dy1); - backbuffer.drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2); } + 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 fillRect(int x1, int y1, int x2, int y2, int color) { - screenDirtyRegions.dirty(x1, y1, x2 - x1, y2 - y1); - backbuffer.fillRect(x1, y1, x2, y2, color); } + public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int argb) { + screenDirtyRegions.dirty(cx1, cy1, cx2 - cx1, cy2 - cy1); + backbuffer.drawPictureAlphaOnly(source, dx, dy, cx1, cy1, cx2, cy2, argb); + } + + public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color) { + 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); } public void render() { super.render(); render_(); } + public void render_() { int[][] dirt = screenDirtyRegions.flush(); for(int i = 0; dirt != null && i < dirt.length; i++) {