]>
git.proxmox.com Git - mirror_qemu.git/blob - vnchextile.h
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 static void CONCAT(send_hextile_tile_
, BPP
)(VncState
*vs
,
6 int x
, int y
, int w
, int h
,
7 pixel_t
*last_bg
, pixel_t
*last_fg
,
8 int *has_bg
, int *has_fg
)
10 char *row
= (vs
->ds
->data
+ y
* vs
->ds
->linesize
+ x
* vs
->depth
);
11 pixel_t
*irow
= (pixel_t
*)row
;
19 uint8_t data
[(sizeof(pixel_t
) + 2) * 16 * 16];
23 for (j
= 0; j
< h
; j
++) {
24 for (i
= 0; i
< w
; i
++) {
37 if (irow
[i
] != bg
&& irow
[i
] != fg
) {
42 else if (irow
[i
] == fg
)
52 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
55 if (n_colors
> 1 && fg_count
> bg_count
) {
61 if (!*has_bg
|| *last_bg
!= bg
) {
67 if (!*has_fg
|| *last_fg
!= fg
) {
80 irow
= (pixel_t
*)row
;
82 for (j
= 0; j
< h
; j
++) {
84 for (i
= 0; i
< w
; i
++) {
88 } else if (min_x
!= -1) {
89 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
96 hextile_enc_cord(data
+ n_data
, min_x
, j
, i
- min_x
, 1);
100 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
106 irow
= (pixel_t
*)row
;
108 if (!*has_bg
|| *last_bg
!= bg
)
111 for (j
= 0; j
< h
; j
++) {
116 for (i
= 0; i
< w
; i
++) {
123 } else if (irow
[i
] != color
) {
126 memcpy(data
+ n_data
, &color
, sizeof(color
));
127 hextile_enc_cord(data
+ n_data
+ sizeof(pixel_t
), min_x
, j
, i
- min_x
, 1);
128 n_data
+= 2 + sizeof(pixel_t
);
140 memcpy(data
+ n_data
, &color
, sizeof(color
));
141 hextile_enc_cord(data
+ n_data
+ sizeof(pixel_t
), min_x
, j
, i
- min_x
, 1);
142 n_data
+= 2 + sizeof(pixel_t
);
145 irow
+= vs
->ds
->linesize
/ sizeof(pixel_t
);
148 /* A SubrectsColoured subtile invalidates the foreground color */
150 if (n_data
> (w
* h
* sizeof(pixel_t
))) {
155 /* we really don't have to invalidate either the bg or fg
156 but we've lost the old values. oh well. */
169 vnc_write_u8(vs
, flags
);
172 vnc_write(vs
, last_bg
, sizeof(pixel_t
));
174 vnc_write(vs
, last_fg
, sizeof(pixel_t
));
176 vnc_write_u8(vs
, n_subtiles
);
177 vnc_write(vs
, data
, n_data
);
180 for (j
= 0; j
< h
; j
++) {
181 vnc_write(vs
, row
, w
* vs
->depth
);
182 row
+= vs
->ds
->linesize
;