1 #define CONCAT_I(a, b) a ## b
2 #define CONCAT(a, b) CONCAT_I(a, b)
3 #define pixel_t CONCAT(uint, CONCAT(BPP, _t))
5 #define NAME CONCAT(generic_, BPP)
10 static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
11 int x, int y, int w, int h,
14 int *has_bg, int *has_fg)
16 VncDisplay *vd = vs->vd;
17 uint8_t *row = vd->server->data + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);
18 pixel_t *irow = (pixel_t *)row;
20 pixel_t *last_bg = (pixel_t *)last_bg_;
21 pixel_t *last_fg = (pixel_t *)last_fg_;
28 uint8_t data[(vs->clientds.pf.bytes_per_pixel + 2) * 16 * 16];
32 for (j = 0; j < h; j++) {
33 for (i = 0; i < w; i++) {
46 if (irow[i] != bg && irow[i] != fg) {
51 else if (irow[i] == fg)
61 irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
64 if (n_colors > 1 && fg_count > bg_count) {
70 if (!*has_bg || *last_bg != bg) {
76 if (n_colors < 3 && (!*has_fg || *last_fg != fg)) {
89 irow = (pixel_t *)row;
91 for (j = 0; j < h; j++) {
93 for (i = 0; i < w; i++) {
97 } else if (min_x != -1) {
98 hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);
105 hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);
109 irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
115 irow = (pixel_t *)row;
117 if (!*has_bg || *last_bg != bg)
120 for (j = 0; j < h; j++) {
123 pixel_t color = 0; /* shut up gcc */
125 for (i = 0; i < w; i++) {
132 } else if (irow[i] != color) {
135 vnc_convert_pixel(vs, data + n_data, color);
136 n_data += vs->clientds.pf.bytes_per_pixel;
138 memcpy(data + n_data, &color, sizeof(color));
139 n_data += sizeof(pixel_t);
141 hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);
155 vnc_convert_pixel(vs, data + n_data, color);
156 n_data += vs->clientds.pf.bytes_per_pixel;
158 memcpy(data + n_data, &color, sizeof(color));
159 n_data += sizeof(pixel_t);
161 hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);
165 irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
168 /* A SubrectsColoured subtile invalidates the foreground color */
170 if (n_data > (w * h * sizeof(pixel_t))) {
175 /* we really don't have to invalidate either the bg or fg
176 but we've lost the old values. oh well. */
190 vnc_write_u8(vs, flags);
193 vs->write_pixels(vs, &vd->server->pf, last_bg, sizeof(pixel_t));
195 vs->write_pixels(vs, &vd->server->pf, last_fg, sizeof(pixel_t));
197 vnc_write_u8(vs, n_subtiles);
198 vnc_write(vs, data, n_data);
201 for (j = 0; j < h; j++) {
202 vs->write_pixels(vs, &vd->server->pf, row,
203 w * ds_get_bytes_per_pixel(vs->ds));
204 row += ds_get_linesize(vs->ds);