[Spice-devel] [spice-server v2 3/9] qxl: Move red_drawable_unref/red_drawable_new

Frediano Ziglio fziglio at redhat.com
Tue Apr 17 18:57:55 UTC 2018


> 
> RedDrawable really is a RedDrawCmd which is parsed by red-parse-qxl.h
> This commit moves them close to the other functions creating/unref'ing
> QXL commands parsed by red-parse-qxl.h
> 

Does not seem a great reason to have different APIs from red-parse-qxl,
this and next patch seems to mix parsing with allocation, is not clear
why for some structure is separate and for some other bound.
Maybe we should join all (even surface and messages)?

> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> ---
>  server/red-parse-qxl.c | 21 +++++++++++++++++++++
>  server/red-parse-qxl.h |  2 ++
>  server/red-worker.c    | 20 --------------------
>  3 files changed, 23 insertions(+), 20 deletions(-)
> 
> diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
> index 4a45c0f76..245235082 100644
> --- a/server/red-parse-qxl.c
> +++ b/server/red-parse-qxl.c
> @@ -26,6 +26,7 @@
>  #include "red-common.h"
>  #include "red-qxl.h"
>  #include "memslot.h"
> +#include "red-qxl.h"

duplicate

>  #include "red-parse-qxl.h"
>  
>  /* Max size in bytes for any data field used in a QXL command.
> @@ -1480,3 +1481,23 @@ void red_put_cursor_cmd(RedCursorCmd *red)
>          red_qxl_release_resource(red->qxl, red->release_info_ext);
>      }
>  }
> +
> +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..0b507b93a 100644
> --- a/server/red-parse-qxl.h
> +++ b/server/red-parse-qxl.h
> @@ -64,6 +64,8 @@ static inline RedDrawable *red_drawable_ref(RedDrawable
> *drawable)
>      drawable->refs++;
>      return drawable;
>  }
> +RedDrawable *red_drawable_new(QXLInstance *qxl);
> +void red_drawable_unref(RedDrawable *red_drawable);
>  

duplicate (unref)

>  void red_drawable_unref(RedDrawable *red_drawable);
>  

here

> diff --git a/server/red-worker.c b/server/red-worker.c
> index eb927f3e0..8f806e8e3 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -99,16 +99,6 @@ static int display_is_connected(RedWorker *worker)
>          red_channel_is_connected(RED_CHANNEL(worker->display_channel));
>  }
>  
> -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;
> @@ -165,16 +155,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;

Frediano


More information about the Spice-devel mailing list