diff --git a/src/java/com/threerings/media/sprite/AnimationManager.java b/src/java/com/threerings/media/sprite/AnimationManager.java
index 906520634..8200c96a9 100644
--- a/src/java/com/threerings/media/sprite/AnimationManager.java
+++ b/src/java/com/threerings/media/sprite/AnimationManager.java
@@ -1,8 +1,9 @@
//
-// $Id: AnimationManager.java,v 1.8 2001/08/07 18:29:18 shaper Exp $
+// $Id: AnimationManager.java,v 1.9 2001/08/08 00:10:50 shaper Exp $
package com.threerings.miso.sprite;
+import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
@@ -84,6 +85,13 @@ public class AnimationManager implements Interval, PerformanceObserver
return false;
}
+ /**
+ * The IntervalManager calls this method as often as
+ * we've requested to obtain our desired frame rate. Since we'd
+ * like to avoid messy thread-synchronization between the AWT
+ * thread and other threads, here we just add the tick task to the
+ * AWT thread for later execution.
+ */
public void intervalExpired (int id, Object arg)
{
if (requestTick()) {
@@ -92,6 +100,10 @@ public class AnimationManager implements Interval, PerformanceObserver
}
}
+ /**
+ * The tick method handles updating sprites and
+ * repainting the target display.
+ */
protected void tick ()
{
// call tick on all sprites
@@ -104,8 +116,27 @@ public class AnimationManager implements Interval, PerformanceObserver
// pass the dirty-rects on to the scene view
_view.invalidateRects(rects);
- // refresh the display
- _target.paintImmediately(_target.getBounds());
+ // refresh the display.
+
+ // since we know the target panel is always opaque and not
+ // dependent on swing's double-buffering, we bypass the
+ // antics that paintImmediately() performs in
+ // the interest of better performance and grab the
+ // target's graphics object straightaway.
+
+ Graphics g = null;
+ try {
+ Graphics pcg = _target.getGraphics();
+ g = pcg.create();
+ pcg.dispose();
+ } catch(NullPointerException e) {
+ g = null;
+ e.printStackTrace();
+ }
+
+ if (g != null) {
+ _target.paint(g);
+ }
}
// update refresh-rate information
@@ -129,7 +160,7 @@ public class AnimationManager implements Interval, PerformanceObserver
protected Runnable _ticker;
/** The desired number of refresh operations per second. */
- protected static final int FRAME_RATE = 20;
+ protected static final int FRAME_RATE = 40;
/** The milliseconds to sleep to obtain desired frame rate. */
protected static final long REFRESH_INTERVAL = 1000 / FRAME_RATE;
diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java
index 2ba664f25..c37ec1e44 100644
--- a/src/java/com/threerings/miso/client/IsoSceneView.java
+++ b/src/java/com/threerings/miso/client/IsoSceneView.java
@@ -1,5 +1,5 @@
//
-// $Id: IsoSceneView.java,v 1.27 2001/08/07 18:29:17 shaper Exp $
+// $Id: IsoSceneView.java,v 1.28 2001/08/08 00:10:50 shaper Exp $
package com.threerings.miso.scene;
@@ -61,10 +61,19 @@ public class IsoSceneView implements EditableSceneView
Shape oldclip = gfx.getClip();
gfx.setClip(0, 0, _model.bounds.width, _model.bounds.height);
- // draw the full scene into the offscreen image buffer
- //renderSceneInvalid(gfx);
- renderScene(gfx);
- drawDirtyRects(gfx);
+ if (_dirty.size() == 0) {
+ // render the full scene
+ renderScene(gfx);
+
+ } else {
+ // render only dirty tiles
+ renderSceneInvalid(gfx);
+
+ // draw frames of dirty tiles and rectangles
+ drawDirtyRegions(gfx);
+
+ clearDirtyRegions();
+ }
// draw an outline around the highlighted tile
paintHighlightedTile(gfx, _htile.x, _htile.y);
@@ -76,13 +85,19 @@ public class IsoSceneView implements EditableSceneView
gfx.setClip(oldclip);
}
- protected void drawDirtyRects (Graphics2D gfx)
+ protected void clearDirtyRegions ()
+ {
+ _dirty.clear();
+ _dirtyRects.clear();
+ }
+
+ protected void drawDirtyRegions (Graphics2D gfx)
{
// draw the dirty tiles
gfx.setColor(Color.cyan);
int size = _dirty.size();
for (int ii = 0; ii < size; ii++) {
- int dinfo[] = (int[])_dirty.remove(0);
+ int dinfo[] = (int[])_dirty.get(ii);
gfx.draw(getTilePolygon(dinfo[0], dinfo[1]));
}
@@ -90,7 +105,7 @@ public class IsoSceneView implements EditableSceneView
gfx.setColor(Color.red);
size = _dirtyRects.size();
for (int ii = 0; ii < size; ii++) {
- Rectangle rect = (Rectangle)_dirtyRects.remove(0);
+ Rectangle rect = (Rectangle)_dirtyRects.get(ii);
gfx.draw(rect);
}
}
@@ -102,13 +117,11 @@ public class IsoSceneView implements EditableSceneView
*/
protected void renderSceneInvalid (Graphics2D gfx)
{
- Log.info("renderSceneInvalid.");
-
int size = _dirty.size();
for (int ii = 0; ii < size; ii++) {
// retrieve the next dirty tile coordinates
- int[] dinfo = (int[])_dirty.remove(0);
+ int[] dinfo = (int[])_dirty.get(ii);
int tx = dinfo[0], ty = dinfo[1];
// get the tile's screen position
@@ -425,6 +438,11 @@ public class IsoSceneView implements EditableSceneView
_scene = scene;
}
+ public boolean getShowCoordinates ()
+ {
+ return _model.showCoords;
+ }
+
public void setShowCoordinates (boolean show)
{
_model.showCoords = show;
diff --git a/src/java/com/threerings/miso/client/SceneViewPanel.java b/src/java/com/threerings/miso/client/SceneViewPanel.java
index 6af9e80c2..2329ef44f 100644
--- a/src/java/com/threerings/miso/client/SceneViewPanel.java
+++ b/src/java/com/threerings/miso/client/SceneViewPanel.java
@@ -1,5 +1,5 @@
//
-// $Id: SceneViewPanel.java,v 1.2 2001/08/06 18:57:39 shaper Exp $
+// $Id: SceneViewPanel.java,v 1.3 2001/08/08 00:10:50 shaper Exp $
package com.threerings.miso.scene;
@@ -43,12 +43,20 @@ public class SceneViewPanel extends JPanel
_view.setScene(scene);
}
+ /**
+ * Get the scene managed by the panel.
+ */
+ public SceneView getSceneView ()
+ {
+ return _view;
+ }
+
/**
* Render the panel and the scene view to the given graphics object.
*/
public void paintComponent (Graphics g)
{
- super.paintComponent(g);
+// super.paintComponent(g);
_view.paint(g);
}