mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
Base FOREACH_DCC on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
9b5f93d1a7
commit
6d4db4f0bf
@ -174,7 +174,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
|
||||
RedSurface *surface = &display->priv->surfaces[surface_id];
|
||||
QXLInstance *qxl = display->common.qxl;
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
if (--surface->refs != 0) {
|
||||
return;
|
||||
@ -196,7 +196,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
|
||||
|
||||
region_destroy(&surface->draw_dirty_region);
|
||||
surface->context.canvas = NULL;
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
dcc_destroy_surface(dcc, surface_id);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
|
||||
{
|
||||
Ring *ring;
|
||||
RingItem *item;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
if (!red_channel_is_connected(RED_CHANNEL(display))) {
|
||||
@ -238,7 +238,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
|
||||
continue;
|
||||
}
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
|
||||
|
||||
if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
|
||||
@ -253,10 +253,10 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
|
||||
static void pipes_add_drawable(DisplayChannel *display, Drawable *drawable)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
spice_warn_if_fail(drawable->pipes == NULL);
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
dcc_prepend_drawable(dcc, drawable);
|
||||
}
|
||||
}
|
||||
@ -281,9 +281,9 @@ static void pipes_add_drawable_after(DisplayChannel *display,
|
||||
return;
|
||||
}
|
||||
if (num_other_linked != g_list_length(display->common.base.clients)) {
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
spice_debug("TODO: not O(n^2)");
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
int sent = 0;
|
||||
GList *l;
|
||||
for (l = pos_after->pipes; l != NULL; l = l->next) {
|
||||
@ -434,7 +434,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
|
||||
|
||||
DisplayChannelClient *dcc;
|
||||
GList *dpi_item;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
other_drawable->refs++;
|
||||
current_remove_drawable(display, other_drawable);
|
||||
@ -443,7 +443,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
|
||||
* (or will receive) other_drawable */
|
||||
dpi_item = g_list_first(other_drawable->pipes);
|
||||
/* dpi contains a sublist of dcc's, ordered the same */
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
if (dpi_item && dcc == ((RedDrawablePipeItem *) dpi_item->data)->dcc) {
|
||||
dpi_item = dpi_item->next;
|
||||
} else {
|
||||
@ -1163,24 +1163,24 @@ void display_channel_flush_all_surfaces(DisplayChannel *display)
|
||||
|
||||
void display_channel_free_glz_drawables_to_free(DisplayChannel *display)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
spice_return_if_fail(display);
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
image_encoders_free_glz_drawables_to_free(dcc_get_encoders(dcc));
|
||||
}
|
||||
}
|
||||
|
||||
void display_channel_free_glz_drawables(DisplayChannel *display)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
spice_return_if_fail(display);
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
image_encoders_free_glz_drawables(dcc_get_encoders(dcc));
|
||||
}
|
||||
}
|
||||
@ -1219,11 +1219,11 @@ void display_channel_free_some(DisplayChannel *display)
|
||||
{
|
||||
int n = 0;
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
spice_debug("#draw=%d, #glz_draw=%d", display->priv->drawable_count,
|
||||
display->priv->encoder_shared_data.glz_drawable_count);
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
ImageEncoders *encoders = dcc_get_encoders(dcc);
|
||||
|
||||
// encoding using the dictionary is prevented since the following operations might
|
||||
@ -1237,7 +1237,7 @@ void display_channel_free_some(DisplayChannel *display)
|
||||
free_one_drawable(display, TRUE);
|
||||
}
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
ImageEncoders *encoders = dcc_get_encoders(dcc);
|
||||
|
||||
image_encoders_glz_encode_unlock(encoders);
|
||||
@ -1703,10 +1703,10 @@ void display_channel_update(DisplayChannel *display,
|
||||
static void clear_surface_drawables_from_pipes(DisplayChannel *display, int surface_id,
|
||||
int wait_if_used)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
if (!dcc_clear_surface_drawables_from_pipe(dcc, surface_id, wait_if_used)) {
|
||||
red_channel_client_disconnect(RED_CHANNEL_CLIENT(dcc));
|
||||
}
|
||||
@ -1770,9 +1770,9 @@ void display_channel_destroy_surfaces(DisplayChannel *display)
|
||||
static void send_create_surface(DisplayChannel *display, int surface_id, int image_ready)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
dcc_create_surface(dcc, surface_id);
|
||||
if (image_ready)
|
||||
dcc_push_surface_image(dcc, surface_id);
|
||||
|
||||
@ -214,14 +214,9 @@ struct DisplayChannel {
|
||||
DisplayChannelPrivate priv[1];
|
||||
};
|
||||
|
||||
#define FOREACH_DCC(channel, _link, _next, _data) \
|
||||
for (_link = (channel ? RED_CHANNEL(channel)->clients : NULL), \
|
||||
_next = (_link ? _link->next : NULL), \
|
||||
_data = (_link ? _link->data : NULL); \
|
||||
_link; \
|
||||
_link = _next, \
|
||||
_next = (_link ? _link->next : NULL), \
|
||||
_data = (_link ? _link->data : NULL))
|
||||
#define FOREACH_DCC(_channel, _iter, _data) \
|
||||
GLIST_FOREACH((_channel ? RED_CHANNEL(_channel)->clients : NULL), \
|
||||
_iter, DisplayChannelClient, _data)
|
||||
|
||||
int display_channel_get_stream_id(DisplayChannel *display, Stream *stream);
|
||||
|
||||
|
||||
@ -590,9 +590,9 @@ static void handle_dev_destroy_surfaces(void *opaque, void *payload)
|
||||
static void red_worker_push_monitors_config(RedWorker *worker)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *item, *next;
|
||||
GListIter iter;
|
||||
|
||||
FOREACH_DCC(worker->display_channel, item, next, dcc) {
|
||||
FOREACH_DCC(worker->display_channel, iter, dcc) {
|
||||
dcc_push_monitors_config(dcc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,13 +96,13 @@ static RedPipeItem *stream_destroy_item_new(StreamAgent *agent)
|
||||
void stream_stop(DisplayChannel *display, Stream *stream)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
spice_return_if_fail(ring_item_is_linked(&stream->link));
|
||||
spice_return_if_fail(!stream->current);
|
||||
|
||||
spice_debug("stream %d", display_channel_get_stream_id(display, stream));
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
StreamAgent *stream_agent;
|
||||
|
||||
stream_agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
|
||||
@ -279,7 +279,7 @@ static bool is_next_stream_frame(DisplayChannel *display,
|
||||
static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
|
||||
spice_assert(drawable && stream);
|
||||
spice_assert(!drawable->stream && !stream->current);
|
||||
@ -298,7 +298,7 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *s
|
||||
stream->num_input_frames++;
|
||||
}
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
StreamAgent *agent;
|
||||
QRegion clip_in_draw_dest;
|
||||
|
||||
@ -335,7 +335,7 @@ static void before_reattach_stream(DisplayChannel *display,
|
||||
int index;
|
||||
StreamAgent *agent;
|
||||
GList *dpi_link, *dpi_next;
|
||||
GList *link, *link_next;
|
||||
GListIter iter;
|
||||
|
||||
spice_return_if_fail(stream->current);
|
||||
|
||||
@ -374,7 +374,7 @@ static void before_reattach_stream(DisplayChannel *display,
|
||||
}
|
||||
|
||||
|
||||
FOREACH_DCC(display, link, link_next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
double drop_factor;
|
||||
|
||||
agent = dcc_get_stream_agent(dcc, index);
|
||||
@ -419,7 +419,7 @@ static Stream *display_channel_stream_try_new(DisplayChannel *display)
|
||||
static void display_channel_create_stream(DisplayChannel *display, Drawable *drawable)
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
Stream *stream;
|
||||
SpiceRect* src_rect;
|
||||
|
||||
@ -456,7 +456,7 @@ static void display_channel_create_stream(DisplayChannel *display, Drawable *dra
|
||||
stream->input_fps_start_time = drawable->creation_time;
|
||||
display->priv->streams_size_total += stream->width * stream->height;
|
||||
display->priv->stream_count++;
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
dcc_create_stream(dcc, stream);
|
||||
}
|
||||
spice_debug("stream %d %dx%d (%d, %d) (%d, %d) %u fps",
|
||||
@ -903,10 +903,10 @@ clear_vis_region:
|
||||
static void detach_stream_gracefully(DisplayChannel *display, Stream *stream,
|
||||
Drawable *update_area_limit)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
dcc_detach_stream_gracefully(dcc, stream, update_area_limit);
|
||||
}
|
||||
if (stream->current) {
|
||||
@ -928,7 +928,7 @@ void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *dr
|
||||
{
|
||||
Ring *ring = &display->priv->streams;
|
||||
RingItem *item = ring_get_head(ring);
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
DisplayChannelClient *dcc;
|
||||
bool is_connected = red_channel_is_connected(RED_CHANNEL(display));
|
||||
|
||||
@ -937,7 +937,7 @@ void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *dr
|
||||
int detach = 0;
|
||||
item = ring_next(ring, item);
|
||||
|
||||
FOREACH_DCC(display, link, next, dcc) {
|
||||
FOREACH_DCC(display, iter, dcc) {
|
||||
StreamAgent *agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
|
||||
|
||||
if (region_intersects(&agent->vis_region, region)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user