patches/realvnc-java-client-04-highcolor.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 11107 ab90f918fbaa
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11107
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     1
diff -urN vnc-4_1-javasrc.sun/java/rdr/InStream.java vnc-4_1-javasrc/java/rdr/InStream.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     2
--- vnc-4_1-javasrc.sun/java/rdr/InStream.java	2007-07-21 01:40:13.534560000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     3
+++ vnc-4_1-javasrc/java/rdr/InStream.java	2007-07-21 03:46:42.289166000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     4
@@ -116,6 +116,48 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     5
                                      int b1 = b[ptr++]; int b2 = b[ptr++];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     6
                                      return b0 << 16 | b1 << 8 | b2; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     7
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     8
+  public final int readPixel() { return readU32(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
     9
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    10
+  public final void readPixels(int[] buf, int length) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    11
+    int n = length;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    12
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    13
+    while (n > 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    14
+      int offset = length - n;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    15
+      int ret;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    16
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    17
+      ret = check(4, n);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    18
+      for (int i = 0; i < ret; i++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    19
+   buf[offset + i] = readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    20
+      n -= ret;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    21
+    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    22
+  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    23
+  
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    24
+  /* CPIXEL is 3 bytes for true-colour = 1, bpp = 32, depth = 24,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    25
+   * red-mask = 0xff0000, green-mask = 0xff00 and blue-mask = 0xff
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    26
+   */
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    27
+  public final int readCPixel() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    28
+    check(3);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    29
+    int b0 = b[ptr++] & 0xff;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    30
+    int b1 = b[ptr++] & 0xff;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    31
+    int b2 = b[ptr++] & 0xff;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    32
+    return b0 << 16 | b1 << 8 | b2;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    33
+  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    34
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    35
+  public final void readCPixels(int[] buf, int length) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    36
+    int n = length;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    37
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    38
+    while (n > 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    39
+      int offset = length - n;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    40
+      int ret;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    41
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    42
+      ret = check(3, n);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    43
+     for (int i = 0; i < ret; i++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    44
+   buf[offset + i] = readCPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    45
+      n -= ret;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    46
+    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    47
+  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    48
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    49
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    50
   // pos() returns the position in the stream.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    51
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    52
   abstract public int pos();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    53
diff -urN vnc-4_1-javasrc.sun/java/rfb/CMsgHandler.java vnc-4_1-javasrc/java/rfb/CMsgHandler.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    54
--- vnc-4_1-javasrc.sun/java/rfb/CMsgHandler.java	2007-07-21 01:40:13.563246000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    55
+++ vnc-4_1-javasrc/java/rfb/CMsgHandler.java	2007-07-21 03:51:23.825069000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    56
@@ -31,7 +31,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    57
     cp.height = h;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    58
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    59
   public void setCursor(int hotspotX, int hotspotY, int w, int h,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    60
-                        byte[] data, byte[] mask) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    61
+                        int[] data, byte[] mask) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    62
   public void setPixelFormat(PixelFormat pf) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    63
     cp.setPF(pf);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    64
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    65
@@ -55,7 +55,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    66
   public void serverCutText(String str) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    67
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    68
   public void fillRect(int x, int y, int w, int h, int pix) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    69
-  public void imageRect(int x, int y, int w, int h, byte[] pix, int offset) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    70
+  public void imageRect(int x, int y, int w, int h, int[] pix) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    71
   public void copyRect(int x, int y, int w, int h, int srcX, int srcY) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    72
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    73
   public ConnParams cp;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    74
diff -urN vnc-4_1-javasrc.sun/java/rfb/CMsgReader.java vnc-4_1-javasrc/java/rfb/CMsgReader.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    75
--- vnc-4_1-javasrc.sun/java/rfb/CMsgReader.java	2007-07-21 01:40:13.563414000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    76
+++ vnc-4_1-javasrc/java/rfb/CMsgReader.java	2007-07-21 03:54:21.011746000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    77
@@ -31,20 +31,11 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    78
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    79
   public rdr.InStream getInStream() { return is; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    80
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    81
-  public byte[] getImageBuf(int required, int requested) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    82
-    int requiredBytes = required * (handler.cp.pf().bpp / 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    83
-    int requestedBytes = requested * (handler.cp.pf().bpp / 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    84
-    int size = requestedBytes;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    85
-    if (size > imageBufIdealSize) size = imageBufIdealSize;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    86
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    87
-    if (size < requiredBytes)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    88
-      size = requiredBytes;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    89
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    90
+  public int[] getImageBuf(int size) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    91
     if (imageBufSize < size) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    92
       imageBufSize = size;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    93
-      imageBuf = new byte[imageBufSize];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    94
+      imageBuf = new int[imageBufSize];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    95
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    96
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    97
     return imageBuf;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    98
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
    99
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   100
@@ -135,12 +126,12 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   101
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   102
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   103
   protected void readSetCursor(int hotspotX, int hotspotY, int w, int h) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   104
-    int data_len = w * h * (handler.cp.pf().bpp/8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   105
+    int data_len = w * h;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   106
     int mask_len = ((w+7)/8) * h;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   107
-    byte[] data = new byte[data_len];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   108
+    int[] data = new int[data_len];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   109
     byte[] mask = new byte[mask_len];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   110
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   111
-    is.readBytes(data, 0, data_len);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   112
+    is.readPixels(data, data_len);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   113
     is.readBytes(mask, 0, mask_len);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   114
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   115
     handler.setCursor(hotspotX, hotspotY, w, h, data, mask);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   116
@@ -149,9 +140,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   117
   CMsgHandler handler;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   118
   rdr.InStream is;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   119
   Decoder[] decoders;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   120
-  byte[] imageBuf;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   121
+  int[] imageBuf;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   122
   int imageBufSize;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   123
-  int imageBufIdealSize;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   124
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   125
   static LogWriter vlog = new LogWriter("CMsgReader");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   126
 }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   127
diff -urN vnc-4_1-javasrc.sun/java/rfb/HextileDecoder.java vnc-4_1-javasrc/java/rfb/HextileDecoder.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   128
--- vnc-4_1-javasrc.sun/java/rfb/HextileDecoder.java	2007-07-21 01:40:13.566481000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   129
+++ vnc-4_1-javasrc/java/rfb/HextileDecoder.java	2007-07-21 03:57:45.031091000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   130
@@ -22,12 +22,9 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   131
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   132
   public HextileDecoder(CMsgReader reader_) { reader = reader_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   133
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   134
-  static final int BPP=8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   135
-  static final int readPixel(rdr.InStream is) { return is.readU8(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   136
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   137
   public void readRect(int x, int y, int w, int h, CMsgHandler handler) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   138
     rdr.InStream is = reader.getInStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   139
-    byte[] buf = reader.getImageBuf(16 * 16 * 4, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   140
+    int[] buf = reader.getImageBuf(16 * 16 * 4);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   141
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   142
     int bg = 0;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   143
     int fg = 0;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   144
@@ -43,20 +40,20 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   145
         int tileType = is.readU8();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   146
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   147
         if ((tileType & Hextile.raw) != 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   148
-          is.readBytes(buf, 0, tw * th * (BPP/8));
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   149
-          handler.imageRect(tx,ty,tw,th, buf, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   150
+          is.readPixels(buf, tw * th);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   151
+          handler.imageRect(tx,ty,tw,th, buf);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   152
           continue;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   153
         }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   154
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   155
         if ((tileType & Hextile.bgSpecified) != 0)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   156
-          bg = readPixel(is);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   157
+          bg = is.readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   158
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   159
         int len = tw * th;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   160
         int ptr = 0;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   161
-        while (len-- > 0) buf[ptr++] = (byte)bg;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   162
+        while (len-- > 0) buf[ptr++] = bg;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   163
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   164
         if ((tileType & Hextile.fgSpecified) != 0)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   165
-          fg = readPixel(is);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   166
+          fg = is.readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   167
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   168
         if ((tileType & Hextile.anySubrects) != 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   169
           int nSubrects = is.readU8();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   170
@@ -64,7 +61,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   171
           for (int i = 0; i < nSubrects; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   172
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   173
             if ((tileType & Hextile.subrectsColoured) != 0)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   174
-              fg = readPixel(is);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   175
+              fg = is.readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   176
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   177
             int xy = is.readU8();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   178
             int wh = is.readU8();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   179
@@ -76,12 +73,12 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   180
             int rowAdd = tw - sw;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   181
             while (sh-- > 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   182
               len = sw;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   183
-              while (len-- > 0) buf[ptr++] = (byte)fg;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   184
+              while (len-- > 0) buf[ptr++] = fg;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   185
               ptr += rowAdd;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   186
             }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   187
           }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   188
         }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   189
-        handler.imageRect(tx,ty,tw,th, buf, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   190
+        handler.imageRect(tx,ty,tw,th, buf);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   191
       }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   192
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   193
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   194
diff -urN vnc-4_1-javasrc.sun/java/rfb/ManagedPixelBuffer.java vnc-4_1-javasrc/java/rfb/ManagedPixelBuffer.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   195
--- vnc-4_1-javasrc.sun/java/rfb/ManagedPixelBuffer.java	2007-07-21 01:40:13.567290000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   196
+++ vnc-4_1-javasrc/java/rfb/ManagedPixelBuffer.java	2007-07-21 03:58:42.631943000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   197
@@ -28,10 +28,10 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   198
     checkDataSize();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   199
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   200
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   201
-  public int dataLen() { return area() * (getPF().bpp/8); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   202
+  public int dataLen() { return area(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   203
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   204
   final void checkDataSize() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   205
     if (data == null || data.length < dataLen())
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   206
-      data = new byte[dataLen()];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   207
+      data = new int[dataLen()];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   208
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   209
 }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   210
diff -urN vnc-4_1-javasrc.sun/java/rfb/PixelBuffer.java vnc-4_1-javasrc/java/rfb/PixelBuffer.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   211
--- vnc-4_1-javasrc.sun/java/rfb/PixelBuffer.java	2007-07-21 01:40:13.567614000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   212
+++ vnc-4_1-javasrc/java/rfb/PixelBuffer.java	2007-07-21 04:03:50.257177000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   213
@@ -16,7 +16,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   214
  * USA.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   215
  */
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   216
 //
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   217
-// PixelBuffer - note that this code is only written for the 8bpp case at the
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   218
+// PixelBuffer - note that this code is only written for the 32bpp case at the
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   219
 // moment.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   220
 //
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   221
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   222
@@ -29,8 +29,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   223
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   224
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   225
   public void setPF(PixelFormat pf) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   226
-    if (pf.bpp != 8)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   227
-      throw new rfb.Exception("Internal error: bpp must be 8 in PixelBuffer");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   228
+    if (pf.bpp != 32)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   229
+      throw new rfb.Exception("Internal error: bpp must be 32 in PixelBuffer");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   230
     format = pf;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   231
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   232
   public PixelFormat getPF() { return format; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   233
@@ -39,28 +39,22 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   234
   public final int height() { return height_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   235
   public final int area() { return width_ * height_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   236
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   237
-  public int getStride() { return width_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   238
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   239
   public void fillRect(int x, int y, int w, int h, int pix) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   240
-    int bytesPerPixel = getPF().bpp/8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   241
-    int bytesPerRow = bytesPerPixel * getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   242
-    for (int ry = y; ry < y+h; ry++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   243
-      for (int rx = x; rx < x+w; rx++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   244
-        data[ry * bytesPerRow + rx] = (byte)pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   245
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   246
+    for (int ry = y; ry < y + h; ry++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   247
+      for (int rx = x; rx < x + w; rx++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   248
+        data[ry * width_ + rx] = pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   249
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   250
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   251
-  public void imageRect(int x, int y, int w, int h, byte[] pix, int offset) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   252
-    int bytesPerPixel = getPF().bpp/8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   253
-    int bytesPerDestRow = bytesPerPixel * getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   254
+  public void imageRect(int x, int y, int w, int h, int[] pix) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   255
     for (int j = 0; j < h; j++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   256
-      System.arraycopy(pix, offset+j*w, data, (y+j) * bytesPerDestRow + x, w);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   257
+      System.arraycopy(pix, (w * j), data, width_ * (y + j) + x, w);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   258
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   259
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   260
   public void copyRect(int x, int y, int w, int h, int srcX, int srcY) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   261
-    int dest = x + y * getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   262
-    int src = srcX + srcY * getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   263
-    int inc = getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   264
+    int dest = (width_ * y) + x;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   265
+    int src = (width_ * srcY) + srcX;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   266
+    int inc = width_;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   267
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   268
     if (y > srcY) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   269
       src += (h-1) * inc;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   270
       dest += (h-1) * inc;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   271
@@ -75,27 +69,31 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   272
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   273
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   274
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   275
-  public void maskRect(int x, int y, int w, int h, byte[] pix, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   276
+  public void maskRect(int x, int y, int w, int h, int[] pix, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   277
     int maskBytesPerRow = (w + 7) / 8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   278
-    int stride = getStride();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   279
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   280
     for (int j = 0; j < h; j++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   281
       int cy = y + j;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   282
-      if (cy >= 0 && cy < height_) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   283
-        for (int i = 0; i < w; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   284
-          int cx = x + i;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   285
-          if (cx >= 0 && cx < width_) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   286
-            int byte_ = j * maskBytesPerRow + i / 8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   287
-            int bit = 7 - i % 8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   288
-            if ((mask[byte_] & (1 << bit)) != 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   289
-              data[cy * stride + cx] = pix[j * w + i];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   290
-            }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   291
-          }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   292
-        }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   293
-      }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   294
+      
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   295
+      if (cy < 0 || cy >= height_)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   296
+        continue;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   297
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   298
+      for (int i = 0; i < w; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   299
+        int cx = x + i;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   300
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   301
+        if (cx < 0 || cx >= width_)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   302
+          continue;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   303
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   304
+        int byte_ = j * maskBytesPerRow + i / 8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   305
+        int bit = 7 - i % 8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   306
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   307
+        if ((mask[byte_] & (1 << bit)) != 0)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   308
+         data[cy * width_ + cx] = pix[j * w + i];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   309
+      }     
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   310
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   311
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   312
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   313
-  public byte[] data;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   314
+  public int[] data;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   315
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   316
   protected PixelFormat format;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   317
   protected int width_, height_;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   318
diff -urN vnc-4_1-javasrc.sun/java/rfb/PixelFormat.java vnc-4_1-javasrc/java/rfb/PixelFormat.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   319
--- vnc-4_1-javasrc.sun/java/rfb/PixelFormat.java	2007-07-21 01:40:13.567775000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   320
+++ vnc-4_1-javasrc/java/rfb/PixelFormat.java	2007-07-21 04:31:18.603092000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   321
@@ -39,7 +39,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   322
     greenShift = gs;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   323
     blueShift = bs;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   324
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   325
-  public PixelFormat() { this(8,8,false,true,7,7,3,0,3,6); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   326
+  public PixelFormat() { this(32, 24, true, true, 0xff, 0xff, 0xff, 16, 8, 0);}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   327
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   328
   public boolean equal(PixelFormat x) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   329
     return (bpp == x.bpp &&
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   330
diff -urN vnc-4_1-javasrc.sun/java/rfb/RREDecoder.java vnc-4_1-javasrc/java/rfb/RREDecoder.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   331
--- vnc-4_1-javasrc.sun/java/rfb/RREDecoder.java	2007-07-21 01:40:13.567934000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   332
+++ vnc-4_1-javasrc/java/rfb/RREDecoder.java	2007-07-21 04:05:32.633576000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   333
@@ -22,17 +22,14 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   334
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   335
   public RREDecoder(CMsgReader reader_) { reader = reader_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   336
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   337
-  static final int BPP=8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   338
-  static final int readPixel(rdr.InStream is) { return is.readU8(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   339
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   340
   public void readRect(int x, int y, int w, int h, CMsgHandler handler) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   341
     rdr.InStream is = reader.getInStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   342
     int nSubrects = is.readU32();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   343
-    int bg = readPixel(is);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   344
+    int bg = is.readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   345
     handler.fillRect(x,y,w,h, bg);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   346
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   347
     for (int i = 0; i < nSubrects; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   348
-      int pix = readPixel(is);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   349
+      int pix = is.readPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   350
       int sx = is.readU16();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   351
       int sy = is.readU16();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   352
       int sw = is.readU16();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   353
diff -urN vnc-4_1-javasrc.sun/java/rfb/RawDecoder.java vnc-4_1-javasrc/java/rfb/RawDecoder.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   354
--- vnc-4_1-javasrc.sun/java/rfb/RawDecoder.java	2007-07-21 01:40:13.568093000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   355
+++ vnc-4_1-javasrc/java/rfb/RawDecoder.java	2007-07-21 04:06:03.921877000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   356
@@ -23,17 +23,10 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   357
   public RawDecoder(CMsgReader reader_) { reader = reader_; }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   358
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   359
   public void readRect(int x, int y, int w, int h, CMsgHandler handler) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   360
-    byte[] imageBuf = reader.getImageBuf(w, w*h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   361
-    int nPixels = imageBuf.length / (reader.bpp() / 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   362
-    int nRows = nPixels / w;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   363
-    int bytesPerRow = w * (reader.bpp() / 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   364
-    while (h > 0) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   365
-      if (nRows > h) nRows = h;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   366
-      reader.getInStream().readBytes(imageBuf, 0, nRows * bytesPerRow);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   367
-      handler.imageRect(x, y, w, nRows, imageBuf, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   368
-      h -= nRows;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   369
-      y += nRows;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   370
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   371
+    int[] imageBuf = reader.getImageBuf(w * h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   372
+
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   373
+    reader.getInStream().readPixels(imageBuf, w * h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   374
+    handler.imageRect(x, y, w, h, imageBuf);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   375
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   376
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   377
   CMsgReader reader;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   378
diff -urN vnc-4_1-javasrc.sun/java/rfb/ZRLEDecoder.java vnc-4_1-javasrc/java/rfb/ZRLEDecoder.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   379
--- vnc-4_1-javasrc.sun/java/rfb/ZRLEDecoder.java	2007-07-21 01:40:13.569746000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   380
+++ vnc-4_1-javasrc/java/rfb/ZRLEDecoder.java	2007-07-21 04:32:10.454770000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   381
@@ -25,12 +25,9 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   382
     zis = new rdr.ZlibInStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   383
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   384
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   385
-  static final int BPP=8;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   386
-  static final int readPixel(rdr.InStream is) { return is.readU8(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   387
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   388
   public void readRect(int x, int y, int w, int h, CMsgHandler handler) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   389
     rdr.InStream is = reader.getInStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   390
-    byte[] buf = reader.getImageBuf(64 * 64 * 4, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   391
+    int[] buf = reader.getImageBuf(64 * 64 * 4);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   392
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   393
     int length = is.readU32();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   394
     zis.setUnderlying(is, length);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   395
@@ -48,10 +45,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   396
         int palSize = mode & 127;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   397
         int[] palette = new int[128];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   398
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   399
-        for (int i = 0; i < palSize; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   400
-          palette[i] = readPixel(zis);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   401
-        }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   402
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   403
+        zis.readCPixels(palette, palSize);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   404
+        
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   405
         if (palSize == 1) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   406
           int pix = palette[0];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   407
           handler.fillRect(tx,ty,tw,th, pix);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   408
@@ -63,7 +58,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   409
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   410
             // raw
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   411
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   412
-            zis.readBytes(buf, 0, tw * th * (BPP / 8));
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   413
+            zis.readCPixels(buf, tw * th);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   414
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   415
           } else {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   416
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   417
@@ -85,7 +80,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   418
                 }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   419
                 nbits -= bppp;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   420
                 int index = (b >> nbits) & ((1 << bppp) - 1) & 127;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   421
-                buf[ptr++] = (byte)palette[index];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   422
+                buf[ptr++] = palette[index];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   423
               }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   424
             }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   425
           }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   426
@@ -99,7 +94,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   427
             int ptr = 0;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   428
             int end = ptr + tw * th;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   429
             while (ptr < end) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   430
-              int pix = readPixel(zis);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   431
+              int pix = zis.readCPixel();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   432
               int len = 1;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   433
               int b;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   434
               do {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   435
@@ -111,7 +106,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   436
                 throw new Exception("ZRLEDecoder: assertion (len <= end - ptr)"
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   437
                                     +" failed");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   438
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   439
-              while (len-- > 0) buf[ptr++] = (byte)pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   440
+              while (len-- > 0) buf[ptr++] = pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   441
             }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   442
           } else {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   443
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   444
@@ -138,12 +133,12 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   445
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   446
               int pix = palette[index];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   447
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   448
-              while (len-- > 0) buf[ptr++] = (byte)pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   449
+              while (len-- > 0) buf[ptr++] = pix;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   450
             }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   451
           }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   452
         }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   453
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   454
-        handler.imageRect(tx,ty,tw,th, buf, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   455
+        handler.imageRect(tx,ty,tw,th, buf);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   456
       }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   457
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   458
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   459
diff -urN vnc-4_1-javasrc.sun/java/vncviewer/CConn.java vnc-4_1-javasrc/java/vncviewer/CConn.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   460
--- vnc-4_1-javasrc.sun/java/vncviewer/CConn.java	2007-07-21 01:40:13.572486000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   461
+++ vnc-4_1-javasrc/java/vncviewer/CConn.java	2007-07-21 04:19:26.328456000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   462
@@ -13,7 +13,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   463
  * You should have received a copy of the GNU General Public License
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   464
  * along with this software; if not, write to the Free Software
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   465
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   466
- * USA.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   467
+ * USA.setServerName
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   468
  */
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   469
 //
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   470
 // CConn
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   471
@@ -141,9 +141,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   472
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   473
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   474
     setServerName(sock.getInetAddress().getHostAddress()+"::"+sock.getPort());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   475
-    jis = new rdr.JavaInStream(sock.getInputStream());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   476
-    jos = new rdr.JavaOutStream(sock.getOutputStream());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   477
-    setStreams(jis, jos);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   478
+    setStreams(new rdr.JavaInStream(sock.getInputStream()),
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   479
+          new rdr.JavaOutStream(sock.getOutputStream()));
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   480
     initialiseProtocol();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   481
     return true;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   482
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   483
@@ -191,6 +190,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   484
   // this point we create the desktop window and display it.  We also tell the
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   485
   // server the pixel format and encodings to use and request the first update.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   486
   public void serverInit() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   487
+    jis = (rdr.JavaInStream)getInStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   488
+    jos = (rdr.JavaOutStream)getOutStream();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   489
     super.serverInit();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   490
     serverPF = cp.pf();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   491
     desktop = new DesktopWindow(serverPF, this);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   492
@@ -205,11 +206,12 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   493
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   494
   // setDesktopSize() is called when the desktop size changes (including when
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   495
   // it is set initially).
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   496
-  public void setDesktopSize(int w, int h) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   497
+  synchronized public void setDesktopSize(int w, int h) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   498
     super.setDesktopSize(w,h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   499
     if (desktop != null) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   500
       desktop.resize();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   501
       recreateViewport();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   502
+      writer().writeFramebufferUpdateRequest(0, 0, cp.width, cp.height, false);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   503
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   504
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   505
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   506
@@ -218,19 +220,15 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   507
   // computed within beginRect() and endRect() to select the format and
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   508
   // encoding appropriately, and then request another incremental update.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   509
   public void framebufferUpdateStart() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   510
+      jis.startTiming();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   511
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   512
   public void framebufferUpdateEnd() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   513
+    jis.stopTiming();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   514
     if (autoSelect)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   515
       autoSelectFormatAndEncoding();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   516
     requestNewUpdate();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   517
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   518
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   519
-  // The rest of the callbacks are fairly self-explanatory...
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   520
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   521
-  public void setColourMapEntries(int firstColour, int nColours, int[] rgbs) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   522
-    desktop.setColourMapEntries(firstColour, nColours, rgbs);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   523
-  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   524
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   525
   public void bell() { desktop.getToolkit().beep(); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   526
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   527
   public void serverCutText(String str) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   528
@@ -239,13 +237,11 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   529
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   530
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   531
   public void beginRect(int x, int y, int w, int h, int encoding) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   532
-    jis.startTiming();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   533
     desktop.beginRect(x, y, w, h, encoding);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   534
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   535
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   536
   public void endRect(int x, int y, int w, int h, int encoding) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   537
     desktop.endRect(x, y, w, h, encoding);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   538
-    jis.stopTiming();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   539
     if ( encoding <= rfb.Encodings.max )
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   540
       lastUsedEncoding = encoding;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   541
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   542
@@ -253,15 +249,15 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   543
   public void fillRect(int x, int y, int w, int h, int p) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   544
     desktop.fillRect(x, y, w, h, p);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   545
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   546
-  public void imageRect(int x, int y, int w, int h, byte[] p, int offset) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   547
-    desktop.imageRect(x, y, w, h, p, offset);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   548
+  public void imageRect(int x, int y, int w, int h, int[] p) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   549
+    desktop.imageRect(x, y, w, h, p);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   550
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   551
   public void copyRect(int x, int y, int w, int h, int sx, int sy) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   552
     desktop.copyRect(x, y, w, h, sx, sy);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   553
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   554
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   555
   public void setCursor(int hotspotX, int hotspotY, int w, int h,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   556
-                        byte[] data, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   557
+                        int[] data, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   558
     desktop.setCursor(hotspotX, hotspotY, w, h, data, mask);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   559
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   560
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   561
@@ -272,12 +268,14 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   562
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   563
   void recreateViewport()
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   564
   {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   565
-    if (viewport != null) viewport.dispose();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   566
+    ViewportFrame oldViewport = viewport;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   567
     viewport = new ViewportFrame("VNC: "+cp.name, this);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   568
     viewport.addChild(desktop);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   569
     reconfigureViewport();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   570
     viewport.show();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   571
     desktop.initGraphics();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   572
+    desktop.requestFocus();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   573
+    if (oldViewport != null) oldViewport.dispose();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   574
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   575
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   576
   void reconfigureViewport()
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   577
@@ -333,7 +331,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   578
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   579
   // requestNewUpdate() requests an update from the server, having set the
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   580
   // format and encoding appropriately.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   581
-  void requestNewUpdate()
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   582
+  synchronized void requestNewUpdate()
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   583
   {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   584
     if (formatChange) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   585
       if (fullColour) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   586
@@ -344,15 +342,11 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   587
       String str = desktop.getPF().print();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   588
       vlog.info("Using pixel format "+str);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   589
       cp.setPF(desktop.getPF());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   590
-      synchronized (this) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   591
-        writer().writeSetPixelFormat(cp.pf());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   592
-      }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   593
+      writer().writeSetPixelFormat(cp.pf());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   594
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   595
     checkEncodings();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   596
-    synchronized (this) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   597
-      writer().writeFramebufferUpdateRequest(0, 0, cp.width, cp.height,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   598
-                                             !formatChange);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   599
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   600
+    writer().writeFramebufferUpdateRequest(0, 0, cp.width, cp.height,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   601
+                                           !formatChange);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   602
     formatChange = false;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   603
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   604
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   605
@@ -427,8 +421,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   606
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   607
   public void getOptions() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   608
     autoSelect = options.autoSelect.getState();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   609
-//      if (fullColour != options.fullColour.getState())
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   610
-//        formatChange = true;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   611
+    if (fullColour != options.fullColour.getState())
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   612
+      formatChange = true;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   613
     fullColour = options.fullColour.getState();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   614
     int newEncoding = (options.zrle.getState() ? rfb.Encodings.ZRLE :
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   615
                        options.hextile.getState() ? rfb.Encodings.hextile :
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   616
@@ -450,8 +444,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   617
       if (desktop != null)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   618
         desktop.resetLocalCursor();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   619
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   620
-    viewer.fastCopyRect.setParam(options.fastCopyRect.getState());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   621
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   622
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   623
     checkEncodings();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   624
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   625
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   626
diff -urN vnc-4_1-javasrc.sun/java/vncviewer/DesktopWindow.java vnc-4_1-javasrc/java/vncviewer/DesktopWindow.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   627
--- vnc-4_1-javasrc.sun/java/vncviewer/DesktopWindow.java	2007-07-21 01:40:13.573008000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   628
+++ vnc-4_1-javasrc/java/vncviewer/DesktopWindow.java	2007-07-21 04:23:51.620057000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   629
@@ -30,7 +30,6 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   630
 import java.awt.datatransfer.Transferable;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   631
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   632
 class DesktopWindow extends Canvas implements
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   633
-                    Runnable,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   634
                     MouseListener,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   635
                     MouseMotionListener,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   636
                     KeyListener,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   637
@@ -67,7 +66,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   638
   // wherever they access data shared with the GUI thread.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   639
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   640
   synchronized public void setCursor(int hotspotX, int hotspotY, int w, int h,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   641
-                                     byte[] data, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   642
+                                     int[] data, byte[] mask) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   643
     // strictly we should use a mutex around this test since useLocalCursor
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   644
     // might be being altered by the GUI thread.  However it's only a single
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   645
     // boolean and it doesn't matter if we get the wrong value anyway.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   646
@@ -93,26 +92,6 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   647
     showLocalCursor();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   648
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   649
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   650
-  // setColourMapEntries() changes some of the entries in the colourmap.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   651
-  // Unfortunately these messages are often sent one at a time, so we delay the
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   652
-  // settings taking effect unless the whole colourmap has changed.  This is
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   653
-  // because getting java to recalculate its internal translation table and
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   654
-  // redraw the screen is expensive.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   655
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   656
-  synchronized public void setColourMapEntries(int firstColour, int nColours,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   657
-                                               int[] rgbs) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   658
-    im.setColourMapEntries(firstColour, nColours, rgbs);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   659
-    if (nColours == 256) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   660
-      im.updateColourMap();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   661
-      im.put(0, 0, im.width(), im.height(), graphics);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   662
-    } else {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   663
-      if (setColourMapEntriesTimerThread == null) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   664
-        setColourMapEntriesTimerThread = new Thread(this);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   665
-        setColourMapEntriesTimerThread.start();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   666
-      }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   667
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   668
-  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   669
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   670
   // resize() is called when the desktop has changed size
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   671
   synchronized public void resize() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   672
     vlog.debug("DesktopWindow.resize() called");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   673
@@ -171,9 +150,9 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   674
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   675
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   676
   synchronized final public void imageRect(int x, int y, int w, int h,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   677
-                                           byte[] pix, int offset) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   678
+                                           int[] pix) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   679
     if (overlapsCursor(x, y, w, h)) hideLocalCursor();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   680
-    im.imageRect(x, y, w, h, pix, offset);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   681
+    im.imageRect(x, y, w, h, pix);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   682
     invalidate(x, y, w, h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   683
     showLocalCursor();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   684
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   685
@@ -378,7 +357,7 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   686
     if (cursorVisible) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   687
       cursorVisible = false;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   688
       im.imageRect(cursorBackingX, cursorBackingY, cursorBacking.width(),
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   689
-                   cursorBacking.height(), cursorBacking.data, 0);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   690
+                   cursorBacking.height(), cursorBacking.data);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   691
       im.put(cursorBackingX, cursorBackingY, cursorBacking.width(),
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   692
              cursorBacking.height(), graphics);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   693
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   694
@@ -419,26 +398,12 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   695
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   696
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   697
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   698
-  // run() is executed by the setColourMapEntriesTimerThread - it sleeps for
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   699
-  // 100ms before actually updating the colourmap.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   700
-  public void run() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   701
-    try {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   702
-      Thread.sleep(100);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   703
-    } catch (InterruptedException e) {}
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   704
-    synchronized (this) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   705
-      im.updateColourMap();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   706
-      im.put(0, 0, im.width(), im.height(), graphics);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   707
-      setColourMapEntriesTimerThread = null;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   708
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   709
-  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   710
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   711
   // access to cc by different threads is specified in CConn
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   712
   CConn cc;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   713
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   714
   // access to the following must be synchronized:
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   715
   PixelBufferImage im;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   716
   Graphics graphics;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   717
-  Thread setColourMapEntriesTimerThread;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   718
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   719
   rfb.Cursor cursor;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   720
   boolean cursorVisible;     // Is cursor currently rendered?
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   721
diff -urN vnc-4_1-javasrc.sun/java/vncviewer/PixelBufferImage.java vnc-4_1-javasrc/java/vncviewer/PixelBufferImage.java
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   722
--- vnc-4_1-javasrc.sun/java/vncviewer/PixelBufferImage.java	2007-07-21 01:40:13.574604000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   723
+++ vnc-4_1-javasrc/java/vncviewer/PixelBufferImage.java	2007-07-21 04:32:39.521516000 +0800
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   724
@@ -28,55 +28,40 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   725
 public class PixelBufferImage extends rfb.PixelBuffer implements ImageProducer
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   726
 {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   727
   public PixelBufferImage(int w, int h, java.awt.Component win) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   728
-    setPF(new rfb.PixelFormat(8, 8, false, false, 0, 0, 0, 0, 0, 0));
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   729
+    setPF(new rfb.PixelFormat(32, 24, true, true, 0xff, 0xff, 0xff, 16, 8, 0));
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   730
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   731
     resize(w, h, win);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   732
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   733
-    reds = new byte[256];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   734
-    greens = new byte[256];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   735
-    blues = new byte[256];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   736
-    // Fill the colour map with bgr233.  This is only so that if the server
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   737
-    // doesn't set the colour map properly, at least we're likely to see
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   738
-    // something instead of a completely black screen.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   739
-    for (int i = 0; i < 256; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   740
-      reds[i] = (byte)(((i & 7) * 255 + 3) / 7);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   741
-      greens[i] = (byte)((((i >> 3) & 7) * 255 + 3) / 7);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   742
-      blues[i] = (byte)((((i >> 6) & 3) * 255 + 1) / 3);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   743
-    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   744
-    cm = new IndexColorModel(8, 256, reds, greens, blues);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   745
+    cm = new DirectColorModel(24, 0xff << 16, 0xff << 8, 0xff);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   746
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   747
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   748
   // resize() resizes the image, preserving the image data where possible.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   749
   public void resize(int w, int h, java.awt.Component win) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   750
     if (w == width() && h == height()) return;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   751
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   752
-    // Clear the ImageConsumer so that we don't attempt to do any drawing until
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   753
-    // the AWT has noticed that the resize has happened.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   754
-    ic = null;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   755
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   756
-    int oldStrideBytes = getStride() * (format.bpp/8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   757
     int rowsToCopy = h < height() ? h : height();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   758
-    int bytesPerRow = (w < width() ? w : width()) * (format.bpp/8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   759
-    byte[] oldData = data;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   760
+    int copyWidth = w < width() ? w : width();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   761
+    int oldWidth = width();
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   762
+    int[] oldData = data;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   763
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   764
     width_ = w;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   765
     height_ = h;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   766
     image = win.createImage(this);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   767
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   768
-    data = new byte[width() * height() * (format.bpp/8)];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   769
+    data = new int[width() * height()];
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   770
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   771
-    int newStrideBytes = getStride() * (format.bpp/8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   772
     for (int i = 0; i < rowsToCopy; i++)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   773
-      System.arraycopy(oldData, oldStrideBytes * i,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   774
-                       data, newStrideBytes * i, bytesPerRow);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   775
+      System.arraycopy(oldData, copyWidth * i,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   776
+                       data, width() * i, copyWidth);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   777
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   778
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   779
   // put() causes the given rectangle to be drawn using the given graphics
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   780
   // context.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   781
   public void put(int x, int y, int w, int h, Graphics g) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   782
-    if (ic == null) return;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   783
-    ic.setPixels(x, y, w, h, cm, data, width() * y + x, width());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   784
-    ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   785
+    if (ic != null) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   786
+      ic.setPixels(x, y, w, h, cm, data, width() * y + x, width());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   787
+      ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   788
+    }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   789
     g.setClip(x, y, w, h);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   790
     g.drawImage(image, 0, 0, null);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   791
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   792
@@ -87,33 +72,22 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   793
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   794
   public void copyRect(int x, int y, int w, int h, int srcX, int srcY) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   795
     super.copyRect(x, y, w, h, srcX, srcY);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   796
-    if (ic == null) return;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   797
-    ic.setPixels(x, y, w, h, cm, data, width() * y + x, width());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   798
-    ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   799
-  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   800
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   801
-  // setColourMapEntries() changes some of the entries in the colourmap.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   802
-  // However these settings won't take effect until updateColourMap() is
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   803
-  // called.  This is because getting java to recalculate its internal
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   804
-  // translation table and redraw the screen is expensive.
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   805
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   806
-  public void setColourMapEntries(int firstColour, int nColours,
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   807
-                                               int[] rgbs) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   808
-    for (int i = 0; i < nColours; i++) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   809
-      reds  [firstColour+i] = (byte)(rgbs[i*3]   >> 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   810
-      greens[firstColour+i] = (byte)(rgbs[i*3+1] >> 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   811
-      blues [firstColour+i] = (byte)(rgbs[i*3+2] >> 8);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   812
+    if (ic != null) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   813
+      ic.setPixels(x, y, w, h, cm, data, width() * y + x, width());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   814
+      ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   815
     }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   816
   }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   817
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   818
   // ImageProducer methods
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   819
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   820
-  public void updateColourMap() {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   821
-    cm = new IndexColorModel(8, 256, reds, greens, blues);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   822
-  }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   823
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   824
   public void addConsumer(ImageConsumer c) {
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   825
+    if (ic == c) return;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   826
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   827
     vlog.debug("adding consumer "+c);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   828
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   829
+    if (ic != null)
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   830
+      vlog.error("Only one ImageConsumer allowed - discarding old one");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   831
+    
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   832
     ic = c;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   833
     ic.setDimensions(width(), height());
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   834
     ic.setHints(ImageConsumer.RANDOMPIXELORDER);
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   835
@@ -134,13 +108,8 @@
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   836
   public void startProduction(ImageConsumer c) { addConsumer(c); }
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   837
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   838
   Image image;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   839
-  Graphics graphics;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   840
   ImageConsumer ic;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   841
   ColorModel cm;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   842
 
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   843
-  byte[] reds;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   844
-  byte[] greens;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   845
-  byte[] blues;
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   846
-
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   847
   static rfb.LogWriter vlog = new rfb.LogWriter("PixelBufferImage");
ab90f918fbaa 2007-11-02 Halton Huo <[email protected]>
halton
parents:
diff changeset
   848
 }