Lines Matching +full:width +full:- +full:mm

19 #include "ui/qemu-spice.h"
20 #include "qemu/error-report.h"
23 #include "qemu/main-loop.h"
29 #include "ui/spice-display.h"
31 #include "standard-headers/drm/drm_fourcc.h"
39 return r->top == r->bottom || r->left == r->right; in qemu_spice_rect_is_empty()
53 dest->top = MIN(dest->top, r->top); in qemu_spice_rect_union()
54 dest->left = MIN(dest->left, r->left); in qemu_spice_rect_union()
55 dest->bottom = MAX(dest->bottom, r->bottom); in qemu_spice_rect_union()
56 dest->right = MAX(dest->right, r->right); in qemu_spice_rect_union()
64 cookie->type = type; in qxl_cookie_new()
65 cookie->io = io; in qxl_cookie_new()
72 trace_qemu_spice_add_memslot(ssd->qxl.id, memslot->slot_id, in qemu_spice_add_memslot()
73 memslot->virt_start, memslot->virt_end, in qemu_spice_add_memslot()
77 spice_qxl_add_memslot_async(&ssd->qxl, memslot, in qemu_spice_add_memslot()
81 spice_qxl_add_memslot(&ssd->qxl, memslot); in qemu_spice_add_memslot()
87 trace_qemu_spice_del_memslot(ssd->qxl.id, gid, sid); in qemu_spice_del_memslot()
88 spice_qxl_del_memslot(&ssd->qxl, gid, sid); in qemu_spice_del_memslot()
95 trace_qemu_spice_create_primary_surface(ssd->qxl.id, id, surface, async); in qemu_spice_create_primary_surface()
97 spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface, in qemu_spice_create_primary_surface()
101 spice_qxl_create_primary_surface(&ssd->qxl, id, surface); in qemu_spice_create_primary_surface()
108 trace_qemu_spice_destroy_primary_surface(ssd->qxl.id, id, async); in qemu_spice_destroy_primary_surface()
110 spice_qxl_destroy_primary_surface_async(&ssd->qxl, id, in qemu_spice_destroy_primary_surface()
114 spice_qxl_destroy_primary_surface(&ssd->qxl, id); in qemu_spice_destroy_primary_surface()
120 trace_qemu_spice_wakeup(ssd->qxl.id); in qemu_spice_wakeup()
121 spice_qxl_wakeup(&ssd->qxl); in qemu_spice_wakeup()
136 rect->left, rect->right, in qemu_spice_create_one_update()
137 rect->top, rect->bottom); in qemu_spice_create_one_update()
140 drawable = &update->drawable; in qemu_spice_create_one_update()
141 image = &update->image; in qemu_spice_create_one_update()
142 cmd = &update->ext.cmd; in qemu_spice_create_one_update()
144 bw = rect->right - rect->left; in qemu_spice_create_one_update()
145 bh = rect->bottom - rect->top; in qemu_spice_create_one_update()
146 update->bitmap = g_malloc(bw * bh * 4); in qemu_spice_create_one_update()
148 drawable->bbox = *rect; in qemu_spice_create_one_update()
149 drawable->clip.type = SPICE_CLIP_TYPE_NONE; in qemu_spice_create_one_update()
150 drawable->effect = QXL_EFFECT_OPAQUE; in qemu_spice_create_one_update()
151 drawable->release_info.id = (uintptr_t)(&update->ext); in qemu_spice_create_one_update()
152 drawable->type = QXL_DRAW_COPY; in qemu_spice_create_one_update()
153 drawable->surfaces_dest[0] = -1; in qemu_spice_create_one_update()
154 drawable->surfaces_dest[1] = -1; in qemu_spice_create_one_update()
155 drawable->surfaces_dest[2] = -1; in qemu_spice_create_one_update()
158 drawable->mm_time = time_space.tv_sec * 1000 in qemu_spice_create_one_update()
161 drawable->u.copy.rop_descriptor = SPICE_ROPD_OP_PUT; in qemu_spice_create_one_update()
162 drawable->u.copy.src_bitmap = (uintptr_t)image; in qemu_spice_create_one_update()
163 drawable->u.copy.src_area.right = bw; in qemu_spice_create_one_update()
164 drawable->u.copy.src_area.bottom = bh; in qemu_spice_create_one_update()
166 QXL_SET_IMAGE_ID(image, QXL_IMAGE_GROUP_DEVICE, ssd->unique++); in qemu_spice_create_one_update()
167 image->descriptor.type = SPICE_IMAGE_TYPE_BITMAP; in qemu_spice_create_one_update()
168 image->bitmap.flags = QXL_BITMAP_DIRECT | QXL_BITMAP_TOP_DOWN; in qemu_spice_create_one_update()
169 image->bitmap.stride = bw * 4; in qemu_spice_create_one_update()
170 image->descriptor.width = image->bitmap.x = bw; in qemu_spice_create_one_update()
171 image->descriptor.height = image->bitmap.y = bh; in qemu_spice_create_one_update()
172 image->bitmap.data = (uintptr_t)(update->bitmap); in qemu_spice_create_one_update()
173 image->bitmap.palette = 0; in qemu_spice_create_one_update()
174 image->bitmap.format = SPICE_BITMAP_FMT_32BIT; in qemu_spice_create_one_update()
177 (void *)update->bitmap, bw * 4); in qemu_spice_create_one_update()
178 pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror, in qemu_spice_create_one_update()
179 rect->left, rect->top, 0, 0, in qemu_spice_create_one_update()
180 rect->left, rect->top, bw, bh); in qemu_spice_create_one_update()
181 pixman_image_composite(PIXMAN_OP_SRC, ssd->mirror, NULL, dest, in qemu_spice_create_one_update()
182 rect->left, rect->top, 0, 0, in qemu_spice_create_one_update()
186 cmd->type = QXL_CMD_DRAW; in qemu_spice_create_one_update()
187 cmd->data = (uintptr_t)drawable; in qemu_spice_create_one_update()
189 QTAILQ_INSERT_TAIL(&ssd->updates, update, next); in qemu_spice_create_one_update()
195 int blocks = DIV_ROUND_UP(surface_width(ssd->ds), blksize); in qemu_spice_create_update()
198 int bpp = surface_bytes_per_pixel(ssd->ds); in qemu_spice_create_update()
201 if (qemu_spice_rect_is_empty(&ssd->dirty)) { in qemu_spice_create_update()
207 dirty_top[blk] = -1; in qemu_spice_create_update()
210 guest = surface_data(ssd->ds); in qemu_spice_create_update()
211 mirror = (void *)pixman_image_get_data(ssd->mirror); in qemu_spice_create_update()
212 for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) { in qemu_spice_create_update()
213 yoff1 = y * surface_stride(ssd->ds); in qemu_spice_create_update()
214 yoff2 = y * pixman_image_get_stride(ssd->mirror); in qemu_spice_create_update()
215 for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { in qemu_spice_create_update()
218 bw = MIN(blksize, ssd->dirty.right - x); in qemu_spice_create_update()
222 if (dirty_top[blk] != -1) { in qemu_spice_create_update()
230 dirty_top[blk] = -1; in qemu_spice_create_update()
233 if (dirty_top[blk] == -1) { in qemu_spice_create_update()
240 for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { in qemu_spice_create_update()
242 bw = MIN(blksize, ssd->dirty.right - x); in qemu_spice_create_update()
243 if (dirty_top[blk] != -1) { in qemu_spice_create_update()
246 .bottom = ssd->dirty.bottom, in qemu_spice_create_update()
251 dirty_top[blk] = -1; in qemu_spice_create_update()
255 memset(&ssd->dirty, 0, sizeof(ssd->dirty)); in qemu_spice_create_update()
263 size_t size = c ? c->width * c->height * 4 : 0; in qemu_spice_create_cursor_update()
270 ccmd = &update->cmd; in qemu_spice_create_cursor_update()
271 cursor = &update->cursor; in qemu_spice_create_cursor_update()
272 cmd = &update->ext.cmd; in qemu_spice_create_cursor_update()
275 ccmd->type = QXL_CURSOR_SET; in qemu_spice_create_cursor_update()
276 ccmd->u.set.position.x = ssd->ptr_x + ssd->hot_x; in qemu_spice_create_cursor_update()
277 ccmd->u.set.position.y = ssd->ptr_y + ssd->hot_y; in qemu_spice_create_cursor_update()
278 ccmd->u.set.visible = true; in qemu_spice_create_cursor_update()
279 ccmd->u.set.shape = (uintptr_t)cursor; in qemu_spice_create_cursor_update()
280 cursor->header.unique = ssd->unique++; in qemu_spice_create_cursor_update()
281 cursor->header.type = SPICE_CURSOR_TYPE_ALPHA; in qemu_spice_create_cursor_update()
282 cursor->header.width = c->width; in qemu_spice_create_cursor_update()
283 cursor->header.height = c->height; in qemu_spice_create_cursor_update()
284 cursor->header.hot_spot_x = c->hot_x; in qemu_spice_create_cursor_update()
285 cursor->header.hot_spot_y = c->hot_y; in qemu_spice_create_cursor_update()
286 cursor->data_size = size; in qemu_spice_create_cursor_update()
287 cursor->chunk.data_size = size; in qemu_spice_create_cursor_update()
288 memcpy(cursor->chunk.data, c->data, size); in qemu_spice_create_cursor_update()
290 ccmd->type = QXL_CURSOR_HIDE; in qemu_spice_create_cursor_update()
292 ccmd->type = QXL_CURSOR_MOVE; in qemu_spice_create_cursor_update()
293 ccmd->u.position.x = ssd->ptr_x + ssd->hot_x; in qemu_spice_create_cursor_update()
294 ccmd->u.position.y = ssd->ptr_y + ssd->hot_y; in qemu_spice_create_cursor_update()
296 ccmd->release_info.id = (uintptr_t)(&update->ext); in qemu_spice_create_cursor_update()
298 cmd->type = QXL_CMD_CURSOR; in qemu_spice_create_cursor_update()
299 cmd->data = (uintptr_t)ccmd; in qemu_spice_create_cursor_update()
308 * - g_free (underlying glibc free is re-entrant).
312 g_free(update->bitmap); in qemu_spice_destroy_update()
333 surface_size = (uint64_t) surface_width(ssd->ds) * in qemu_spice_create_host_primary()
334 surface_height(ssd->ds) * 4; in qemu_spice_create_host_primary()
337 if (ssd->bufsize < surface_size) { in qemu_spice_create_host_primary()
338 ssd->bufsize = surface_size; in qemu_spice_create_host_primary()
339 g_free(ssd->buf); in qemu_spice_create_host_primary()
340 ssd->buf = g_malloc(ssd->bufsize); in qemu_spice_create_host_primary()
344 surface.width = surface_width(ssd->ds); in qemu_spice_create_host_primary()
345 surface.height = surface_height(ssd->ds); in qemu_spice_create_host_primary()
346 surface.stride = -surface.width * 4; in qemu_spice_create_host_primary()
350 surface.mem = (uintptr_t)ssd->buf; in qemu_spice_create_host_primary()
363 qemu_mutex_init(&ssd->lock); in qemu_spice_display_init_common()
364 QTAILQ_INIT(&ssd->updates); in qemu_spice_display_init_common()
365 ssd->mouse_x = -1; in qemu_spice_display_init_common()
366 ssd->mouse_y = -1; in qemu_spice_display_init_common()
367 if (ssd->num_surfaces == 0) { in qemu_spice_display_init_common()
368 ssd->num_surfaces = 1024; in qemu_spice_display_init_common()
379 trace_qemu_spice_display_update(ssd->qxl.id, x, y, w, h); in qemu_spice_display_update()
385 if (qemu_spice_rect_is_empty(&ssd->dirty)) { in qemu_spice_display_update()
386 ssd->notify++; in qemu_spice_display_update()
388 qemu_spice_rect_union(&ssd->dirty, &update_area); in qemu_spice_display_update()
397 if (ssd->surface && in qemu_spice_display_switch()
398 surface_width(surface) == pixman_image_get_width(ssd->surface) && in qemu_spice_display_switch()
399 surface_height(surface) == pixman_image_get_height(ssd->surface) && in qemu_spice_display_switch()
400 surface_format(surface) == pixman_image_get_format(ssd->surface)) { in qemu_spice_display_switch()
401 /* no-resize fast path: just swap backing store */ in qemu_spice_display_switch()
402 trace_qemu_spice_display_surface(ssd->qxl.id, in qemu_spice_display_switch()
406 qemu_mutex_lock(&ssd->lock); in qemu_spice_display_switch()
407 ssd->ds = surface; in qemu_spice_display_switch()
408 pixman_image_unref(ssd->surface); in qemu_spice_display_switch()
409 ssd->surface = pixman_image_ref(ssd->ds->image); in qemu_spice_display_switch()
410 qemu_mutex_unlock(&ssd->lock); in qemu_spice_display_switch()
418 trace_qemu_spice_display_surface(ssd->qxl.id, in qemu_spice_display_switch()
423 memset(&ssd->dirty, 0, sizeof(ssd->dirty)); in qemu_spice_display_switch()
424 if (ssd->surface) { in qemu_spice_display_switch()
425 pixman_image_unref(ssd->surface); in qemu_spice_display_switch()
426 ssd->surface = NULL; in qemu_spice_display_switch()
427 pixman_image_unref(ssd->mirror); in qemu_spice_display_switch()
428 ssd->mirror = NULL; in qemu_spice_display_switch()
431 qemu_mutex_lock(&ssd->lock); in qemu_spice_display_switch()
432 need_destroy = (ssd->ds != NULL); in qemu_spice_display_switch()
433 ssd->ds = surface; in qemu_spice_display_switch()
434 while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) { in qemu_spice_display_switch()
435 QTAILQ_REMOVE(&ssd->updates, update, next); in qemu_spice_display_switch()
438 qemu_mutex_unlock(&ssd->lock); in qemu_spice_display_switch()
442 if (ssd->ds) { in qemu_spice_display_switch()
443 ssd->surface = pixman_image_ref(ssd->ds->image); in qemu_spice_display_switch()
444 ssd->mirror = qemu_pixman_mirror_create(surface_format(ssd->ds), in qemu_spice_display_switch()
445 ssd->ds->image); in qemu_spice_display_switch()
449 memset(&ssd->dirty, 0, sizeof(ssd->dirty)); in qemu_spice_display_switch()
450 ssd->notify++; in qemu_spice_display_switch()
452 qemu_mutex_lock(&ssd->lock); in qemu_spice_display_switch()
453 if (ssd->cursor) { in qemu_spice_display_switch()
454 g_free(ssd->ptr_define); in qemu_spice_display_switch()
455 ssd->ptr_define = in qemu_spice_display_switch()
456 qemu_spice_create_cursor_update(ssd, ssd->cursor, false); in qemu_spice_display_switch()
458 qemu_mutex_unlock(&ssd->lock); in qemu_spice_display_switch()
465 qemu_mutex_lock(&ssd->lock); in qemu_spice_cursor_refresh_bh()
466 if (ssd->cursor) { in qemu_spice_cursor_refresh_bh()
467 QEMUCursor *c = ssd->cursor; in qemu_spice_cursor_refresh_bh()
468 assert(ssd->dcl.con); in qemu_spice_cursor_refresh_bh()
470 qemu_mutex_unlock(&ssd->lock); in qemu_spice_cursor_refresh_bh()
471 dpy_cursor_define(ssd->dcl.con, c); in qemu_spice_cursor_refresh_bh()
472 qemu_mutex_lock(&ssd->lock); in qemu_spice_cursor_refresh_bh()
476 if (ssd->mouse_x != -1 && ssd->mouse_y != -1) { in qemu_spice_cursor_refresh_bh()
478 assert(ssd->dcl.con); in qemu_spice_cursor_refresh_bh()
479 x = ssd->mouse_x; in qemu_spice_cursor_refresh_bh()
480 y = ssd->mouse_y; in qemu_spice_cursor_refresh_bh()
481 ssd->mouse_x = -1; in qemu_spice_cursor_refresh_bh()
482 ssd->mouse_y = -1; in qemu_spice_cursor_refresh_bh()
483 qemu_mutex_unlock(&ssd->lock); in qemu_spice_cursor_refresh_bh()
484 dpy_mouse_set(ssd->dcl.con, x, y, true); in qemu_spice_cursor_refresh_bh()
486 qemu_mutex_unlock(&ssd->lock); in qemu_spice_cursor_refresh_bh()
492 graphic_hw_update(ssd->dcl.con); in qemu_spice_display_refresh()
494 WITH_QEMU_LOCK_GUARD(&ssd->lock) { in qemu_spice_display_refresh()
495 if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) { in qemu_spice_display_refresh()
497 ssd->notify++; in qemu_spice_display_refresh()
501 trace_qemu_spice_display_refresh(ssd->qxl.id, ssd->notify); in qemu_spice_display_refresh()
502 if (ssd->notify) { in qemu_spice_display_refresh()
503 ssd->notify = 0; in qemu_spice_display_refresh()
531 info->memslot_gen_bits = MEMSLOT_GENERATION_BITS; in interface_get_init_info()
532 info->memslot_id_bits = MEMSLOT_SLOT_BITS; in interface_get_init_info()
533 info->num_memslots = NUM_MEMSLOTS; in interface_get_init_info()
534 info->num_memslots_groups = NUM_MEMSLOTS_GROUPS; in interface_get_init_info()
535 info->internal_groupslot_id = 0; in interface_get_init_info()
536 info->qxl_ram_size = 16 * 1024 * 1024; in interface_get_init_info()
537 info->n_surfaces = ssd->num_surfaces; in interface_get_init_info()
546 qemu_mutex_lock(&ssd->lock); in interface_get_command()
547 update = QTAILQ_FIRST(&ssd->updates); in interface_get_command()
549 QTAILQ_REMOVE(&ssd->updates, update, next); in interface_get_command()
550 *ext = update->ext; in interface_get_command()
553 qemu_mutex_unlock(&ssd->lock); in interface_get_command()
575 ext = (void *)(intptr_t)(rext.info->id); in interface_release_resource()
576 switch (ext->cmd.type) { in interface_release_resource()
595 QEMU_LOCK_GUARD(&ssd->lock); in interface_get_cursor_command()
596 if (ssd->ptr_define) { in interface_get_cursor_command()
597 *ext = ssd->ptr_define->ext; in interface_get_cursor_command()
598 ssd->ptr_define = NULL; in interface_get_cursor_command()
600 } else if (ssd->ptr_move) { in interface_get_cursor_command()
601 *ext = ssd->ptr_move->ext; in interface_get_cursor_command()
602 ssd->ptr_move = NULL; in interface_get_cursor_command()
642 switch (cookie->type) { in interface_async_complete()
647 qemu_bh_schedule(ssd->gl_unblock_bh); in interface_async_complete()
651 if (cookie->io == QXL_IO_MONITORS_CONFIG_ASYNC) { in interface_async_complete()
652 g_free(cookie->u.data); in interface_async_complete()
678 if (!dpy_ui_info_supported(ssd->dcl.con)) { in interface_client_monitors_config()
686 info = *dpy_get_ui_info(ssd->dcl.con); in interface_client_monitors_config()
688 head = qemu_console_get_index(ssd->dcl.con); in interface_client_monitors_config()
689 if (mc->num_of_monitors > head) { in interface_client_monitors_config()
690 info.width = mc->monitors[head].width; in interface_client_monitors_config()
691 info.height = mc->monitors[head].height; in interface_client_monitors_config()
693 if (mc->flags & VD_AGENT_CONFIG_MONITORS_FLAG_PHYSICAL_SIZE) { in interface_client_monitors_config()
694 VDAgentMonitorMM *mm = (void *)&mc->monitors[mc->num_of_monitors]; in interface_client_monitors_config() local
695 info.width_mm = mm[head].width; in interface_client_monitors_config()
696 info.height_mm = mm[head].height; in interface_client_monitors_config()
701 trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height); in interface_client_monitors_config()
702 dpy_set_ui_info(ssd->dcl.con, &info, false); in interface_client_monitors_config()
759 qemu_mutex_lock(&ssd->lock); in display_mouse_set()
760 ssd->ptr_x = x; in display_mouse_set()
761 ssd->ptr_y = y; in display_mouse_set()
762 g_free(ssd->ptr_move); in display_mouse_set()
763 ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on); in display_mouse_set()
764 qemu_mutex_unlock(&ssd->lock); in display_mouse_set()
773 qemu_mutex_lock(&ssd->lock); in display_mouse_define()
775 cursor_unref(ssd->cursor); in display_mouse_define()
776 ssd->cursor = c; in display_mouse_define()
777 ssd->hot_x = c->hot_x; in display_mouse_define()
778 ssd->hot_y = c->hot_y; in display_mouse_define()
779 g_free(ssd->ptr_move); in display_mouse_define()
780 ssd->ptr_move = NULL; in display_mouse_define()
781 g_free(ssd->ptr_define); in display_mouse_define()
782 ssd->ptr_define = qemu_spice_create_cursor_update(ssd, c, false); in display_mouse_define()
783 qemu_mutex_unlock(&ssd->lock); in display_mouse_define()
806 config->count = 1; in qemu_spice_gl_monitor_config()
807 config->max_allowed = 1; in qemu_spice_gl_monitor_config()
808 config->heads[0].x = x; in qemu_spice_gl_monitor_config()
809 config->heads[0].y = y; in qemu_spice_gl_monitor_config()
810 config->heads[0].width = w; in qemu_spice_gl_monitor_config()
811 config->heads[0].height = h; in qemu_spice_gl_monitor_config()
814 cookie->u.data = config; in qemu_spice_gl_monitor_config()
816 spice_qxl_monitors_config_async(&ssd->qxl, in qemu_spice_gl_monitor_config()
829 timer_mod(ssd->gl_unblock_timer, timeout); in qemu_spice_gl_block()
831 timer_del(ssd->gl_unblock_timer); in qemu_spice_gl_block()
833 graphic_hw_gl_block(ssd->dcl.con, block); in qemu_spice_gl_block()
845 warn_report("spice: no gl-draw-done within one second"); in qemu_spice_gl_block_timer()
854 spice_qxl_gl_draw_async(&ssd->qxl, x, y, w, h, cookie); in spice_gl_draw()
861 if (!ssd->ds) { in spice_gl_refresh()
865 if (qemu_console_is_gl_blocked(ssd->dcl.con)) { in spice_gl_refresh()
866 if (spice_remote_client && ssd->gl_updates && ssd->have_scanout) { in spice_gl_refresh()
869 surface_width(ssd->ds), surface_height(ssd->ds)); in spice_gl_refresh()
870 ssd->gl_updates = 0; in spice_gl_refresh()
872 dcl->update_interval = 1000 / spice_max_refresh_rate; in spice_gl_refresh()
877 graphic_hw_update(dcl->con); in spice_gl_refresh()
878 if (ssd->gl_updates && ssd->have_surface) { in spice_gl_refresh()
882 surface_width(ssd->ds), surface_height(ssd->ds)); in spice_gl_refresh()
883 ssd->gl_updates = 0; in spice_gl_refresh()
892 surface_gl_update_texture(ssd->gls, ssd->ds, x, y, w, h); in spice_gl_update()
893 ssd->gl_updates++; in spice_gl_update()
923 if (!surface_gl_create_texture_from_fd(ssd->ds, fds[0], &texture, in spice_gl_replace_fd_texture()
952 ret = egl_dmabuf_export_texture(ssd->ds->texture, in spice_gl_replace_fd_texture()
960 surface_gl_destroy_texture(ssd->gls, ssd->ds); in spice_gl_replace_fd_texture()
964 surface_gl_destroy_texture(ssd->gls, ssd->ds); in spice_gl_replace_fd_texture()
965 ssd->ds->texture = texture; in spice_gl_replace_fd_texture()
966 ssd->ds->mem_obj = mem_obj; in spice_gl_replace_fd_texture()
973 uint32_t width, uint32_t height, in spice_server_gl_scanout() argument
980 spice_qxl_gl_scanout2(qxl, fd, width, height, offset, stride, in spice_server_gl_scanout()
984 spice_qxl_gl_scanout(qxl, -1, 0, 0, 0, 0, false); in spice_server_gl_scanout()
986 spice_qxl_gl_scanout(qxl, fd[0], width, height, stride[0], format, y_0_top); in spice_server_gl_scanout()
999 if (ssd->ds) { in spice_gl_switch()
1000 surface_gl_destroy_texture(ssd->gls, ssd->ds); in spice_gl_switch()
1002 ssd->ds = new_surface; in spice_gl_switch()
1003 if (ssd->ds) { in spice_gl_switch()
1008 surface_gl_create_texture(ssd->gls, ssd->ds); in spice_gl_switch()
1009 if (!egl_dmabuf_export_texture(ssd->ds->texture, in spice_gl_switch()
1016 surface_gl_destroy_texture(ssd->gls, ssd->ds); in spice_gl_switch()
1022 surface_gl_destroy_texture(ssd->gls, ssd->ds); in spice_gl_switch()
1026 trace_qemu_spice_gl_surface(ssd->qxl.id, in spice_gl_switch()
1027 surface_width(ssd->ds), in spice_gl_switch()
1028 surface_height(ssd->ds), in spice_gl_switch()
1032 spice_server_gl_scanout(&ssd->qxl, fd, in spice_gl_switch()
1033 surface_width(ssd->ds), in spice_gl_switch()
1034 surface_height(ssd->ds), in spice_gl_switch()
1037 ssd->have_surface = true; in spice_gl_switch()
1038 ssd->have_scanout = false; in spice_gl_switch()
1041 surface_width(ssd->ds), in spice_gl_switch()
1042 surface_height(ssd->ds)); in spice_gl_switch()
1058 trace_qemu_spice_gl_scanout_disable(ssd->qxl.id); in qemu_spice_gl_scanout_disable()
1067 if (qemu_console_is_gl_blocked(ssd->dcl.con)) { in qemu_spice_gl_scanout_disable()
1068 if (spice_remote_client && ssd->gl_updates && ssd->have_scanout) { in qemu_spice_gl_scanout_disable()
1069 ssd->gl_updates = 0; in qemu_spice_gl_scanout_disable()
1073 spice_server_gl_scanout(&ssd->qxl, NULL, 0, 0, NULL, NULL, 0, DRM_FORMAT_INVALID, in qemu_spice_gl_scanout_disable()
1076 ssd->have_surface = false; in qemu_spice_gl_scanout_disable()
1077 ssd->have_scanout = false; in qemu_spice_gl_scanout_disable()
1101 trace_qemu_spice_gl_scanout_texture(ssd->qxl.id, w, h, fourcc); in qemu_spice_gl_scanout_texture()
1104 egl_fb_destroy(&ssd->guest_fb); in qemu_spice_gl_scanout_texture()
1105 egl_fb_setup_for_tex(&ssd->guest_fb, in qemu_spice_gl_scanout_texture()
1108 ssd->backing_y_0_top = y_0_top; in qemu_spice_gl_scanout_texture()
1109 ssd->blit_scanout_texture = true; in qemu_spice_gl_scanout_texture()
1110 ssd->new_scanout_texture = true; in qemu_spice_gl_scanout_texture()
1117 spice_server_gl_scanout(&ssd->qxl, fd, backing_width, backing_height, in qemu_spice_gl_scanout_texture()
1123 ssd->have_surface = false; in qemu_spice_gl_scanout_texture()
1124 ssd->have_scanout = true; in qemu_spice_gl_scanout_texture()
1132 ssd->guest_dmabuf = dmabuf; in qemu_spice_gl_scanout_dmabuf()
1133 ssd->guest_dmabuf_refresh = true; in qemu_spice_gl_scanout_dmabuf()
1135 ssd->have_surface = false; in qemu_spice_gl_scanout_dmabuf()
1136 ssd->have_scanout = true; in qemu_spice_gl_scanout_dmabuf()
1144 uint32_t width, height, texture; in qemu_spice_gl_cursor_dmabuf() local
1146 ssd->have_hot = have_hot; in qemu_spice_gl_cursor_dmabuf()
1147 ssd->hot_x = hot_x; in qemu_spice_gl_cursor_dmabuf()
1148 ssd->hot_y = hot_y; in qemu_spice_gl_cursor_dmabuf()
1150 trace_qemu_spice_gl_cursor(ssd->qxl.id, dmabuf != NULL, have_hot); in qemu_spice_gl_cursor_dmabuf()
1157 width = qemu_dmabuf_get_width(dmabuf); in qemu_spice_gl_cursor_dmabuf()
1159 egl_fb_setup_for_tex(&ssd->cursor_fb, width, height, texture, false); in qemu_spice_gl_cursor_dmabuf()
1161 egl_fb_destroy(&ssd->cursor_fb); in qemu_spice_gl_cursor_dmabuf()
1170 qemu_mutex_lock(&ssd->lock); in qemu_spice_gl_cursor_position()
1171 ssd->ptr_x = pos_x; in qemu_spice_gl_cursor_position()
1172 ssd->ptr_y = pos_y; in qemu_spice_gl_cursor_position()
1173 qemu_mutex_unlock(&ssd->lock); in qemu_spice_gl_cursor_position()
1181 if (ssd->guest_dmabuf == dmabuf) { in qemu_spice_gl_release_dmabuf()
1182 ssd->guest_dmabuf = NULL; in qemu_spice_gl_release_dmabuf()
1183 ssd->guest_dmabuf_refresh = false; in qemu_spice_gl_release_dmabuf()
1197 surface_width(ssd->ds), surface_height(ssd->ds), in spice_gl_blit_scanout_texture()
1198 ssd->ds->texture, false); in spice_gl_blit_scanout_texture()
1199 egl_fb_blit(&scanout_tex_fb, &ssd->guest_fb, false); in spice_gl_blit_scanout_texture()
1203 if (!ssd->new_scanout_texture) { in spice_gl_blit_scanout_texture()
1207 ret = egl_dmabuf_export_texture(ssd->ds->texture, in spice_gl_blit_scanout_texture()
1219 spice_server_gl_scanout(&ssd->qxl, fds, in spice_gl_blit_scanout_texture()
1220 surface_width(ssd->ds), in spice_gl_blit_scanout_texture()
1221 surface_height(ssd->ds), in spice_gl_blit_scanout_texture()
1224 ssd->backing_y_0_top); in spice_gl_blit_scanout_texture()
1226 surface_width(ssd->ds), in spice_gl_blit_scanout_texture()
1227 surface_height(ssd->ds)); in spice_gl_blit_scanout_texture()
1228 ssd->new_scanout_texture = false; in spice_gl_blit_scanout_texture()
1240 uint32_t width, height, texture; in qemu_spice_gl_update() local
1242 if (!ssd->have_scanout) { in qemu_spice_gl_update()
1246 if (ssd->cursor_fb.texture) { in qemu_spice_gl_update()
1249 if (ssd->render_cursor != render_cursor) { in qemu_spice_gl_update()
1250 ssd->render_cursor = render_cursor; in qemu_spice_gl_update()
1251 ssd->guest_dmabuf_refresh = true; in qemu_spice_gl_update()
1252 egl_fb_destroy(&ssd->blit_fb); in qemu_spice_gl_update()
1255 if (ssd->guest_dmabuf_refresh) { in qemu_spice_gl_update()
1256 QemuDmaBuf *dmabuf = ssd->guest_dmabuf; in qemu_spice_gl_update()
1257 width = qemu_dmabuf_get_width(dmabuf); in qemu_spice_gl_update()
1268 egl_fb_setup_for_tex(&ssd->guest_fb, width, height, in qemu_spice_gl_update()
1272 if (ssd->blit_fb.width != width || in qemu_spice_gl_update()
1273 ssd->blit_fb.height != height) { in qemu_spice_gl_update()
1278 trace_qemu_spice_gl_render_dmabuf(ssd->qxl.id, width, in qemu_spice_gl_update()
1280 egl_fb_destroy(&ssd->blit_fb); in qemu_spice_gl_update()
1281 egl_fb_setup_new_tex(&ssd->blit_fb, in qemu_spice_gl_update()
1282 width, height); in qemu_spice_gl_update()
1283 if (!egl_dmabuf_export_texture(ssd->blit_fb.texture, fds, in qemu_spice_gl_update()
1291 spice_server_gl_scanout(&ssd->qxl, fds, width, height, offsets, strides, in qemu_spice_gl_update()
1308 trace_qemu_spice_gl_forward_dmabuf(ssd->qxl.id, width, height); in qemu_spice_gl_update()
1310 spice_server_gl_scanout(&ssd->qxl, fds, width, height, in qemu_spice_gl_update()
1316 qemu_spice_gl_monitor_config(ssd, 0, 0, width, height); in qemu_spice_gl_update()
1317 ssd->guest_dmabuf_refresh = false; in qemu_spice_gl_update()
1323 qemu_mutex_lock(&ssd->lock); in qemu_spice_gl_update()
1324 ptr_x = ssd->ptr_x; in qemu_spice_gl_update()
1325 ptr_y = ssd->ptr_y; in qemu_spice_gl_update()
1326 qemu_mutex_unlock(&ssd->lock); in qemu_spice_gl_update()
1327 egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb, in qemu_spice_gl_update()
1329 egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb, in qemu_spice_gl_update()
1334 if (spice_remote_client && ssd->blit_scanout_texture) { in qemu_spice_gl_update()
1341 trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); in qemu_spice_gl_update()
1353 ssd->gl_updates++; in qemu_spice_gl_update()
1360 .dpy_name = "spice-egl",
1381 return dcl->ops == &display_listener_gl_ops; in qemu_spice_is_compatible_dcl()
1399 ssd->dcl.ops = &display_listener_ops; in qemu_spice_display_init_one()
1402 ssd->dcl.ops = &display_listener_gl_ops; in qemu_spice_display_init_one()
1403 ssd->dgc.ops = &gl_ctx_ops; in qemu_spice_display_init_one()
1404 ssd->gl_unblock_bh = qemu_bh_new(qemu_spice_gl_unblock_bh, ssd); in qemu_spice_display_init_one()
1405 ssd->gl_unblock_timer = timer_new_ms(QEMU_CLOCK_REALTIME, in qemu_spice_display_init_one()
1407 ssd->gls = qemu_gl_init_shader(); in qemu_spice_display_init_one()
1408 ssd->have_surface = false; in qemu_spice_display_init_one()
1409 ssd->have_scanout = false; in qemu_spice_display_init_one()
1412 ssd->dcl.con = con; in qemu_spice_display_init_one()
1414 ssd->qxl.base.sif = &dpy_interface.base; in qemu_spice_display_init_one()
1415 qemu_spice_add_display_interface(&ssd->qxl, con); in qemu_spice_display_init_one()
1421 spice_qxl_set_device_info(&ssd->qxl, in qemu_spice_display_init_one()
1433 qemu_console_set_display_gl_ctx(con, &ssd->dgc); in qemu_spice_display_init_one()
1435 register_displaychangelistener(&ssd->dcl); in qemu_spice_display_init_one()
1441 QemuOpts *opts = QTAILQ_FIRST(&olist->head); in qemu_spice_display_init()