# HG changeset patch # User oshiro # Date 1550305894 -32400 # Node ID 5455c62a37758fa3d45cd0235cb000a00ef52ae4 # Parent 8d95d64c33bfb6fb8c5d4cc15fdec5e7fec2b225 fix multicastput diff -r 8d95d64c33bf -r 5455c62a3775 src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Fri Feb 15 20:11:47 2019 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Sat Feb 16 17:31:34 2019 +0900 @@ -88,9 +88,9 @@ offset += decodePacked(bytes, offset, renderer, paletteSize, tileX, tileY, tileWidth, tileHeight); } } + rfbProto.multicastPut(rect, bytes, prevoffset, offset, tileWidth, tileHeight); + prevoffset = offset; } - rfbProto.multicastPut(byte, prevoffset, offset); - prevoffset = offset; } } diff -r 8d95d64c33bf -r 5455c62a3775 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Feb 15 20:11:47 2019 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Feb 16 17:31:34 2019 +0900 @@ -75,6 +75,8 @@ private static int uniqueNodeId = 0; // uniquenodeid in all trees (less than MAX_UNIQUE_NODE_ID) private int deflate_size = 65507; private ByteBuffer header; + private ByteBuffer c1; + private FramebufferUpdateRectangle c1rect; public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { nets.setMyRfb(this); @@ -758,41 +760,33 @@ unzip(inflater, inputs, 0, bytes, inflate_size); this.header = header; // dump32(inputs); + c1 = multicastqueue.allocate(deflate_size); + c1rect = new FramebufferUpdateRectangle(rect.x, rect.y, 0, 0); return; } - public void multicastPut(Rectangle rect, byte[] bytes, int prevoffset, int offset, int bytePerPixel) { - byte subencoding = bytes[0]; - int inputIndex = 1; - ByteBuffer c1 = multicastqueue.allocate(deflate_size); + public void multicastPut(FramebufferUpdateRectangle rect, byte[] bytes, int prevoffset, int offset, int tilex, int tiley) { + int span = offset - prevoffset; int x = rect.x, y = rect.y, w = 0, h = 0, w0 = 0, h0 = 0; - int span = rect.width; - while (inputIndex < INFLATE_BUFSIZE) { - byte save = bytes[inputIndex-1]; - bytes[inputIndex-1] = subencoding; - deflater.setInput(bytes,inputIndex-1,span * bytePerPixel +1); - if (c1.remaining() < span * bytePerPixel || inputIndex >= INFLATE_BUFSIZE - span * bytePerPixel) { - deflater.deflate(c1, Deflater.FULL_FLUSH); - c1.flip(); - try { - writeUpdateRectangleWithHeader(c1,header,c1.remaining(),x+w,y+h,rect.width,h-h0); - } catch (InterruptedException e) { - e.printStackTrace(); - } - h0 = h; - w0 = w; - c1 = multicastqueue.allocate(deflate_size); - } else { - deflater.deflate(c1,Deflater.SYNC_FLUSH); + deflater.setInput(bytes,prevoffset,span); + c1rect.height = tiley; + if (c1.remaining() < span || x + tilex >= rect.x + rect.width ) { + deflater.deflate(c1, Deflater.FULL_FLUSH); + c1.flip(); + try { + writeUpdateRectangleWithHeader(c1,header,c1.remaining(), c1rect.x, c1rect.y, c1rect.width, c1rect.height); + } catch (InterruptedException e) { + e.printStackTrace(); } - bytes[inputIndex-1] = save; - w += span; - if (w >= rect.width ) { - h++; - w = 0; - w0 = 0; - } - inputIndex += rect.width * bytePerPixel; + c1 = multicastqueue.allocate(deflate_size); + } else { + deflater.deflate(c1, Deflater.SYNC_FLUSH); + } + c1rect.width += tilex; + if (c1rect.width >= rect.width) { + c1rect.width = 0; + c1rect.x = 0; + c1rect.y += tiley; } }