view Paper/src/multicastPut.java @ 11:c9d0d3e1a82f

add code
author riono <e165729@ie.u-ryukyu.ac.jp>
date Thu, 07 May 2020 19:45:00 +0900
parents
children
line wrap: on
line source

public void multicastPut(TreeRFBProto rfb, boolean last, byte[] bytes, int offset, int tileW, int tileH, int tileX, int tileY) throws TransportException {
  int span = offset - prevoffset;
  if (span==0) return;
  deflater.setInput(bytes, prevoffset, span);
  width += tileW;
  c1rect.width += tileW;
  do {
    deflater.deflate(c1, Deflater.SYNC_FLUSH);
    if (!deflater.needsInput()) {
      flushDeflator(true," full ");
      int bytesRead = (int)deflater.getBytesRead();
      prevoffset = flushOffset+bytesRead;
      if (c0rect!=null) { // finish pahse 1
        flushRectangle(c0rect,prevC1LineOffset," full c0rect");
        c0rect = null;
       }
      flushRectangle(c1rect,c1.position()," full c1rect"); // phase 2
      flushMuticast(rfb, bytes);
    }
  } while (! deflater.needsInput());
  prevoffset = offset;
  if (last) {
    flushDeflator(false," last");
    if (c0rect!=null) {
      flushRectangle(c0rect,prevC1LineOffset," last c0rect");
      makeHeaderSpace();
      c0rect = null;
    }
    flushRectangle(c1rect,c1.position()," last c1rect");
    flushMuticast(rfb, bytes);
    return;
  }
  if (c1rect.x > rect.x) {  // phase 0
    assert(c0rect==null);
    if (width >= rect.width) {  // end of phase 0
      boolean end = flushDeflator(false," end of phase 0 ");
      width = 0;
      flushRectangle(c1rect,c1.position()," end of phase 0");
      c1rect = new FramebufferUpdateRectangle(rect.x,c1rect.y+tileH,0,0);
      if (end || c1rect.y  >= rect.y+rect.height) {
        flushMuticast(rfb,bytes);
        return;
      }
      c1.position(c1.position()+ RECT_HEADER_SIZE); // header space
      prevC1Offset = c1.position();
    }
  } else {  // phase 1
    if (width >= rect.width) { // next line
      boolean end = flushDeflator(false, " phoase 1 next line ");
      width = 0;
      prevC1LineOffset = c1.position();
      if (c0rect!=null) { // extend phase 1
        c0rect.height += tileH;
      } else { // first phase 1 case
        c0rect = c1rect;
      }
      c1rect = new FramebufferUpdateRectangle(rect.x, c0rect.y+c0rect.height, 0, 0);
      if (end || c1rect.y >= rect.y+rect.height) {
        c0rect = null; // next will be first phase 1 case
        flushMuticast(rfb,bytes);
        return;
      }
    }
  }
}