[Spice-commits] 5 commits - server/display-channel.c server/display-channel.h server/red_worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Nov 6 01:38:21 PST 2015


 server/display-channel.c |  100 +++++++++++++++++++++++++
 server/display-channel.h |    3 
 server/red_worker.c      |  183 +++++++++--------------------------------------
 3 files changed, 141 insertions(+), 145 deletions(-)

New commits:
commit ed70743f7c65a90b929c95b027080dc6efb5a945
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Sep 13 21:25:29 2013 +0200

    worker: move some compress stats to display
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index 3dc5a94..5deab13 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -16,6 +16,106 @@
 */
 #include "display-channel.h"
 
+void display_channel_compress_stats_reset(DisplayChannel *display_channel)
+{
+    spice_return_if_fail(display_channel);
+
+#ifdef COMPRESS_STAT
+    stat_reset(&worker->display_channel->quic_stat);
+    stat_reset(&worker->display_channel->lz_stat);
+    stat_reset(&worker->display_channel->glz_stat);
+    stat_reset(&worker->display_channel->jpeg_stat);
+    stat_reset(&worker->display_channel->zlib_glz_stat);
+    stat_reset(&worker->display_channel->jpeg_alpha_stat);
+    stat_reset(&worker->display_channel->lz4_stat);
+#endif
+}
+
+void display_channel_compress_stats_print(const DisplayChannel *display_channel)
+{
+    spice_return_if_fail(display_channel);
+
+#ifdef COMPRESS_STAT
+    uint64_t glz_enc_size;
+
+    glz_enc_size = display_channel->enable_zlib_glz_wrap ?
+                       display_channel->zlib_glz_stat.comp_size :
+                       display_channel->glz_stat.comp_size;
+
+    spice_info("==> Compression stats for display %u", display_channel->common.id);
+    spice_info("Method   \t  count  \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
+    spice_info("QUIC     \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->quic_stat.count,
+               stat_byte_to_mega(display_channel->quic_stat.orig_size),
+               stat_byte_to_mega(display_channel->quic_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->quic_stat.total)
+               );
+    spice_info("GLZ      \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->glz_stat.count,
+               stat_byte_to_mega(display_channel->glz_stat.orig_size),
+               stat_byte_to_mega(display_channel->glz_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->glz_stat.total)
+               );
+    spice_info("ZLIB GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->zlib_glz_stat.count,
+               stat_byte_to_mega(display_channel->zlib_glz_stat.orig_size),
+               stat_byte_to_mega(display_channel->zlib_glz_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->zlib_glz_stat.total)
+               );
+    spice_info("LZ       \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->lz_stat.count,
+               stat_byte_to_mega(display_channel->lz_stat.orig_size),
+               stat_byte_to_mega(display_channel->lz_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->lz_stat.total)
+               );
+    spice_info("JPEG     \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->jpeg_stat.count,
+               stat_byte_to_mega(display_channel->jpeg_stat.orig_size),
+               stat_byte_to_mega(display_channel->jpeg_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->jpeg_stat.total)
+               );
+    spice_info("JPEG-RGBA\t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->jpeg_alpha_stat.count,
+               stat_byte_to_mega(display_channel->jpeg_alpha_stat.orig_size),
+               stat_byte_to_mega(display_channel->jpeg_alpha_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->jpeg_alpha_stat.total)
+               );
+    spice_info("LZ4      \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->lz4_stat.count,
+               stat_byte_to_mega(display_channel->lz4_stat.orig_size),
+               stat_byte_to_mega(display_channel->lz4_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->lz4_stat.total)
+               );
+    spice_info("-------------------------------------------------------------------");
+    spice_info("Total    \t%8d\t%13.2f\t%12.2f\t%12.2f",
+               display_channel->lz_stat.count + display_channel->glz_stat.count +
+                                                display_channel->quic_stat.count +
+                                                display_channel->jpeg_stat.count +
+                                                display_channel->lz4_stat.count +
+                                                display_channel->jpeg_alpha_stat.count,
+               stat_byte_to_mega(display_channel->lz_stat.orig_size +
+                                 display_channel->glz_stat.orig_size +
+                                 display_channel->quic_stat.orig_size +
+                                 display_channel->jpeg_stat.orig_size +
+                                 display_channel->lz4_stat.orig_size +
+                                 display_channel->jpeg_alpha_stat.orig_size),
+               stat_byte_to_mega(display_channel->lz_stat.comp_size +
+                                 glz_enc_size +
+                                 display_channel->quic_stat.comp_size +
+                                 display_channel->jpeg_stat.comp_size +
+                                 display_channel->lz4_stat.comp_size +
+                                 display_channel->jpeg_alpha_stat.comp_size),
+               stat_cpu_time_to_sec(display_channel->lz_stat.total +
+                                    display_channel->glz_stat.total +
+                                    display_channel->zlib_glz_stat.total +
+                                    display_channel->quic_stat.total +
+                                    display_channel->jpeg_stat.total +
+                                    display_channel->lz4_stat.total +
+                                    display_channel->jpeg_alpha_stat.total)
+               );
+#endif
+}
+
 DisplayChannelClient *dcc_new(DisplayChannel *display,
                               RedClient *client, RedsStream *stream,
                               int mig_target,
diff --git a/server/display-channel.h b/server/display-channel.h
index d6d65e0..827a9d4 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -360,4 +360,7 @@ struct DisplayChannel {
 #endif
 };
 
+void                       display_channel_compress_stats_print      (const DisplayChannel *display);
+void                       display_channel_compress_stats_reset      (DisplayChannel *display);
+
 #endif /* DISPLAY_CHANNEL_H_ */
diff --git a/server/red_worker.c b/server/red_worker.c
index 31720d5..3ffb576 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -604,95 +604,6 @@ void drawable_pipe_item_unref(DrawablePipeItem *dpi)
     free(dpi);
 }
 
-
-#ifdef COMPRESS_STAT
-static void print_compress_stats(DisplayChannel *display_channel)
-{
-    uint64_t glz_enc_size;
-
-    if (!display_channel) {
-        return;
-    }
-
-    glz_enc_size = display_channel->enable_zlib_glz_wrap ?
-                       display_channel->zlib_glz_stat.comp_size :
-                       display_channel->glz_stat.comp_size;
-
-    spice_info("==> Compression stats for display %u", display_channel->common.base.id);
-    spice_info("Method   \t  count  \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
-    spice_info("QUIC     \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->quic_stat.count,
-               stat_byte_to_mega(display_channel->quic_stat.orig_size),
-               stat_byte_to_mega(display_channel->quic_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->quic_stat.total)
-               );
-    spice_info("GLZ      \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->glz_stat.count,
-               stat_byte_to_mega(display_channel->glz_stat.orig_size),
-               stat_byte_to_mega(display_channel->glz_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->glz_stat.total)
-               );
-    spice_info("ZLIB GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->zlib_glz_stat.count,
-               stat_byte_to_mega(display_channel->zlib_glz_stat.orig_size),
-               stat_byte_to_mega(display_channel->zlib_glz_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->zlib_glz_stat.total)
-               );
-    spice_info("LZ       \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->lz_stat.count,
-               stat_byte_to_mega(display_channel->lz_stat.orig_size),
-               stat_byte_to_mega(display_channel->lz_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->lz_stat.total)
-               );
-    spice_info("JPEG     \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->jpeg_stat.count,
-               stat_byte_to_mega(display_channel->jpeg_stat.orig_size),
-               stat_byte_to_mega(display_channel->jpeg_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->jpeg_stat.total)
-               );
-    spice_info("JPEG-RGBA\t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->jpeg_alpha_stat.count,
-               stat_byte_to_mega(display_channel->jpeg_alpha_stat.orig_size),
-               stat_byte_to_mega(display_channel->jpeg_alpha_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->jpeg_alpha_stat.total)
-               );
-    spice_info("LZ4      \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->lz4_stat.count,
-               stat_byte_to_mega(display_channel->lz4_stat.orig_size),
-               stat_byte_to_mega(display_channel->lz4_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->lz4_stat.total)
-               );
-    spice_info("-------------------------------------------------------------------");
-    spice_info("Total    \t%8d\t%13.2f\t%12.2f\t%12.2f",
-               display_channel->lz_stat.count + display_channel->glz_stat.count +
-                                                display_channel->quic_stat.count +
-                                                display_channel->jpeg_stat.count +
-                                                display_channel->lz4_stat.count +
-                                                display_channel->jpeg_alpha_stat.count,
-               stat_byte_to_mega(display_channel->lz_stat.orig_size +
-                                 display_channel->glz_stat.orig_size +
-                                 display_channel->quic_stat.orig_size +
-                                 display_channel->jpeg_stat.orig_size +
-                                 display_channel->lz4_stat.orig_size +
-                                 display_channel->jpeg_alpha_stat.orig_size),
-               stat_byte_to_mega(display_channel->lz_stat.comp_size +
-                                 glz_enc_size +
-                                 display_channel->quic_stat.comp_size +
-                                 display_channel->jpeg_stat.comp_size +
-                                 display_channel->lz4_stat.comp_size +
-                                 display_channel->jpeg_alpha_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->lz_stat.total +
-                                    display_channel->glz_stat.total +
-                                    display_channel->zlib_glz_stat.total +
-                                    display_channel->quic_stat.total +
-                                    display_channel->jpeg_stat.total +
-                                    display_channel->lz4_stat.total +
-                                    display_channel->jpeg_alpha_stat.total)
-               );
-}
-
-#endif
-
 QXLInstance* red_worker_get_qxl(RedWorker *worker)
 {
     spice_return_val_if_fail(worker != NULL, NULL);
@@ -7978,9 +7889,7 @@ static void display_channel_client_on_disconnect(RedChannelClient *rcc)
     worker = common->worker;
     display_channel = (DisplayChannel *)rcc->channel;
     spice_assert(display_channel == worker->display_channel);
-#ifdef COMPRESS_STAT
-    print_compress_stats(display_channel);
-#endif
+    display_channel_compress_stats_print(display_channel);
     pixmap_cache_unref(dcc->pixmap_cache);
     dcc->pixmap_cache = NULL;
     red_release_glz(dcc);
@@ -10018,18 +9927,9 @@ void handle_dev_set_compression(void *opaque, void *payload)
     default:
         spice_warning("ic invalid");
     }
-#ifdef COMPRESS_STAT
-    print_compress_stats(worker->display_channel);
-    if (worker->display_channel) {
-        stat_reset(&worker->display_channel->quic_stat);
-        stat_reset(&worker->display_channel->lz_stat);
-        stat_reset(&worker->display_channel->glz_stat);
-        stat_reset(&worker->display_channel->jpeg_stat);
-        stat_reset(&worker->display_channel->zlib_glz_stat);
-        stat_reset(&worker->display_channel->jpeg_alpha_stat);
-        stat_reset(&worker->display_channel->lz4_stat);
-    }
-#endif
+
+    display_channel_compress_stats_print(worker->display_channel);
+    display_channel_compress_stats_reset(worker->display_channel);
 }
 
 void handle_dev_set_streaming_video(void *opaque, void *payload)
commit e839dc23b3401fd93f13473af3301240418b0820
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Sep 13 21:11:37 2013 +0200

    worker: rename WORKER_FOREACH_DCC_SAFE macro to FOREACH_DCC
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 0788eea..31720d5 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -552,10 +552,8 @@ static void display_channel_client_release_item_after_push(DisplayChannelClient
     SAFE_FOREACH(link, next, channel,  &(channel)->clients, dcc, LINK_TO_DCC(link))
 
 
-#define WORKER_FOREACH_DCC_SAFE(worker, link, next, dcc)      \
-    DCC_FOREACH_SAFE(link, next, dcc,                         \
-                ((((worker) && (worker)->display_channel))?   \
-                 (&(worker)->display_channel->common.base) : NULL))
+#define FOREACH_DCC(display_channel, link, next, dcc)      \
+    DCC_FOREACH_SAFE(link, next, dcc, RED_CHANNEL(display_channel))
 
 
 #define LINK_TO_DPI(ptr) SPICE_CONTAINEROF((ptr), DrawablePipeItem, base)
@@ -811,7 +809,7 @@ static void red_pipes_add_drawable(RedWorker *worker, Drawable *drawable)
     RingItem *dcc_ring_item, *next;
 
     spice_warn_if(!ring_is_empty(&drawable->pipes));
-    WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
         dcc_add_drawable(dcc, drawable);
     }
 }
@@ -851,7 +849,7 @@ static inline void red_pipes_add_drawable_after(RedWorker *worker,
     if (num_other_linked != worker->display_channel->common.base.clients_num) {
         RingItem *worker_item, *next;
         spice_debug("TODO: not O(n^2)");
-        WORKER_FOREACH_DCC_SAFE(worker, worker_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, worker_item, next, dcc) {
             int sent = 0;
             DRAWABLE_FOREACH_DPI_SAFE(pos_after, dpi_link, dpi_next, dpi_pos_after) {
                 if (dpi_pos_after->dcc == dcc) {
@@ -1044,7 +1042,7 @@ static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id)
 
         region_destroy(&surface->draw_dirty_region);
         surface->context.canvas = NULL;
-        WORKER_FOREACH_DCC_SAFE(worker, link, next, dcc) {
+        FOREACH_DCC(worker->display_channel, link, next, dcc) {
             red_destroy_surface_item(worker, dcc, surface_id);
         }
 
@@ -1378,7 +1376,7 @@ static void red_clear_surface_drawables_from_pipes(RedWorker *worker,
     RingItem *item, *next;
     DisplayChannelClient *dcc;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         if (!red_clear_surface_drawables_from_pipe(dcc, surface_id, wait_if_used)) {
             red_channel_client_disconnect(&dcc->common.base);
         }
@@ -1758,7 +1756,7 @@ static void red_attach_stream(RedWorker *worker, Drawable *drawable, Stream *str
         stream->num_input_frames++;
     }
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         StreamAgent *agent;
         QRegion clip_in_draw_dest;
 
@@ -1824,7 +1822,7 @@ static void red_stop_stream(RedWorker *worker, Stream *stream)
     spice_assert(ring_item_is_linked(&stream->link));
     spice_assert(!stream->current);
     spice_debug("stream %d", get_stream_id(worker, stream));
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         StreamAgent *stream_agent;
 
         stream_agent = &dcc->stream_agents[get_stream_id(worker, stream)];
@@ -1941,7 +1939,7 @@ static inline void red_detach_stream_gracefully(RedWorker *worker, Stream *strea
     RingItem *item, *next;
     DisplayChannelClient *dcc;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_display_detach_stream_gracefully(dcc, stream, update_area_limit);
     }
     if (stream->current) {
@@ -1972,7 +1970,7 @@ static void red_detach_streams_behind(RedWorker *worker, QRegion *region, Drawab
         int detach_stream = 0;
         item = ring_next(ring, item);
 
-        WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
             StreamAgent *agent = &dcc->stream_agents[get_stream_id(worker, stream)];
 
             if (region_intersects(&agent->vis_region, region)) {
@@ -2020,7 +2018,7 @@ static void red_streams_update_visible_region(RedWorker *worker, Drawable *drawa
             continue;
         }
 
-        WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
             agent = &dcc->stream_agents[get_stream_id(worker, stream)];
 
             if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
@@ -2293,7 +2291,7 @@ static void red_create_stream(RedWorker *worker, Drawable *drawable)
     stream->input_fps_start_time = drawable->creation_time;
     worker->streams_size_total += stream->width * stream->height;
     worker->stream_count++;
-    WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
         red_display_create_stream(dcc, stream);
     }
     spice_debug("stream %d %dx%d (%d, %d) (%d, %d)", (int)(stream - worker->streams_buf), stream->width,
@@ -2486,7 +2484,7 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream, Drawa
     }
 
 
-    WORKER_FOREACH_DCC_SAFE(worker, ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, ring_item, next, dcc) {
         double drop_factor;
 
         agent = &dcc->stream_agents[index];
@@ -4000,7 +3998,7 @@ static void red_free_some(RedWorker *worker)
 
     spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d", worker->drawable_count,
                 worker->red_drawable_count, worker->glz_drawable_count);
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
 
         if (glz_dict) {
@@ -4015,7 +4013,7 @@ static void red_free_some(RedWorker *worker)
         free_one_drawable(worker, TRUE);
     }
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
 
         if (glz_dict) {
@@ -8177,7 +8175,7 @@ static void red_worker_create_surface_item(RedWorker *worker, int surface_id)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_create_surface_item(dcc, surface_id);
     }
 }
@@ -8188,7 +8186,7 @@ static void red_worker_push_surface_image(RedWorker *worker, int surface_id)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_push_surface_image(dcc, surface_id);
     }
 }
@@ -9534,7 +9532,7 @@ static void red_worker_push_monitors_config(RedWorker *worker)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         dcc_push_monitors_config(dcc);
     }
 }
commit de1ab756b0b87cab9f83bb0068768c507fc209c6
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Nov 5 11:27:00 2015 +0000

    worker: remove unused WORKER_TO_DCC macro
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 8904568..0788eea 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -569,12 +569,6 @@ static void display_channel_client_release_item_after_push(DisplayChannelClient
     SAFE_FOREACH(link, next, drawable, &(drawable)->glz_ring, glz, LINK_TO_GLZ(link))
 
 
-// TODO: replace with DCC_FOREACH when it is introduced
-#define WORKER_TO_DCC(worker) \
-    (worker->display_channel ? SPICE_CONTAINEROF(worker->display_channel->common.base.rcc,\
-                       DisplayChannelClient, common.base) : NULL)
-
-
 /* fixme: move to display channel */
 DrawablePipeItem *drawable_pipe_item_new(DisplayChannelClient *dcc,
                                          Drawable *drawable)
commit 13888ae6a23daf531b6afda665d3dfa1c776e772
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Nov 5 11:26:42 2015 +0000

    worker: rename red_pipe_add_drawable* to dcc_add_drawable*
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index fb05ef0..8904568 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -802,7 +802,7 @@ static int cursor_is_connected(RedWorker *worker)
         red_channel_is_connected(RED_CHANNEL(worker->cursor_channel));
 }
 
-static inline void red_pipe_add_drawable(DisplayChannelClient *dcc, Drawable *drawable)
+static void dcc_add_drawable(DisplayChannelClient *dcc, Drawable *drawable)
 {
     DrawablePipeItem *dpi;
 
@@ -811,18 +811,18 @@ static inline void red_pipe_add_drawable(DisplayChannelClient *dcc, Drawable *dr
     red_channel_client_pipe_add(&dcc->common.base, &dpi->dpi_pipe_item);
 }
 
-static inline void red_pipes_add_drawable(RedWorker *worker, Drawable *drawable)
+static void red_pipes_add_drawable(RedWorker *worker, Drawable *drawable)
 {
     DisplayChannelClient *dcc;
     RingItem *dcc_ring_item, *next;
 
     spice_warn_if(!ring_is_empty(&drawable->pipes));
     WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
-        red_pipe_add_drawable(dcc, drawable);
+        dcc_add_drawable(dcc, drawable);
     }
 }
 
-static inline void red_pipe_add_drawable_to_tail(DisplayChannelClient *dcc, Drawable *drawable)
+static void dcc_add_drawable_to_tail(DisplayChannelClient *dcc, Drawable *drawable)
 {
     DrawablePipeItem *dpi;
 
@@ -866,7 +866,7 @@ static inline void red_pipes_add_drawable_after(RedWorker *worker,
                 }
             }
             if (!sent) {
-                red_pipe_add_drawable(dcc, drawable);
+                dcc_add_drawable(dcc, drawable);
             }
         }
     }
@@ -2690,7 +2690,7 @@ static inline int red_current_add_equal(RedWorker *worker, DrawItem *item, TreeI
                                         common.base.channel_link);
                 dpi = SPICE_CONTAINEROF(dpi_ring_item, DrawablePipeItem, base);
                 while (worker_ring_item && (!dpi || dcc != dpi->dcc)) {
-                    red_pipe_add_drawable(dcc, drawable);
+                    dcc_add_drawable(dcc, drawable);
                     worker_ring_item = ring_next(&RED_CHANNEL(worker->display_channel)->clients,
                                                  worker_ring_item);
                     dcc = SPICE_CONTAINEROF(worker_ring_item, DisplayChannelClient,
@@ -6061,7 +6061,7 @@ static void red_add_lossless_drawable_dependencies(RedWorker *worker,
 
     if (!sync_rendered) {
         // pushing the pipe item back to the pipe
-        red_pipe_add_drawable_to_tail(dcc, item);
+        dcc_add_drawable_to_tail(dcc, item);
         // the surfaces areas will be sent as DRAW_COPY commands, that
         // will be executed before the current drawable
         for (i = 0; i < num_deps; i++) {
commit f1c7bca4d4676ae52f9fc807ef39c3034008353d
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Sep 13 18:03:08 2013 +0200

    worker: move delta computation
    
    Move delta computation from red_add_drawable to red_current_add_with_shadow.
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 2ba1896..fb05ef0 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -2951,15 +2951,20 @@ static inline Shadow *__new_shadow(RedWorker *worker, Drawable *item, SpicePoint
     return shadow;
 }
 
-static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Drawable *item,
-                                              SpicePoint *delta)
+static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Drawable *item)
 {
 #ifdef RED_WORKER_STAT
     stat_time_t start_time = stat_now(worker);
     ++worker->add_with_shadow_count;
 #endif
 
-    Shadow *shadow = __new_shadow(worker, item, delta);
+    RedDrawable *red_drawable = item->red_drawable;
+    SpicePoint delta = {
+        .x = red_drawable->u.copy_bits.src_pos.x - red_drawable->bbox.left,
+        .y = red_drawable->u.copy_bits.src_pos.y - red_drawable->bbox.top
+    };
+
+    Shadow *shadow = __new_shadow(worker, item, &delta);
     if (!shadow) {
         stat_add(&worker->add_stat, start_time);
         return FALSE;
@@ -3067,11 +3072,7 @@ static int red_add_drawable(RedWorker *worker, Drawable *drawable)
     Ring *ring = &worker->surfaces[surface_id].current;
 
     if (has_shadow(red_drawable)) {
-        SpicePoint delta = {
-            .x = red_drawable->u.copy_bits.src_pos.x - red_drawable->bbox.left,
-            .y = red_drawable->u.copy_bits.src_pos.y - red_drawable->bbox.top
-        };
-        ret = red_current_add_with_shadow(worker, ring, drawable, &delta);
+        ret = red_current_add_with_shadow(worker, ring, drawable);
     } else {
         red_update_streamable(worker, drawable, red_drawable);
         ret = red_current_add(worker, ring, drawable);


More information about the Spice-commits mailing list