mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 19:33:39 +08:00
qxl: stride fixup
spice uses negative stride value to signal the bitmap is upside down. The qxl renderer (used for scl, vnc and screenshots) wants a positive value because it is easier to work with. The positive value is then stored in the very same variable, which has the drawback that the upside-down test works only once. Fix by using two variables. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
ff74c5a9a9
commit
0e2487bd6f
@ -28,16 +28,16 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
|
|||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
src += (qxl->guest_primary.surface.height - rect->top - 1) *
|
src += (qxl->guest_primary.surface.height - rect->top - 1) *
|
||||||
qxl->guest_primary.stride;
|
qxl->guest_primary.abs_stride;
|
||||||
dst += rect->top * qxl->guest_primary.stride;
|
dst += rect->top * qxl->guest_primary.abs_stride;
|
||||||
src += rect->left * qxl->guest_primary.bytes_pp;
|
src += rect->left * qxl->guest_primary.bytes_pp;
|
||||||
dst += rect->left * qxl->guest_primary.bytes_pp;
|
dst += rect->left * qxl->guest_primary.bytes_pp;
|
||||||
len = (rect->right - rect->left) * qxl->guest_primary.bytes_pp;
|
len = (rect->right - rect->left) * qxl->guest_primary.bytes_pp;
|
||||||
|
|
||||||
for (i = rect->top; i < rect->bottom; i++) {
|
for (i = rect->top; i < rect->bottom; i++) {
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
dst += qxl->guest_primary.stride;
|
dst += qxl->guest_primary.abs_stride;
|
||||||
src -= qxl->guest_primary.stride;
|
src -= qxl->guest_primary.abs_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,8 @@ void qxl_render_resize(PCIQXLDevice *qxl)
|
|||||||
{
|
{
|
||||||
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
|
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
|
||||||
|
|
||||||
qxl->guest_primary.stride = sc->stride;
|
qxl->guest_primary.qxl_stride = sc->stride;
|
||||||
|
qxl->guest_primary.abs_stride = abs(sc->stride);
|
||||||
qxl->guest_primary.resized++;
|
qxl->guest_primary.resized++;
|
||||||
switch (sc->format) {
|
switch (sc->format) {
|
||||||
case SPICE_SURFACE_FMT_16_555:
|
case SPICE_SURFACE_FMT_16_555:
|
||||||
@ -87,11 +88,11 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
|||||||
qemu_free_displaysurface(vga->ds);
|
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.stride < 0) {
|
if (qxl->guest_primary.qxl_stride < 0) {
|
||||||
/* spice surface is upside down -> need extra buffer to flip */
|
/* spice surface is upside down -> need extra buffer to flip */
|
||||||
qxl->guest_primary.stride = -qxl->guest_primary.stride;
|
qxl->guest_primary.flipped =
|
||||||
qxl->guest_primary.flipped = g_malloc(qxl->guest_primary.surface.width *
|
g_malloc(qxl->guest_primary.surface.width *
|
||||||
qxl->guest_primary.stride);
|
qxl->guest_primary.abs_stride);
|
||||||
ptr = qxl->guest_primary.flipped;
|
ptr = qxl->guest_primary.flipped;
|
||||||
} else {
|
} else {
|
||||||
ptr = qxl->guest_primary.data;
|
ptr = qxl->guest_primary.data;
|
||||||
@ -100,7 +101,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
|||||||
__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.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");
|
qxl->guest_primary.flipped ? "yes" : "no");
|
||||||
@ -108,7 +109,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
|||||||
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.stride,
|
qxl->guest_primary.abs_stride,
|
||||||
ptr);
|
ptr);
|
||||||
dpy_resize(vga->ds);
|
dpy_resize(vga->ds);
|
||||||
}
|
}
|
||||||
|
3
hw/qxl.h
3
hw/qxl.h
@ -48,7 +48,8 @@ typedef struct PCIQXLDevice {
|
|||||||
QXLSurfaceCreate surface;
|
QXLSurfaceCreate surface;
|
||||||
uint32_t commands;
|
uint32_t commands;
|
||||||
uint32_t resized;
|
uint32_t resized;
|
||||||
int32_t stride;
|
int32_t qxl_stride;
|
||||||
|
uint32_t abs_stride;
|
||||||
uint32_t bits_pp;
|
uint32_t bits_pp;
|
||||||
uint32_t bytes_pp;
|
uint32_t bytes_pp;
|
||||||
uint8_t *data, *flipped;
|
uint8_t *data, *flipped;
|
||||||
|
Loading…
Reference in New Issue
Block a user