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