# HG changeset patch # User oshiro # Date 1549526650 -32400 # Node ID 11f587612329482032555e662f691abe9437fdb2 # Parent 7007d9785737efabd54c4c2476455a6e3f81f6ca change zrleeBlocking treevnc/TreeRFBProto.java diff -r 7007d9785737 -r 11f587612329 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Wed Feb 06 20:39:58 2019 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Thu Feb 07 17:04:10 2019 +0900 @@ -755,23 +755,32 @@ out.add(ByteBuffer.wrap(bytes)); int inputIndex = 0; ByteBuffer c1 = multicastqueue.allocate(deflate_size); + int x = rect.x, y = rect.y, w = 0, h = 0, w0 = 0, h0 = 0; + int span = rect.width; while (inputIndex < inflate_size) { - c1.reset(); - deflater.finish(); - deflater.setInput(bytes,inputIndex,rect.width * bytePerPixel); - if (c1.remaining() < rect.width * bytePerPixel) { + deflater.setInput(bytes,inputIndex,span * bytePerPixel); + if (c1.remaining() < span * bytePerPixel || inputIndex < inflate_size - span * bytePerPixel) { deflater.deflate(c1,Deflater.FULL_FLUSH); c1.flip(); - writeUpdateRectangleWithHeader(c1,header,c1.remaining()); + writeUpdateRectangleWithHeader(c1,header,c1.remaining(),x+w,y+h,h-h0,w-w0); + h0 = h; + w0 = w; + c1.reset(); } else { deflater.deflate(c1); } + w += span; + if (w >= rect.width ) { + h++; + w = 0; + w0 = 0; + } inputIndex += rect.width * bytePerPixel; } return; } - private void writeUpdateRectangleWithHeader(ByteBuffer c1, ByteBuffer header, int len2) throws InterruptedException { + private void writeUpdateRectangleWithHeader(ByteBuffer c1, ByteBuffer header, int len2, int x, int y, int w, int h) throws InterruptedException { LinkedList bufs = new LinkedList(); bufs.add(c1); deflater.reset(); @@ -780,10 +789,16 @@ blen.putInt(len2); blen.flip(); bufs.addFirst(blen); + ByteBuffer hdr = multicastqueue.allocate(header.array().length); + hdr.put(header.array()); + hdr.putShort(4,(short) x); + hdr.putShort(6,(short) y); + hdr.putShort(8,(short) w); + hdr.putShort(10,(short) h); if (checkDelay) { - bufs = createCheckDelayHeader(bufs, header); + bufs = createCheckDelayHeader(bufs, hdr); } else { - bufs.addFirst(header); + bufs.addFirst(hdr); } if (addSerialNum) { addSerialNumber(bufs);