Mercurial > hg > Applications > TreeVNC
diff src/main/java/com/glavsoft/rfb/protocol/TreeTask.java @ 23:6a4312344a5a
remove set rfb TreeTask
author | one |
---|---|
date | Thu, 30 Aug 2012 14:40:32 +0900 |
parents | ea83f4be0cc9 |
children | 1fe39e8ba3e9 |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/TreeTask.java Wed Aug 29 23:35:54 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/TreeTask.java Thu Aug 30 14:40:32 2012 +0900 @@ -6,41 +6,76 @@ import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.ClipboardController; import com.glavsoft.rfb.IRepaintController; +import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage; +import com.glavsoft.rfb.client.SetPixelFormatMessage; import com.glavsoft.rfb.encoding.EncodingType; +import com.glavsoft.rfb.encoding.decoder.Decoder; import com.glavsoft.rfb.encoding.decoder.DecodersContainer; import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; +import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; import com.glavsoft.transport.Reader; public class TreeTask extends ReceiverTask { final static String versionMsg_3_855 = "RFB 003.855\n"; - private Reader reader; private MyRfbProtoProxy rfb; - private ProtocolContext context; public TreeTask(Reader reader, IRepaintController repaintController, ClipboardController clipboardController, - DecodersContainer decoders, ProtocolContext context, boolean flag) { + DecodersContainer decoders, ProtocolContext context, MyRfbProtoProxy _rfb) { super(reader, repaintController, clipboardController, decoders, context, true); - this.context = context; - this.reader = reader; + rfb = _rfb; } @Override public void framebufferUpdateMessage() throws CommonException { reader.readByte(); // padding int numberOfRectangles = reader.readUInt16(); // number of rectangles + while (numberOfRectangles-- > 0) { FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader); - int zrleLength = getZrleLength(rect); - reader.reset(); - rfb.readSendData(zrleLength, reader); - boolean fullUpdateNeeded = false; - int w = context.getFbWidth(); - int h = context.getFbHeight(); - rfb.writeFramebufferUpdateRequest(0, 0, w, h, !fullUpdateNeeded); - // rfb.checkDelayData(); + + Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); + logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : "")); + if (decoder != null) { + /* + decoder.decode(reader, renderer, rect); + repaintController.repaintBitmap(rect); + */ + int zrleLength = getZrleLength(rect); + reader.reset(); + rfb.readSendData(zrleLength, reader); + + } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { + RichCursorDecoder.getInstance().decode(reader, renderer, rect); + repaintController.repaintCursor(); + } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { + renderer.decodeCursorPosition(rect); + repaintController.repaintCursor(); + } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE) { + fullscreenFbUpdateIncrementalRequest = + new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, true); + synchronized (renderer) { + renderer = repaintController.createRenderer(reader, rect.width, rect.height, + context.getPixelFormat()); + } + context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); +// repaintController.repaintCursor(); + } else + throw new CommonException("Unprocessed encoding: " + rect.toString()); + } + synchronized (this) { + if (needSendPixelFormat) { + needSendPixelFormat = false; + context.setPixelFormat(pixelFormat); + context.sendMessage(new SetPixelFormatMessage(pixelFormat)); + logger.fine("sent: "+pixelFormat); + context.sendRefreshMessage(); + logger.fine("sent: nonincremental fb update"); + } else { + context.sendMessage(fullscreenFbUpdateIncrementalRequest); + } } } @@ -56,8 +91,4 @@ return zrleLength + 20; } - @Override - public void setRfb(MyRfbProtoProxy _rfb) { - rfb = _rfb; - } }