* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "qxl.h"
#include "trace.h"
qxl->guest_primary.bits_pp = 32;
break;
default:
- fprintf(stderr, "%s: unhandled format: %x\n", __FUNCTION__,
+ fprintf(stderr, "%s: unhandled format: %x\n", __func__,
qxl->guest_primary.surface.format);
qxl->guest_primary.bytes_pp = 4;
qxl->guest_primary.bits_pp = 32;
{
VGACommonState *vga = &qxl->vga;
DisplaySurface *surface;
+ int width = qxl->guest_head0_width ?: qxl->guest_primary.surface.width;
+ int height = qxl->guest_head0_height ?: qxl->guest_primary.surface.height;
int i;
if (qxl->guest_primary.resized) {
qxl_set_rect_to_surface(qxl, &qxl->dirty[0]);
qxl->num_dirty_rects = 1;
trace_qxl_render_guest_primary_resized(
- qxl->guest_primary.surface.width,
- qxl->guest_primary.surface.height,
+ width,
+ height,
qxl->guest_primary.qxl_stride,
qxl->guest_primary.bytes_pp,
qxl->guest_primary.bits_pp);
if (qxl->guest_primary.qxl_stride > 0) {
+ pixman_format_code_t format =
+ qemu_default_pixman_format(qxl->guest_primary.bits_pp, true);
surface = qemu_create_displaysurface_from
- (qxl->guest_primary.surface.width,
- qxl->guest_primary.surface.height,
- qxl->guest_primary.bits_pp,
+ (width,
+ height,
+ format,
qxl->guest_primary.abs_stride,
- qxl->guest_primary.data,
- false);
+ qxl->guest_primary.data);
} else {
surface = qemu_create_displaysurface
- (qxl->guest_primary.surface.width,
- qxl->guest_primary.surface.height);
+ (width,
+ height);
}
dpy_gfx_replace_surface(vga->con, surface);
}
if (qemu_spice_rect_is_empty(qxl->dirty+i)) {
break;
}
+ if (qxl->dirty[i].left < 0 ||
+ qxl->dirty[i].top < 0 ||
+ qxl->dirty[i].left > qxl->dirty[i].right ||
+ qxl->dirty[i].top > qxl->dirty[i].bottom ||
+ qxl->dirty[i].right > width ||
+ qxl->dirty[i].bottom > height) {
+ continue;
+ }
qxl_blit(qxl, qxl->dirty+i);
dpy_gfx_update(vga->con,
qxl->dirty[i].left, qxl->dirty[i].top,
/*
* use ssd.lock to protect render_update_cookie_num.
* qxl_render_update is called by io thread or vcpu thread, and the completion
- * callbacks are called by spice_server thread, defering to bh called from the
+ * callbacks are called by spice_server thread, deferring to bh called from the
* io thread.
*/
void qxl_render_update(PCIQXLDevice *qxl)
qemu_mutex_lock(&qxl->ssd.lock);
- if (!runstate_is_running() || !qxl->guest_primary.commands) {
+ if (!runstate_is_running() || !qxl->guest_primary.commands ||
+ qxl->mode == QXL_MODE_UNDEFINED) {
qxl_render_update_area_unlocked(qxl);
qemu_mutex_unlock(&qxl->ssd.lock);
return;
g_free(cookie);
}
-static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor)
+static void qxl_unpack_chunks(void *dest, size_t size, PCIQXLDevice *qxl,
+ QXLDataChunk *chunk, uint32_t group_id)
+{
+ uint32_t max_chunks = 32;
+ size_t offset = 0;
+ size_t bytes;
+
+ for (;;) {
+ bytes = MIN(size - offset, chunk->data_size);
+ memcpy(dest + offset, chunk->data, bytes);
+ offset += bytes;
+ if (offset == size) {
+ return;
+ }
+ chunk = qxl_phys2virt(qxl, chunk->next_chunk, group_id);
+ if (!chunk) {
+ return;
+ }
+ max_chunks--;
+ if (max_chunks == 0) {
+ return;
+ }
+ }
+}
+
+static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
+ uint32_t group_id)
{
QEMUCursor *c;
- uint8_t *image, *mask;
+ uint8_t *and_mask, *xor_mask;
size_t size;
c = cursor_alloc(cursor->header.width, cursor->header.height);
c->hot_x = cursor->header.hot_spot_x;
c->hot_y = cursor->header.hot_spot_y;
switch (cursor->header.type) {
- case SPICE_CURSOR_TYPE_ALPHA:
- size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
- memcpy(c->data, cursor->chunk.data, size);
+ case SPICE_CURSOR_TYPE_MONO:
+ /* Assume that the full cursor is available in a single chunk. */
+ size = 2 * cursor_get_mono_bpl(c) * c->height;
+ if (size != cursor->data_size) {
+ fprintf(stderr, "%s: bad monochrome cursor %ux%u with size %u\n",
+ __func__, c->width, c->height, cursor->data_size);
+ goto fail;
+ }
+ and_mask = cursor->chunk.data;
+ xor_mask = and_mask + cursor_get_mono_bpl(c) * c->height;
+ cursor_set_mono(c, 0xffffff, 0x000000, xor_mask, 1, and_mask);
if (qxl->debug > 2) {
- cursor_print_ascii_art(c, "qxl/alpha");
+ cursor_print_ascii_art(c, "qxl/mono");
}
break;
- case SPICE_CURSOR_TYPE_MONO:
- mask = cursor->chunk.data;
- image = mask + cursor_get_mono_bpl(c) * c->width;
- cursor_set_mono(c, 0xffffff, 0x000000, image, 1, mask);
+ case SPICE_CURSOR_TYPE_ALPHA:
+ size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
+ qxl_unpack_chunks(c->data, size, qxl, &cursor->chunk, group_id);
if (qxl->debug > 2) {
- cursor_print_ascii_art(c, "qxl/mono");
+ cursor_print_ascii_art(c, "qxl/alpha");
}
break;
default:
fprintf(stderr, "%s: not implemented: type %d\n",
- __FUNCTION__, cursor->header.type);
+ __func__, cursor->header.type);
goto fail;
}
return c;
}
if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {
- fprintf(stderr, "%s", __FUNCTION__);
+ fprintf(stderr, "%s", __func__);
qxl_log_cmd_cursor(qxl, cmd, ext->group_id);
fprintf(stderr, "\n");
}
if (!cursor) {
return 1;
}
- if (cursor->chunk.data_size != cursor->data_size) {
- fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
- return 1;
- }
- c = qxl_cursor(qxl, cursor);
+ c = qxl_cursor(qxl, cursor, ext->group_id);
if (c == NULL) {
c = cursor_builtin_left_ptr();
}
qxl->ssd.mouse_x = cmd->u.set.position.x;
qxl->ssd.mouse_y = cmd->u.set.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
+ qemu_bh_schedule(qxl->ssd.cursor_bh);
break;
case QXL_CURSOR_MOVE:
qemu_mutex_lock(&qxl->ssd.lock);
qxl->ssd.mouse_x = cmd->u.position.x;
qxl->ssd.mouse_y = cmd->u.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
+ qemu_bh_schedule(qxl->ssd.cursor_bh);
break;
}
return 0;