]> git.proxmox.com Git - qemu.git/blame - ui/vnc-enc-hextile.c
Merge remote-tracking branch 'luiz/queue/qmp' into staging
[qemu.git] / ui / vnc-enc-hextile.c
CommitLineData
70a4568f
CC
1/*
2 * QEMU VNC display driver: hextile encoding
3 *
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include "vnc.h"
28
29static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h)
30{
31 ptr[0] = ((x & 0x0F) << 4) | (y & 0x0F);
32 ptr[1] = (((w - 1) & 0x0F) << 4) | ((h - 1) & 0x0F);
33}
34
70a4568f 35#define BPP 32
245f7b51 36#include "vnc-enc-hextile-template.h"
70a4568f
CC
37#undef BPP
38
70a4568f
CC
39#define GENERIC
40#define BPP 32
245f7b51 41#include "vnc-enc-hextile-template.h"
70a4568f
CC
42#undef BPP
43#undef GENERIC
44
a885211e
CC
45int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
46 int y, int w, int h)
70a4568f
CC
47{
48 int i, j;
49 int has_fg, has_bg;
50 uint8_t *last_fg, *last_bg;
70a4568f 51
9f64916d
GH
52 last_fg = (uint8_t *) g_malloc(VNC_SERVER_FB_BYTES);
53 last_bg = (uint8_t *) g_malloc(VNC_SERVER_FB_BYTES);
70a4568f
CC
54 has_fg = has_bg = 0;
55 for (j = y; j < (y + h); j += 16) {
56 for (i = x; i < (x + w); i += 16) {
d1af0e05 57 vs->hextile.send_tile(vs, i, j,
70a4568f
CC
58 MIN(16, x + w - i), MIN(16, y + h - j),
59 last_bg, last_fg, &has_bg, &has_fg);
60 }
61 }
ae878b17
SW
62 g_free(last_fg);
63 g_free(last_bg);
70a4568f 64
a885211e 65 return 1;
70a4568f
CC
66}
67
68void vnc_hextile_set_pixel_conversion(VncState *vs, int generic)
69{
70 if (!generic) {
9f64916d 71 switch (VNC_SERVER_FB_BITS) {
9f64916d
GH
72 case 32:
73 vs->hextile.send_tile = send_hextile_tile_32;
74 break;
70a4568f
CC
75 }
76 } else {
9f64916d 77 switch (VNC_SERVER_FB_BITS) {
9f64916d
GH
78 case 32:
79 vs->hextile.send_tile = send_hextile_tile_generic_32;
80 break;
70a4568f
CC
81 }
82 }
83}