aboutsummaryrefslogtreecommitdiffstats
path: root/java/com
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2011-10-24 02:14:55 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2011-10-24 02:14:55 +0000
commita5f0fc897260115ea64e66f80da5ac011118eb1d (patch)
tree650b9a2aa6b936e79683da523051a7789d8d7836 /java/com
parent06b92cf08123dbd94f7be06ca79938d42a7a86fc (diff)
downloadtigervnc-a5f0fc897260115ea64e66f80da5ac011118eb1d.tar.gz
tigervnc-a5f0fc897260115ea64e66f80da5ac011118eb1d.zip
performance improvements
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4733 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com')
-rw-r--r--java/com/tigervnc/rdr/InStream.java23
-rw-r--r--java/com/tigervnc/rdr/JavaInStream.java6
-rw-r--r--java/com/tigervnc/vncviewer/DesktopWindow.java3
-rw-r--r--java/com/tigervnc/vncviewer/PixelBufferImage.java3
4 files changed, 19 insertions, 16 deletions
diff --git a/java/com/tigervnc/rdr/InStream.java b/java/com/tigervnc/rdr/InStream.java
index 1e0d226e..803f55f6 100644
--- a/java/com/tigervnc/rdr/InStream.java
+++ b/java/com/tigervnc/rdr/InStream.java
@@ -30,11 +30,12 @@ abstract public class InStream {
// 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;
}
@@ -50,10 +51,10 @@ abstract public class InStream {
// 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;
@@ -88,7 +89,7 @@ abstract public class InStream {
public final void skip(int bytes) {
while (bytes > 0) {
- int n = check(1, bytes);
+ int n = check(1, bytes, true);
ptr += n;
bytes -= n;
}
@@ -99,7 +100,7 @@ abstract public class InStream {
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;
@@ -109,7 +110,7 @@ abstract public class InStream {
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;
@@ -122,10 +123,10 @@ abstract public class InStream {
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; }
diff --git a/java/com/tigervnc/rdr/JavaInStream.java b/java/com/tigervnc/rdr/JavaInStream.java
index ce8efddc..5c350369 100644
--- a/java/com/tigervnc/rdr/JavaInStream.java
+++ b/java/com/tigervnc/rdr/JavaInStream.java
@@ -111,14 +111,14 @@ public class JavaInStream extends InStream {
try {
long before = 0;
if (timing)
- before = System.currentTimeMillis();
+ before = System.nanoTime();
int n = jis.read(buf, bufPtr, len);
if (n < 0) throw new EndOfStream();
if (timing) {
- long after = System.currentTimeMillis();
- long newTimeWaited = (after - before) * 10;
+ long after = System.nanoTime();
+ long newTimeWaited = (after - before) / 100000;
int newKbits = n * 8 / 1000;
// limit rate to between 10kbit/s and 40Mbit/s
diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java
index 978368de..c0071dad 100644
--- a/java/com/tigervnc/vncviewer/DesktopWindow.java
+++ b/java/com/tigervnc/vncviewer/DesktopWindow.java
@@ -163,6 +163,7 @@ class DesktopWindow extends JPanel implements
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);
@@ -282,7 +283,7 @@ class DesktopWindow extends JPanel implements
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);
diff --git a/java/com/tigervnc/vncviewer/PixelBufferImage.java b/java/com/tigervnc/vncviewer/PixelBufferImage.java
index ef0eed86..78697d8d 100644
--- a/java/com/tigervnc/vncviewer/PixelBufferImage.java
+++ b/java/com/tigervnc/vncviewer/PixelBufferImage.java
@@ -112,10 +112,11 @@ public class PixelBufferImage extends PixelBuffer implements ImageProducer
// 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);
}