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))
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 char *row
= (vs
->ds
->data
+ y
* vs
->ds
->linesize
+ x
* vs
->depth
);
17 pixel_t
*irow
= (pixel_t
*)row
;
19 pixel_t
*last_bg
= (pixel_t
*)last_bg32
;
20 pixel_t
*last_fg
= (pixel_t
*)last_fg32
;
27 uint8_t data
[(sizeof(pixel_t
) + 2) * 16 * 16];
31 for (j
= 0; j
< h
; j
++) {
32 for (i
= 0; i
< w
; i
++) {
45 if (irow
[i
] != bg
&& irow
[i
] != fg
) {
50 else if (irow
[i
] == fg
)
60 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
63 if (n_colors
> 1 && fg_count
> bg_count
) {
69 if (!*has_bg
|| *last_bg
!= bg
) {
75 if (!*has_fg
|| *last_fg
!= fg
) {
88 irow
= (pixel_t
*)row
;
90 for (j
= 0; j
< h
; j
++) {
92 for (i
= 0; i
< w
; i
++) {
96 } else if (min_x
!= -1) {
97 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
104 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
108 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
114 irow
= (pixel_t
*)row
;
116 if (!*has_bg
|| *last_bg
!= bg
)
119 for (j
= 0; j
< h
; j
++) {
124 for (i
= 0; i
< w
; i
++) {
131 } else if (irow
[i
] != color
) {
134 vnc_convert_pixel(vs
, data
+ n_data
, color
);
135 n_data
+= vs
->pix_bpp
;
137 memcpy(data
+ n_data
, &color
, sizeof(color
));
138 n_data
+= sizeof(pixel_t
);
140 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
154 vnc_convert_pixel(vs
, data
+ n_data
, color
);
155 n_data
+= vs
->pix_bpp
;
157 memcpy(data
+ n_data
, &color
, sizeof(color
));
158 n_data
+= sizeof(pixel_t
);
160 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
164 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
167 /* A SubrectsColoured subtile invalidates the foreground color */
169 if (n_data
> (w
* h
* sizeof(pixel_t
))) {
174 /* we really don't have to invalidate either the bg or fg
175 but we've lost the old values. oh well. */
188 vnc_write_u8(vs
, flags
);
191 vs
->write_pixels(vs
, last_bg
, sizeof(pixel_t
));
193 vs
->write_pixels(vs
, last_fg
, sizeof(pixel_t
));
195 vnc_write_u8(vs
, n_subtiles
);
196 vnc_write(vs
, data
, n_data
);
199 for (j
= 0; j
< h
; j
++) {
200 vs
->write_pixels(vs
, row
, w
* vs
->depth
);
201 row
+= vs
->ds
->linesize
;