[Spice-devel] [PATCH 07/18] server/red_worker: extract common_release_pipe_item from red_pipe_clear
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Feb 8 13:07:40 PST 2011
Hopefully we can find a more elegant solution to the downcasting
introduced in patch 03: CommonChannel *common =
SPICE_CONTAINEROF(channel, CommonChannel, base);
I would rather modify the function common_release_pipe_item(RedChannel
*channel, PipeItem *item) to be:
common_release_pipe_item(CommonChannel *common, PipeItem *item).
On Mon, Feb 7, 2011 at 7:19 PM, Alon Levy <alevy at redhat.com> wrote:
> ---
> server/red_worker.c | 106 +++++++++++++++++++++++++++------------------------
> 1 files changed, 56 insertions(+), 50 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 76d0ef6..08aeef2 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -1354,63 +1354,69 @@ static void release_upgrade_item(RedWorker* worker, UpgradeItem *item)
> }
> }
>
> +static void common_release_pipe_item(RedChannel *channel, PipeItem *item)
> +{
> + CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
> +
> + switch (item->type) {
> + case PIPE_ITEM_TYPE_DRAW:
> + release_drawable(common->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
> + break;
> + case PIPE_ITEM_TYPE_CURSOR:
> + red_release_cursor(common->worker, (CursorItem *)item);
> + break;
> + case PIPE_ITEM_TYPE_UPGRADE:
> + release_upgrade_item(common->worker, (UpgradeItem *)item);
> + break;
> + case PIPE_ITEM_TYPE_PIXMAP_RESET:
> + case PIPE_ITEM_TYPE_PIXMAP_SYNC:
> + case PIPE_ITEM_TYPE_INVAL_ONE:
> + case PIPE_ITEM_TYPE_MIGRATE:
> + case PIPE_ITEM_TYPE_SET_ACK:
> + case PIPE_ITEM_TYPE_CURSOR_INIT:
> + case PIPE_ITEM_TYPE_VERB:
> + case PIPE_ITEM_TYPE_MIGRATE_DATA:
> + case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
> + case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
> + free(item);
> + break;
> + case PIPE_ITEM_TYPE_IMAGE:
> + release_image_item((ImageItem *)item);
> + break;
> + case PIPE_ITEM_TYPE_STREAM_CREATE:
> + red_display_release_stream((DisplayChannel *)channel,
> + SPICE_CONTAINEROF(item, StreamAgent, create_item));
> + break;
> + case PIPE_ITEM_TYPE_STREAM_CLIP:
> + red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem*)item);
> + break;
> + case PIPE_ITEM_TYPE_STREAM_DESTROY:
> + red_display_release_stream((DisplayChannel *)channel,
> + SPICE_CONTAINEROF(item, StreamAgent, destroy_item));
> + break;
> + case PIPE_ITEM_TYPE_CREATE_SURFACE: {
> + SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(item, SurfaceCreateItem,
> + pipe_item);
> + free(surface_create);
> + break;
> + }
> + case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
> + SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(item, SurfaceDestroyItem,
> + pipe_item);
> + free(surface_destroy);
> + break;
> + }
> + }
> +}
> +
> static void red_pipe_clear(RedChannel *channel)
> {
> PipeItem *item;
> - CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
>
> ASSERT(channel);
> while ((item = (PipeItem *)ring_get_head(&channel->pipe))) {
> ring_remove(&item->link);
> - switch (item->type) {
> - case PIPE_ITEM_TYPE_DRAW:
> - release_drawable(common->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
> - break;
> - case PIPE_ITEM_TYPE_CURSOR:
> - red_release_cursor(common->worker, (CursorItem *)item);
> - break;
> - case PIPE_ITEM_TYPE_UPGRADE:
> - release_upgrade_item(common->worker, (UpgradeItem *)item);
> - break;
> - case PIPE_ITEM_TYPE_PIXMAP_RESET:
> - case PIPE_ITEM_TYPE_PIXMAP_SYNC:
> - case PIPE_ITEM_TYPE_INVAL_ONE:
> - case PIPE_ITEM_TYPE_MIGRATE:
> - case PIPE_ITEM_TYPE_SET_ACK:
> - case PIPE_ITEM_TYPE_CURSOR_INIT:
> - case PIPE_ITEM_TYPE_VERB:
> - case PIPE_ITEM_TYPE_MIGRATE_DATA:
> - case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
> - case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
> - free(item);
> - break;
> - case PIPE_ITEM_TYPE_IMAGE:
> - release_image_item((ImageItem *)item);
> - break;
> - case PIPE_ITEM_TYPE_STREAM_CREATE:
> - red_display_release_stream((DisplayChannel *)channel,
> - SPICE_CONTAINEROF(item, StreamAgent, create_item));
> - break;
> - case PIPE_ITEM_TYPE_STREAM_CLIP:
> - red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem*)item);
> - break;
> - case PIPE_ITEM_TYPE_STREAM_DESTROY:
> - red_display_release_stream((DisplayChannel *)channel,
> - SPICE_CONTAINEROF(item, StreamAgent, destroy_item));
> - break;
> - case PIPE_ITEM_TYPE_CREATE_SURFACE: {
> - SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(item, SurfaceCreateItem,
> - pipe_item);
> - free(surface_create);
> - break;
> - }
> - case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
> - SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(item, SurfaceDestroyItem,
> - pipe_item);
> - free(surface_destroy);
> - break;
> - }
> - }
> + common_release_pipe_item(channel, item);
> }
> channel->pipe_size = 0;
> }
> --
> 1.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
--
Marc-André Lureau
More information about the Spice-devel
mailing list