Update OpenBIOS images to r771
[qemu/aliguori-queue.git] / vnc-encoding-hextile.c
bloba01c5e260f1b08291d4353f43fcacb02610541a8
1 /*
2 * QEMU VNC display driver: hextile encoding
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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.
27 #include "vnc.h"
29 static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h)
31 ptr[0] = ((x & 0x0F) << 4) | (y & 0x0F);
32 ptr[1] = (((w - 1) & 0x0F) << 4) | ((h - 1) & 0x0F);
35 #define BPP 8
36 #include "vnchextile.h"
37 #undef BPP
39 #define BPP 16
40 #include "vnchextile.h"
41 #undef BPP
43 #define BPP 32
44 #include "vnchextile.h"
45 #undef BPP
47 #define GENERIC
48 #define BPP 8
49 #include "vnchextile.h"
50 #undef BPP
51 #undef GENERIC
53 #define GENERIC
54 #define BPP 16
55 #include "vnchextile.h"
56 #undef BPP
57 #undef GENERIC
59 #define GENERIC
60 #define BPP 32
61 #include "vnchextile.h"
62 #undef BPP
63 #undef GENERIC
65 void vnc_hextile_send_framebuffer_update(VncState *vs, int x,
66 int y, int w, int h)
68 int i, j;
69 int has_fg, has_bg;
70 uint8_t *last_fg, *last_bg;
71 VncDisplay *vd = vs->vd;
73 last_fg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
74 last_bg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
75 has_fg = has_bg = 0;
76 for (j = y; j < (y + h); j += 16) {
77 for (i = x; i < (x + w); i += 16) {
78 vs->send_hextile_tile(vs, i, j,
79 MIN(16, x + w - i), MIN(16, y + h - j),
80 last_bg, last_fg, &has_bg, &has_fg);
83 free(last_fg);
84 free(last_bg);
88 void vnc_hextile_set_pixel_conversion(VncState *vs, int generic)
90 if (!generic) {
91 switch (vs->ds->surface->pf.bits_per_pixel) {
92 case 8:
93 vs->send_hextile_tile = send_hextile_tile_8;
94 break;
95 case 16:
96 vs->send_hextile_tile = send_hextile_tile_16;
97 break;
98 case 32:
99 vs->send_hextile_tile = send_hextile_tile_32;
100 break;
102 } else {
103 switch (vs->ds->surface->pf.bits_per_pixel) {
104 case 8:
105 vs->send_hextile_tile = send_hextile_tile_generic_8;
106 break;
107 case 16:
108 vs->send_hextile_tile = send_hextile_tile_generic_16;
109 break;
110 case 32:
111 vs->send_hextile_tile = send_hextile_tile_generic_32;
112 break;