From 4a1668a755fb2af6e27a0ab7acb69c6e84842200 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sat, 14 Sep 2013 03:21:28 +0200 Subject: worker: move red_destroy_surface_item() Acked-by: Jonathon Jongsma --- server/display-channel.c | 36 ++++++++++++++++++++++++++++++++++++ server/display-channel.h | 12 ++++++++++++ server/red_worker.c | 43 +------------------------------------------ 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/server/display-channel.c b/server/display-channel.c index 8775496b..b5d8830a 100644 --- a/server/display-channel.c +++ b/server/display-channel.c @@ -226,6 +226,42 @@ void dcc_push_monitors_config(DisplayChannelClient *dcc) red_channel_client_push(&dcc->common.base); } +static SurfaceDestroyItem *surface_destroy_item_new(RedChannel *channel, + uint32_t surface_id) +{ + SurfaceDestroyItem *destroy; + + destroy = spice_malloc(sizeof(SurfaceDestroyItem)); + destroy->surface_destroy.surface_id = surface_id; + red_channel_pipe_item_init(channel, &destroy->pipe_item, + PIPE_ITEM_TYPE_DESTROY_SURFACE); + + return destroy; +} + +void dcc_push_destroy_surface(DisplayChannelClient *dcc, uint32_t surface_id) +{ + DisplayChannel *display; + RedChannel *channel; + SurfaceDestroyItem *destroy; + + if (!dcc) { + return; + } + + display = DCC_TO_DC(dcc); + channel = RED_CHANNEL(display); + + if (COMMON_CHANNEL(display)->during_target_migrate || + !dcc->surface_client_created[surface_id]) { + return; + } + + dcc->surface_client_created[surface_id] = FALSE; + destroy = surface_destroy_item_new(channel, surface_id); + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &destroy->pipe_item); +} + int display_channel_get_streams_timeout(DisplayChannel *display) { int timeout = INT_MAX; diff --git a/server/display-channel.h b/server/display-channel.h index 24fb3541..19366df3 100644 --- a/server/display-channel.h +++ b/server/display-channel.h @@ -236,6 +236,8 @@ DisplayChannelClient* dcc_new (DisplayCha uint32_t *caps, int num_caps); void dcc_push_monitors_config (DisplayChannelClient *dcc); +void dcc_push_destroy_surface (DisplayChannelClient *dcc, + uint32_t surface_id); typedef struct DrawablePipeItem { RingItem base; /* link for a list of pipe items held by Drawable */ @@ -313,6 +315,16 @@ struct DisplayChannel { stat_info_t lz4_stat; #endif }; +typedef struct SurfaceDestroyItem { + SpiceMsgSurfaceDestroy surface_destroy; + PipeItem pipe_item; +} SurfaceDestroyItem; + +typedef struct SurfaceCreateItem { + SpiceMsgSurfaceCreate surface_create; + PipeItem pipe_item; +} SurfaceCreateItem; + void display_channel_set_stream_video (DisplayChannel *display, int stream_video); diff --git a/server/red_worker.c b/server/red_worker.c index 7e755543..9d89d489 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -217,16 +217,6 @@ struct SpiceWatch { #define MAX_LZ_ENCODERS MAX_CACHE_CLIENTS -typedef struct SurfaceCreateItem { - SpiceMsgSurfaceCreate surface_create; - PipeItem pipe_item; -} SurfaceCreateItem; - -typedef struct SurfaceDestroyItem { - SpiceMsgSurfaceDestroy surface_destroy; - PipeItem pipe_item; -} SurfaceDestroyItem; - #define MAX_PIPE_SIZE 50 #define WIDE_CLIENT_ACK_WINDOW 40 @@ -959,37 +949,6 @@ static void drawables_init(RedWorker *worker) } -static SurfaceDestroyItem *get_surface_destroy_item(RedChannel *channel, - uint32_t surface_id) -{ - SurfaceDestroyItem *destroy; - - destroy = spice_malloc(sizeof(SurfaceDestroyItem)); - - destroy->surface_destroy.surface_id = surface_id; - - red_channel_pipe_item_init(channel, - &destroy->pipe_item, PIPE_ITEM_TYPE_DESTROY_SURFACE); - - return destroy; -} - -static inline void red_destroy_surface_item(RedWorker *worker, - DisplayChannelClient *dcc, uint32_t surface_id) -{ - SurfaceDestroyItem *destroy; - RedChannel *channel; - - if (!dcc || worker->display_channel->common.during_target_migrate || - !dcc->surface_client_created[surface_id]) { - return; - } - dcc->surface_client_created[surface_id] = FALSE; - channel = RED_CHANNEL(worker->display_channel); - destroy = get_surface_destroy_item(channel, surface_id); - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &destroy->pipe_item); -} - static void stop_streams(DisplayChannel *display) { Ring *ring = &display->streams; @@ -1037,7 +996,7 @@ static void red_surface_unref(RedWorker *worker, uint32_t surface_id) region_destroy(&surface->draw_dirty_region); surface->context.canvas = NULL; FOREACH_DCC(worker->display_channel, link, next, dcc) { - red_destroy_surface_item(worker, dcc, surface_id); + dcc_push_destroy_surface(dcc, surface_id); } spice_warn_if(!ring_is_empty(&surface->depend_on_me)); -- cgit