Commit fb437313284d74bc89060b8de5b9899bd9d1d3c3
1 parent
26f8b9cc
Add some tight awareness to vnc.c (Alexander Graf)
This patch enables the vnc server to understand fundamental tight extensions. It changes from a "Hextile or not" scheme when sending framebuffer updates to a "preferred encoding", namely the last one set. While this is not perfect, as actually a list of "preferred encodings" should be kept, it's good enough for now. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6496 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
21 additions
and
2 deletions
vnc.c
| @@ -103,6 +103,10 @@ struct VncState | @@ -103,6 +103,10 @@ struct VncState | ||
| 103 | int last_x; | 103 | int last_x; |
| 104 | int last_y; | 104 | int last_y; |
| 105 | 105 | ||
| 106 | + uint32_t vnc_encoding; | ||
| 107 | + uint8_t tight_quality; | ||
| 108 | + uint8_t tight_compression; | ||
| 109 | + | ||
| 106 | int major; | 110 | int major; |
| 107 | int minor; | 111 | int minor; |
| 108 | 112 | ||
| @@ -450,10 +454,14 @@ static void send_framebuffer_update_hextile(VncState *vs, int x, int y, int w, i | @@ -450,10 +454,14 @@ static void send_framebuffer_update_hextile(VncState *vs, int x, int y, int w, i | ||
| 450 | 454 | ||
| 451 | static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h) | 455 | static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h) |
| 452 | { | 456 | { |
| 453 | - if (vnc_has_feature(vs, VNC_FEATURE_HEXTILE)) | 457 | + switch(vs->vnc_encoding) { |
| 458 | + case VNC_ENCODING_HEXTILE: | ||
| 454 | send_framebuffer_update_hextile(vs, x, y, w, h); | 459 | send_framebuffer_update_hextile(vs, x, y, w, h); |
| 455 | - else | 460 | + break; |
| 461 | + default: | ||
| 456 | send_framebuffer_update_raw(vs, x, y, w, h); | 462 | send_framebuffer_update_raw(vs, x, y, w, h); |
| 463 | + break; | ||
| 464 | + } | ||
| 457 | } | 465 | } |
| 458 | 466 | ||
| 459 | static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h) | 467 | static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h) |
| @@ -1164,6 +1172,9 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | @@ -1164,6 +1172,9 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | ||
| 1164 | unsigned int enc = 0; | 1172 | unsigned int enc = 0; |
| 1165 | 1173 | ||
| 1166 | vs->features = 0; | 1174 | vs->features = 0; |
| 1175 | + vs->vnc_encoding = 0; | ||
| 1176 | + vs->tight_compression = 9; | ||
| 1177 | + vs->tight_quality = 9; | ||
| 1167 | vs->absolute = -1; | 1178 | vs->absolute = -1; |
| 1168 | dcl->dpy_copy = NULL; | 1179 | dcl->dpy_copy = NULL; |
| 1169 | 1180 | ||
| @@ -1171,12 +1182,14 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | @@ -1171,12 +1182,14 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | ||
| 1171 | enc = encodings[i]; | 1182 | enc = encodings[i]; |
| 1172 | switch (enc) { | 1183 | switch (enc) { |
| 1173 | case VNC_ENCODING_RAW: | 1184 | case VNC_ENCODING_RAW: |
| 1185 | + vs->vnc_encoding = enc; | ||
| 1174 | break; | 1186 | break; |
| 1175 | case VNC_ENCODING_COPYRECT: | 1187 | case VNC_ENCODING_COPYRECT: |
| 1176 | dcl->dpy_copy = vnc_copy; | 1188 | dcl->dpy_copy = vnc_copy; |
| 1177 | break; | 1189 | break; |
| 1178 | case VNC_ENCODING_HEXTILE: | 1190 | case VNC_ENCODING_HEXTILE: |
| 1179 | vs->features |= VNC_FEATURE_HEXTILE_MASK; | 1191 | vs->features |= VNC_FEATURE_HEXTILE_MASK; |
| 1192 | + vs->vnc_encoding = enc; | ||
| 1180 | break; | 1193 | break; |
| 1181 | case VNC_ENCODING_DESKTOPRESIZE: | 1194 | case VNC_ENCODING_DESKTOPRESIZE: |
| 1182 | vs->features |= VNC_FEATURE_RESIZE_MASK; | 1195 | vs->features |= VNC_FEATURE_RESIZE_MASK; |
| @@ -1193,6 +1206,12 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | @@ -1193,6 +1206,12 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) | ||
| 1193 | case VNC_ENCODING_WMVi: | 1206 | case VNC_ENCODING_WMVi: |
| 1194 | vs->features |= VNC_FEATURE_WMVI_MASK; | 1207 | vs->features |= VNC_FEATURE_WMVI_MASK; |
| 1195 | break; | 1208 | break; |
| 1209 | + case VNC_ENCODING_COMPRESSLEVEL0 ... VNC_ENCODING_COMPRESSLEVEL0 + 9: | ||
| 1210 | + vs->tight_compression = (enc & 0x0F); | ||
| 1211 | + break; | ||
| 1212 | + case VNC_ENCODING_QUALITYLEVEL0 ... VNC_ENCODING_QUALITYLEVEL0 + 9: | ||
| 1213 | + vs->tight_quality = (enc & 0x0F); | ||
| 1214 | + break; | ||
| 1196 | default: | 1215 | default: |
| 1197 | VNC_DEBUG("Unknown encoding: %d (0x%.8x): %d\n", i, enc, enc); | 1216 | VNC_DEBUG("Unknown encoding: %d (0x%.8x): %d\n", i, enc, enc); |
| 1198 | break; | 1217 | break; |