qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 20/27] vhost-user-gpu: add vg_send_cursor_update()


From: marcandre . lureau
Subject: [PATCH 20/27] vhost-user-gpu: add vg_send_cursor_update()
Date: Fri, 12 Mar 2021 14:01:01 +0400

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 contrib/vhost-user-gpu/vugpu.h          |  4 ++-
 contrib/vhost-user-gpu/vhost-user-gpu.c | 46 +++++++++++++++----------
 2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h
index bf513e9295..02a22bae34 100644
--- a/contrib/vhost-user-gpu/vugpu.h
+++ b/contrib/vhost-user-gpu/vugpu.h
@@ -195,5 +195,7 @@ void    vg_send_dmabuf_update(VuGpu *g,
                               uint32_t width,
                               uint32_t height);
 void    vg_send_scanout(VuGpu *g, uint32_t scanout_id);
-
+void    vg_send_cursor_update(VuGpu *g,
+                              const struct virtio_gpu_update_cursor *cursor,
+                              const void *data);
 #endif
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c 
b/contrib/vhost-user-gpu/vhost-user-gpu.c
index a11f406350..32bcbaa9a1 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -935,6 +935,30 @@ update_cursor_data_simple(VuGpu *g, uint32_t resource_id, 
gpointer data)
     memcpy(data, pixman_image_get_data(res->image), 64 * 64 * 
sizeof(uint32_t));
 }
 
+void
+vg_send_cursor_update(VuGpu *g,
+                      const struct virtio_gpu_update_cursor *cursor,
+                      const void *data)
+{
+    VhostUserGpuMsg msg = {
+        .request = VHOST_USER_GPU_CURSOR_UPDATE,
+        .size = sizeof(VhostUserGpuCursorUpdate),
+        .payload.cursor_update = {
+            .pos = {
+                .scanout_id = cursor->pos.scanout_id,
+                .x = cursor->pos.x,
+                .y = cursor->pos.y,
+            },
+            .hot_x = cursor->hot_x,
+            .hot_y = cursor->hot_y,
+        }
+    };
+    /* we can afford that cursor copy */
+    memcpy(msg.payload.cursor_update.data, data,
+           sizeof(msg.payload.cursor_update.data));
+    vg_send_msg(g, &msg, -1);
+}
+
 static void
 vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
 {
@@ -955,28 +979,14 @@ vg_process_cursor_cmd(VuGpu *g, struct 
virtio_gpu_update_cursor *cursor)
         break;
     }
     case VIRTIO_GPU_CMD_UPDATE_CURSOR: {
-        VhostUserGpuMsg msg = {
-            .request = VHOST_USER_GPU_CURSOR_UPDATE,
-            .size = sizeof(VhostUserGpuCursorUpdate),
-            .payload.cursor_update = {
-                .pos = {
-                    .scanout_id = cursor->pos.scanout_id,
-                    .x = cursor->pos.x,
-                    .y = cursor->pos.y,
-                },
-                .hot_x = cursor->hot_x,
-                .hot_y = cursor->hot_y,
-            }
-        };
+        uint32_t data[64 * 64] = { 0, };
         g_debug("%s: update", G_STRFUNC);
         if (g->virgl) {
-            vg_virgl_update_cursor_data(g, cursor->resource_id,
-                                        msg.payload.cursor_update.data);
+            vg_virgl_update_cursor_data(g, cursor->resource_id, data);
         } else {
-            update_cursor_data_simple(g, cursor->resource_id,
-                                      msg.payload.cursor_update.data);
+            update_cursor_data_simple(g, cursor->resource_id, data);
         }
-        vg_send_msg(g, &msg, -1);
+        vg_send_cursor_update(g, cursor, data);
         break;
     }
     default:
-- 
2.29.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]