[Spice-commits] 4 commits - server/dcc.c server/dcc-encoders.c server/dcc-encoders.h server/dcc.h server/red_worker.c server/stream.c server/stream.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Nov 20 02:23:22 PST 2015


 server/dcc-encoders.c |    9 +++
 server/dcc-encoders.h |    1 
 server/dcc.c          |   90 ++++++++++++++++++++++++++++++++
 server/dcc.h          |    2 
 server/red_worker.c   |  139 ++++----------------------------------------------
 server/stream.c       |   12 ++++
 server/stream.h       |    6 +-
 7 files changed, 130 insertions(+), 129 deletions(-)

New commits:
commit ff070be68f11b934bc22ea51c6b3c66db2c4d745
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Wed Sep 25 15:55:42 2013 +0200

    worker: move stream_clip_item_unref()
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index ab4253d..6d974d6 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -192,16 +192,6 @@ static void red_create_surface(DisplayChannel *display, uint32_t surface_id, uin
                                uint32_t height, int32_t stride, uint32_t format,
                                void *line_0, int data_is_valid, int send_client);
 
-static void display_stream_clip_unref(DisplayChannel *display, StreamClipItem *item)
-{
-    if (--item->refs != 0)
-        return;
-
-    stream_agent_unref(display, item->stream_agent);
-    free(item->rects);
-    free(item);
-}
-
 void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
 {
     DisplayChannelClient *dcc;
@@ -5477,7 +5467,7 @@ static void display_channel_client_release_item_after_push(DisplayChannelClient
         drawable_pipe_item_unref(SPICE_CONTAINEROF(item, DrawablePipeItem, dpi_pipe_item));
         break;
     case PIPE_ITEM_TYPE_STREAM_CLIP:
-        display_stream_clip_unref(display, (StreamClipItem *)item);
+        stream_clip_item_unref(dcc, (StreamClipItem *)item);
         break;
     case PIPE_ITEM_TYPE_UPGRADE:
         upgrade_item_unref(display, (UpgradeItem *)item);
@@ -5520,7 +5510,7 @@ static void display_channel_client_release_item_before_push(DisplayChannelClient
         break;
     }
     case PIPE_ITEM_TYPE_STREAM_CLIP:
-        display_stream_clip_unref(display, (StreamClipItem *)item);
+        stream_clip_item_unref(dcc, (StreamClipItem *)item);
         break;
     case PIPE_ITEM_TYPE_STREAM_DESTROY: {
         StreamAgent *agent = SPICE_CONTAINEROF(item, StreamAgent, destroy_item);
diff --git a/server/stream.c b/server/stream.c
index f242da7..a2acd3a 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -145,6 +145,18 @@ StreamClipItem *stream_clip_item_new(DisplayChannelClient* dcc, StreamAgent *age
     return item;
 }
 
+void stream_clip_item_unref(DisplayChannelClient *dcc, StreamClipItem *item)
+{
+    DisplayChannel *display = DCC_TO_DC(dcc);
+
+    if (--item->refs != 0)
+        return;
+
+    stream_agent_unref(display, item->stream_agent);
+    free(item->rects);
+    free(item);
+}
+
 static int is_stream_start(Drawable *drawable)
 {
     return ((drawable->frames_count >= RED_STREAM_FRAMES_START_CONDITION) &&
diff --git a/server/stream.h b/server/stream.h
index 0577dc8..3627b0f 100644
--- a/server/stream.h
+++ b/server/stream.h
@@ -107,8 +107,10 @@ typedef struct StreamClipItem {
     SpiceClipRects *rects;
 } StreamClipItem;
 
-StreamClipItem *stream_clip_item_new(DisplayChannelClient* dcc,
-                                     StreamAgent *agent);
+StreamClipItem *      stream_clip_item_new                          (DisplayChannelClient* dcc,
+                                                                     StreamAgent *agent);
+void                  stream_clip_item_unref                        (DisplayChannelClient *dcc,
+                                                                     StreamClipItem *item);
 
 typedef struct ItemTrace {
     red_time_t time;
commit f06ce6c1c45721182e88a8a580d3037489369371
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Wed Sep 25 16:00:51 2013 +0200

    worker: merge red_draw_qxl_drawable in drawable_draw
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 155d2a2..ab4253d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -176,8 +176,7 @@ typedef struct BitmapData {
 
 static inline int validate_surface(DisplayChannel *display, uint32_t surface_id);
 
-static void red_draw_qxl_drawable(DisplayChannel *display, Drawable *drawable);
-static void red_draw_drawable(DisplayChannel *display, Drawable *item);
+static void drawable_draw(DisplayChannel *display, Drawable *item);
 static void red_update_area(DisplayChannel *display, const SpiceRect *area, int surface_id);
 static void red_update_area_till(DisplayChannel *display, const SpiceRect *area, int surface_id,
                                  Drawable *last);
@@ -1150,7 +1149,7 @@ static bool free_one_drawable(DisplayChannel *display, int force_glz_free)
             dcc_free_glz_drawable(glz->dcc, glz);
         }
     }
-    red_draw_drawable(display, drawable);
+    drawable_draw(display, drawable);
     container = drawable->tree_item.base.container;
 
     current_remove_drawable(display, drawable);
@@ -1412,14 +1411,17 @@ static void image_surface_init(DisplayChannel *display)
     display->image_surfaces.ops = &image_surfaces_ops;
 }
 
-static void red_draw_qxl_drawable(DisplayChannel *display, Drawable *drawable)
+static void drawable_draw(DisplayChannel *display, Drawable *drawable)
 {
     RedSurface *surface;
     SpiceCanvas *canvas;
     SpiceClip clip = drawable->red_drawable->clip;
 
+    red_flush_source_surfaces(display, drawable);
+
     surface = &display->surfaces[drawable->surface_id];
     canvas = surface->context.canvas;
+    spice_return_if_fail(canvas);
 
     image_cache_aging(&display->image_cache);
 
@@ -1549,12 +1551,6 @@ static void red_draw_qxl_drawable(DisplayChannel *display, Drawable *drawable)
     }
 }
 
-static void red_draw_drawable(DisplayChannel *display, Drawable *drawable)
-{
-    red_flush_source_surfaces(display, drawable);
-    red_draw_qxl_drawable(display, drawable);
-}
-
 static void validate_area(DisplayChannel *display, const SpiceRect *area, uint32_t surface_id)
 {
     RedSurface *surface;
@@ -1648,12 +1644,12 @@ static void red_update_area_till(DisplayChannel *display, const SpiceRect *area,
         container = now->tree_item.base.container;
         current_remove_drawable(display, now);
         container_cleanup(container);
-        /* red_draw_drawable may call red_update_area for the surfaces 'now' depends on. Notice,
+        /* drawable_draw may call red_update_area for the surfaces 'now' depends on. Notice,
            that it is valid to call red_update_area in this case and not red_update_area_till:
            It is impossible that there was newer item then 'last' in one of the surfaces
            that red_update_area is called for, Otherwise, 'now' would have already been rendered.
            See the call for red_handle_depends_on_target_surface in red_process_draw */
-        red_draw_drawable(display, now);
+        drawable_draw(display, now);
         display_channel_drawable_unref(display, now);
     } while (now != surface_last);
     validate_area(display, area, surface_id);
@@ -1706,7 +1702,7 @@ static void red_update_area(DisplayChannel *display, const SpiceRect *area, int
         container = now->tree_item.base.container;
         current_remove_drawable(display, now);
         container_cleanup(container);
-        red_draw_drawable(display, now);
+        drawable_draw(display, now);
         display_channel_drawable_unref(display, now);
     } while (now != last);
     validate_area(display, area, surface_id);
commit 8ef5be6cd97dec0a3db6dff34aabfcc653603718
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 24 18:10:31 2013 +0200

    worker: move dcc_pixmap_cache_add
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/dcc.c b/server/dcc.c
index 1e18814..9af6d84 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -940,3 +940,93 @@ void dcc_palette_cache_reset(DisplayChannelClient *dcc)
 {
     red_palette_cache_reset(dcc, CLIENT_PALETTE_CACHE_SIZE);
 }
+
+static void dcc_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t id,
+                             uint64_t* sync_data)
+{
+    FreeList *free_list = &dcc->send_data.free_list;
+    int i;
+
+    for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
+        free_list->sync[i] = MAX(free_list->sync[i], sync_data[i]);
+    }
+
+    if (free_list->res->count == free_list->res_size) {
+        SpiceResourceList *new_list;
+        new_list = spice_malloc(sizeof(*new_list) +
+                                free_list->res_size * sizeof(SpiceResourceID) * 2);
+        new_list->count = free_list->res->count;
+        memcpy(new_list->resources, free_list->res->resources,
+               new_list->count * sizeof(SpiceResourceID));
+        free(free_list->res);
+        free_list->res = new_list;
+        free_list->res_size *= 2;
+    }
+    free_list->res->resources[free_list->res->count].type = type;
+    free_list->res->resources[free_list->res->count++].id = id;
+}
+
+int dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
+                                  uint32_t size, int lossy)
+{
+    PixmapCache *cache = dcc->pixmap_cache;
+    NewCacheItem *item;
+    uint64_t serial;
+    int key;
+
+    spice_assert(size > 0);
+
+    item = spice_new(NewCacheItem, 1);
+    serial = red_channel_client_get_message_serial(RED_CHANNEL_CLIENT(dcc));
+
+    if (cache->generation != dcc->pixmap_cache_generation) {
+        if (!dcc->pending_pixmaps_sync) {
+            red_channel_client_pipe_add_type(
+                                             RED_CHANNEL_CLIENT(dcc), PIPE_ITEM_TYPE_PIXMAP_SYNC);
+            dcc->pending_pixmaps_sync = TRUE;
+        }
+        free(item);
+        return FALSE;
+    }
+
+    cache->available -= size;
+    while (cache->available < 0) {
+        NewCacheItem *tail;
+        NewCacheItem **now;
+
+        if (!(tail = (NewCacheItem *)ring_get_tail(&cache->lru)) ||
+                                                   tail->sync[dcc->common.id] == serial) {
+            cache->available += size;
+            free(item);
+            return FALSE;
+        }
+
+        now = &cache->hash_table[BITS_CACHE_HASH_KEY(tail->id)];
+        for (;;) {
+            spice_assert(*now);
+            if (*now == tail) {
+                *now = tail->next;
+                break;
+            }
+            now = &(*now)->next;
+        }
+        ring_remove(&tail->lru_link);
+        cache->items--;
+        cache->available += tail->size;
+        cache->sync[dcc->common.id] = serial;
+        dcc_push_release(dcc, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
+        free(tail);
+    }
+    ++cache->items;
+    item->next = cache->hash_table[(key = BITS_CACHE_HASH_KEY(id))];
+    cache->hash_table[key] = item;
+    ring_item_init(&item->lru_link);
+    ring_add(&cache->lru, &item->lru_link);
+    item->id = id;
+    item->size = size;
+    item->lossy = lossy;
+    memset(item->sync, 0, sizeof(item->sync));
+    item->sync[dcc->common.id] = serial;
+    cache->sync[dcc->common.id] = serial;
+    return TRUE;
+}
diff --git a/server/dcc.h b/server/dcc.h
index 7827f72..c62c3c9 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -167,6 +167,8 @@ void                       dcc_palette_cache_reset                   (DisplayCha
 void                       dcc_palette_cache_palette                 (DisplayChannelClient *dcc,
                                                                       SpicePalette *palette,
                                                                       uint8_t *flags);
+int                        dcc_pixmap_cache_unlocked_add             (DisplayChannelClient *dcc,
+                                                                      uint64_t id, uint32_t size, int lossy);
 
 typedef struct compress_send_data_t {
     void*    comp_buf;
diff --git a/server/red_worker.c b/server/red_worker.c
index 5550628..155d2a2 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -183,8 +183,6 @@ static void red_update_area_till(DisplayChannel *display, const SpiceRect *area,
                                  Drawable *last);
 static inline void display_begin_send_message(RedChannelClient *rcc);
 static void dcc_release_glz(DisplayChannelClient *dcc);
-static void display_channel_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t id,
-                                         uint64_t* sync_data);
 static int red_display_free_some_independent_glz_drawables(DisplayChannelClient *dcc);
 static void dcc_free_glz_drawable(DisplayChannelClient *dcc, RedGlzDrawable *drawable);
 static void display_channel_client_release_item_before_push(DisplayChannelClient *dcc,
@@ -2096,70 +2094,6 @@ static int red_display_free_some_independent_glz_drawables(DisplayChannelClient
     return n;
 }
 
-int dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id, uint32_t size, int lossy)
-{
-    PixmapCache *cache = dcc->pixmap_cache;
-    NewCacheItem *item;
-    uint64_t serial;
-    int key;
-
-    spice_assert(size > 0);
-
-    item = spice_new(NewCacheItem, 1);
-    serial = red_channel_client_get_message_serial(RED_CHANNEL_CLIENT(dcc));
-
-    if (cache->generation != dcc->pixmap_cache_generation) {
-        if (!dcc->pending_pixmaps_sync) {
-            red_channel_client_pipe_add_type(
-                                             RED_CHANNEL_CLIENT(dcc), PIPE_ITEM_TYPE_PIXMAP_SYNC);
-            dcc->pending_pixmaps_sync = TRUE;
-        }
-        free(item);
-        return FALSE;
-    }
-
-    cache->available -= size;
-    while (cache->available < 0) {
-        NewCacheItem *tail;
-        NewCacheItem **now;
-
-        if (!(tail = (NewCacheItem *)ring_get_tail(&cache->lru)) ||
-                                                   tail->sync[dcc->common.id] == serial) {
-            cache->available += size;
-            free(item);
-            return FALSE;
-        }
-
-        now = &cache->hash_table[BITS_CACHE_HASH_KEY(tail->id)];
-        for (;;) {
-            spice_assert(*now);
-            if (*now == tail) {
-                *now = tail->next;
-                break;
-            }
-            now = &(*now)->next;
-        }
-        ring_remove(&tail->lru_link);
-        cache->items--;
-        cache->available += tail->size;
-        cache->sync[dcc->common.id] = serial;
-        display_channel_push_release(dcc, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
-        free(tail);
-    }
-    ++cache->items;
-    item->next = cache->hash_table[(key = BITS_CACHE_HASH_KEY(id))];
-    cache->hash_table[key] = item;
-    ring_item_init(&item->lru_link);
-    ring_add(&cache->lru, &item->lru_link);
-    item->id = id;
-    item->size = size;
-    item->lossy = lossy;
-    memset(item->sync, 0, sizeof(item->sync));
-    item->sync[dcc->common.id] = serial;
-    cache->sync[dcc->common.id] = serial;
-    return TRUE;
-}
-
 static inline void red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
                                                          SpiceImage *image, SpiceImage *io_image,
                                                          int is_lossy)
@@ -3766,31 +3700,6 @@ static inline void red_marshall_qxl_drawable(RedChannelClient *rcc,
     }
 }
 
-static void display_channel_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t id,
-                                         uint64_t* sync_data)
-{
-    FreeList *free_list = &dcc->send_data.free_list;
-    int i;
-
-    for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
-        free_list->sync[i] = MAX(free_list->sync[i], sync_data[i]);
-    }
-
-    if (free_list->res->count == free_list->res_size) {
-        SpiceResourceList *new_list;
-        new_list = spice_malloc(sizeof(*new_list) +
-                                free_list->res_size * sizeof(SpiceResourceID) * 2);
-        new_list->count = free_list->res->count;
-        memcpy(new_list->resources, free_list->res->resources,
-               new_list->count * sizeof(SpiceResourceID));
-        free(free_list->res);
-        free_list->res = new_list;
-        free_list->res_size *= 2;
-    }
-    free_list->res->resources[free_list->res->count].type = type;
-    free_list->res->resources[free_list->res->count++].id = id;
-}
-
 static inline void display_marshal_sub_msg_inval_list(SpiceMarshaller *m,
                                                        FreeList *free_list)
 {
commit 036451cce9d1700145559a96091b3befec377f99
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 24 18:03:04 2013 +0200

    worker: move dcc_freeze_glz
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index d8d6617..e2e25e5 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -489,3 +489,12 @@ void dcc_free_glz_drawables_to_free(DisplayChannelClient* dcc)
     }
     pthread_mutex_unlock(&dcc->glz_drawables_inst_to_free_lock);
 }
+
+void dcc_freeze_glz(DisplayChannelClient *dcc)
+{
+    pthread_rwlock_wrlock(&dcc->glz_dict->encode_lock);
+    if (!dcc->glz_dict->migrate_freeze) {
+        dcc->glz_dict->migrate_freeze = TRUE;
+    }
+    pthread_rwlock_unlock(&dcc->glz_dict->encode_lock);
+}
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 811183c..5ae15ba 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -39,6 +39,7 @@ void             dcc_encoders_init                           (DisplayChannelClie
 void             dcc_free_glz_drawable_instance              (DisplayChannelClient *dcc,
                                                               GlzDrawableInstanceItem *item);
 void             dcc_free_glz_drawables_to_free              (DisplayChannelClient* dcc);
+void             dcc_freeze_glz                              (DisplayChannelClient *dcc);
 
 void             marshaller_add_compressed                   (SpiceMarshaller *m,
                                                               RedCompressBuf *comp_buf,
diff --git a/server/red_worker.c b/server/red_worker.c
index 747bb9e..5550628 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -183,7 +183,6 @@ static void red_update_area_till(DisplayChannel *display, const SpiceRect *area,
                                  Drawable *last);
 static inline void display_begin_send_message(RedChannelClient *rcc);
 static void dcc_release_glz(DisplayChannelClient *dcc);
-static void red_freeze_glz(DisplayChannelClient *dcc);
 static void display_channel_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t id,
                                          uint64_t* sync_data);
 static int red_display_free_some_independent_glz_drawables(DisplayChannelClient *dcc);
@@ -4134,7 +4133,7 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
            sizeof(display_data.pixmap_cache_clients));
 
     spice_assert(dcc->glz_dict);
-    red_freeze_glz(dcc);
+    dcc_freeze_glz(dcc);
     display_data.glz_dict_id = dcc->glz_dict->id;
     glz_enc_dictionary_get_restore_data(dcc->glz_dict->dict,
                                         &display_data.glz_dict_data,
@@ -5057,15 +5056,6 @@ static GlzSharedDictionary *red_restore_glz_dictionary(DisplayChannelClient *dcc
     return shared_dict;
 }
 
-static void red_freeze_glz(DisplayChannelClient *dcc)
-{
-    pthread_rwlock_wrlock(&dcc->glz_dict->encode_lock);
-    if (!dcc->glz_dict->migrate_freeze) {
-        dcc->glz_dict->migrate_freeze = TRUE;
-    }
-    pthread_rwlock_unlock(&dcc->glz_dict->encode_lock);
-}
-
 /* destroy encoder, and dictionary if no one uses it*/
 static void dcc_release_glz(DisplayChannelClient *dcc)
 {


More information about the Spice-commits mailing list