diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-04-30 13:35:40 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2021-05-10 13:55:28 +0200 |
commit | 2c267d66fde11c8813d5b6d91871fc501e891122 (patch) | |
tree | ce91eb9209a8b07e50d737ac07956a67174522e1 /hw/display/virtio-gpu-gl.c | |
parent | 2f47691a0f8dbb4661216cba2c687efc28b1bcf5 (diff) |
virtio-gpu: move update_cursor_data
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20210430113547.1816178-1-kraxel@redhat.com
Message-Id: <20210430113547.1816178-10-kraxel@redhat.com>
Diffstat (limited to 'hw/display/virtio-gpu-gl.c')
-rw-r--r-- | hw/display/virtio-gpu-gl.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 792cc0b412..b4303cc5bb 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -23,6 +23,35 @@ #include "hw/virtio/virtio-gpu-pixman.h" #include "hw/qdev-properties.h" +#include <virglrenderer.h> + +static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g, + struct virtio_gpu_scanout *s, + uint32_t resource_id) +{ + uint32_t width, height; + uint32_t pixels, *data; + + if (g->parent_obj.use_virgl_renderer) { + data = virgl_renderer_get_cursor_data(resource_id, &width, &height); + if (!data) { + return; + } + + if (width != s->current_cursor->width || + height != s->current_cursor->height) { + free(data); + return; + } + + pixels = s->current_cursor->width * s->current_cursor->height; + memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t)); + free(data); + return; + } + virtio_gpu_update_cursor_data(g, s, resource_id); +} + static void virtio_gpu_gl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -127,6 +156,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data) vbc->gl_flushed = virtio_gpu_gl_flushed; vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl; vgc->process_cmd = virtio_gpu_gl_process_cmd; + vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data; vdc->realize = virtio_gpu_gl_device_realize; vdc->reset = virtio_gpu_gl_reset; |