[spice-server 6/8] Add more red_qxl_ methods

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

 



Add red_qxl_ methods wrapping the QXLInterface vfuncs. This allows to
remove most of the qxl_get_interface() use outside of red-qxl.c
---
 server/cursor-channel.c  |  2 +-
 server/display-channel.c |  4 +--
 server/red-qxl.c         | 78 +++++++++++++++++++++++++++++++++++++++++++++++-
 server/red-qxl.h         | 17 +++++++++++
 server/red-worker.c      | 31 ++++++++++---------
 5 files changed, 112 insertions(+), 20 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index a904cff..7d5ac6a 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -116,7 +116,7 @@ static void cursor_item_unref(CursorItem *item)
         return;
 
     cursor_cmd = item->red_cursor;
-    qxl_get_interface(item->qxl)->release_resource(item->qxl, cursor_cmd->release_info_ext);
+    red_qxl_release_resource(item->qxl, cursor_cmd->release_info_ext);
     red_put_cursor_cmd(cursor_cmd);
     free(cursor_cmd);
 
diff --git a/server/display-channel.c b/server/display-channel.c
index f5f3527..3f61926 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -268,10 +268,10 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
 
     surface->context.canvas->ops->destroy(surface->context.canvas);
     if (surface->create.info) {
-        qxl_get_interface(qxl)->release_resource(qxl, surface->create);
+        red_qxl_release_resource(qxl, surface->create);
     }
     if (surface->destroy.info) {
-        qxl_get_interface(qxl)->release_resource(qxl, surface->destroy);
+        red_qxl_release_resource(qxl, surface->destroy);
     }
 
     region_destroy(&surface->draw_dirty_region);
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 1550ec8..0f608db 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -664,7 +664,9 @@ void red_qxl_set_compression_level(QXLInstance *qxl, int level)
 uint32_t red_qxl_get_ram_size(QXLInstance *qxl)
 {
     QXLDevInitInfo qxl_info;
-    qxl_get_interface(qxl)->get_init_info(qxl, &qxl_info);
+
+    red_qxl_get_init_info(qxl, &qxl_info);
+
     return qxl_info.qxl_ram_size;
 }
 
@@ -1062,3 +1064,77 @@ RedsState* red_qxl_get_server(QXLState *qxl_state)
 {
     return qxl_state->reds;
 }
+
+void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    interface->get_init_info(qxl, info);
+}
+
+int red_qxl_get_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    return interface->get_command(qxl, cmd);
+}
+
+int red_qxl_req_cmd_notification(QXLInstance *qxl)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    return interface->req_cmd_notification(qxl);
+}
+
+void red_qxl_release_resource(QXLInstance *qxl, struct QXLReleaseInfoExt release_info)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    interface->release_resource(qxl, release_info);
+}
+
+int red_qxl_get_cursor_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    return interface->get_cursor_command(qxl, cmd);
+}
+
+int red_qxl_req_cursor_notification(QXLInstance *qxl)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    return interface->req_cursor_notification(qxl);
+}
+
+void red_qxl_notify_update(QXLInstance *qxl, uint32_t update_id)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    interface->notify_update(qxl, update_id);
+}
+
+int red_qxl_flush_resources(QXLInstance *qxl)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    return interface->flush_resources(qxl);
+}
+
+void red_qxl_update_area_complete(QXLInstance *qxl, uint32_t surface_id,
+                                  struct QXLRect *updated_rects,
+                                  uint32_t num_updated_rects)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    interface->update_area_complete(qxl, surface_id, updated_rects, num_updated_rects);
+}
+
+void red_qxl_set_client_capabilities(QXLInstance *qxl,
+                                     uint8_t client_present,
+                                     uint8_t caps[SPICE_CAPABILITIES_SIZE])
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+
+    interface->set_client_capabilities(qxl, client_present, caps);
+}
diff --git a/server/red-qxl.h b/server/red-qxl.h
index 7e158c2..f58d42b 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -46,6 +46,23 @@ void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scan
 void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
 SpiceServer* red_qxl_get_server(QXLState *qxl);
 
+/* Wrappers around QXLInterface vfuncs */
+void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info);;
+int red_qxl_get_command(QXLInstance *qxl, struct QXLCommandExt *cmd);
+int red_qxl_req_cmd_notification(QXLInstance *qxl);
+void red_qxl_release_resource(QXLInstance *qxl, struct QXLReleaseInfoExt release_info);
+int red_qxl_get_cursor_command(QXLInstance *qxl, struct QXLCommandExt *cmd);
+int red_qxl_req_cursor_notification(QXLInstance *qxl);
+void red_qxl_notify_update(QXLInstance *qxl, uint32_t update_id);
+int red_qxl_flush_resources(QXLInstance *qxl);
+void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *cmd);
+void red_qxl_update_area_complete(QXLInstance *qxl, uint32_t surface_id,
+                                  struct QXLRect *updated_rects,
+                                  uint32_t num_updated_rects);
+void red_qxl_set_client_capabilities(QXLInstance *qxl,
+                                     uint8_t client_present,
+                                     uint8_t caps[SPICE_CAPABILITIES_SIZE]);
+
 typedef uint32_t RedWorkerMessage;
 
 /* Keep message order, only append new messages!
diff --git a/server/red-worker.c b/server/red-worker.c
index 2eb4fee..3a82aa4 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -128,8 +128,7 @@ void red_drawable_unref(RedDrawable *red_drawable)
     if (--red_drawable->refs) {
         return;
     }
-    qxl_get_interface(red_drawable->qxl)->release_resource(red_drawable->qxl,
-                                                           red_drawable->release_info_ext);
+    red_qxl_release_resource(red_drawable->qxl, red_drawable->release_info_ext);
     red_put_drawable(red_drawable);
     free(red_drawable);
 }
@@ -146,12 +145,12 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
 
     *ring_is_empty = FALSE;
     while (red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
-        if (!qxl_get_interface(worker->qxl)->get_cursor_command(worker->qxl, &ext_cmd)) {
+        if (!red_qxl_get_cursor_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;
             if (worker->cursor_poll_tries < CMD_RING_POLL_RETRIES) {
                 worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
             } else if (worker->cursor_poll_tries == CMD_RING_POLL_RETRIES &&
-                       !qxl_get_interface(worker->qxl)->req_cursor_notification(worker->qxl)) {
+                       !red_qxl_req_cursor_notification(worker->qxl)) {
                 continue;
             }
             worker->cursor_poll_tries++;
@@ -204,12 +203,12 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
     worker->process_display_generation++;
     *ring_is_empty = FALSE;
     while (red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
-        if (!qxl_get_interface(worker->qxl)->get_command(worker->qxl, &ext_cmd)) {
+        if (!red_qxl_get_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;
             if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
                 worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
             } else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES &&
-                       !qxl_get_interface(worker->qxl)->req_cmd_notification(worker->qxl)) {
+                       !red_qxl_req_cmd_notification(worker->qxl)) {
                 continue;
             }
             worker->display_poll_tries++;
@@ -246,9 +245,9 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                 spice_warning("Invalid surface in QXL_CMD_UPDATE");
             } else {
                 display_channel_draw(worker->display_channel, &update.area, update.surface_id);
-                qxl_get_interface(worker->qxl)->notify_update(worker->qxl, update.update_id);
+                red_qxl_notify_update(worker->qxl, update.update_id);
             }
-            qxl_get_interface(worker->qxl)->release_resource(worker->qxl, update.release_info_ext);
+            red_qxl_release_resource(worker->qxl, update.release_info_ext);
             red_put_update_cmd(&update);
             break;
         }
@@ -263,7 +262,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
             /* alert: accessing message.data is insecure */
             spice_warning("MESSAGE: %s", message.data);
 #endif
-            qxl_get_interface(worker->qxl)->release_resource(worker->qxl, message.release_info_ext);
+            red_qxl_release_resource(worker->qxl, message.release_info_ext);
             red_put_message(&message);
             break;
         }
@@ -528,7 +527,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
     }
     if ((worker->display_channel == NULL) ||
         (RED_CHANNEL(worker->display_channel)->clients_num == 0)) {
-        qif->set_client_capabilities(worker->qxl, FALSE, caps);
+        red_qxl_set_client_capabilities(worker->qxl, FALSE, caps);
     } else {
         // Take least common denominator
         for (i = 0 ; i < sizeof(caps_available) / sizeof(caps_available[0]); ++i) {
@@ -541,7 +540,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
                     CLEAR_CAP(caps, caps_available[i]);
             }
         }
-        qif->set_client_capabilities(worker->qxl, TRUE, caps);
+        red_qxl_set_client_capabilities(worker->qxl, TRUE, caps);
     }
 }
 
@@ -587,8 +586,8 @@ static void handle_dev_update_async(void *opaque, void *payload)
                            msg->surface_id, &msg->qxl_area, msg->clear_dirty_region,
                            &qxl_dirty_rects, &num_dirty_rects);
 
-    qxl_get_interface(worker->qxl)->update_area_complete(worker->qxl, msg->surface_id,
-                                                         qxl_dirty_rects, num_dirty_rects);
+    red_qxl_update_area_complete(worker->qxl, msg->surface_id,
+                                 qxl_dirty_rects, num_dirty_rects);
     free(qxl_dirty_rects);
 }
 
@@ -847,9 +846,9 @@ static void handle_dev_oom(void *opaque, void *payload)
     while (red_process_display(worker, &ring_is_empty)) {
         red_channel_push(display_red_channel);
     }
-    if (qxl_get_interface(worker->qxl)->flush_resources(worker->qxl) == 0) {
+    if (red_qxl_flush_resources(worker->qxl) == 0) {
         display_channel_free_some(worker->display_channel);
-        qxl_get_interface(worker->qxl)->flush_resources(worker->qxl);
+        red_qxl_flush_resources(worker->qxl);
     }
     spice_debug("OOM2 #draw=%u, #glz_draw=%u current %u pipes %u",
                 display->drawable_count,
@@ -1473,7 +1472,7 @@ RedWorker* red_worker_new(QXLInstance *qxl)
     const char *record_filename;
     RedsState *reds = red_qxl_get_server(qxl->st);
 
-    qxl_get_interface(qxl)->get_init_info(qxl, &init_info);
+    red_qxl_get_init_info(qxl, &init_info);
 
     worker = spice_new0(RedWorker, 1);
     worker->core = event_loop_core;
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]