Commit 9f64916d authored by Gerd Hoffmann's avatar Gerd Hoffmann
Browse files

pixman/vnc: use pixman images in vnc.



The vnc code uses *three* DisplaySurfaces:

First is the surface of the actual QemuConsole, usually the guest
screen, but could also be a text console (monitor/serial reachable via
Ctrl-Alt-<nr> keys).  This is left as-is.

Second is the current server's view of the screen content.  The vnc code
uses this to figure which parts of the guest screen did _really_ change
to reduce the amount of updates sent to the vnc clients.  It is also
used as data source when sending out the updates to the clients.  This
surface gets replaced by a pixman image.  The format changes too,
instead of using the guest screen format we'll use fixed 32bit rgb
framebuffer and convert the pixels on the fly when comparing and
updating the server framebuffer.

Third surface carries the format expected by the vnc client.  That isn't
used to store image data.  This surface is switched to PixelFormat and a
boolean for bigendian byte order.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent b12f32c4
......@@ -14,7 +14,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
int *has_bg, int *has_fg)
{
VncDisplay *vd = vs->vd;
uint8_t *row = vd->server->data + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);
uint8_t *row = vnc_server_fb_ptr(vd, x, y);
pixel_t *irow = (pixel_t *)row;
int j, i;
pixel_t *last_bg = (pixel_t *)last_bg_;
......@@ -25,7 +25,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
int bg_count = 0;
int fg_count = 0;
int flags = 0;
uint8_t data[(vs->clientds.pf.bytes_per_pixel + 2) * 16 * 16];
uint8_t data[(vs->client_pf.bytes_per_pixel + 2) * 16 * 16];
int n_data = 0;
int n_subtiles = 0;
......@@ -58,7 +58,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
}
if (n_colors > 2)
break;
irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
irow += vnc_server_fb_stride(vd) / sizeof(pixel_t);
}
if (n_colors > 1 && fg_count > bg_count) {
......@@ -106,7 +106,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
n_data += 2;
n_subtiles++;
}
irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
irow += vnc_server_fb_stride(vd) / sizeof(pixel_t);
}
break;
case 3:
......@@ -133,7 +133,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
has_color = 0;
#ifdef GENERIC
vnc_convert_pixel(vs, data + n_data, color);
n_data += vs->clientds.pf.bytes_per_pixel;
n_data += vs->client_pf.bytes_per_pixel;
#else
memcpy(data + n_data, &color, sizeof(color));
n_data += sizeof(pixel_t);
......@@ -153,7 +153,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
if (has_color) {
#ifdef GENERIC
vnc_convert_pixel(vs, data + n_data, color);
n_data += vs->clientds.pf.bytes_per_pixel;
n_data += vs->client_pf.bytes_per_pixel;
#else
memcpy(data + n_data, &color, sizeof(color));
n_data += sizeof(pixel_t);
......@@ -162,7 +162,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
n_data += 2;
n_subtiles++;
}
irow += ds_get_linesize(vs->ds) / sizeof(pixel_t);
irow += vnc_server_fb_stride(vd) / sizeof(pixel_t);
}
/* A SubrectsColoured subtile invalidates the foreground color */
......@@ -190,18 +190,17 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,
vnc_write_u8(vs, flags);
if (n_colors < 4) {
if (flags & 0x02)
vs->write_pixels(vs, &vd->server->pf, last_bg, sizeof(pixel_t));
vs->write_pixels(vs, last_bg, sizeof(pixel_t));
if (flags & 0x04)
vs->write_pixels(vs, &vd->server->pf, last_fg, sizeof(pixel_t));
vs->write_pixels(vs, last_fg, sizeof(pixel_t));
if (n_subtiles) {
vnc_write_u8(vs, n_subtiles);
vnc_write(vs, data, n_data);
}
} else {
for (j = 0; j < h; j++) {
vs->write_pixels(vs, &vd->server->pf, row,
w * ds_get_bytes_per_pixel(vs->ds));
row += ds_get_linesize(vs->ds);
vs->write_pixels(vs, row, w * 4);
row += vnc_server_fb_stride(vd);
}
}
}
......
......@@ -68,10 +68,9 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
int i, j;
int has_fg, has_bg;
uint8_t *last_fg, *last_bg;
VncDisplay *vd = vs->vd;
last_fg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
last_bg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
last_fg = (uint8_t *) g_malloc(VNC_SERVER_FB_BYTES);
last_bg = (uint8_t *) g_malloc(VNC_SERVER_FB_BYTES);
has_fg = has_bg = 0;
for (j = y; j < (y + h); j += 16) {
for (i = x; i < (x + w); i += 16) {
......@@ -89,28 +88,28 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
void vnc_hextile_set_pixel_conversion(VncState *vs, int generic)
{
if (!generic) {
switch (vs->ds->surface->pf.bits_per_pixel) {
case 8:
vs->hextile.send_tile = send_hextile_tile_8;
break;
case 16:
vs->hextile.send_tile = send_hextile_tile_16;
break;
case 32:
vs->hextile.send_tile = send_hextile_tile_32;
break;
switch (VNC_SERVER_FB_BITS) {
case 8:
vs->hextile.send_tile = send_hextile_tile_8;
break;
case 16:
vs->hextile.send_tile = send_hextile_tile_16;
break;
case 32:
vs->hextile.send_tile = send_hextile_tile_32;
break;
}
} else {
switch (vs->ds->surface->pf.bits_per_pixel) {
case 8:
vs->hextile.send_tile = send_hextile_tile_generic_8;
break;
case 16:
vs->hextile.send_tile = send_hextile_tile_generic_16;
break;
case 32:
vs->hextile.send_tile = send_hextile_tile_generic_32;
break;
switch (VNC_SERVER_FB_BITS) {
case 8:
vs->hextile.send_tile = send_hextile_tile_generic_8;
break;
case 16:
vs->hextile.send_tile = send_hextile_tile_generic_16;
break;
case 32:
vs->hextile.send_tile = send_hextile_tile_generic_32;
break;
}
}
}
......@@ -124,7 +124,7 @@ static bool tight_can_send_png_rect(VncState *vs, int w, int h)
}
if (ds_get_bytes_per_pixel(vs->ds) == 1 ||
vs->clientds.pf.bytes_per_pixel == 1) {
vs->client_pf.bytes_per_pixel == 1) {
return false;
}
......@@ -153,7 +153,7 @@ tight_detect_smooth_image24(VncState *vs, int w, int h)
* If client is big-endian, color samples begin from the second
* byte (offset 1) of a 32-bit pixel value.
*/
off = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG);
off = vs->client_be;
memset(stats, 0, sizeof (stats));
......@@ -216,16 +216,16 @@ tight_detect_smooth_image24(VncState *vs, int w, int h)
unsigned int errors; \
unsigned char *buf = vs->tight.tight.buffer; \
\
endian = ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) != \
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)); \
endian = 0; /* FIXME: ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) != \
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)); */ \
\
\
max[0] = vs->clientds.pf.rmax; \
max[1] = vs->clientds.pf.gmax; \
max[2] = vs->clientds.pf.bmax; \
shift[0] = vs->clientds.pf.rshift; \
shift[1] = vs->clientds.pf.gshift; \
shift[2] = vs->clientds.pf.bshift; \
max[0] = vs->client_pf.rmax; \
max[1] = vs->client_pf.gmax; \
max[2] = vs->client_pf.bmax; \
shift[0] = vs->client_pf.rshift; \
shift[1] = vs->client_pf.gshift; \
shift[2] = vs->client_pf.bshift; \
\
memset(stats, 0, sizeof(stats)); \
\
......@@ -302,7 +302,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
}
if (ds_get_bytes_per_pixel(vs->ds) == 1 ||
vs->clientds.pf.bytes_per_pixel == 1 ||
vs->client_pf.bytes_per_pixel == 1 ||
w < VNC_TIGHT_DETECT_MIN_WIDTH || h < VNC_TIGHT_DETECT_MIN_HEIGHT) {
return 0;
}
......@@ -317,7 +317,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
}
}
if (vs->clientds.pf.bytes_per_pixel == 4) {
if (vs->client_pf.bytes_per_pixel == 4) {
if (vs->tight.pixel24) {
errors = tight_detect_smooth_image24(vs, w, h);
if (vs->tight.quality != (uint8_t)-1) {
......@@ -430,7 +430,7 @@ static int tight_fill_palette(VncState *vs, int x, int y,
max = 256;
}
switch(vs->clientds.pf.bytes_per_pixel) {
switch (vs->client_pf.bytes_per_pixel) {
case 4:
return tight_fill_palette32(vs, x, y, max, count, bg, fg, palette);
case 2:
......@@ -557,15 +557,15 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int w, int h)
buf32 = (uint32_t *)buf;
memset(vs->tight.gradient.buffer, 0, w * 3 * sizeof(int));
if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {
shift[0] = vs->clientds.pf.rshift;
shift[1] = vs->clientds.pf.gshift;
shift[2] = vs->clientds.pf.bshift;
if (1 /* FIXME: (vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG) */) {
shift[0] = vs->client_pf.rshift;
shift[1] = vs->client_pf.gshift;
shift[2] = vs->client_pf.bshift;
} else {
shift[0] = 24 - vs->clientds.pf.rshift;
shift[1] = 24 - vs->clientds.pf.gshift;
shift[2] = 24 - vs->clientds.pf.bshift;
shift[0] = 24 - vs->client_pf.rshift;
shift[1] = 24 - vs->client_pf.gshift;
shift[2] = 24 - vs->client_pf.bshift;
}
for (y = 0; y < h; y++) {
......@@ -615,15 +615,15 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int w, int h)
\
memset (vs->tight.gradient.buffer, 0, w * 3 * sizeof(int)); \
\
endian = ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) != \
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)); \
endian = 0; /* FIXME: ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) != \
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)); */ \
\
max[0] = vs->clientds.pf.rmax; \
max[1] = vs->clientds.pf.gmax; \
max[2] = vs->clientds.pf.bmax; \
shift[0] = vs->clientds.pf.rshift; \
shift[1] = vs->clientds.pf.gshift; \
shift[2] = vs->clientds.pf.bshift; \
max[0] = vs->client_pf.rmax; \
max[1] = vs->client_pf.gmax; \
max[2] = vs->client_pf.bmax; \
shift[0] = vs->client_pf.rshift; \
shift[1] = vs->client_pf.gshift; \
shift[2] = vs->client_pf.bshift; \
\
for (y = 0; y < h; y++) { \
for (c = 0; c < 3; c++) { \
......@@ -682,9 +682,7 @@ DEFINE_GRADIENT_FILTER_FUNCTION(32)
uint##bpp##_t c; \
int dx, dy; \
\
fbptr = (uint##bpp##_t *) \
(vd->server->data + y * ds_get_linesize(vs->ds) + \
x * ds_get_bytes_per_pixel(vs->ds)); \
fbptr = vnc_server_fb_ptr(vd, x, y); \
\
c = *fbptr; \
if (samecolor && (uint32_t)c != *color) { \
......@@ -698,7 +696,7 @@ DEFINE_GRADIENT_FILTER_FUNCTION(32)
} \
} \
fbptr = (uint##bpp##_t *) \
((uint8_t *)fbptr + ds_get_linesize(vs->ds)); \
((uint8_t *)fbptr + vnc_server_fb_stride(vd)); \
} \
\
*color = (uint32_t)c; \
......@@ -712,9 +710,7 @@ DEFINE_CHECK_SOLID_FUNCTION(8)
static bool check_solid_tile(VncState *vs, int x, int y, int w, int h,
uint32_t* color, bool samecolor)
{
VncDisplay *vd = vs->vd;
switch(vd->server->pf.bytes_per_pixel) {
switch (VNC_SERVER_FB_BYTES) {
case 4:
return check_solid_tile32(vs, x, y, w, h, color, samecolor);
case 2:
......@@ -906,15 +902,15 @@ static void tight_pack24(VncState *vs, uint8_t *buf, size_t count, size_t *ret)
buf32 = (uint32_t *)buf;
if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {
rshift = vs->clientds.pf.rshift;
gshift = vs->clientds.pf.gshift;
bshift = vs->clientds.pf.bshift;
if (1 /* FIXME: (vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
(vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG) */) {
rshift = vs->client_pf.rshift;
gshift = vs->client_pf.gshift;
bshift = vs->client_pf.bshift;
} else {
rshift = 24 - vs->clientds.pf.rshift;
gshift = 24 - vs->clientds.pf.gshift;
bshift = 24 - vs->clientds.pf.bshift;
rshift = 24 - vs->client_pf.rshift;
gshift = 24 - vs->client_pf.gshift;
bshift = 24 - vs->client_pf.bshift;
}
if (ret) {
......@@ -946,7 +942,7 @@ static int send_full_color_rect(VncState *vs, int x, int y, int w, int h)
tight_pack24(vs, vs->tight.tight.buffer, w * h, &vs->tight.tight.offset);
bytes = 3;
} else {
bytes = vs->clientds.pf.bytes_per_pixel;
bytes = vs->client_pf.bytes_per_pixel;
}
bytes = tight_compress_data(vs, stream, w * h * bytes,
......@@ -966,7 +962,7 @@ static int send_solid_rect(VncState *vs)
tight_pack24(vs, vs->tight.tight.buffer, 1, &vs->tight.tight.offset);
bytes = 3;
} else {
bytes = vs->clientds.pf.bytes_per_pixel;
bytes = vs->client_pf.bytes_per_pixel;
}
vnc_write(vs, vs->tight.tight.buffer, bytes);
......@@ -983,7 +979,7 @@ static int send_mono_rect(VncState *vs, int x, int y,
#ifdef CONFIG_VNC_PNG
if (tight_can_send_png_rect(vs, w, h)) {
int ret;
int bpp = vs->clientds.pf.bytes_per_pixel * 8;
int bpp = vs->client_pf.bytes_per_pixel * 8;
VncPalette *palette = palette_new(2, bpp);
palette_put(palette, bg);
......@@ -1000,7 +996,7 @@ static int send_mono_rect(VncState *vs, int x, int y,
vnc_write_u8(vs, VNC_TIGHT_FILTER_PALETTE);
vnc_write_u8(vs, 1);
switch(vs->clientds.pf.bytes_per_pixel) {
switch (vs->client_pf.bytes_per_pixel) {
case 4:
{
uint32_t buf[2] = {bg, fg};
......@@ -1043,7 +1039,7 @@ static void write_palette(int idx, uint32_t color, void *opaque)
{
struct palette_cb_priv *priv = opaque;
VncState *vs = priv->vs;
uint32_t bytes = vs->clientds.pf.bytes_per_pixel;
uint32_t bytes = vs->client_pf.bytes_per_pixel;
if (bytes == 4) {
((uint32_t*)priv->header)[idx] = color;
......@@ -1058,8 +1054,9 @@ static bool send_gradient_rect(VncState *vs, int x, int y, int w, int h)
int level = tight_conf[vs->tight.compression].gradient_zlib_level;
ssize_t bytes;
if (vs->clientds.pf.bytes_per_pixel == 1)
if (vs->client_pf.bytes_per_pixel == 1) {
return send_full_color_rect(vs, x, y, w, h);
}
vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);
......@@ -1069,7 +1066,7 @@ static bool send_gradient_rect(VncState *vs, int x, int y, int w, int h)
if (vs->tight.pixel24) {
tight_filter_gradient24(vs, vs->tight.tight.buffer, w, h);
bytes = 3;
} else if (vs->clientds.pf.bytes_per_pixel == 4) {
} else if (vs->client_pf.bytes_per_pixel == 4) {
tight_filter_gradient32(vs, (uint32_t *)vs->tight.tight.buffer, w, h);
bytes = 4;
} else {
......@@ -1107,7 +1104,7 @@ static int send_palette_rect(VncState *vs, int x, int y,
vnc_write_u8(vs, VNC_TIGHT_FILTER_PALETTE);
vnc_write_u8(vs, colors - 1);
switch(vs->clientds.pf.bytes_per_pixel) {
switch (vs->client_pf.bytes_per_pixel) {
case 4:
{
size_t old_offset, offset;
......@@ -1156,8 +1153,7 @@ static void rgb_prepare_row24(VncState *vs, uint8_t *dst, int x, int y,
uint32_t *fbptr;
uint32_t pix;
fbptr = (uint32_t *)(vd->server->data + y * ds_get_linesize(vs->ds) +
x * ds_get_bytes_per_pixel(vs->ds));
fbptr = vnc_server_fb_ptr(vd, x, y);
while (count--) {
pix = *fbptr++;
......@@ -1178,9 +1174,7 @@ static void rgb_prepare_row24(VncState *vs, uint8_t *dst, int x, int y,
uint##bpp##_t pix; \
int r, g, b; \
\
fbptr = (uint##bpp##_t *) \
(vd->server->data + y * ds_get_linesize(vs->ds) + \
x * ds_get_bytes_per_pixel(vs->ds)); \
fbptr = vnc_server_fb_ptr(vd, x, y); \
\
while (count--) { \
pix = *fbptr++; \
......@@ -1207,10 +1201,8 @@ DEFINE_RGB_GET_ROW_FUNCTION(32)
static void rgb_prepare_row(VncState *vs, uint8_t *dst, int x, int y,
int count)
{
if (ds_get_bytes_per_pixel(vs->ds) == 4) {
if (vs->ds->surface->pf.rmax == 0xFF &&
vs->ds->surface->pf.gmax == 0xFF &&
vs->ds->surface->pf.bmax == 0xFF) {
if (VNC_SERVER_FB_BYTES == 4) {
if (1) {
rgb_prepare_row24(vs, dst, x, y, count);
} else {
rgb_prepare_row32(vs, dst, x, y, count);
......@@ -1326,23 +1318,23 @@ static void write_png_palette(int idx, uint32_t pix, void *opaque)
if (vs->tight.pixel24)
{
color->red = (pix >> vs->clientds.pf.rshift) & vs->clientds.pf.rmax;
color->green = (pix >> vs->clientds.pf.gshift) & vs->clientds.pf.gmax;
color->blue = (pix >> vs->clientds.pf.bshift) & vs->clientds.pf.bmax;
color->red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax;
color->green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax;
color->blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax;
}
else
{
int red, green, blue;
red = (pix >> vs->clientds.pf.rshift) & vs->clientds.pf.rmax;
green = (pix >> vs->clientds.pf.gshift) & vs->clientds.pf.gmax;
blue = (pix >> vs->clientds.pf.bshift) & vs->clientds.pf.bmax;
color->red = ((red * 255 + vs->clientds.pf.rmax / 2) /
vs->clientds.pf.rmax);
color->green = ((green * 255 + vs->clientds.pf.gmax / 2) /
vs->clientds.pf.gmax);
color->blue = ((blue * 255 + vs->clientds.pf.bmax / 2) /
vs->clientds.pf.bmax);
red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax;
green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax;
blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax;
color->red = ((red * 255 + vs->client_pf.rmax / 2) /
vs->client_pf.rmax);
color->green = ((green * 255 + vs->client_pf.gmax / 2) /
vs->client_pf.gmax);
color->blue = ((blue * 255 + vs->client_pf.bmax / 2) /
vs->client_pf.bmax);
}
}
......@@ -1422,7 +1414,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,
png_set_PLTE(png_ptr, info_ptr, png_palette, palette_size(palette));
if (vs->clientds.pf.bytes_per_pixel == 4) {
if (vs->client_pf.bytes_per_pixel == 4) {
tight_encode_indexed_rect32(vs->tight.tight.buffer, w * h, palette);
} else {
tight_encode_indexed_rect16(vs->tight.tight.buffer, w * h, palette);
......@@ -1713,8 +1705,8 @@ static int tight_send_framebuffer_update(VncState *vs, int x, int y,
{
int max_rows;
if (vs->clientds.pf.bytes_per_pixel == 4 && vs->clientds.pf.rmax == 0xFF &&
vs->clientds.pf.bmax == 0xFF && vs->clientds.pf.gmax == 0xFF) {
if (vs->client_pf.bytes_per_pixel == 4 && vs->client_pf.rmax == 0xFF &&
vs->client_pf.bmax == 0xFF && vs->client_pf.gmax == 0xFF) {
vs->tight.pixel24 = true;
} else {
vs->tight.pixel24 = false;
......
......@@ -255,7 +255,7 @@ static void zrle_write_u8(VncState *vs, uint8_t value)
static int zrle_send_framebuffer_update(VncState *vs, int x, int y,
int w, int h)
{
bool be = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG);
bool be = vs->client_be;
size_t bytes;
int zywrle_level;
......@@ -277,13 +277,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,
vnc_zrle_start(vs);
switch(vs->clientds.pf.bytes_per_pixel) {
switch (vs->client_pf.bytes_per_pixel) {
case 1:
zrle_encode_8ne(vs, x, y, w, h, zywrle_level);
break;
case 2:
if (vs->clientds.pf.gmax > 0x1F) {
if (vs->client_pf.gmax > 0x1F) {
if (be) {
zrle_encode_16be(vs, x, y, w, h, zywrle_level);
} else {
......@@ -304,13 +304,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,
bool fits_in_ms3bytes;
fits_in_ls3bytes =
((vs->clientds.pf.rmax << vs->clientds.pf.rshift) < (1 << 24) &&
(vs->clientds.pf.gmax << vs->clientds.pf.gshift) < (1 << 24) &&
(vs->clientds.pf.bmax << vs->clientds.pf.bshift) < (1 << 24));
((vs->client_pf.rmax << vs->client_pf.rshift) < (1 << 24) &&
(vs->client_pf.gmax << vs->client_pf.gshift) < (1 << 24) &&
(vs->client_pf.bmax << vs->client_pf.bshift) < (1 << 24));
fits_in_ms3bytes = (vs->clientds.pf.rshift > 7 &&
vs->clientds.pf.gshift > 7 &&
vs->clientds.pf.bshift > 7);
fits_in_ms3bytes = (vs->client_pf.rshift > 7 &&
vs->client_pf.gshift > 7 &&
vs->client_pf.bshift > 7);
if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) {
if (be) {
......
......@@ -187,7 +187,8 @@ static void vnc_async_encoding_start(VncState *orig, VncState *local)
local->vd = orig->vd;
local->lossy_rect = orig->lossy_rect;
local->write_pixels = orig->write_pixels;
local->clientds = orig->clientds;
local->client_pf = orig->client_pf;
local->client_be = orig->client_be;
local->tight = orig->tight;
local->zlib = orig->zlib;
local->hextile = orig->hextile;
......
......@@ -436,6 +436,8 @@ static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
int i;
VncDisplay *vd = ds->opaque;
struct VncSurface *s = &vd->guest;
int width = ds_get_width(ds);
int height = ds_get_height(ds);
h += y;
......@@ -446,10 +448,10 @@ static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
w += (x % 16);
x -= (x % 16);
x = MIN(x, s->ds->width);
y = MIN(y, s->ds->height);
w = MIN(x + w, s->ds->width) - x;
h = MIN(h, s->ds->height);
x = MIN(x, width);
y = MIN(y, height);
w = MIN(x + w, width) - x;
h = MIN(h, height);
for (; y < h; y++)
for (i = 0; i < w; i += 16)
......@@ -550,6 +552,21 @@ static void vnc_abort_display_jobs(VncDisplay *vd)
}
}
int vnc_server_fb_stride(VncDisplay *vd)
{
return pixman_image_get_stride(vd->server);
}
void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
{
uint8_t *ptr;
ptr = (uint8_t *)pixman_image_get_data(vd->server);
ptr += y * vnc_server_fb_stride(vd);
ptr += x * VNC_SERVER_FB_BYTES;
return ptr;
}
static void vnc_dpy_resize(DisplayState *ds)
{
VncDisplay *vd = ds->opaque;
......@@ -558,20 +575,20 @@ static void vnc_dpy_resize(DisplayState *ds)
vnc_abort_display_jobs(vd);
/* server surface */
if (!vd->server)
vd->server = g_malloc0(sizeof(*vd->server));
if (vd->server->data)
g_free(vd->server->data);
*(vd->server) = *(ds->surface);
vd->server->data = g_malloc0(vd->server->linesize *
vd->server->height);
qemu_pixman_image_unref(vd->server);
vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
ds_get_width(ds),
ds_get_height(ds),
NULL, 0);
/* guest surface */
if (!vd->guest.ds)
vd->guest.ds = g_malloc0(sizeof(*vd->guest.ds));
#if 0 /* FIXME */
if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)
console_color_init(ds);
*(vd->guest.ds) = *(ds->surface);
#endif
qemu_pixman_image_unref(vd->guest.fb);
vd->guest.fb = pixman_image_ref(ds->surface->image);
vd->guest.format = ds->surface->format;
memset(vd->guest.dirty, 0xFF, sizeof(vd->guest.dirty));
QTAILQ_FOREACH(vs, &vd->clients, next) {
......@@ -585,7 +602,7 @@ static void vnc_dpy_resize(DisplayState *ds)
}
/* fastest code */