Automated code formatting by NetBeans IDE.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2529 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/VncCanvas.java b/java/src/com/tightvnc/rfbplayer/VncCanvas.java
index 8272016..57bb858 100644
--- a/java/src/com/tightvnc/rfbplayer/VncCanvas.java
+++ b/java/src/com/tightvnc/rfbplayer/VncCanvas.java
@@ -32,7 +32,6 @@
//
// VncCanvas is a subclass of Canvas which draws a VNC desktop on it.
//
-
class VncCanvas extends Canvas implements Observer {
RfbPlayer player;
@@ -69,7 +68,6 @@
//
// The constructor.
//
-
VncCanvas(RfbPlayer player) throws IOException {
this.player = player;
rfb = player.rfb;
@@ -83,7 +81,6 @@
//
// Callback methods to determine geometry of our Component.
//
-
public Dimension getPreferredSize() {
return new Dimension(rfb.framebufferWidth, rfb.framebufferHeight);
}
@@ -99,7 +96,6 @@
//
// All painting is performed here.
//
-
public void update(Graphics g) {
paint(g);
}
@@ -114,22 +110,21 @@
// Override the ImageObserver interface method to handle drawing of
// JPEG-encoded data.
//
-
public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int width, int height) {
+ int x, int y, int width, int height) {
if ((infoflags & (ALLBITS | ABORT)) == 0) {
return true; // We need more image data.
} else {
// If the whole image is available, draw it now.
if ((infoflags & ALLBITS) != 0) {
- if (jpegRect != null) {
- synchronized(jpegRect) {
- memGraphics.drawImage(img, jpegRect.x, jpegRect.y, null);
- scheduleRepaint(jpegRect.x, jpegRect.y,
- jpegRect.width, jpegRect.height);
- jpegRect.notify();
- }
- }
+ if (jpegRect != null) {
+ synchronized(jpegRect) {
+ memGraphics.drawImage(img, jpegRect.x, jpegRect.y, null);
+ scheduleRepaint(jpegRect.x, jpegRect.y,
+ jpegRect.width, jpegRect.height);
+ jpegRect.notify();
+ }
+ }
}
return false; // All image data was processed.
}
@@ -148,10 +143,10 @@
memImage = player.createImage(fbWidth, fbHeight);
memGraphics = memImage.getGraphics();
} else if (memImage.getWidth(null) != fbWidth ||
- memImage.getHeight(null) != fbHeight) {
+ memImage.getHeight(null) != fbHeight) {
synchronized(memImage) {
- memImage = player.createImage(fbWidth, fbHeight);
- memGraphics = memImage.getGraphics();
+ memImage = player.createImage(fbWidth, fbHeight);
+ memGraphics = memImage.getGraphics();
}
}
@@ -159,14 +154,14 @@
// of geometry or pixel format.
pixels24 = new int[fbWidth * fbHeight];
pixelsSource =
- new MemoryImageSource(fbWidth, fbHeight, cm24, pixels24, 0, fbWidth);
+ new MemoryImageSource(fbWidth, fbHeight, cm24, pixels24, 0, fbWidth);
pixelsSource.setAnimated(true);
rawPixelsImage = createImage(pixelsSource);
// Update the size of desktop containers.
if (player.inSeparateFrame) {
if (player.desktopScrollPane != null)
- resizeDesktopFrame();
+ resizeDesktopFrame();
} else {
setSize(fbWidth, fbHeight);
}
@@ -179,9 +174,9 @@
// ScrollPane. -- const
Insets insets = player.desktopScrollPane.getInsets();
player.desktopScrollPane.setSize(rfb.framebufferWidth +
- 2 * Math.min(insets.left, insets.right),
- rfb.framebufferHeight +
- 2 * Math.min(insets.top, insets.bottom));
+ 2 * Math.min(insets.left, insets.right),
+ rfb.framebufferHeight +
+ 2 * Math.min(insets.top, insets.bottom));
player.vncFrame.pack();
@@ -209,7 +204,6 @@
// processNormalProtocol() - executed by the rfbThread to deal with
// the RFB data.
//
-
public void processNormalProtocol() throws Exception {
zlibInflater = new Inflater();
@@ -230,70 +224,70 @@
switch (msgType) {
case RfbProto.FramebufferUpdate:
- rfb.readFramebufferUpdate();
+ rfb.readFramebufferUpdate();
- for (int i = 0; i < rfb.updateNRects; i++) {
- rfb.readFramebufferUpdateRectHdr();
- int rx = rfb.updateRectX, ry = rfb.updateRectY;
- int rw = rfb.updateRectW, rh = rfb.updateRectH;
+ for (int i = 0; i < rfb.updateNRects; i++) {
+ rfb.readFramebufferUpdateRectHdr();
+ int rx = rfb.updateRectX, ry = rfb.updateRectY;
+ int rw = rfb.updateRectW, rh = rfb.updateRectH;
- if (rfb.updateRectEncoding == rfb.EncodingLastRect)
- break;
+ if (rfb.updateRectEncoding == rfb.EncodingLastRect)
+ break;
- if (rfb.updateRectEncoding == rfb.EncodingNewFBSize) {
- rfb.setFramebufferSize(rfb.updateRectW, rfb.updateRectH);
- updateFramebufferSize();
- break;
- }
+ if (rfb.updateRectEncoding == rfb.EncodingNewFBSize) {
+ rfb.setFramebufferSize(rfb.updateRectW, rfb.updateRectH);
+ updateFramebufferSize();
+ break;
+ }
- if (rfb.updateRectEncoding == rfb.EncodingXCursor ||
- rfb.updateRectEncoding == rfb.EncodingRichCursor) {
- throw new Exception("Sorry, no support for" +
- " cursor shape updates yet");
- }
+ if (rfb.updateRectEncoding == rfb.EncodingXCursor ||
+ rfb.updateRectEncoding == rfb.EncodingRichCursor) {
+ throw new Exception("Sorry, no support for" +
+ " cursor shape updates yet");
+ }
- switch (rfb.updateRectEncoding) {
- case RfbProto.EncodingRaw:
- handleRawRect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingCopyRect:
- handleCopyRect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingRRE:
- handleRRERect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingCoRRE:
- handleCoRRERect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingHextile:
- handleHextileRect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingZlib:
+ switch (rfb.updateRectEncoding) {
+ case RfbProto.EncodingRaw:
+ handleRawRect(rx, ry, rw, rh);
+ break;
+ case RfbProto.EncodingCopyRect:
+ handleCopyRect(rx, ry, rw, rh);
+ break;
+ case RfbProto.EncodingRRE:
+ handleRRERect(rx, ry, rw, rh);
+ break;
+ case RfbProto.EncodingCoRRE:
+ handleCoRRERect(rx, ry, rw, rh);
+ break;
+ case RfbProto.EncodingHextile:
+ handleHextileRect(rx, ry, rw, rh);
+ break;
+ case RfbProto.EncodingZlib:
handleZlibRect(rx, ry, rw, rh);
- break;
- case RfbProto.EncodingTight:
- handleTightRect(rx, ry, rw, rh);
- break;
- default:
- throw new Exception("Unknown RFB rectangle encoding " +
- rfb.updateRectEncoding);
- }
- }
- break;
+ break;
+ case RfbProto.EncodingTight:
+ handleTightRect(rx, ry, rw, rh);
+ break;
+ default:
+ throw new Exception("Unknown RFB rectangle encoding " +
+ rfb.updateRectEncoding);
+ }
+ }
+ break;
case RfbProto.SetColourMapEntries:
- throw new Exception("Can't handle SetColourMapEntries message");
+ throw new Exception("Can't handle SetColourMapEntries message");
case RfbProto.Bell:
Toolkit.getDefaultToolkit().beep();
- break;
+ break;
case RfbProto.ServerCutText:
- String s = rfb.readServerCutText();
- break;
+ String s = rfb.readServerCutText();
+ break;
default:
- throw new Exception("Unknown RFB message type " + msgType);
+ throw new Exception("Unknown RFB message type " + msgType);
}
player.updatePos();
@@ -304,7 +298,6 @@
//
// Handle a raw rectangle.
//
-
void handleRawRect(int x, int y, int w, int h) throws IOException {
byte[] buf = new byte[w * 4];
@@ -313,10 +306,10 @@
rfb.is.readFully(buf);
offset = dy * rfb.framebufferWidth + x;
for (i = 0; i < w; i++) {
- pixels24[offset + i] =
- (buf[i * 4 + 2] & 0xFF) << 16 |
- (buf[i * 4 + 1] & 0xFF) << 8 |
- (buf[i * 4] & 0xFF);
+ pixels24[offset + i] =
+ (buf[i * 4 + 2] & 0xFF) << 16 |
+ (buf[i * 4 + 1] & 0xFF) << 8 |
+ (buf[i * 4] & 0xFF);
}
}
@@ -328,12 +321,11 @@
//
// Handle a CopyRect rectangle.
//
-
void handleCopyRect(int x, int y, int w, int h) throws IOException {
rfb.readCopyRect();
memGraphics.copyArea(rfb.copyRectSrcX, rfb.copyRectSrcY, w, h,
- x - rfb.copyRectSrcX, y - rfb.copyRectSrcY);
+ x - rfb.copyRectSrcX, y - rfb.copyRectSrcY);
scheduleRepaint(x, y, w, h);
}
@@ -341,7 +333,6 @@
//
// Handle an RRE-encoded rectangle.
//
-
void handleRRERect(int x, int y, int w, int h) throws IOException {
int nSubrects = rfb.is.readInt();
@@ -371,7 +362,6 @@
//
// Handle a CoRRE-encoded rectangle.
//
-
void handleCoRRERect(int x, int y, int w, int h) throws IOException {
int nSubrects = rfb.is.readInt();
@@ -403,7 +393,7 @@
//
// These colors should be kept between handleHextileSubrect() calls.
- private Color hextile_bg, hextile_fg;
+ private Color hextile_bg, hextile_fg;
void handleHextileRect(int x, int y, int w, int h) throws IOException {
@@ -413,14 +403,14 @@
for (int ty = y; ty < y + h; ty += 16) {
int th = 16;
if (y + h - ty < 16)
- th = y + h - ty;
+ th = y + h - ty;
for (int tx = x; tx < x + w; tx += 16) {
- int tw = 16;
- if (x + w - tx < 16)
- tw = x + w - tx;
+ int tw = 16;
+ if (x + w - tx < 16)
+ tw = x + w - tx;
- handleHextileSubrect(tx, ty, tw, th);
+ handleHextileSubrect(tx, ty, tw, th);
}
// Finished with a row of tiles, now let's show it.
@@ -431,9 +421,8 @@
//
// Handle one tile in the Hextile-encoded data.
//
-
void handleHextileSubrect(int tx, int ty, int tw, int th)
- throws IOException {
+ throws IOException {
byte[] buf = new byte[256 * 4];
@@ -443,14 +432,14 @@
if ((subencoding & rfb.HextileRaw) != 0) {
int count, offset;
for (int j = ty; j < ty + th; j++) {
- rfb.is.readFully(buf, 0, tw * 4);
- offset = j * rfb.framebufferWidth + tx;
- for (count = 0; count < tw; count++) {
- pixels24[offset + count] =
- (buf[count * 4 + 2] & 0xFF) << 16 |
- (buf[count * 4 + 1] & 0xFF) << 8 |
- (buf[count * 4] & 0xFF);
- }
+ rfb.is.readFully(buf, 0, tw * 4);
+ offset = j * rfb.framebufferWidth + tx;
+ for (count = 0; count < tw; count++) {
+ pixels24[offset + count] =
+ (buf[count * 4 + 2] & 0xFF) << 16 |
+ (buf[count * 4 + 1] & 0xFF) << 8 |
+ (buf[count * 4] & 0xFF);
+ }
}
handleUpdatedPixels(tx, ty, tw, th);
return;
@@ -479,27 +468,27 @@
int b1, b2, sx, sy, sw, sh;
if ((subencoding & rfb.HextileSubrectsColoured) != 0) {
for (int j = 0; j < nSubrects; j++) {
- rfb.is.readFully(buf, 0, 4);
- hextile_fg = new Color(buf[2] & 0xFF, buf[1] & 0xFF, buf[0] & 0xFF);
- b1 = rfb.is.readUnsignedByte();
- b2 = rfb.is.readUnsignedByte();
- sx = tx + (b1 >> 4);
- sy = ty + (b1 & 0xf);
- sw = (b2 >> 4) + 1;
- sh = (b2 & 0xf) + 1;
- memGraphics.setColor(hextile_fg);
- memGraphics.fillRect(sx, sy, sw, sh);
+ rfb.is.readFully(buf, 0, 4);
+ hextile_fg = new Color(buf[2] & 0xFF, buf[1] & 0xFF, buf[0] & 0xFF);
+ b1 = rfb.is.readUnsignedByte();
+ b2 = rfb.is.readUnsignedByte();
+ sx = tx + (b1 >> 4);
+ sy = ty + (b1 & 0xf);
+ sw = (b2 >> 4) + 1;
+ sh = (b2 & 0xf) + 1;
+ memGraphics.setColor(hextile_fg);
+ memGraphics.fillRect(sx, sy, sw, sh);
}
} else {
memGraphics.setColor(hextile_fg);
for (int j = 0; j < nSubrects; j++) {
- b1 = rfb.is.readUnsignedByte();
- b2 = rfb.is.readUnsignedByte();
- sx = tx + (b1 >> 4);
- sy = ty + (b1 & 0xf);
- sw = (b2 >> 4) + 1;
- sh = (b2 & 0xf) + 1;
- memGraphics.fillRect(sx, sy, sw, sh);
+ b1 = rfb.is.readUnsignedByte();
+ b2 = rfb.is.readUnsignedByte();
+ sx = tx + (b1 >> 4);
+ sy = ty + (b1 & 0xf);
+ sw = (b2 >> 4) + 1;
+ sh = (b2 & 0xf) + 1;
+ memGraphics.fillRect(sx, sy, sw, sh);
}
}
}
@@ -507,7 +496,6 @@
//
// Handle a Zlib-encoded rectangle.
//
-
void handleZlibRect(int x, int y, int w, int h) throws Exception {
int nBytes = rfb.is.readInt();
@@ -524,17 +512,16 @@
byte[] buf = new byte[w * 4];
int i, offset;
for (int dy = y; dy < y + h; dy++) {
- zlibInflater.inflate(buf);
- offset = dy * rfb.framebufferWidth + x;
- for (i = 0; i < w; i++) {
- pixels24[offset + i] =
- (buf[i * 4 + 2] & 0xFF) << 16 |
- (buf[i * 4 + 1] & 0xFF) << 8 |
- (buf[i * 4] & 0xFF);
- }
+ zlibInflater.inflate(buf);
+ offset = dy * rfb.framebufferWidth + x;
+ for (i = 0; i < w; i++) {
+ pixels24[offset + i] =
+ (buf[i * 4 + 2] & 0xFF) << 16 |
+ (buf[i * 4 + 1] & 0xFF) << 8 |
+ (buf[i * 4] & 0xFF);
+ }
}
- }
- catch (DataFormatException dfe) {
+ } catch (DataFormatException dfe) {
throw new Exception(dfe.toString());
}
@@ -545,7 +532,6 @@
//
// Handle a Tight-encoded rectangle.
//
-
void handleTightRect(int x, int y, int w, int h) throws Exception {
int comp_ctl = rfb.is.readUnsignedByte();
@@ -553,7 +539,7 @@
// Flush zlib streams if we are told by the server to do so.
for (int stream_id = 0; stream_id < 4; stream_id++) {
if ((comp_ctl & 1) != 0 && tightInflaters[stream_id] != null) {
- tightInflaters[stream_id] = null;
+ tightInflaters[stream_id] = null;
}
comp_ctl >>= 1;
}
@@ -589,13 +575,13 @@
// Let the imageUpdate() method do the actual drawing, here just
// wait until the image is fully loaded and drawn.
synchronized(jpegRect) {
- Toolkit.getDefaultToolkit().prepareImage(jpegImage, -1, -1, this);
- try {
- // Wait no longer than three seconds.
- jpegRect.wait(3000);
- } catch (InterruptedException e) {
- throw new Exception("Interrupted while decoding JPEG image");
- }
+ Toolkit.getDefaultToolkit().prepareImage(jpegImage, -1, -1, this);
+ try {
+ // Wait no longer than three seconds.
+ jpegRect.wait(3000);
+ } catch (InterruptedException e) {
+ throw new Exception("Interrupted while decoding JPEG image");
+ }
}
// Done, jpegRect is not needed any more.
@@ -612,20 +598,20 @@
if ((comp_ctl & rfb.TightExplicitFilter) != 0) {
int filter_id = rfb.is.readUnsignedByte();
if (filter_id == rfb.TightFilterPalette) {
- numColors = rfb.is.readUnsignedByte() + 1;
- byte[] buf = new byte[numColors * 3];
- rfb.is.readFully(buf);
- for (int i = 0; i < numColors; i++) {
- palette24[i] = ((buf[i * 3] & 0xFF) << 16 |
- (buf[i * 3 + 1] & 0xFF) << 8 |
- (buf[i * 3 + 2] & 0xFF));
- }
- if (numColors == 2)
- rowSize = (w + 7) / 8;
+ numColors = rfb.is.readUnsignedByte() + 1;
+ byte[] buf = new byte[numColors * 3];
+ rfb.is.readFully(buf);
+ for (int i = 0; i < numColors; i++) {
+ palette24[i] = ((buf[i * 3] & 0xFF) << 16 |
+ (buf[i * 3 + 1] & 0xFF) << 8 |
+ (buf[i * 3 + 2] & 0xFF));
+ }
+ if (numColors == 2)
+ rowSize = (w + 7) / 8;
} else if (filter_id == rfb.TightFilterGradient) {
- useGradient = true;
+ useGradient = true;
} else if (filter_id != rfb.TightFilterCopy) {
- throw new Exception("Incorrect tight filter id: " + filter_id);
+ throw new Exception("Incorrect tight filter id: " + filter_id);
}
}
if (numColors == 0)
@@ -636,41 +622,41 @@
if (dataSize < rfb.TightMinToCompress) {
// Data size is small - not compressed with zlib.
if (numColors != 0) {
- // Indexed colors.
- byte[] indexedData = new byte[dataSize];
- rfb.is.readFully(indexedData);
- if (numColors == 2) {
- // Two colors.
- decodeMonoData(x, y, w, h, indexedData, palette24);
- } else {
- // 3..255 colors.
- int i = 0;
- for (int dy = y; dy < y + h; dy++) {
- for (int dx = x; dx < x + w; dx++) {
- pixels24[dy * rfb.framebufferWidth + dx] =
- palette24[indexedData[i++] & 0xFF];
- }
- }
- }
+ // Indexed colors.
+ byte[] indexedData = new byte[dataSize];
+ rfb.is.readFully(indexedData);
+ if (numColors == 2) {
+ // Two colors.
+ decodeMonoData(x, y, w, h, indexedData, palette24);
+ } else {
+ // 3..255 colors.
+ int i = 0;
+ for (int dy = y; dy < y + h; dy++) {
+ for (int dx = x; dx < x + w; dx++) {
+ pixels24[dy * rfb.framebufferWidth + dx] =
+ palette24[indexedData[i++] & 0xFF];
+ }
+ }
+ }
} else if (useGradient) {
- // "Gradient"-processed data
- byte[] buf = new byte[w * h * 3];
- rfb.is.readFully(buf);
- decodeGradientData(x, y, w, h, buf);
+ // "Gradient"-processed data
+ byte[] buf = new byte[w * h * 3];
+ rfb.is.readFully(buf);
+ decodeGradientData(x, y, w, h, buf);
} else {
- // Raw truecolor data.
- byte[] buf = new byte[w * 3];
- int i, offset;
- for (int dy = y; dy < y + h; dy++) {
- rfb.is.readFully(buf);
- offset = dy * rfb.framebufferWidth + x;
- for (i = 0; i < w; i++) {
- pixels24[offset + i] =
- (buf[i * 3] & 0xFF) << 16 |
- (buf[i * 3 + 1] & 0xFF) << 8 |
- (buf[i * 3 + 2] & 0xFF);
- }
- }
+ // Raw truecolor data.
+ byte[] buf = new byte[w * 3];
+ int i, offset;
+ for (int dy = y; dy < y + h; dy++) {
+ rfb.is.readFully(buf);
+ offset = dy * rfb.framebufferWidth + x;
+ for (i = 0; i < w; i++) {
+ pixels24[offset + i] =
+ (buf[i * 3] & 0xFF) << 16 |
+ (buf[i * 3 + 1] & 0xFF) << 8 |
+ (buf[i * 3 + 2] & 0xFF);
+ }
+ }
}
} else {
// Data was compressed with zlib.
@@ -679,51 +665,50 @@
rfb.is.readFully(zlibData);
int stream_id = comp_ctl & 0x03;
if (tightInflaters[stream_id] == null) {
- tightInflaters[stream_id] = new Inflater();
+ tightInflaters[stream_id] = new Inflater();
}
Inflater myInflater = tightInflaters[stream_id];
myInflater.setInput(zlibData);
try {
- if (numColors != 0) {
- // Indexed colors.
- byte[] indexedData = new byte[dataSize];
- myInflater.inflate(indexedData);
- if (numColors == 2) {
- // Two colors.
- decodeMonoData(x, y, w, h, indexedData, palette24);
- } else {
- // More than two colors.
- int i = 0;
- for (int dy = y; dy < y + h; dy++) {
- for (int dx = x; dx < x + w; dx++) {
- pixels24[dy * rfb.framebufferWidth + dx] =
- palette24[indexedData[i++] & 0xFF];
- }
- }
- }
- } else if (useGradient) {
- // Compressed "Gradient"-filtered data.
- byte[] buf = new byte[w * h * 3];
- myInflater.inflate(buf);
- decodeGradientData(x, y, w, h, buf);
- } else {
- // Compressed truecolor data.
- byte[] buf = new byte[w * 3];
- int i, offset;
- for (int dy = y; dy < y + h; dy++) {
- myInflater.inflate(buf);
- offset = dy * rfb.framebufferWidth + x;
- for (i = 0; i < w; i++) {
- pixels24[offset + i] =
- (buf[i * 3] & 0xFF) << 16 |
- (buf[i * 3 + 1] & 0xFF) << 8 |
- (buf[i * 3 + 2] & 0xFF);
- }
- }
- }
- }
- catch(DataFormatException dfe) {
- throw new Exception(dfe.toString());
+ if (numColors != 0) {
+ // Indexed colors.
+ byte[] indexedData = new byte[dataSize];
+ myInflater.inflate(indexedData);
+ if (numColors == 2) {
+ // Two colors.
+ decodeMonoData(x, y, w, h, indexedData, palette24);
+ } else {
+ // More than two colors.
+ int i = 0;
+ for (int dy = y; dy < y + h; dy++) {
+ for (int dx = x; dx < x + w; dx++) {
+ pixels24[dy * rfb.framebufferWidth + dx] =
+ palette24[indexedData[i++] & 0xFF];
+ }
+ }
+ }
+ } else if (useGradient) {
+ // Compressed "Gradient"-filtered data.
+ byte[] buf = new byte[w * h * 3];
+ myInflater.inflate(buf);
+ decodeGradientData(x, y, w, h, buf);
+ } else {
+ // Compressed truecolor data.
+ byte[] buf = new byte[w * 3];
+ int i, offset;
+ for (int dy = y; dy < y + h; dy++) {
+ myInflater.inflate(buf);
+ offset = dy * rfb.framebufferWidth + x;
+ for (i = 0; i < w; i++) {
+ pixels24[offset + i] =
+ (buf[i * 3] & 0xFF) << 16 |
+ (buf[i * 3 + 1] & 0xFF) << 8 |
+ (buf[i * 3 + 2] & 0xFF);
+ }
+ }
+ }
+ } catch (DataFormatException dfe) {
+ throw new Exception(dfe.toString());
}
}
@@ -734,7 +719,6 @@
//
// Decode 1bpp-encoded bi-color rectangle.
//
-
void decodeMonoData(int x, int y, int w, int h, byte[] src, int[] palette) {
int dx, dy, n;
@@ -744,12 +728,12 @@
for (dy = 0; dy < h; dy++) {
for (dx = 0; dx < w / 8; dx++) {
- b = src[dy*rowBytes+dx];
- for (n = 7; n >= 0; n--)
- pixels24[i++] = palette[b >> n & 1];
+ b = src[dy * rowBytes + dx];
+ for (n = 7; n >= 0; n--)
+ pixels24[i++] = palette[b >> n & 1];
}
for (n = 7; n >= 8 - w % 8; n--) {
- pixels24[i++] = palette[src[dy*rowBytes+dx] >> n & 1];
+ pixels24[i++] = palette[src[dy * rowBytes + dx] >> n & 1];
}
i += (rfb.framebufferWidth - w);
}
@@ -758,8 +742,7 @@
//
// Decode data processed with the "Gradient" filter.
//
-
- void decodeGradientData (int x, int y, int w, int h, byte[] buf) {
+ void decodeGradientData(int x, int y, int w, int h, byte[] buf) {
int dx, dy, c;
byte[] prevRow = new byte[w * 3];
@@ -773,27 +756,27 @@
/* First pixel in a row */
for (c = 0; c < 3; c++) {
- pix[c] = (byte)(prevRow[c] + buf[dy * w * 3 + c]);
- thisRow[c] = pix[c];
+ pix[c] = (byte)(prevRow[c] + buf[dy * w * 3 + c]);
+ thisRow[c] = pix[c];
}
pixels24[offset++] =
- (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
+ (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
/* Remaining pixels of a row */
for (dx = 1; dx < w; dx++) {
- for (c = 0; c < 3; c++) {
- est[c] = ((prevRow[dx * 3 + c] & 0xFF) + (pix[c] & 0xFF) -
- (prevRow[(dx-1) * 3 + c] & 0xFF));
- if (est[c] > 0xFF) {
- est[c] = 0xFF;
- } else if (est[c] < 0x00) {
- est[c] = 0x00;
- }
- pix[c] = (byte)(est[c] + buf[(dy * w + dx) * 3 + c]);
- thisRow[dx * 3 + c] = pix[c];
- }
- pixels24[offset++] =
- (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
+ for (c = 0; c < 3; c++) {
+ est[c] = ((prevRow[dx * 3 + c] & 0xFF) + (pix[c] & 0xFF) -
+ (prevRow[(dx - 1) * 3 + c] & 0xFF));
+ if (est[c] > 0xFF) {
+ est[c] = 0xFF;
+ } else if (est[c] < 0x00) {
+ est[c] = 0x00;
+ }
+ pix[c] = (byte)(est[c] + buf[(dy * w + dx) * 3 + c]);
+ thisRow[dx * 3 + c] = pix[c];
+ }
+ pixels24[offset++] =
+ (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
}
System.arraycopy(thisRow, 0, prevRow, 0, w * 3);
@@ -805,7 +788,6 @@
//
// Display newly updated area of pixels.
//
-
void handleUpdatedPixels(int x, int y, int w, int h) {
// Draw updated pixels of the off-screen image.
@@ -819,18 +801,17 @@
//
// Tell JVM to repaint specified desktop area.
//
-
void scheduleRepaint(int x, int y, int w, int h) {
if (rfb.fbs.isSeeking()) {
// Do nothing, and remember we are seeking.
seekMode = true;
} else {
if (seekMode) {
- // Immediate repaint of the whole desktop after seeking.
- repaint();
+ // Immediate repaint of the whole desktop after seeking.
+ repaint();
} else {
- // Usual incremental repaint.
- repaint(player.deferScreenUpdates, x, y, w, h);
+ // Usual incremental repaint.
+ repaint(player.deferScreenUpdates, x, y, w, h);
}
seekMode = false;
}
@@ -841,7 +822,6 @@
// switching to the `paused' mode. In such cases we want to repaint
// our desktop if we were seeking.
//
-
public void update(Observable o, Object arg) {
// Immediate repaint of the whole desktop after seeking.
repaint();