* Platform subclasses should include an inner class subclass of
* Surface to return from the Platform._createSurface() method
*/
-public abstract class Surface extends PixelBuffer implements Callable {
+public abstract class Surface implements Callable {
// Static Data ////////////////////////////////////////////////////////////////////////////////
// Methods to be overridden by subclasses ///////////////////////////////////////////////////////
+ public abstract PixelBuffer getPixelBuffer(); ///< returns a PixelBuffer representing this Surface
public abstract void toBack(); ///< should push surface to the back of the stacking order
public abstract void toFront(); ///< should pull surface to the front of the stacking order
public abstract void syncCursor(); ///< set the actual cursor to this.cursor if they do not match
}
}
- public void dirty(int x, int y, int w, int h) {
- dirtyRegions.dirty(x, y, w, h);
- Refresh();
- }
+ // This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not
+ public void Dirty(int x, int y, int w, int h) { dirty(x,y,w,h); }
+ public void dirty(int x, int y, int w, int h) { dirtyRegions.dirty(x, y, w, h); Refresh(); }
public static Surface fromBox(Box b) {
// FIXME use a hash table here
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, identity);
- drawPicture(scarImage, 0, root.height - scarImage.height, x, y, x+w, y+h);
+ 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);
if (abort) {
// x,y,w,h is only partially reconstructed, so we must be careful not to re-blit it
// Default PixelBuffer implementation /////////////////////////////////////////////////////////
- public static abstract class DoubleBufferedSurface extends Surface {
+ public static abstract class DoubleBufferedSurface extends Surface implements PixelBuffer {
public DoubleBufferedSurface(Box root) { super(root); }
PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
DirtyList screenDirtyRegions = new DirtyList();
+ public PixelBuffer getPixelBuffer() { return this; }
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) {
+ 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);
+ backbuffer.drawGlyph(source, dx, dy, cx1, cy1, cx2, cy2, argb, bc);
+ }
+
+ public void stroke(Polygon p, int color) {
+ // FIXME
+ }
+
+ public void fill(Polygon p, Paint paint) {
+ // FIXME
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2, int color) {
+ screenDirtyRegions.dirty(x1, y1, x2, y2);
+ backbuffer.drawLine(x1, y1, x2, y2, color);
}
+ public abstract void _fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color) {
+ // we don't dirty trapezoid-fills since it's faster to just do them directly than to copy from the backbuffer
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);
+ //_fillTrapezoid(x1, x2, y1, x3, x4, y2, color);
}
public void render() {
}
}
- /** This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not */
+ // 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();
super.dirty(x, y, w, h);
}
- /** copies a region from the doublebuffer to this surface */
+ // copies a region from the doublebuffer to this surface
public abstract void blit(PixelBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2);
-
+ protected void blit(int x, int y, int w, int h) {
+ blit(backbuffer, x, y, x, y, w + x, h + y);
+ }
}
}