Changed debug logging so that it is easier to enable and disable since I
seem to be debugging the fucking rendering every other day. Fixed bug with dirty region combining. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1331 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FrameRepaintManager.java,v 1.5 2002/05/03 04:14:20 mdb Exp $
|
// $Id: FrameRepaintManager.java,v 1.6 2002/05/04 03:09:46 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
@@ -73,14 +73,21 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
// if we found no validation root we can abort as this component
|
// if we found no validation root we can abort as this component
|
||||||
// is not part of any valid widget hierarchy
|
// is not part of any valid widget hierarchy
|
||||||
if (vroot == null) {
|
if (vroot == null) {
|
||||||
// Log.info("Skipping vrootless component: " + comp);
|
if (DEBUG) {
|
||||||
|
Log.info("Skipping vrootless component: " + toString(comp));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that the component is actually in a window or applet
|
// make sure that the component is actually in a window or applet
|
||||||
// that is showing
|
// that is showing
|
||||||
if (getRoot(vroot) == null) {
|
if (getRoot(vroot) == null) {
|
||||||
// Log.info("Skipping rootless component: " + comp + "/" + vroot);
|
if (DEBUG) {
|
||||||
|
Log.info("Skipping rootless component " +
|
||||||
|
"[comp=" + toString(comp) +
|
||||||
|
", vroot=" + toString(vroot) + "].");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +125,12 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.info("Dirtying component [comp=" + toString(comp) +
|
||||||
|
", drect=" + StringUtil.toString(
|
||||||
|
new Rectangle(x, y, width, height)) + "].");
|
||||||
|
}
|
||||||
|
|
||||||
// if we made it this far, we can queue up a dirty region for this
|
// if we made it this far, we can queue up a dirty region for this
|
||||||
// component to be repainted on the next tick
|
// component to be repainted on the next tick
|
||||||
_dirty.put(comp, new Rectangle(x, y, width, height));
|
_dirty.put(comp, new Rectangle(x, y, width, height));
|
||||||
@@ -208,9 +221,9 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
Entry entry = (Entry)iter.next();
|
Entry entry = (Entry)iter.next();
|
||||||
JComponent comp = (JComponent)entry.getKey();
|
JComponent comp = (JComponent)entry.getKey();
|
||||||
Rectangle drect = (Rectangle)entry.getValue();
|
Rectangle drect = (Rectangle)entry.getValue();
|
||||||
int x = drect.x, y = drect.y;
|
int x = comp.getX() + drect.x, y = comp.getY() + drect.y;
|
||||||
|
|
||||||
// climb up the parent heirarchy, looking for the first opaque
|
// climb up the parent hierarchy, looking for the first opaque
|
||||||
// parent as well as the root component
|
// parent as well as the root component
|
||||||
for (Component c = comp.getParent(); c != null; c = c.getParent()) {
|
for (Component c = comp.getParent(); c != null; c = c.getParent()) {
|
||||||
// stop looking for combinable parents for non-visible or
|
// stop looking for combinable parents for non-visible or
|
||||||
@@ -223,18 +236,24 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
// check to see if this parent is dirty
|
// check to see if this parent is dirty
|
||||||
Rectangle prect = (Rectangle)_spare.get(c);
|
Rectangle prect = (Rectangle)_spare.get(c);
|
||||||
if (prect != null) {
|
if (prect != null) {
|
||||||
// Log.info("Found dirty parent " +
|
|
||||||
// "[comp=" + comp.getClass().getName() +
|
|
||||||
// ", drect=" + StringUtil.toString(drect) +
|
|
||||||
// ", pcomp=" + comp.getClass().getName() +
|
|
||||||
// ", prect=" + StringUtil.toString(prect) + "].");
|
|
||||||
// we wanted to avoid modifying drect until we knew
|
|
||||||
// that we were going to merge it with its parent and
|
// that we were going to merge it with its parent and
|
||||||
// blow it away
|
// blow it away
|
||||||
drect.x = x;
|
drect.x = x;
|
||||||
drect.y = y;
|
drect.y = y;
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.info("Found dirty parent " +
|
||||||
|
"[comp=" + toString(comp) +
|
||||||
|
", drect=" + StringUtil.toString(drect) +
|
||||||
|
", pcomp=" + toString(c) +
|
||||||
|
", prect=" + StringUtil.toString(prect) +
|
||||||
|
"].");
|
||||||
|
}
|
||||||
prect.add(drect);
|
prect.add(drect);
|
||||||
// Log.info("New prect " + StringUtil.toString(prect));
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.info("New prect " + StringUtil.toString(prect));
|
||||||
|
}
|
||||||
|
|
||||||
// remove the child component and be on our way
|
// remove the child component and be on our way
|
||||||
iter.remove();
|
iter.remove();
|
||||||
@@ -266,7 +285,7 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
// opaque parent component's bounds if and when we find one
|
// opaque parent component's bounds if and when we find one
|
||||||
_cbounds.setBounds(0, 0, comp.getWidth(), comp.getHeight());
|
_cbounds.setBounds(0, 0, comp.getWidth(), comp.getHeight());
|
||||||
|
|
||||||
// climb up the parent heirarchy, looking for the first opaque
|
// climb up the parent hierarchy, looking for the first opaque
|
||||||
// parent as well as the root component
|
// parent as well as the root component
|
||||||
for (Component c = comp; c != null; c = c.getParent()) {
|
for (Component c = comp; c != null; c = c.getParent()) {
|
||||||
if (!c.isVisible() || c.getPeer() == null) {
|
if (!c.isVisible() || c.getPeer() == null) {
|
||||||
@@ -309,20 +328,27 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
// if this component is rooted in our frame, repaint it into
|
// if this component is rooted in our frame, repaint it into
|
||||||
// the supplied graphics instance
|
// the supplied graphics instance
|
||||||
if (root == _rootFrame) {
|
if (root == _rootFrame) {
|
||||||
// Log.info("Repainting [comp=" + comp.getClass().getName() +
|
if (DEBUG) {
|
||||||
// StringUtil.toString(_cbounds) +
|
Log.info("Repainting [comp=" + toString(comp) +
|
||||||
// ", ocomp=" + ocomp.getClass().getName() +
|
StringUtil.toString(_cbounds) +
|
||||||
// ", drect=" + StringUtil.toString(drect) + "].");
|
", ocomp=" + toString(ocomp) +
|
||||||
|
", drect=" + StringUtil.toString(drect) + "].");
|
||||||
|
}
|
||||||
|
|
||||||
g.setClip(drect);
|
g.setClip(drect);
|
||||||
g.translate(_cbounds.x, _cbounds.y);
|
g.translate(_cbounds.x, _cbounds.y);
|
||||||
ocomp.paint(g);
|
ocomp.paint(g);
|
||||||
g.translate(-_cbounds.x, -_cbounds.y);
|
g.translate(-_cbounds.x, -_cbounds.y);
|
||||||
|
|
||||||
} else if (root != null) {
|
} else if (root != null) {
|
||||||
// Log.info("Repainting old-school " +
|
if (DEBUG) {
|
||||||
// "[comp=" + comp.getClass().getName() +
|
Log.info("Repainting old-school " +
|
||||||
// ", ocomp=" + ocomp.getClass().getName() +
|
"[comp=" + toString(comp) +
|
||||||
// ", bounds=" + StringUtil.toString(_cbounds) + "].");
|
", ocomp=" + toString(ocomp) +
|
||||||
|
", bounds=" + StringUtil.toString(_cbounds) +
|
||||||
|
"].");
|
||||||
|
}
|
||||||
|
|
||||||
// otherwise, repaint with standard swing double buffers
|
// otherwise, repaint with standard swing double buffers
|
||||||
Image obuf = getOffscreenBuffer(
|
Image obuf = getOffscreenBuffer(
|
||||||
ocomp, _cbounds.width, _cbounds.height);
|
ocomp, _cbounds.width, _cbounds.height);
|
||||||
@@ -348,6 +374,15 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
_spare.clear();
|
_spare.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to dump a component when debugging.
|
||||||
|
*/
|
||||||
|
protected String toString (Component comp)
|
||||||
|
{
|
||||||
|
return comp.getClass().getName() +
|
||||||
|
StringUtil.toString(comp.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
/** The managed frame. */
|
/** The managed frame. */
|
||||||
protected Frame _rootFrame;
|
protected Frame _rootFrame;
|
||||||
|
|
||||||
@@ -363,4 +398,8 @@ public class FrameRepaintManager extends RepaintManager
|
|||||||
|
|
||||||
/** Used to compute dirty components' bounds. */
|
/** Used to compute dirty components' bounds. */
|
||||||
protected Rectangle _cbounds = new Rectangle();
|
protected Rectangle _cbounds = new Rectangle();
|
||||||
|
|
||||||
|
/** We debug so much that we have to make it easy to enable and
|
||||||
|
* disable debug logging. Yay! */
|
||||||
|
protected static final boolean DEBUG = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user