[Spice-devel] [spice-server v4 01/11] qxl: Move red_drawable_unref/red_drawable_new

Christophe Fergeau cfergeau at redhat.com
Thu Nov 29 12:50:03 UTC 2018


RedDrawable really is a RedDrawCmd which is parsed by red-parse-qxl.h
Moreover, red_drawable_ref() is already defined inline in
red-parse-qxl.h, and red_drawable_unref() is declared there too even if
its code is still in red-worker.c
This commit moves them close to the other functions creating/unref'ing
QXL commands parsed by red-parse-qxl.h.
---
 server/red-parse-qxl.c | 26 ++++++++++++++++++++++++++
 server/red-parse-qxl.h | 12 ++++--------
 server/red-worker.c    | 20 --------------------
 3 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 86abe3ca4..e1f547b7a 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1469,3 +1469,29 @@ void red_put_cursor_cmd(RedCursorCmd *red)
         red_qxl_release_resource(red->qxl, red->release_info_ext);
     }
 }
+
+RedDrawable *red_drawable_ref(RedDrawable *drawable)
+{
+    drawable->refs++;
+    return drawable;
+}
+
+void red_drawable_unref(RedDrawable *red_drawable)
+{
+    if (--red_drawable->refs) {
+        return;
+    }
+    red_qxl_release_resource(red_drawable->qxl, red_drawable->release_info_ext);
+    red_put_drawable(red_drawable);
+    g_free(red_drawable);
+}
+
+RedDrawable *red_drawable_new(QXLInstance *qxl)
+{
+    RedDrawable * red = g_new0(RedDrawable, 1);
+
+    red->refs = 1;
+    red->qxl = qxl;
+
+    return red;
+}
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index a33f36adb..3b815a860 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -59,14 +59,6 @@ typedef struct RedDrawable {
     } u;
 } RedDrawable;
 
-static inline RedDrawable *red_drawable_ref(RedDrawable *drawable)
-{
-    drawable->refs++;
-    return drawable;
-}
-
-void red_drawable_unref(RedDrawable *red_drawable);
-
 typedef struct RedUpdateCmd {
     QXLReleaseInfoExt release_info_ext;
     SpiceRect area;
@@ -118,6 +110,10 @@ typedef struct RedCursorCmd {
 
 void red_get_rect_ptr(SpiceRect *red, const QXLRect *qxl);
 
+RedDrawable *red_drawable_new(QXLInstance *qxl);
+RedDrawable *red_drawable_ref(RedDrawable *drawable);
+void red_drawable_unref(RedDrawable *red_drawable);
+
 bool red_get_drawable(RedMemSlotInfo *slots, int group_id,
                       RedDrawable *red, QXLPHYSICAL addr, uint32_t flags);
 void red_put_drawable(RedDrawable *red);
diff --git a/server/red-worker.c b/server/red-worker.c
index ccab9d960..d9ae792af 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -92,16 +92,6 @@ struct RedWorker {
     GMainLoop *loop;
 };
 
-void red_drawable_unref(RedDrawable *red_drawable)
-{
-    if (--red_drawable->refs) {
-        return;
-    }
-    red_qxl_release_resource(red_drawable->qxl, red_drawable->release_info_ext);
-    red_put_drawable(red_drawable);
-    g_free(red_drawable);
-}
-
 static gboolean red_process_cursor_cmd(RedWorker *worker, const QXLCommandExt *ext)
 {
     RedCursorCmd *cursor_cmd;
@@ -158,16 +148,6 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
     return n;
 }
 
-static RedDrawable *red_drawable_new(QXLInstance *qxl)
-{
-    RedDrawable * red = g_new0(RedDrawable, 1);
-
-    red->refs = 1;
-    red->qxl = qxl;
-
-    return red;
-}
-
 static gboolean red_process_surface_cmd(RedWorker *worker, QXLCommandExt *ext, gboolean loadvm)
 {
     RedSurfaceCmd surface_cmd;
-- 
2.19.1



More information about the Spice-devel mailing list