Home | History | Annotate | Download | only in libvncclient
      1 /*
      2  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
      3  *
      4  *  This is free software; you can redistribute it and/or modify
      5  *  it under the terms of the GNU General Public License as published by
      6  *  the Free Software Foundation; either version 2 of the License, or
      7  *  (at your option) any later version.
      8  *
      9  *  This software is distributed in the hope that it will be useful,
     10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  *  GNU General Public License for more details.
     13  *
     14  *  You should have received a copy of the GNU General Public License
     15  *  along with this software; if not, write to the Free Software
     16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
     17  *  USA.
     18  */
     19 
     20 /*
     21  * corre.c - handle CoRRE encoding.
     22  *
     23  * This file shouldn't be compiled directly.  It is included multiple times by
     24  * rfbproto.c, each time with a different definition of the macro BPP.  For
     25  * each value of BPP, this file defines a function which handles a CoRRE
     26  * encoded rectangle with BPP bits per pixel.
     27  */
     28 
     29 #define HandleCoRREBPP CONCAT2E(HandleCoRRE,BPP)
     30 #define CARDBPP CONCAT3E(uint,BPP,_t)
     31 
     32 static rfbBool
     33 HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
     34 {
     35     rfbRREHeader hdr;
     36     int i;
     37     CARDBPP pix;
     38     uint8_t *ptr;
     39     int x, y, w, h;
     40 
     41     if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))
     42 	return FALSE;
     43 
     44     hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);
     45 
     46     if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
     47 	return FALSE;
     48 
     49     FillRectangle(client, rx, ry, rw, rh, pix);
     50 
     51     if (!ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8))))
     52 	return FALSE;
     53 
     54     ptr = (uint8_t *)client->buffer;
     55 
     56     for (i = 0; i < hdr.nSubrects; i++) {
     57 	pix = *(CARDBPP *)ptr;
     58 	ptr += BPP/8;
     59 	x = *ptr++;
     60 	y = *ptr++;
     61 	w = *ptr++;
     62 	h = *ptr++;
     63 
     64 	FillRectangle(client, rx+x, ry+y, w, h, pix);
     65     }
     66 
     67     return TRUE;
     68 }
     69 
     70 #undef CARDBPP
     71