Only dirty regions in the MediaOverlay corresponding to its actual media.
Since its dirty regions propagate out to the repaint manager, a big update there would lead to dirty calls ping-ponging back and forth for a few cycles. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@600 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -68,7 +68,7 @@ public class ActiveRepaintManager extends RepaintManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addInvalidComponent (JComponent comp)
|
||||
public synchronized void addInvalidComponent (JComponent comp)
|
||||
{
|
||||
Component vroot = null;
|
||||
if (DEBUG) {
|
||||
@@ -128,7 +128,7 @@ public class ActiveRepaintManager extends RepaintManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addDirtyRegion (JComponent comp, int x, int y, int width, int height)
|
||||
public synchronized void addDirtyRegion (JComponent comp, int x, int y, int width, int height)
|
||||
{
|
||||
// ignore invalid requests
|
||||
if ((width <= 0) || (height <= 0) || (comp == null) ||
|
||||
@@ -382,7 +382,7 @@ public class ActiveRepaintManager extends RepaintManager
|
||||
|
||||
// we also need to repaint any components in this layer that are above our freshly
|
||||
// repainted component
|
||||
fmgr.renderLayers((Graphics2D)g, ocomp, _cbounds, _clipped);
|
||||
fmgr.renderLayers((Graphics2D)g, ocomp, _cbounds, _clipped, drect);
|
||||
|
||||
} else if (root != null) {
|
||||
if (DEBUG) {
|
||||
@@ -436,7 +436,7 @@ public class ActiveRepaintManager extends RepaintManager
|
||||
comp = comp.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** The root of our interface. */
|
||||
protected Component _root;
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class FrameManager
|
||||
{
|
||||
return _timer.getElapsedMillis();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we return
|
||||
* if we're not using a CalibratingTimer)
|
||||
@@ -220,7 +220,7 @@ public abstract class FrameManager
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears out the maximum drift our timer remembers seeing.
|
||||
*/
|
||||
@@ -411,8 +411,8 @@ public abstract class FrameManager
|
||||
}
|
||||
|
||||
// tick all of our frame participants
|
||||
for (int ii = 0; ii < _participants.length; ii++) {
|
||||
FrameParticipant part = (FrameParticipant)_participants[ii];
|
||||
for (Object _participant : _participants) {
|
||||
FrameParticipant part = (FrameParticipant)_participant;
|
||||
if (part == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -467,8 +467,8 @@ public abstract class FrameManager
|
||||
{
|
||||
// paint our frame participants (which want to be handled specially)
|
||||
int painted = 0;
|
||||
for (int ii = 0; ii < _participants.length; ii++) {
|
||||
FrameParticipant part = (FrameParticipant)_participants[ii];
|
||||
for (Object _participant : _participants) {
|
||||
FrameParticipant part = (FrameParticipant)_participant;
|
||||
if (part == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ public abstract class FrameManager
|
||||
|
||||
// render any components in our layered pane that are not in the default layer
|
||||
_clipped[0] = false;
|
||||
renderLayers(gfx, pcomp, _tbounds, _clipped);
|
||||
renderLayers(gfx, pcomp, _tbounds, _clipped, _tbounds);
|
||||
|
||||
if (HANG_DEBUG) {
|
||||
long delay = (System.currentTimeMillis() - start);
|
||||
@@ -551,8 +551,8 @@ public abstract class FrameManager
|
||||
* Renders all components in all {@link JLayeredPane} layers that intersect the supplied
|
||||
* bounds.
|
||||
*/
|
||||
protected void renderLayers (Graphics2D g, Component pcomp,
|
||||
Rectangle bounds, boolean[] clipped)
|
||||
protected void renderLayers (Graphics2D g, Component pcomp, Rectangle bounds,
|
||||
boolean[] clipped, Rectangle dirty)
|
||||
{
|
||||
JLayeredPane lpane = JLayeredPane.getLayeredPaneAbove(pcomp);
|
||||
if (lpane != null) {
|
||||
@@ -565,7 +565,7 @@ public abstract class FrameManager
|
||||
// if we have a MediaOverlay, let it know that any sprites in this region need to be
|
||||
// repainted as the components beneath them have just been redrawn
|
||||
if (_overlay != null) {
|
||||
_overlay.addDirtyRegion(new Rectangle(bounds));
|
||||
_overlay.addDirtyRegion(dirty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ public abstract class FrameManager
|
||||
{
|
||||
super("FrameManagerTicker");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.threerings.media;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JRootPane;
|
||||
|
||||
import com.threerings.media.animation.Animation;
|
||||
@@ -122,12 +123,18 @@ public class MediaOverlay
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a dirty region to this overlay. Note: control of the rectangle is granted to our
|
||||
* underlying {@link RegionManager} which may bend, fold or mutilate it.
|
||||
* Adds a dirty region to this overlay.
|
||||
*/
|
||||
public void addDirtyRegion (Rectangle rect)
|
||||
{
|
||||
_metamgr.getRegionManager().addDirtyRegion(rect);
|
||||
// Only add dirty regions where rect intersects our actual media as the set region will
|
||||
// propagate out to the repaint manager.
|
||||
for (AbstractMedia media : _metamgr) {
|
||||
Rectangle intersection = media.getBounds().intersection(rect);
|
||||
if (!intersection.isEmpty()) {
|
||||
_metamgr.getRegionManager().addDirtyRegion(intersection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +151,7 @@ public class MediaOverlay
|
||||
List<Rectangle> dlist = _metamgr.getRegionManager().peekDirtyRegions();
|
||||
for (int ii = 0, ll = dlist.size(); ii < ll; ii++) {
|
||||
Rectangle dirty = dlist.get(ii);
|
||||
repmgr.addDirtyRegion(root, dirty.x - root.getX(), dirty.y - root.getY(),
|
||||
repmgr.addDirtyRegion(root, dirty.x - root.getX(), dirty.y - root.getY(),
|
||||
dirty.width, dirty.height);
|
||||
}
|
||||
}
|
||||
@@ -163,10 +170,10 @@ public class MediaOverlay
|
||||
}
|
||||
|
||||
Rectangle[] dirty = _metamgr.getRegionManager().getDirtyRegions();
|
||||
for (int ii = 0; ii < dirty.length; ii++) {
|
||||
gfx.setClip(dirty[ii]);
|
||||
_metamgr.paintMedia(gfx, MediaConstants.BACK, dirty[ii]);
|
||||
_metamgr.paintMedia(gfx, MediaConstants.FRONT, dirty[ii]);
|
||||
for (Rectangle element : dirty) {
|
||||
gfx.setClip(element);
|
||||
_metamgr.paintMedia(gfx, MediaConstants.BACK, element);
|
||||
_metamgr.paintMedia(gfx, MediaConstants.FRONT, element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,24 +21,28 @@
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
import java.util.Arrays;
|
||||
import static com.threerings.media.Log.log;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import com.samskivert.swing.Label;
|
||||
import com.samskivert.util.IntListUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
import com.samskivert.swing.Label;
|
||||
|
||||
import com.threerings.media.animation.Animation;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
|
||||
import static com.threerings.media.Log.log;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
import com.threerings.media.timer.MediaTimer;
|
||||
|
||||
/**
|
||||
* Coordinates interaction between a sprite and animation manager and the media host that hosts and
|
||||
@@ -47,7 +51,7 @@ import static com.threerings.media.Log.log;
|
||||
* functionality, we're constrained by all the extant usages and derivations.
|
||||
*/
|
||||
public class MetaMediaManager
|
||||
implements MediaConstants
|
||||
implements MediaConstants, Iterable<AbstractMedia>
|
||||
{
|
||||
public MetaMediaManager (FrameManager framemgr, MediaHost host)
|
||||
{
|
||||
@@ -332,6 +336,11 @@ public class MetaMediaManager
|
||||
_spritemgr.viewLocationDidChange(dx, dy);
|
||||
}
|
||||
|
||||
public Iterator<AbstractMedia> iterator ()
|
||||
{
|
||||
return Iterators.concat(_spritemgr.enumerateSprites(), _animmgr.iterator());
|
||||
}
|
||||
|
||||
/** The frame manager with whom we register. */
|
||||
protected FrameManager _framemgr;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
package com.threerings.media.animation;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
|
||||
import com.threerings.media.AbstractMedia;
|
||||
@@ -31,6 +33,7 @@ import com.threerings.media.AbstractMediaManager;
|
||||
* generating events when animations finish and suchlike.
|
||||
*/
|
||||
public class AnimationManager extends AbstractMediaManager
|
||||
implements Iterable<Animation>
|
||||
{
|
||||
/**
|
||||
* Registers the given {@link Animation} with the animation manager for ticking and painting.
|
||||
@@ -50,6 +53,11 @@ public class AnimationManager extends AbstractMediaManager
|
||||
removeMedia(anim);
|
||||
}
|
||||
|
||||
public Iterator<Animation> iterator ()
|
||||
{
|
||||
return _anims.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tickAllMedia (long tickStamp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user