2 * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * hextile.c - handle hextile encoding.
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 hextile
26 * encoded rectangle with BPP bits per pixel.
29 #define HandleHextileBPP CONCAT2E(HandleHextile,BPP)
30 #define CARDBPP CONCAT2E(CARD,BPP)
31 #define GET_PIXEL CONCAT2E(GET_PIXEL,BPP)
32 #define FillRectangleBPP CONCAT2E(FillRectangle,BPP)
35 HandleHextileBPP (int rx
, int ry
, int rw
, int rh
)
45 for (y
= ry
; y
< ry
+rh
; y
+= 16) {
46 for (x
= rx
; x
< rx
+rw
; x
+= 16) {
53 if (!ReadFromRFBServer((char *)&subencoding
, 1))
56 if (subencoding
& rfbHextileRaw
) {
57 if (!ReadFromRFBServer(buffer
, w
* h
* (BPP
/ 8)))
60 CopyDataToScreen(buffer
, x
, y
, w
, h
);
64 if (subencoding
& rfbHextileBackgroundSpecified
)
65 if (!ReadFromRFBServer((char *)&bg
, sizeof(bg
)))
69 if (subencoding
& rfbHextileBackgroundSpecified
)
70 FillRectangleBPP(bg
, x
, y
, w
, h
);
72 if (subencoding
& rfbHextileForegroundSpecified
)
73 if (!ReadFromRFBServer((char *)&fg
, sizeof(fg
))) {
78 if (!(subencoding
& rfbHextileAnySubrects
)) {
80 SyncScreenRegion(x
, y
, w
, h
);
84 if (!ReadFromRFBServer((char *)&nSubrects
, 1)) {
89 ptr
= (CARD8
*)buffer
;
91 if (subencoding
& rfbHextileSubrectsColoured
) {
92 if (!ReadFromRFBServer(buffer
, nSubrects
* (2 + (BPP
/ 8)))) {
97 for (i
= 0; i
< nSubrects
; i
++) {
99 sx
= rfbHextileExtractX(*ptr
);
100 sy
= rfbHextileExtractY(*ptr
);
102 sw
= rfbHextileExtractW(*ptr
);
103 sh
= rfbHextileExtractH(*ptr
);
105 FillRectangleBPP(fg
, x
+sx
, y
+sy
, sw
, sh
);
109 if (!ReadFromRFBServer(buffer
, nSubrects
* 2)) {
114 for (i
= 0; i
< nSubrects
; i
++) {
115 sx
= rfbHextileExtractX(*ptr
);
116 sy
= rfbHextileExtractY(*ptr
);
118 sw
= rfbHextileExtractW(*ptr
);
119 sh
= rfbHextileExtractH(*ptr
);
121 FillRectangleBPP(fg
, x
+sx
, y
+sy
, sw
, sh
);
125 SyncScreenRegion(x
, y
, w
, h
);