Exemple #1
0
Bool
VNCViewer::HandleHextileBPP (sgVNCViewer *ct, int rx, int ry, int rw, int rh)
{
    CARDBPP bg, fg;
    int i;
    CARD8 *ptr;
    int x, y, w, h;
    int sx, sy, sw, sh;
    CARD8 subencoding;
    CARD8 nSubrects;

    for (y = ry; y < ry+rh; y += 16) {
        for (x = rx; x < rx+rw; x += 16) {
            w = h = 16;
            if (rx+rw - x < 16)
                w = rx+rw - x;
            if (ry+rh - y < 16)
                h = ry+rh - y;

            if (!ReadFromRFBServer((char *)&subencoding, 1))
                return False;

            if (subencoding & rfbHextileRaw) {
                if (!ReadFromRFBServer(buffer, w * h * (BPP / 8)))
                    return False;

                ct->CopyDataToScreen(buffer, x, y, w, h);
                continue;
            }

            if (subencoding & rfbHextileBackgroundSpecified)
                if (!ReadFromRFBServer((char *)&bg, sizeof(bg)))
                    return False;

            ct->FillToScreen(bg, x, y, w, h);

            if (subencoding & rfbHextileForegroundSpecified)
                if (!ReadFromRFBServer((char *)&fg, sizeof(fg)))
                    return False;

            if (!(subencoding & rfbHextileAnySubrects)) {
                continue;
            }

            if (!ReadFromRFBServer((char *)&nSubrects, 1))
                return False;

            ptr = (CARD8 *)buffer;

            if (subencoding & rfbHextileSubrectsColoured) {
                if (!ReadFromRFBServer(buffer, nSubrects * (2 + (BPP / 8))))
                    return False;

                for (i = 0; i < nSubrects; i++) {
                    GET_PIXEL(fg, ptr);
                    sx = rfbHextileExtractX(*ptr);
                    sy = rfbHextileExtractY(*ptr);
                    ptr++;
                    sw = rfbHextileExtractW(*ptr);
                    sh = rfbHextileExtractH(*ptr);
                    ptr++;

                    ct->FillToScreen(fg, x+sx, y+sy, sw, sh);
                }

            } else {
                if (!ReadFromRFBServer(buffer, nSubrects * 2))
                    return False;

                for (i = 0; i < nSubrects; i++) {
                    sx = rfbHextileExtractX(*ptr);
                    sy = rfbHextileExtractY(*ptr);
                    ptr++;
                    sw = rfbHextileExtractW(*ptr);
                    sh = rfbHextileExtractH(*ptr);
                    ptr++;

                    ct->FillToScreen(fg, x+sx, y+sy, sw, sh);
                }
            }
        }
    }

    return True;
}
Exemple #2
0
static Bool
HandleHextileBPP (int rx, int ry, int rw, int rh)
{
  CARDBPP bg, fg;
/*  XGCValues gcv; */
  int i;
  CARD8 *ptr;
  int x, y, w, h;
  int sx, sy, sw, sh;
  CARD8 subencoding;
  CARD8 nSubrects;

  for (y = ry; y < ry+rh; y += 16) {
    for (x = rx; x < rx+rw; x += 16) {
      w = h = 16;
      if (rx+rw - x < 16)
	w = rx+rw - x;
      if (ry+rh - y < 16)
	h = ry+rh - y;

      if (!ReadFromRFBServer((char *)&subencoding, 1))
	return False;

      if (subencoding & rfbHextileRaw) {
	if (!ReadFromRFBServer(buffer, w * h * (BPP / 8)))
	  return False;

/*	CopyDataToScreen(buffer, x, y, w, h); */
	continue;
      }

      if (subencoding & rfbHextileBackgroundSpecified)
	if (!ReadFromRFBServer((char *)&bg, sizeof(bg)))
	  return False;

#if (BPP == 8)
/*      if (appData.useBGR233)
	gcv.foreground = BGR233ToPixel[bg];
      else */
#endif
/*	gcv.foreground = bg;

      XChangeGC(dpy, gc, GCForeground, &gcv);
      XFillRectangle(dpy, desktopWin, gc, x, y, w, h); */

      if (subencoding & rfbHextileForegroundSpecified)
	if (!ReadFromRFBServer((char *)&fg, sizeof(fg)))
	  return False;

      if (!(subencoding & rfbHextileAnySubrects)) {
	continue;
      }

      if (!ReadFromRFBServer((char *)&nSubrects, 1))
	return False;

      ptr = (CARD8 *)buffer;

      if (subencoding & rfbHextileSubrectsColoured) {
	if (!ReadFromRFBServer(buffer, nSubrects * (2 + (BPP / 8))))
	  return False;

	for (i = 0; i < nSubrects; i++) {
	  GET_PIXEL(fg, ptr);
	  sx = rfbHextileExtractX(*ptr);
	  sy = rfbHextileExtractY(*ptr);
	  ptr++;
	  sw = rfbHextileExtractW(*ptr);
	  sh = rfbHextileExtractH(*ptr);
	  ptr++;
#if (BPP == 8)
/*	  if (appData.useBGR233)
	    gcv.foreground = BGR233ToPixel[fg];
	  else */
#endif
/*	    gcv.foreground = fg;

	  XChangeGC(dpy, gc, GCForeground, &gcv);
	  XFillRectangle(dpy, desktopWin, gc, x+sx, y+sy, sw, sh); */
	}

      } else {
	if (!ReadFromRFBServer(buffer, nSubrects * 2))
	  return False;

#if (BPP == 8)
/*	if (appData.useBGR233)
	  gcv.foreground = BGR233ToPixel[fg];
	else */
#endif
/*	  gcv.foreground = fg;

	XChangeGC(dpy, gc, GCForeground, &gcv); */

	for (i = 0; i < nSubrects; i++) {
	  sx = rfbHextileExtractX(*ptr);
	  sy = rfbHextileExtractY(*ptr);
	  ptr++;
	  sw = rfbHextileExtractW(*ptr);
	  sh = rfbHextileExtractH(*ptr);
	  ptr++;
/*	  XFillRectangle(dpy, desktopWin, gc, x+sx, y+sy, sw, sh); */
	}
      }
    }
  }

  return True;
}