Clemens Eisserer
By: a guest | Jan 3rd, 2009 | Syntax:
Java | Size: 1.51 KB | Hits: 40 | Expires: Never
public static void main
(String[] args
) {
XRRenderQueue queue = new XRRenderQueue(false);
queue.socketTaken = true;
while (true) {
long start
= System.
currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
// SunToolkit.awtLock();
try {
queue.XRenderRectangle((int) start, XRUtils.PictOpAdd, XRColor.FULL_ALPHA, i, i, i, i);
} finally {
// SunToolkit.awtUnlock();
}
}
long end
= System.
currentTimeMillis();
System.
out.
println("Took: " + (end
- start
));
}
}
public final void XRenderRectangle(int dst, byte op, XRColor color, int x, int y, int width, int height) {
prepareRequest(28);
putRequestHeader(MAJOR_RENDER, FILL_RECTANGLES, 7);
buf.putByte(op);
buf.skip(3);
buf.putInt(dst);
color.writeToBuffer(buf);
buf.putShort((short) x);
buf.putShort((short) (y));
buf.putShort((short) (width));
buf.putShort((short) (height));
}
public final RenderBuffer putByte(byte x) {
unsafe.putByte(curAddress, x);
curAddress += SIZEOF_BYTE;
return this;
}
public final void prepareRequest(int opsize) {
if (buf.remaining() < opsize) {
flush(false);
}
checkSocketAccess();
requestCount++;
}
protected void checkSocketAccess() {
if (!socketTaken) {
flushThread.takeSocket();
socketTaken = true;
}
}
public void flush(boolean sync) {
buf.clear();
requestCount = 0;
}
public final void clear() {
curAddress = baseAddress;
}