1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
35#define BPP 8
36#include "vnc-enc-hextile-template.h"
37#undef BPP
38
39#define BPP 16
40#include "vnc-enc-hextile-template.h"
41#undef BPP
42
43#define BPP 32
44#include "vnc-enc-hextile-template.h"
45#undef BPP
46
47#define GENERIC
48#define BPP 8
49#include "vnc-enc-hextile-template.h"
50#undef BPP
51#undef GENERIC
52
53#define GENERIC
54#define BPP 16
55#include "vnc-enc-hextile-template.h"
56#undef BPP
57#undef GENERIC
58
59#define GENERIC
60#define BPP 32
61#include "vnc-enc-hextile-template.h"
62#undef BPP
63#undef GENERIC
64
65int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
66 int y, int w, int h)
67{
68 int i, j;
69 int has_fg, has_bg;
70 uint8_t *last_fg, *last_bg;
71 VncDisplay *vd = vs->vd;
72
73 last_fg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
74 last_bg = (uint8_t *) g_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->hextile.send_tile(vs, i, j,
79 MIN(16, x + w - i), MIN(16, y + h - j),
80 last_bg, last_fg, &has_bg, &has_fg);
81 }
82 }
83 g_free(last_fg);
84 g_free(last_bg);
85
86 return 1;
87}
88
89void vnc_hextile_set_pixel_conversion(VncState *vs, int generic)
90{
91 if (!generic) {
92 switch (vs->ds->surface->pf.bits_per_pixel) {
93 case 8:
94 vs->hextile.send_tile = send_hextile_tile_8;
95 break;
96 case 16:
97 vs->hextile.send_tile = send_hextile_tile_16;
98 break;
99 case 32:
100 vs->hextile.send_tile = send_hextile_tile_32;
101 break;
102 }
103 } else {
104 switch (vs->ds->surface->pf.bits_per_pixel) {
105 case 8:
106 vs->hextile.send_tile = send_hextile_tile_generic_8;
107 break;
108 case 16:
109 vs->hextile.send_tile = send_hextile_tile_generic_16;
110 break;
111 case 32:
112 vs->hextile.send_tile = send_hextile_tile_generic_32;
113 break;
114 }
115 }
116}
117