We need to ensure that dirty regions are constrained to the bounds of the
component in MediaPanel as well as VirtualMediaPanel. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1482 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MediaPanel.java,v 1.14 2002/06/18 22:25:33 mdb Exp $
|
||||
// $Id: MediaPanel.java,v 1.15 2002/06/19 07:41:37 mdb Exp $
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.awt.Shape;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.RepaintManager;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
@@ -263,10 +264,16 @@ public class MediaPanel extends JComponent
|
||||
|
||||
for (int ii = 0; ii < dcount; ii++) {
|
||||
Rectangle clip = dirty[ii];
|
||||
|
||||
// constrain this dirty region to the bounds of the component
|
||||
constrainToBounds(clip);
|
||||
|
||||
// ignore rectangles that were reduced to nothingness
|
||||
if (clip.width == 0 || clip.height == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// clip to this dirty region
|
||||
clipToDirtyRegion(gfx, clip);
|
||||
|
||||
// paint the behind the scenes stuff
|
||||
@@ -286,6 +293,19 @@ public class MediaPanel extends JComponent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the main rendering code to constrain this dirty rectangle
|
||||
* to the bounds of the media panel. If a derived class is using dirty
|
||||
* rectangles that live in some sort of virtual coordinate system,
|
||||
* they'll want to override this method and constraint the rectangles
|
||||
* properly.
|
||||
*/
|
||||
protected void constrainToBounds (Rectangle dirty)
|
||||
{
|
||||
SwingUtilities.computeIntersection(
|
||||
0, 0, getWidth(), getHeight(), dirty);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called to clip the rendering output to the supplied dirty
|
||||
* region. This should use {@link Graphics#setClip} because the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: VirtualMediaPanel.java,v 1.3 2002/06/19 02:34:39 mdb Exp $
|
||||
// $Id: VirtualMediaPanel.java,v 1.4 2002/06/19 07:41:37 mdb Exp $
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
@@ -168,11 +168,9 @@ public class VirtualMediaPanel extends MediaPanel
|
||||
// documentation inherited
|
||||
protected void paint (Graphics2D gfx, Rectangle[] dirty)
|
||||
{
|
||||
int width = getWidth(), height = getHeight();
|
||||
int dcount = dirty.length;
|
||||
|
||||
// if we're scrolling, go ahead and do the business
|
||||
if (_dx != 0 || _dy != 0) {
|
||||
int width = getWidth(), height = getHeight();
|
||||
int cx = (_dx > 0) ? _dx : 0;
|
||||
int cy = (_dy > 0) ? _dy : 0;
|
||||
|
||||
@@ -190,14 +188,6 @@ public class VirtualMediaPanel extends MediaPanel
|
||||
_dx = 0; _dy = 0;
|
||||
}
|
||||
|
||||
// clip the dirty regions to the viewport
|
||||
for (int ii = 0; ii < dcount; ii++) {
|
||||
SwingUtilities.computeIntersection(
|
||||
_tx, _ty, width, height, dirty[ii]);
|
||||
// Log.info("Intersected [rect=" + StringUtil.toString(dirty[ii]) +
|
||||
// ", tx=" + _tx + ", ty=" + _ty + "].");
|
||||
}
|
||||
|
||||
// translate into happy space
|
||||
gfx.translate(-_tx, -_ty);
|
||||
|
||||
@@ -208,6 +198,13 @@ public class VirtualMediaPanel extends MediaPanel
|
||||
gfx.translate(_tx, _ty);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void constrainToBounds (Rectangle dirty)
|
||||
{
|
||||
SwingUtilities.computeIntersection(
|
||||
_tx, _tx, getWidth(), getHeight(), dirty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to compute our viewport offsets.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user