Fix initialization ordering problems in MetaMediaManager ->
Sprite/AnimationManager -> AbstractMediaManager. A smidgen more progress on MediaOverlay, but we need to get these bits checked in ASAP. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@114 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -39,12 +39,12 @@ public abstract class AbstractMediaManager
|
||||
implements MediaConstants
|
||||
{
|
||||
/**
|
||||
* Default constructor.
|
||||
* Provides this media manager with its host and region manager.
|
||||
*/
|
||||
public AbstractMediaManager (MediaHost host)
|
||||
public void init (MediaHost host, RegionManager remgr)
|
||||
{
|
||||
_host = host;
|
||||
_remgr = host.getRegionManager();
|
||||
_remgr = remgr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -210,6 +210,33 @@ public abstract class FrameManager
|
||||
return _timer.getElapsedMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an overlay that can be used to render sprites and animations on top of the entire
|
||||
* frame. This is lazily created the first time this method is called and the overlay will
|
||||
* remain a frame participant until {@link #clearMediaOverlay} is called. Be sure to coordinate
|
||||
* access to the overlay in your application as there is only one overlay in existence at any
|
||||
* time, and attempts to use an overlay after it has been cleared will fail.
|
||||
*/
|
||||
public MediaOverlay getMediaOverlay ()
|
||||
{
|
||||
if (_overlay == null) {
|
||||
_overlay = new MediaOverlay(this);
|
||||
registerFrameParticipant(_overlay);
|
||||
}
|
||||
return _overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out any media overlay that is in use.
|
||||
*/
|
||||
public void clearMediaOverlay ()
|
||||
{
|
||||
if (_overlay != null) {
|
||||
removeFrameParticipant(_overlay);
|
||||
_overlay = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts up the per-frame tick
|
||||
*/
|
||||
@@ -651,6 +678,9 @@ public abstract class FrameManager
|
||||
/** Our custom repaint manager. */
|
||||
protected ActiveRepaintManager _remgr;
|
||||
|
||||
/** If active, an overlay that will be rendering sprites and animations on top of the frame. */
|
||||
protected MediaOverlay _overlay;
|
||||
|
||||
/** The number of milliseconds per frame (14 by default, which gives an fps of ~71). */
|
||||
protected long _millisPerFrame = 14;
|
||||
|
||||
|
||||
@@ -35,9 +35,4 @@ public interface MediaHost
|
||||
* disposed by the caller.
|
||||
*/
|
||||
public Graphics2D createGraphics ();
|
||||
|
||||
/**
|
||||
* Returns the region manager being used to manage dirty regions by the host.
|
||||
*/
|
||||
public RegionManager getRegionManager ();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import com.threerings.media.FrameParticipant;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
@@ -33,22 +35,14 @@ import com.threerings.media.sprite.SpriteManager;
|
||||
* it has left dirty.
|
||||
*/
|
||||
public class MediaOverlay
|
||||
implements MediaHost
|
||||
implements MediaHost, FrameParticipant
|
||||
{
|
||||
protected MediaOverlay (FrameManager fmgr)
|
||||
{
|
||||
_framemgr = fmgr;
|
||||
_remgr = new RegionManager();
|
||||
_animmgr = new AnimationManager(this);
|
||||
_spritemgr = new SpriteManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the animation manager used by this media panel.
|
||||
*/
|
||||
public AnimationManager getAnimationManager ()
|
||||
{
|
||||
return _animmgr;
|
||||
return _metamgr.getAnimationManager();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,30 +50,48 @@ public class MediaOverlay
|
||||
*/
|
||||
public SpriteManager getSpriteManager ()
|
||||
{
|
||||
return _spritemgr;
|
||||
return _metamgr.getSpriteManager();
|
||||
}
|
||||
|
||||
// from interface MediaHost
|
||||
public Graphics2D createGraphics ()
|
||||
{
|
||||
return _framemgr.createGraphics();
|
||||
return _metamgr.getFrameManager().createGraphics();
|
||||
}
|
||||
|
||||
// from interface MediaHost
|
||||
public RegionManager getRegionManager ()
|
||||
// from interface FrameParticipant
|
||||
public void tick (long tickStamp)
|
||||
{
|
||||
return _remgr;
|
||||
if (!_metamgr.isPaused()) {
|
||||
// tick our meta manager which will tick our sprites and animations
|
||||
_metamgr.tick(tickStamp);
|
||||
}
|
||||
}
|
||||
|
||||
// from interface FrameParticipant
|
||||
public boolean needsPaint ()
|
||||
{
|
||||
return _metamgr.needsPaint();
|
||||
}
|
||||
|
||||
// from interface FrameParticipant
|
||||
public Component getComponent ()
|
||||
{
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a media overlay. Only the {@link FrameManager} will construct an instance.
|
||||
*/
|
||||
protected MediaOverlay (FrameManager fmgr)
|
||||
{
|
||||
_framemgr = fmgr;
|
||||
_metamgr = new MetaMediaManager(fmgr, this);
|
||||
}
|
||||
|
||||
/** The frame manager with whom we cooperate. */
|
||||
protected FrameManager _framemgr;
|
||||
|
||||
/** The animation manager in use by this overlay. */
|
||||
protected AnimationManager _animmgr;
|
||||
|
||||
/** The sprite manager in use by this overlay. */
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
/** Used to accumulate and merge dirty regions on each tick. */
|
||||
protected RegionManager _remgr;
|
||||
/** Handles the heavy lifting involving media. */
|
||||
protected MetaMediaManager _metamgr;
|
||||
}
|
||||
|
||||
@@ -233,12 +233,6 @@ public class MediaPanel extends JComponent
|
||||
_metamgr.clearAnimations();
|
||||
}
|
||||
|
||||
// from interface MediaHost
|
||||
public RegionManager getRegionManager ()
|
||||
{
|
||||
return _metamgr.getRegionManager();
|
||||
}
|
||||
|
||||
// from interface MediaHost
|
||||
public Graphics2D createGraphics ()
|
||||
{
|
||||
|
||||
@@ -53,12 +53,9 @@ public class MetaMediaManager
|
||||
_framemgr = framemgr;
|
||||
_host = host;
|
||||
|
||||
// create our region manager
|
||||
_remgr = new RegionManager();
|
||||
|
||||
// create our animation and sprite managers
|
||||
_animmgr = new AnimationManager(host);
|
||||
_spritemgr = new SpriteManager(host);
|
||||
// initialize our managers
|
||||
_animmgr.init(host, _remgr);
|
||||
_spritemgr.init(host, _remgr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,14 +336,14 @@ public class MetaMediaManager
|
||||
/** Our media host, so gracious and accomodating. */
|
||||
protected MediaHost _host;
|
||||
|
||||
/** Used to accumulate and merge dirty regions on each tick. */
|
||||
protected RegionManager _remgr = new RegionManager();
|
||||
|
||||
/** The animation manager in use by this panel. */
|
||||
protected AnimationManager _animmgr;
|
||||
protected AnimationManager _animmgr = new AnimationManager();
|
||||
|
||||
/** The sprite manager in use by this panel. */
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
/** Used to accumulate and merge dirty regions on each tick. */
|
||||
protected RegionManager _remgr;
|
||||
protected SpriteManager _spritemgr = new SpriteManager();
|
||||
|
||||
/** Whether we're currently paused. */
|
||||
protected boolean _paused;
|
||||
|
||||
@@ -31,15 +31,6 @@ import com.threerings.media.MediaHost;
|
||||
*/
|
||||
public class AnimationManager extends AbstractMediaManager
|
||||
{
|
||||
/**
|
||||
* Construct and initialize the animation manager which readies itself
|
||||
* to manage animations.
|
||||
*/
|
||||
public AnimationManager (MediaHost host)
|
||||
{
|
||||
super(host);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given {@link Animation} with the animation manager
|
||||
* for ticking and painting.
|
||||
|
||||
@@ -38,14 +38,6 @@ import com.threerings.media.MediaHost;
|
||||
*/
|
||||
public class SpriteManager extends AbstractMediaManager
|
||||
{
|
||||
/**
|
||||
* Construct and initialize the sprite manager.
|
||||
*/
|
||||
public SpriteManager (MediaHost host)
|
||||
{
|
||||
super(host);
|
||||
}
|
||||
|
||||
/**
|
||||
* When an animated view processes its dirty rectangles, it may
|
||||
* require an expansion of the dirty region which may in turn
|
||||
|
||||
Reference in New Issue
Block a user