// maximum of nItems).
public int check(int itemSize, int nItems, boolean wait) {
- if (ptr + itemSize * nItems > end) {
- if (ptr + itemSize > end)
+ int available = end - ptr;
+ if (itemSize * nItems > available) {
+ if (itemSize > available)
return overrun(itemSize, nItems, wait);
- nItems = (end - ptr) / itemSize;
+ nItems = available / itemSize;
}
return nItems;
}
// readU/SN() methods read unsigned and signed N-bit integers.
- public final int readS8() { check(1); return b[ptr++]; }
- public final int readS16() { check(2); int b0 = b[ptr++];
+ public final int readS8() { check(1,1,true); return b[ptr++]; }
+ public final int readS16() { check(2,1,true); int b0 = b[ptr++];
int b1 = b[ptr++] & 0xff; return b0 << 8 | b1; }
- public final int readS32() { check(4); int b0 = b[ptr++];
+ public final int readS32() { check(4,1,true); int b0 = b[ptr++];
int b1 = b[ptr++] & 0xff;
int b2 = b[ptr++] & 0xff;
int b3 = b[ptr++] & 0xff;
public final void skip(int bytes) {
while (bytes > 0) {
- int n = check(1, bytes);
+ int n = check(1, bytes, true);
ptr += n;
bytes -= n;
}
public void readBytes(byte[] data, int dataPtr, int length) {
int dataEnd = dataPtr + length;
while (dataPtr < dataEnd) {
- int n = check(1, dataEnd - dataPtr);
+ int n = check(1, dataEnd - dataPtr, true);
System.arraycopy(b, ptr, data, dataPtr, n);
ptr += n;
dataPtr += n;
public void readBytes(int[] data, int dataPtr, int length) {
int dataEnd = dataPtr + length;
while (dataPtr < dataEnd) {
- int n = check(1, dataEnd - dataPtr);
+ int n = check(1, dataEnd - dataPtr, true);
System.arraycopy(b, ptr, data, dataPtr, n);
ptr += n;
dataPtr += n;
public final int readOpaque8() { return readU8(); }
public final int readOpaque16() { return readU16(); }
public final int readOpaque32() { return readU32(); }
- public final int readOpaque24A() { check(3); int b0 = b[ptr++];
+ public final int readOpaque24A() { check(3, 1, true); int b0 = b[ptr++];
int b1 = b[ptr++]; int b2 = b[ptr++];
return b0 << 24 | b1 << 16 | b2 << 8; }
- public final int readOpaque24B() { check(3); int b0 = b[ptr++];
+ public final int readOpaque24B() { check(3, 1, true); int b0 = b[ptr++];
int b1 = b[ptr++]; int b2 = b[ptr++];
return b0 << 16 | b1 << 8 | b2; }
tk.createImage(bitmap).getScaledInstance(cw,ch,hint);
softCursor = tk.createCustomCursor(cursorImage,
new java.awt.Point(hotspot.x,hotspot.y), "Cursor");
+ cursorImage.flush();
if (softCursor != null) {
setCursor(softCursor);
if (overlapsCursor(x, y, w, h) || overlapsCursor(srcX, srcY, w, h))
hideLocalCursor();
synchronized (im) {
- im.copyRect(x, y, w, h, srcX, srcY);
+ im.copyRect(x, y, w, h, srcX, srcY, graphics);
}
if (!cc.viewer.fastCopyRect.getValue()) {
invalidate(x, y, w, h);
// copyRect() we also need to tell the ImageConsumer that the pixels have
// changed (this is done in the put() call for the others).
- public void copyRect(int x, int y, int w, int h, int srcX, int srcY) {
+ public void copyRect(int x, int y, int w, int h, int srcX, int srcY, Graphics g) {
super.copyRect(x, y, w, h, srcX, srcY);
if (ic == null) return;
ic.setPixels(x, y, w, h, cm, data, width() * y + x, width());
+ g.setClip(x, y, w, h);
ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
}