mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-07 21:03:10 +00:00
dcc: use PipeItem refcounting for ImageItem
Since the base class now implements refcounting, there's no need to re-invent it here.
This commit is contained in:
parent
75a2873c6b
commit
3bd6b215d3
@ -728,7 +728,7 @@ static void red_pipe_replace_rendered_drawables_with_images(DisplayChannelClient
|
||||
|
||||
spice_assert(image);
|
||||
red_channel_client_pipe_remove_and_release(RED_CHANNEL_CLIENT(dcc), &dpi->dpi_pipe_item);
|
||||
pipe_item = &image->link;
|
||||
pipe_item = &image->base;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1949,7 +1949,7 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
|
||||
chunks = spice_chunks_new_linear(item->data, bitmap.stride * bitmap.y);
|
||||
bitmap.data = chunks;
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, &item->link);
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, &item->base);
|
||||
|
||||
copy.base.surface_id = item->surface_id;
|
||||
copy.base.box.left = item->pos.x;
|
||||
|
||||
19
server/dcc.c
19
server/dcc.c
@ -184,9 +184,8 @@ ImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc, int surface_id,
|
||||
|
||||
item = (ImageItem *)spice_malloc_n_m(height, stride, sizeof(ImageItem));
|
||||
|
||||
pipe_item_init(&item->link, PIPE_ITEM_TYPE_IMAGE);
|
||||
pipe_item_init(&item->base, PIPE_ITEM_TYPE_IMAGE);
|
||||
|
||||
item->refs = 1;
|
||||
item->surface_id = surface_id;
|
||||
item->image_format =
|
||||
spice_bitmap_from_surface_type(surface->context.format);
|
||||
@ -214,9 +213,9 @@ ImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc, int surface_id,
|
||||
}
|
||||
|
||||
if (pos) {
|
||||
red_channel_client_pipe_add_after(RED_CHANNEL_CLIENT(dcc), &item->link, pos);
|
||||
red_channel_client_pipe_add_after(RED_CHANNEL_CLIENT(dcc), &item->base, pos);
|
||||
} else {
|
||||
red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &item->link);
|
||||
red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &item->base);
|
||||
}
|
||||
|
||||
return item;
|
||||
@ -1591,14 +1590,6 @@ int dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mess
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void image_item_unref(ImageItem *item)
|
||||
{
|
||||
if (--item->refs != 0)
|
||||
return;
|
||||
|
||||
free(item);
|
||||
}
|
||||
|
||||
static void upgrade_item_unref(DisplayChannel *display, UpgradeItem *item)
|
||||
{
|
||||
if (--item->refs != 0)
|
||||
@ -1624,7 +1615,7 @@ static void release_item_after_push(DisplayChannelClient *dcc, PipeItem *item)
|
||||
upgrade_item_unref(display, (UpgradeItem *)item);
|
||||
break;
|
||||
case PIPE_ITEM_TYPE_IMAGE:
|
||||
image_item_unref((ImageItem *)item);
|
||||
pipe_item_unref(item);
|
||||
break;
|
||||
case PIPE_ITEM_TYPE_GL_SCANOUT:
|
||||
case PIPE_ITEM_TYPE_GL_DRAW:
|
||||
@ -1674,7 +1665,7 @@ static void release_item_before_push(DisplayChannelClient *dcc, PipeItem *item)
|
||||
upgrade_item_unref(display, (UpgradeItem *)item);
|
||||
break;
|
||||
case PIPE_ITEM_TYPE_IMAGE:
|
||||
image_item_unref((ImageItem *)item);
|
||||
pipe_item_unref(item);
|
||||
break;
|
||||
case PIPE_ITEM_TYPE_CREATE_SURFACE: {
|
||||
SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(item, SurfaceCreateItem,
|
||||
|
||||
@ -136,8 +136,7 @@ typedef struct GlDrawItem {
|
||||
} GlDrawItem;
|
||||
|
||||
typedef struct ImageItem {
|
||||
PipeItem link;
|
||||
int refs;
|
||||
PipeItem base;
|
||||
SpicePoint pos;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@ -1980,7 +1980,7 @@ static void hold_item(RedChannelClient *rcc, PipeItem *item)
|
||||
((UpgradeItem *)item)->refs++;
|
||||
break;
|
||||
case PIPE_ITEM_TYPE_IMAGE:
|
||||
((ImageItem *)item)->refs++;
|
||||
pipe_item_ref(item);
|
||||
break;
|
||||
default:
|
||||
spice_warn_if_reached();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user