Modified frame manager to do the right thing in terms of repainting
everything if we lose our volatile offscreen buffer image. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1313 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FrameManager.java,v 1.5 2002/04/27 22:39:45 mdb Exp $
|
// $Id: FrameManager.java,v 1.6 2002/04/28 02:49:32 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
@@ -252,14 +252,17 @@ public class FrameManager
|
|||||||
// _bufstrat = _frame.getBufferStrategy();
|
// _bufstrat = _frame.getBufferStrategy();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// create our off-screen buffer if necessary
|
// start out assuming we can do an incremental render
|
||||||
GraphicsConfiguration gc = _frame.getGraphicsConfiguration();
|
boolean incremental = true;
|
||||||
if (_backimg == null) {
|
|
||||||
createBackBuffer(gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// render into our back buffer
|
|
||||||
do {
|
do {
|
||||||
|
GraphicsConfiguration gc = _frame.getGraphicsConfiguration();
|
||||||
|
|
||||||
|
// create our off-screen buffer if necessary
|
||||||
|
if (_backimg == null) {
|
||||||
|
createBackBuffer(gc);
|
||||||
|
}
|
||||||
|
|
||||||
// make sure our back buffer hasn't disappeared
|
// make sure our back buffer hasn't disappeared
|
||||||
int valres = _backimg.validate(gc);
|
int valres = _backimg.validate(gc);
|
||||||
|
|
||||||
@@ -269,6 +272,13 @@ public class FrameManager
|
|||||||
createBackBuffer(gc);
|
createBackBuffer(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the image wasn't A-OK, we need to rerender the whole
|
||||||
|
// business rather than just the dirty parts
|
||||||
|
if (valres != VolatileImage.IMAGE_OK) {
|
||||||
|
Log.info("Lost back buffer, redrawing.");
|
||||||
|
incremental = false;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle bounds = new Rectangle();
|
Rectangle bounds = new Rectangle();
|
||||||
Graphics g = null, fg = null;
|
Graphics g = null, fg = null;
|
||||||
try {
|
try {
|
||||||
@@ -276,10 +286,9 @@ public class FrameManager
|
|||||||
fg = _frame.getGraphics();
|
fg = _frame.getGraphics();
|
||||||
// g = _bufstrat.getDrawGraphics();
|
// g = _bufstrat.getDrawGraphics();
|
||||||
|
|
||||||
// if the image wasn't A-OK, we need to rerender the
|
// dirty everything if we're not incrementally rendering
|
||||||
// whole business rather than just the dirty parts
|
if (!incremental) {
|
||||||
if (valres != VolatileImage.IMAGE_OK) {
|
_frame.update(g);
|
||||||
Log.info("Lost back buffer, redrawing.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// repaint any widgets that have declared there need to be
|
// repaint any widgets that have declared there need to be
|
||||||
@@ -339,6 +348,10 @@ public class FrameManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we loop through a second time, we'll need to rerender
|
||||||
|
// everything
|
||||||
|
incremental = false;
|
||||||
|
|
||||||
} while (_backimg.contentsLost());
|
} while (_backimg.contentsLost());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user