spice: switch to pixman

Switch over spice-display.c to use the pixman library
instead of the home-grown pflib bits.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2012-11-02 09:12:49 +01:00
parent e32c25b5f2
commit d9a86569ca
5 changed files with 45 additions and 33 deletions

View File

@ -377,6 +377,11 @@ static inline pixman_format_code_t ds_get_format(DisplayState *ds)
return ds->surface->format; return ds->surface->format;
} }
static inline pixman_image_t *ds_get_image(DisplayState *ds)
{
return ds->surface->image;
}
static inline int ds_get_depth(DisplayState *ds) static inline int ds_get_depth(DisplayState *ds)
{ {
return ds->surface->pf.depth; return ds->surface->pf.depth;

View File

@ -51,6 +51,19 @@ void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
0, y, 0, 0, 0, 0, width, 1); 0, y, 0, 0, 0, 0, width, 1);
} }
pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
pixman_image_t *image)
{
pixman_image_t *mirror;
mirror = pixman_image_create_bits(format,
pixman_image_get_width(image),
pixman_image_get_height(image),
NULL,
pixman_image_get_stride(image));
return mirror;
}
void qemu_pixman_image_unref(pixman_image_t *image) void qemu_pixman_image_unref(pixman_image_t *image)
{ {
if (image == NULL) { if (image == NULL) {

View File

@ -27,6 +27,8 @@ pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
int width); int width);
void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb, void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
int width, int y); int width, int y);
pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
pixman_image_t *image);
void qemu_pixman_image_unref(pixman_image_t *image); void qemu_pixman_image_unref(pixman_image_t *image);
#endif /* QEMU_PIXMAN_H */ #endif /* QEMU_PIXMAN_H */

View File

@ -150,9 +150,9 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
QXLDrawable *drawable; QXLDrawable *drawable;
QXLImage *image; QXLImage *image;
QXLCommand *cmd; QXLCommand *cmd;
uint8_t *src, *mirror, *dst; int bw, bh;
int by, bw, bh, offset, bytes;
struct timespec time_space; struct timespec time_space;
pixman_image_t *dest;
trace_qemu_spice_create_update( trace_qemu_spice_create_update(
rect->left, rect->right, rect->left, rect->right,
@ -195,20 +195,15 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
image->bitmap.palette = 0; image->bitmap.palette = 0;
image->bitmap.format = SPICE_BITMAP_FMT_32BIT; image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
offset = dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
rect->top * ds_get_linesize(ssd->ds) + (void *)update->bitmap, bw * 4);
rect->left * ds_get_bytes_per_pixel(ssd->ds); pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror,
bytes = ds_get_bytes_per_pixel(ssd->ds) * bw; rect->left, rect->top, 0, 0,
src = ds_get_data(ssd->ds) + offset; rect->left, rect->top, bw, bh);
mirror = ssd->ds_mirror + offset; pixman_image_composite(PIXMAN_OP_SRC, ssd->mirror, NULL, dest,
dst = update->bitmap; rect->left, rect->top, 0, 0,
for (by = 0; by < bh; by++) { 0, 0, bw, bh);
memcpy(mirror, src, bytes); pixman_image_unref(dest);
qemu_pf_conv_run(ssd->conv, dst, mirror, bw);
src += ds_get_linesize(ssd->ds);
mirror += ds_get_linesize(ssd->ds);
dst += image->bitmap.stride;
}
cmd->type = QXL_CMD_DRAW; cmd->type = QXL_CMD_DRAW;
cmd->data = (uintptr_t)drawable; cmd->data = (uintptr_t)drawable;
@ -229,14 +224,10 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
return; return;
}; };
if (ssd->conv == NULL) { if (ssd->surface == NULL) {
PixelFormat dst = qemu_default_pixelformat(32); ssd->surface = pixman_image_ref(ds_get_image(ssd->ds));
ssd->conv = qemu_pf_conv_get(&dst, &ssd->ds->surface->pf); ssd->mirror = qemu_pixman_mirror_create(ds_get_format(ssd->ds),
assert(ssd->conv); ds_get_image(ssd->ds));
}
if (ssd->ds_mirror == NULL) {
int size = ds_get_height(ssd->ds) * ds_get_linesize(ssd->ds);
ssd->ds_mirror = g_malloc0(size);
} }
for (blk = 0; blk < blocks; blk++) { for (blk = 0; blk < blocks; blk++) {
@ -244,7 +235,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
} }
guest = ds_get_data(ssd->ds); guest = ds_get_data(ssd->ds);
mirror = ssd->ds_mirror; mirror = (void *)pixman_image_get_data(ssd->mirror);
for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) { for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) {
yoff = y * ds_get_linesize(ssd->ds); yoff = y * ds_get_linesize(ssd->ds);
for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) {
@ -383,10 +374,12 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
dprint(1, "%s:\n", __FUNCTION__); dprint(1, "%s:\n", __FUNCTION__);
memset(&ssd->dirty, 0, sizeof(ssd->dirty)); memset(&ssd->dirty, 0, sizeof(ssd->dirty));
qemu_pf_conv_put(ssd->conv); if (ssd->surface) {
ssd->conv = NULL; pixman_image_unref(ssd->surface);
g_free(ssd->ds_mirror); ssd->surface = NULL;
ssd->ds_mirror = NULL; pixman_image_unref(ssd->mirror);
ssd->mirror = NULL;
}
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) { while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {

View File

@ -20,8 +20,7 @@
#include <spice/qxl_dev.h> #include <spice/qxl_dev.h>
#include "qemu-thread.h" #include "qemu-thread.h"
#include "console.h" #include "qemu-pixman.h"
#include "pflib.h"
#include "sysemu.h" #include "sysemu.h"
#define NUM_MEMSLOTS 8 #define NUM_MEMSLOTS 8
@ -72,13 +71,13 @@ typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
struct SimpleSpiceDisplay { struct SimpleSpiceDisplay {
DisplayState *ds; DisplayState *ds;
uint8_t *ds_mirror;
void *buf; void *buf;
int bufsize; int bufsize;
QXLWorker *worker; QXLWorker *worker;
QXLInstance qxl; QXLInstance qxl;
uint32_t unique; uint32_t unique;
QemuPfConv *conv; pixman_image_t *surface;
pixman_image_t *mirror;
int32_t num_surfaces; int32_t num_surfaces;
QXLRect dirty; QXLRect dirty;