diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-09-27 15:44:38 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-02-13 17:37:59 +0100 |
commit | 52d941308bd9d8cfcf499008e52990fc81fa066a (patch) | |
tree | 7a339d1d6d375a4f9b0e5c7de042fc235ccbf83b | |
parent | 51d334c30a4c79c59d8c5185b3d307aea5ba1bd5 (diff) |
display: reuse code in display_channel_draw_until
-rw-r--r-- | server/display_channel.c | 44 | ||||
-rw-r--r-- | server/display_channel.h | 2 | ||||
-rw-r--r-- | server/red_worker.c | 5 |
3 files changed, 16 insertions, 35 deletions
diff --git a/server/display_channel.c b/server/display_channel.c index d7c740ca..f9587e7a 100644 --- a/server/display_channel.c +++ b/server/display_channel.c @@ -1287,20 +1287,18 @@ static void draw_until(DisplayChannel *display, RedSurface *surface, Drawable *l } while (now != last); } -static Drawable* current_find_intersects_rect(Ring *current, const SpiceRect *area) +static Drawable* current_find_intersects_rect(Ring *current, RingItem *from, + const SpiceRect *area) { - Ring *ring; - RingItem *ring_item; + RingItem *it; QRegion rgn; Drawable *last = NULL, *now; - ring = current; - ring_item = ring; region_init(&rgn); region_add(&rgn, area); - while ((ring_item = ring_next(ring, ring_item))) { - now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link); + for (it = from ?: ring_next(current, current); it != NULL; it = ring_next(current, it)) { + now = SPICE_CONTAINEROF(it, Drawable, surface_list_link); if (region_intersects(&rgn, &now->tree_item.base.rgn)) { last = now; break; @@ -1316,7 +1314,7 @@ static Drawable* current_find_intersects_rect(Ring *current, const SpiceRect *ar * than 'last' (exclusive). * FIXME: merge with display_channel_draw()? */ -void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, int surface_id, +void display_channel_draw_until(DisplayChannel *display, const SpiceRect *area, int surface_id, Drawable *last) { RedSurface *surface; @@ -1324,7 +1322,6 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i Ring *ring; RingItem *ring_item; Drawable *now; - QRegion rgn; spice_return_if_fail(last); spice_return_if_fail(ring_item_is_linked(&last->list_link)); @@ -1349,26 +1346,13 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i } } - if (!surface_last) { + if (!surface_last) return; - } - - ring = &surface->current_list; - ring_item = &surface_last->surface_list_link; - - region_init(&rgn); - region_add(&rgn, area); - - // find the first older drawable that intersects with the area - do { - now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link); - if (region_intersects(&rgn, &now->tree_item.base.rgn)) { - surface_last = now; - break; - } - } while ((ring_item = ring_next(ring, ring_item))); - region_destroy(&rgn); + last = current_find_intersects_rect(&surface->current_list, + &surface_last->surface_list_link, area); + if (!last) + return; /* drawable_draw may call display_channel_draw for the surfaces * 'now' depends on. Notice, that it is valid to call @@ -1379,9 +1363,7 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i * already been rendered. See the call for * red_handle_depends_on_target_surface in red_process_draw */ - if (surface_last) - draw_until(display, surface, surface_last); - + draw_until(display, surface, last); surface_update_dest(surface, area); } @@ -1400,7 +1382,7 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su surface = &display->surfaces[surface_id]; - last = current_find_intersects_rect(&surface->current_list, area); + last = current_find_intersects_rect(&surface->current_list, NULL, area); if (!last) return; diff --git a/server/display_channel.h b/server/display_channel.h index 86f91da5..1865eca0 100644 --- a/server/display_channel.h +++ b/server/display_channel.h @@ -237,7 +237,7 @@ typedef struct UpgradeItem { void display_channel_draw (DisplayChannel *display, const SpiceRect *area, int surface_id); -void display_channel_draw_till (DisplayChannel *display, +void display_channel_draw_until (DisplayChannel *display, const SpiceRect *area, int surface_id, Drawable *last); diff --git a/server/red_worker.c b/server/red_worker.c index ac50be4f..ccb07fe9 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -484,7 +484,7 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc, stream_id, stream->current != NULL); rect_debug(&upgrade_area); if (update_area_limit) { - display_channel_draw_till(DCC_TO_DC(dcc), &upgrade_area, 0, update_area_limit); + display_channel_draw_until(DCC_TO_DC(dcc), &upgrade_area, 0, update_area_limit); } else { display_channel_draw(DCC_TO_DC(dcc), &upgrade_area, 0); } @@ -1655,8 +1655,7 @@ static void red_add_lossless_drawable_dependencies(RedChannelClient *rcc, } else { sync_rendered = FALSE; for (i = 0; i < num_deps; i++) { - display_channel_draw_till(display, deps_areas[i], - deps_surfaces_ids[i], item); + display_channel_draw_until(display, deps_areas[i], deps_surfaces_ids[i], item); } } |