CGraphicsQpublic class CGraphicsQ extends Object Chameleon graphics queue class. This class contains methods
to help to better control when, how, and how many pixels
actually get blitted from the buffer to the physical display. |
Fields Summary |
---|
public static final boolean | DEBUGBy turning on "debug" mode, all of Chameleon's graphics engine
will output tracing info regarding dirty regions, layer locations,
bounds, repaints, etc. | protected Vector | refreshQA queue of refresh areas, represented by 4 element arrays |
Constructors Summary |
---|
public CGraphicsQ()Construct a new Graphics queue.
refreshQ = new Vector();
|
Methods Summary |
---|
public java.lang.Object[] | getRefreshRegions()Get the queue of all areas of the screen to be refreshed
(blitted to the screen). This method will empty the queue
and return its contents. Each element in the array will be
a 4 element int[] holding the x, y, w, and h of each refresh
region
synchronized (refreshQ) {
Object[] q = new Object[refreshQ.size()];
refreshQ.copyInto(q);
refreshQ.removeAllElements();
return q;
}
| public void | queueRefresh(int x, int y, int w, int h)Add the specified region to the queue of areas to be
refreshed. That is, the region specified by the given
coordinates represents a region that has been repainted
and needs to be blitted to the display. The coordinates
of the region should be in raw screen coordinates, that
is, 0,0 would represent the topleft pixel on the screen.
synchronized (refreshQ) {
int[] region;
for (int i = 0; i < refreshQ.size(); i++) {
region = (int[])refreshQ.elementAt(i);
// We test to see if we already have the dirty region
if (region[0] == x && region[1] == y &&
region[2] == w && region[3] == h)
{
return;
}
// We also test to see if the dirty region is wholely
// contained within another region
if (x >= region[0] && y >= region[1] &&
(x + w) <= (region[0] + region[1]) &&
(y + h) <= (region[1] + region[3]))
{
return;
}
// Lastly, we do a special case whereby the region
// is congruent with a previous region. For instance,
// when changing screens, the title area will repaint,
// the body area will repaint, and the soft button
// area will repaint. All 3 areas are congruent and
// can be coalesced.
if (x == region[0] && w == region[2]) {
if ((region[1] + region[3]) == y ||
(y + h) == region[1])
{
if (region[1] > y) {
region[1] = y;
}
region[3] += h;
return;
}
}
}
refreshQ.addElement(new int[] {x, y, w, h});
}
|
|