Because we cleverly do nothing in paint() if there are no dirty regions,
we have to go out of our way to let the abstract media managers know when tick() is all done and paint() *may* be called. This way they can properly clear out their tick stamps because they know that no more media fooling around will happen between the call to willPaint() and the call to paint() (which used to be called renderMedia() but is now paint() to remain in line with all the other places were we tick() and then paint()). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2508 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AbstractMediaManager.java,v 1.9 2003/04/30 00:43:54 mdb Exp $
|
||||
// $Id: AbstractMediaManager.java,v 1.10 2003/04/30 20:48:38 mdb Exp $
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
@@ -36,6 +36,33 @@ public abstract class AbstractMediaManager
|
||||
return _remgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called every frame so that the media can be properly
|
||||
* updated.
|
||||
*/
|
||||
public void tick (long tickStamp)
|
||||
{
|
||||
_tickStamp = tickStamp;
|
||||
tickAllMedia(tickStamp);
|
||||
dispatchNotifications();
|
||||
// we clear our tick stamp when we're about to be painted, this
|
||||
// lets us handle situations when yet more media is slipped in
|
||||
// between our being ticked and our being painted
|
||||
}
|
||||
|
||||
/**
|
||||
* This will always be called prior to the {@link #paint} calls for a
|
||||
* particular tick. Because it is possible that there will be no dirty
|
||||
* regions and thus no calls to {@link #paint} this method exists so
|
||||
* that the media manager can guarantee that it will be notified when
|
||||
* all ticking is complete and the painting phase has begun.
|
||||
*/
|
||||
public void willPaint ()
|
||||
{
|
||||
// now that we're done ticking, we can safely clear this
|
||||
_tickStamp = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders all registered media in the given layer that intersect
|
||||
* the supplied clipping rectangle to the given graphics context.
|
||||
@@ -45,11 +72,8 @@ public abstract class AbstractMediaManager
|
||||
* with a positive render order; the back layer contains all
|
||||
* animations with a negative render order; all, both.
|
||||
*/
|
||||
public void renderMedia (Graphics2D gfx, int layer, Shape clip)
|
||||
public void paint (Graphics2D gfx, int layer, Shape clip)
|
||||
{
|
||||
// now that we're rendering, we can safely clear this; see tick()
|
||||
_tickStamp = 0;
|
||||
|
||||
for (int ii = 0, nn = _media.size(); ii < nn; ii++) {
|
||||
AbstractMedia media = (AbstractMedia)_media.get(ii);
|
||||
int order = media.getRenderOrder();
|
||||
@@ -69,20 +93,6 @@ public abstract class AbstractMediaManager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called every frame so that the media can be properly
|
||||
* updated.
|
||||
*/
|
||||
public void tick (long tickStamp)
|
||||
{
|
||||
_tickStamp = tickStamp;
|
||||
tickAllMedia(tickStamp);
|
||||
dispatchNotifications();
|
||||
// we clear our tick stamp when we've been painted, this lets us
|
||||
// handle situations when yet more media is slipped in between our
|
||||
// being ticked and our being painted
|
||||
}
|
||||
|
||||
/**
|
||||
* If the manager is paused for some length of time, it should
|
||||
* be fast forwarded by the appropriate number of milliseconds. This
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MediaPanel.java,v 1.34 2003/04/30 06:34:55 mdb Exp $
|
||||
// $Id: MediaPanel.java,v 1.35 2003/04/30 20:48:38 mdb Exp $
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
@@ -300,6 +300,14 @@ public class MediaPanel extends JComponent
|
||||
{
|
||||
Graphics2D gfx = (Graphics2D)g;
|
||||
|
||||
// regardless of whether or not we paint, we need to let our
|
||||
// abstract media managers know that we've gotten to the point of
|
||||
// painting because they need to remain prepared to deal with
|
||||
// media changes that happen any time between the tick() and the
|
||||
// paint() and thus need to know when paint() happens
|
||||
_animmgr.willPaint();
|
||||
_spritemgr.willPaint();
|
||||
|
||||
// no use in painting if we're not showing or if we've not yet
|
||||
// been validated
|
||||
if (!isValid() || !isShowing()) {
|
||||
@@ -474,8 +482,8 @@ public class MediaPanel extends JComponent
|
||||
*/
|
||||
protected void paintBits (Graphics2D gfx, int layer, Rectangle dirty)
|
||||
{
|
||||
_animmgr.renderMedia(gfx, layer, dirty);
|
||||
_spritemgr.renderMedia(gfx, layer, dirty);
|
||||
_animmgr.paint(gfx, layer, dirty);
|
||||
_spritemgr.paint(gfx, layer, dirty);
|
||||
}
|
||||
|
||||
/** The frame manager with whom we register. */
|
||||
|
||||
Reference in New Issue
Block a user