[Spice-devel] [spice] Use display_channel_surface_has_canvas() instead of free coding it
Frediano Ziglio
fziglio at redhat.com
Thu Mar 21 13:16:01 UTC 2019
>
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> ---
> server/dcc.c | 2 +-
> server/display-channel.c | 16 ++++++++--------
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/server/dcc.c b/server/dcc.c
> index ae7b4380f..a05b6e59e 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -579,7 +579,7 @@ void dcc_start(DisplayChannelClient *dcc)
> return;
>
> red_channel_client_ack_zero_messages_window(rcc);
> - if (display->priv->surfaces[0].context.canvas) {
> + if (display_channel_surface_has_canvas(display, 0)) {
> display_channel_current_flush(display, 0);
> red_channel_client_pipe_add_type(rcc,
> RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
> dcc_create_surface(dcc, 0);
> diff --git a/server/display-channel.c b/server/display-channel.c
> index e179abfd3..cf12e99bf 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -108,7 +108,7 @@ display_channel_finalize(GObject *object)
> spice_assert(ring_is_empty(&self->priv->streams));
>
> for (count = 0; count < NUM_SURFACES; ++count) {
> - spice_assert(self->priv->surfaces[count].context.canvas ==
> NULL);
> + spice_assert(!display_channel_surface_has_canvas(self, count));
> }
> }
>
> @@ -1498,7 +1498,7 @@ void display_channel_flush_all_surfaces(DisplayChannel
> *display)
> int x;
>
> for (x = 0; x < NUM_SURFACES; ++x) {
> - if (display->priv->surfaces[x].context.canvas) {
> + if (display_channel_surface_has_canvas(display, x)) {
> display_channel_current_flush(display, x);
> }
> }
> @@ -2072,7 +2072,7 @@ void
> display_channel_destroy_surface_wait(DisplayChannel *display, uint32_t surf
> {
> if (!display_channel_validate_surface(display, surface_id))
> return;
> - if (!display->priv->surfaces[surface_id].context.canvas)
> + if (!display_channel_surface_has_canvas(display, surface_id))
> return;
>
> draw_depend_on_me(display, surface_id);
> @@ -2092,12 +2092,12 @@ void display_channel_destroy_surfaces(DisplayChannel
> *display)
> spice_debug("trace");
> //to handle better
> for (i = 0; i < NUM_SURFACES; ++i) {
> - if (display->priv->surfaces[i].context.canvas) {
> + if (display_channel_surface_has_canvas(display, i)) {
> display_channel_destroy_surface_wait(display, i);
> - if (display->priv->surfaces[i].context.canvas) {
> + if (display_channel_surface_has_canvas(display, i)) {
> display_channel_surface_unref(display, i);
> }
> - spice_assert(!display->priv->surfaces[i].context.canvas);
> + spice_assert(!display_channel_surface_has_canvas(display, i));
> }
> }
> spice_warn_if_fail(ring_is_empty(&display->priv->streams));
> @@ -2424,7 +2424,7 @@ gboolean
> display_channel_validate_surface(DisplayChannel *display, uint32_t surf
> spice_warning("invalid surface_id %u", surface_id);
> return FALSE;
> }
> - if (!display->priv->surfaces[surface_id].context.canvas) {
> + if (!display_channel_surface_has_canvas(display, surface_id)) {
> spice_warning("canvas address is %p for %d (and is NULL)",
> &(display->priv->surfaces[surface_id].context.canvas),
> surface_id);
> spice_warning("failed on %d", surface_id);
> @@ -2462,7 +2462,7 @@ void
> display_channel_set_monitors_config_to_primary(DisplayChannel *display)
> QXLHead head = { 0, };
> uint16_t old_max = 1;
>
> - spice_return_if_fail(display->priv->surfaces[0].context.canvas);
> + spice_return_if_fail(display_channel_surface_has_canvas(display, 0));
>
> if (display->priv->monitors_config) {
> old_max = display->priv->monitors_config->max_allowed;
My paranoia level is saying that this function should be inlined, on the other
hand is also used in red-worker.c where can't be inlined.
Frediano
More information about the Spice-devel
mailing list