mirror of https://github.com/xemu-project/xemu.git
qxl: remove flipped
Tested on linux and windows guests. For negative stride, qxl_flip copies directly to vga->ds->surface->data, for positive it's reallocated to share qxl->guest_primary.data Signed-off-by: Alon Levy <alevy@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
4295e15aa7
commit
4c19ebb51d
|
@ -23,10 +23,21 @@
|
||||||
|
|
||||||
static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
|
static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
|
||||||
{
|
{
|
||||||
uint8_t *src = qxl->guest_primary.data;
|
uint8_t *src;
|
||||||
uint8_t *dst = qxl->guest_primary.flipped;
|
uint8_t *dst = qxl->vga.ds->surface->data;
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
|
if (qxl->guest_primary.qxl_stride > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!qxl->guest_primary.data) {
|
||||||
|
dprint(qxl, 1, "%s: initializing guest_primary.data\n", __func__);
|
||||||
|
qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
|
||||||
|
}
|
||||||
|
dprint(qxl, 1, "%s: stride %d, [%d, %d, %d, %d]\n", __func__,
|
||||||
|
qxl->guest_primary.qxl_stride,
|
||||||
|
rect->left, rect->right, rect->top, rect->bottom);
|
||||||
|
src = qxl->guest_primary.data;
|
||||||
src += (qxl->guest_primary.surface.height - rect->top - 1) *
|
src += (qxl->guest_primary.surface.height - rect->top - 1) *
|
||||||
qxl->guest_primary.abs_stride;
|
qxl->guest_primary.abs_stride;
|
||||||
dst += rect->top * qxl->guest_primary.abs_stride;
|
dst += rect->top * qxl->guest_primary.abs_stride;
|
||||||
|
@ -75,52 +86,38 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
||||||
{
|
{
|
||||||
VGACommonState *vga = &qxl->vga;
|
VGACommonState *vga = &qxl->vga;
|
||||||
QXLRect dirty[32], update;
|
QXLRect dirty[32], update;
|
||||||
void *ptr;
|
|
||||||
int i, redraw = 0;
|
int i, redraw = 0;
|
||||||
|
DisplaySurface *surface = vga->ds->surface;
|
||||||
if (!is_buffer_shared(vga->ds->surface)) {
|
|
||||||
dprint(qxl, 1, "%s: restoring shared displaysurface\n", __func__);
|
|
||||||
qxl->guest_primary.resized++;
|
|
||||||
qxl->guest_primary.commands++;
|
|
||||||
redraw = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qxl->guest_primary.resized) {
|
if (qxl->guest_primary.resized) {
|
||||||
qxl->guest_primary.resized = 0;
|
qxl->guest_primary.resized = 0;
|
||||||
|
|
||||||
if (qxl->guest_primary.flipped) {
|
|
||||||
g_free(qxl->guest_primary.flipped);
|
|
||||||
qxl->guest_primary.flipped = NULL;
|
|
||||||
}
|
|
||||||
qemu_free_displaysurface(vga->ds);
|
|
||||||
|
|
||||||
qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
|
qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
|
||||||
if (qxl->guest_primary.qxl_stride < 0) {
|
dprint(qxl, 1, "%s: %dx%d, stride %d, bpp %d, depth %d\n",
|
||||||
/* spice surface is upside down -> need extra buffer to flip */
|
|
||||||
qxl->guest_primary.flipped =
|
|
||||||
g_malloc(qxl->guest_primary.surface.width *
|
|
||||||
qxl->guest_primary.abs_stride);
|
|
||||||
ptr = qxl->guest_primary.flipped;
|
|
||||||
} else {
|
|
||||||
ptr = qxl->guest_primary.data;
|
|
||||||
}
|
|
||||||
dprint(qxl, 1, "%s: %dx%d, stride %d, bpp %d, depth %d, flip %s\n",
|
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
qxl->guest_primary.surface.width,
|
qxl->guest_primary.surface.width,
|
||||||
qxl->guest_primary.surface.height,
|
qxl->guest_primary.surface.height,
|
||||||
qxl->guest_primary.qxl_stride,
|
qxl->guest_primary.qxl_stride,
|
||||||
qxl->guest_primary.bytes_pp,
|
qxl->guest_primary.bytes_pp,
|
||||||
qxl->guest_primary.bits_pp,
|
qxl->guest_primary.bits_pp);
|
||||||
qxl->guest_primary.flipped ? "yes" : "no");
|
}
|
||||||
vga->ds->surface =
|
if (surface->width != qxl->guest_primary.surface.width ||
|
||||||
|
surface->height != qxl->guest_primary.surface.height) {
|
||||||
|
dprint(qxl, 1, "%s: resizing displaysurface to guest_primary\n",
|
||||||
|
__func__);
|
||||||
|
if (qxl->guest_primary.qxl_stride > 0) {
|
||||||
|
qemu_free_displaysurface(vga->ds);
|
||||||
qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
|
qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
|
||||||
qxl->guest_primary.surface.height,
|
qxl->guest_primary.surface.height,
|
||||||
qxl->guest_primary.bits_pp,
|
qxl->guest_primary.bits_pp,
|
||||||
qxl->guest_primary.abs_stride,
|
qxl->guest_primary.abs_stride,
|
||||||
ptr);
|
qxl->guest_primary.data);
|
||||||
dpy_resize(vga->ds);
|
} else {
|
||||||
|
qemu_resize_displaysurface(vga->ds,
|
||||||
|
qxl->guest_primary.surface.width,
|
||||||
|
qxl->guest_primary.surface.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update.left = 0;
|
update.left = 0;
|
||||||
update.right = qxl->guest_primary.surface.width;
|
update.right = qxl->guest_primary.surface.width;
|
||||||
update.top = 0;
|
update.top = 0;
|
||||||
|
@ -136,14 +133,11 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
||||||
memset(dirty, 0, sizeof(dirty));
|
memset(dirty, 0, sizeof(dirty));
|
||||||
dirty[0] = update;
|
dirty[0] = update;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(dirty); i++) {
|
for (i = 0; i < ARRAY_SIZE(dirty); i++) {
|
||||||
if (qemu_spice_rect_is_empty(dirty+i)) {
|
if (qemu_spice_rect_is_empty(dirty+i)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (qxl->guest_primary.flipped) {
|
qxl_flip(qxl, dirty+i);
|
||||||
qxl_flip(qxl, dirty+i);
|
|
||||||
}
|
|
||||||
dpy_update(vga->ds,
|
dpy_update(vga->ds,
|
||||||
dirty[i].left, dirty[i].top,
|
dirty[i].left, dirty[i].top,
|
||||||
dirty[i].right - dirty[i].left,
|
dirty[i].right - dirty[i].left,
|
||||||
|
|
Loading…
Reference in New Issue