diff src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java @ 566:e93a8058344d

several fixes
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 03 Feb 2020 19:56:08 +0900
parents 2a601e25ce10
children 44920845d4e1
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java	Mon Feb 03 17:33:27 2020 +0900
+++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java	Mon Feb 03 19:56:08 2020 +0900
@@ -73,10 +73,10 @@
 		 * @throws UnsupportedEncodingException
 		 */
 
-		public TileLoop(int offset) {
+		public TileLoop(TreeRFBProto rfb, int offset) {
 			prevoffset = prevLineOffset = offset;
 			prevC1Offset = 0;
-			if (offset < deflate_size + spanGap) {
+			if (rfb == null || offset < deflate_size + spanGap) {
 				// packet size fit in broadcast send it all at once
 				blocking = false;
 			} else
@@ -266,7 +266,7 @@
 		int maxX = rect.x + rect.width;
 		int maxY = rect.y + rect.height;
 
-		TileLoop tileloop = new TileLoop(zippedLength);
+		TileLoop tileloop = new TileLoop(rfbProto, zippedLength);
 		//System.out.println("decode1: "+rect.toString());
 		if (null == palette) {
 			palette = new int[128];
@@ -275,17 +275,18 @@
 			decodedBitmap = new int[MAX_TILE_SIZE * MAX_TILE_SIZE];
 		}
 
-		if (rfbProto.multicastBlocking) {
+		if (rfbProto !=null && rfbProto.multicastBlocking) {
 			tileloop.zrleeBlocking(rfbProto, header, rect, bytes);
 		}
 		try {
 			for (int tileY = rect.y; tileY < maxY; tileY += MAX_TILE_SIZE) {
 				int tileHeight = Math.min(maxY - tileY, MAX_TILE_SIZE);
-				tileloop.c1rect.height += tileHeight;
+				if (tileloop.blocking)
+					tileloop.c1rect.height += tileHeight;
 
 				for (int tileX = rect.x; tileX < maxX; tileX += MAX_TILE_SIZE) {
 					int tileWidth = Math.min(maxX - tileX, MAX_TILE_SIZE);
-					if (tileloop.c1rect.x + tileloop.c1rect.width < rect.x + rect.width)
+					if (tileloop.blocking && tileloop.c1rect.x + tileloop.c1rect.width < rect.x + rect.width)
 						tileloop.c1rect.width += tileWidth;
 					int subencoding = bytes[offset++] & 0x0ff;
 					if (subencoding != 0)