In theory this should work (modulo some particularly fiddly bits that I'm going

to have to think about), but it's totally untested. That comes next!


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@115 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2007-01-20 02:35:56 +00:00
parent 088bc4b88b
commit 81a3dd4dd9
5 changed files with 166 additions and 159 deletions
+45 -15
View File
@@ -23,8 +23,9 @@ package com.threerings.media;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JRootPane;
import com.threerings.media.FrameParticipant;
import com.threerings.media.animation.AnimationManager;
import com.threerings.media.sprite.SpriteManager;
@@ -35,7 +36,7 @@ import com.threerings.media.sprite.SpriteManager;
* it has left dirty.
*/
public class MediaOverlay
implements MediaHost, FrameParticipant
implements MediaHost
{
/**
* Returns a reference to the animation manager used by this media panel.
@@ -53,13 +54,51 @@ public class MediaOverlay
return _metamgr.getSpriteManager();
}
/**
* Called by the {@link FrameManager} to propagate our dirty regions to the active repaint
* manager so that it can repaint the underlying components just prior to our painting our
* media. This will be followe by a call to {@link paint} after the components have been
* repainted.
*/
public void propagateDirtyRegions (ActiveRepaintManager repmgr, JRootPane root)
{
// this will clear out our region manager, so we need to keep these around for our
// subsequent call to paint
_dirty = _metamgr.getRegionManager().getDirtyRegions();
for (int ii = 0; ii < _dirty.length; ii++) {
Rectangle dirty = _dirty[ii];
repmgr.addDirtyRegion(root, dirty.x, dirty.y, dirty.width, dirty.height);
}
}
/**
* Called by the {@link FrameManager} after everything is done painting, allowing us to paint
* gloriously overtop of everything in the frame.
*
* @return true if we painted something, false otherwise.
*/
public boolean paint (Graphics2D gfx)
{
if (_metamgr.needsPaint()) {
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]);
}
return true;
}
return false;
}
// from interface MediaHost
public Graphics2D createGraphics ()
{
return _metamgr.getFrameManager().createGraphics();
}
// from interface FrameParticipant
/**
* Called by the frame manager on every tick.
*/
public void tick (long tickStamp)
{
if (!_metamgr.isPaused()) {
@@ -68,18 +107,6 @@ public class MediaOverlay
}
}
// 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.
*/
@@ -94,4 +121,7 @@ public class MediaOverlay
/** Handles the heavy lifting involving media. */
protected MetaMediaManager _metamgr;
/** A temporary list of dirty rectangles maintained during the painting process. */
protected Rectangle[] _dirty;
}