[Spice-devel] [RFCv5 24/47] server/red_worker: cleanup

Alon Levy alevy at redhat.com
Sun May 8 06:11:20 PDT 2011


---
 server/red_worker.c |   93 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 55 insertions(+), 38 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index f3de49f..9ccd80e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -952,7 +952,8 @@ static void red_display_release_stream_clip(DisplayChannel* channel, StreamClipI
 static int red_display_free_some_independent_glz_drawables(DisplayChannel *channel);
 static void red_display_free_glz_drawable(DisplayChannel *channel, RedGlzDrawable *drawable);
 static void reset_rate(RedWorker *worker, StreamAgent *stream_agent);
-static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id);
+static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBitmap *bitmap,
+                                                      uint32_t group_id);
 static inline int _stride_is_extra(SpiceBitmap *bitmap);
 static void red_disconnect_cursor(RedChannel *channel);
 static void red_wait_pipe_item_sent(RedChannel *channel, PipeItem *item);
@@ -1228,7 +1229,8 @@ static inline void red_pipe_add_drawable_to_tail(RedWorker *worker, Drawable *dr
         return;
     }
     drawable->refs++;
-    red_channel_client_pipe_add_tail(worker->display_channel->common.base.rcc, &drawable->pipe_item);
+    red_channel_client_pipe_add_tail(worker->display_channel->common.base.rcc,
+                                     &drawable->pipe_item);
 }
 
 static inline void red_pipe_add_drawable_after(RedWorker *worker, Drawable *drawable,
@@ -1243,7 +1245,8 @@ static inline void red_pipe_add_drawable_after(RedWorker *worker, Drawable *draw
         return;
     }
     drawable->refs++;
-    red_channel_client_pipe_add_after(worker->display_channel->common.base.rcc, &drawable->pipe_item, &pos_after->pipe_item);
+    red_channel_client_pipe_add_after(worker->display_channel->common.base.rcc,
+                                      &drawable->pipe_item, &pos_after->pipe_item);
 }
 
 static inline PipeItem *red_pipe_get_tail(RedWorker *worker)
@@ -2285,7 +2288,8 @@ static inline void red_detach_stream_gracefully(RedWorker *worker, Stream *strea
         n_rects = pixman_region32_n_rects(&upgrade_item->drawable->tree_item.base.rgn);
         upgrade_item->rects = spice_malloc_n_m(n_rects, sizeof(SpiceRect), sizeof(SpiceClipRects));
         upgrade_item->rects->num_rects = n_rects;
-        region_ret_rects(&upgrade_item->drawable->tree_item.base.rgn, upgrade_item->rects->rects, n_rects);
+        region_ret_rects(&upgrade_item->drawable->tree_item.base.rgn,
+                         upgrade_item->rects->rects, n_rects);
         red_channel_client_pipe_add(channel->common.base.rcc, &upgrade_item->base);
     }
     red_detach_stream(&worker->render, stream);
@@ -2673,7 +2677,8 @@ static inline void red_update_copy_graduality(RedWorker* worker, Drawable *drawa
         (bitmap->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE)) {
         drawable->copy_bitmap_graduality = BITMAP_GRADUAL_NOT_AVAIL;
     } else  {
-        drawable->copy_bitmap_graduality = _get_bitmap_graduality_level(worker, bitmap, drawable->group_id);
+        drawable->copy_bitmap_graduality =
+            _get_bitmap_graduality_level(worker, bitmap,drawable->group_id);
     }
 }
 
@@ -3230,8 +3235,10 @@ static inline int red_handle_self_bitmap(RedRender *render, Drawable *drawable)
 
     bpp = SPICE_SURFACE_FMT_DEPTH(surface->context.format) / 8;
 
-    width = drawable->red_drawable->self_bitmap_area.right - drawable->red_drawable->self_bitmap_area.left;
-    height = drawable->red_drawable->self_bitmap_area.bottom - drawable->red_drawable->self_bitmap_area.top;
+    width = drawable->red_drawable->self_bitmap_area.right
+            - drawable->red_drawable->self_bitmap_area.left;
+    height = drawable->red_drawable->self_bitmap_area.bottom
+            - drawable->red_drawable->self_bitmap_area.top;
     dest_stride = SPICE_ALIGN(width * bpp, 4);
 
     image = spice_new0(SpiceImage, 1);
@@ -3253,7 +3260,7 @@ static inline int red_handle_self_bitmap(RedRender *render, Drawable *drawable)
     red_get_area(render, drawable->surface_id,
                  &drawable->red_drawable->self_bitmap_area, dest, dest_stride, TRUE);
 
-    /* For 32bit non-primary surfaces we need to keep any non-zero
+    /* For 32bit non-primary surface we need to keep any non-zero
        high bytes as the surface may be used as source to an alpha_blend */
     if (!is_primary_surface(drawable->surface_id) &&
         image->u.bitmap.format == SPICE_BITMAP_FMT_32BIT &&
@@ -3461,8 +3468,7 @@ static inline void red_process_drawable_surfaces(RedRender *render, RedDrawable
         return;
     }
 
-    if (red_current_add_qxl(render,
-                            &render->surfaces[surface_id].current, item,
+    if (red_current_add_qxl(render, &render->surfaces[surface_id].current, item,
                             drawable)) {
         if (item->tree_item.effect != QXL_EFFECT_OPAQUE) {
             render->transparent_count++;
@@ -3683,7 +3689,8 @@ static void image_cache_eaging(ImageCache *cache)
 #endif
 }
 
-static void localize_bitmap(RedWorker *worker, SpiceImage **image_ptr, SpiceImage *image_store, Drawable *drawable)
+static void localize_bitmap(RedWorker *worker, SpiceImage **image_ptr, SpiceImage *image_store,
+                            Drawable *drawable)
 {
     SpiceImage *image = *image_ptr;
 
@@ -4048,7 +4055,7 @@ static void red_update_area_till(RedRender *render, const SpiceRect *area, int s
     region_init(&rgn);
     region_add(&rgn, area);
 
-    // find the first older drawable that intersects with the 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)) {
@@ -4058,7 +4065,7 @@ static void red_update_area_till(RedRender *render, const SpiceRect *area, int s
     } while ((ring_item = ring_next(ring, ring_item)));
 
     region_destroy(&rgn);
-    
+
     if (!surface_last) {
         return;
     }
@@ -4393,8 +4400,9 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
             red_error("bad command type");
         }
         n++;
-        if ((worker->display_channel && red_channel_all_blocked(&worker->display_channel->common.base)) ||
-            red_now() - start > 10 * 1000 * 1000) {
+        if ((worker->display_channel &&
+             red_channel_all_blocked(&worker->display_channel->common.base))
+            || red_now() - start > 10 * 1000 * 1000) {
             worker->epoll_timeout = 0;
             return n;
         }
@@ -5181,7 +5189,8 @@ typedef uint16_t rgb16_pixel_t;
 #define GRADUAL_MEDIUM_SCORE_TH 0.002
 
 // assumes that stride doesn't overflow
-static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id)
+static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBitmap *bitmap,
+                                                      uint32_t group_id)
 {
     double score = 0.0;
     int num_samples = 0;
@@ -5988,7 +5997,8 @@ static void fill_attr(SpiceMarshaller *m, SpiceLineAttr *attr, uint32_t group_id
     }
 }
 
-static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor, CursorItem *cursor, AddBufInfo *addbuf)
+static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
+                        CursorItem *cursor, AddBufInfo *addbuf)
 {
     addbuf->data = NULL;
 
@@ -6008,7 +6018,8 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
                 red_cursor->flags |= SPICE_CURSOR_FLAGS_FROM_CACHE;
                 return;
             }
-            if (red_cursor_cache_add(cursor_channel->common.base.rcc, red_cursor->header.unique, 1)) {
+            if (red_cursor_cache_add(cursor_channel->common.base.rcc,
+                                     red_cursor->header.unique, 1)) {
                 red_cursor->flags |= SPICE_CURSOR_FLAGS_CACHE_ME;
             }
         }
@@ -7301,7 +7312,8 @@ static void display_channel_push_release(DisplayChannel *channel, uint8_t type,
 
     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 = 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));
@@ -7313,7 +7325,8 @@ static void display_channel_push_release(DisplayChannel *channel, uint8_t type,
     free_list->res->resources[free_list->res->count++].id = id;
 }
 
-static inline void display_begin_send_message(RedChannelClient *rcc, SpiceMarshaller *base_marshaller)
+static inline void display_begin_send_message(RedChannelClient *rcc,
+                                              SpiceMarshaller *base_marshaller)
 {
     DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
     FreeList *free_list = &display_channel->send_data.free_list;
@@ -7330,8 +7343,8 @@ static inline void display_begin_send_message(RedChannelClient *rcc, SpiceMarsha
 
         /* type + size + submessage */
         spice_marshaller_add_uint16(inval_m, SPICE_MSG_DISPLAY_INVAL_LIST);
-        spice_marshaller_add_uint32(inval_m,
-                                    sizeof(*free_list->res) + free_list->res->count * sizeof(free_list->res->resources[0]));
+        spice_marshaller_add_uint32(inval_m, sizeof(*free_list->res) +
+                        free_list->res->count * sizeof(free_list->res->resources[0]));
         spice_marshall_msg_display_inval_list(inval_m, free_list->res);
 
         for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
@@ -7348,8 +7361,8 @@ static inline void display_begin_send_message(RedChannelClient *rcc, SpiceMarsha
 
             /* type + size + submessage */
             spice_marshaller_add_uint16(wait_m, SPICE_MSG_WAIT_FOR_CHANNELS);
-            spice_marshaller_add_uint32(wait_m,
-                                        sizeof(free_list->wait.header) + sync_count * sizeof(free_list->wait.buf[0]));
+            spice_marshaller_add_uint32(wait_m, sizeof(free_list->wait.header) +
+                                                sync_count * sizeof(free_list->wait.buf[0]));
             spice_marshall_msg_wait_for_channels(wait_m, &free_list->wait.header);
             sub_list_len++;
         }
@@ -7697,7 +7710,8 @@ static void display_channel_marshall_migrate(RedChannelClient *rcc,
     display_channel->expect_migrate_mark = TRUE;
 }
 
-static void display_channel_marshall_migrate_data(RedChannelClient *rcc, SpiceMarshaller *base_marshaller)
+static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
+                                                  SpiceMarshaller *base_marshaller)
 {
     DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
     DisplayChannelMigrateData display_data;
@@ -7728,7 +7742,8 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc, SpiceMa
                              (uint8_t *)&display_data, sizeof(display_data));
 }
 
-static void display_channel_marshall_pixmap_sync(RedChannelClient *rcc, SpiceMarshaller *base_marshaller)
+static void display_channel_marshall_pixmap_sync(RedChannelClient *rcc,
+                                                 SpiceMarshaller *base_marshaller)
 {
     DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
     SpiceMsgWaitForChannels wait;
@@ -7751,7 +7766,8 @@ static void display_channel_marshall_pixmap_sync(RedChannelClient *rcc, SpiceMar
     spice_marshall_msg_wait_for_channels(base_marshaller, &wait);
 }
 
-static void display_channel_marshall_reset_cache(RedChannelClient *rcc, SpiceMarshaller *base_marshaller)
+static void display_channel_marshall_reset_cache(RedChannelClient *rcc,
+                                                 SpiceMarshaller *base_marshaller)
 {
     DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
     SpiceMsgWaitForChannels wait;
@@ -7896,7 +7912,8 @@ static void red_marshall_image( RedChannelClient *rcc, SpiceMarshaller *m, Image
     spice_chunks_destroy(chunks);
 }
 
-static void red_display_marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller *m, UpgradeItem *item)
+static void red_display_marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller *m,
+                                         UpgradeItem *item)
 {
     RedDrawable *red_drawable;
     SpiceMsgDisplayDrawCopy copy;
@@ -8040,7 +8057,8 @@ static void red_marshall_local_cursor(RedChannelClient *rcc,
     red_release_cursor(worker, (CursorItem *)cursor);
 }
 
-static void cursor_channel_marshall_migrate(RedChannelClient *rcc, SpiceMarshaller *base_marshaller)
+static void cursor_channel_marshall_migrate(RedChannelClient *rcc,
+                                            SpiceMarshaller *base_marshaller)
 {
     SpiceMsgMigrate migrate;
 
@@ -8582,8 +8600,7 @@ static inline void red_create_surface(RedRender *render, uint32_t surface_id, ui
     region_init(&surface->draw_dirty_region);
     surface->refs = 1;
     if (worker->renderer != RED_RENDERER_INVALID) {
-        surface->context.canvas = create_canvas_for_surface(render,
-                                                            surface, worker->renderer,
+        surface->context.canvas = create_canvas_for_surface(render, surface, worker->renderer,
                                                             width, height, stride,
                                                             surface->context.format, line_0);
         if (!surface->context.canvas) {
@@ -8595,8 +8612,7 @@ static inline void red_create_surface(RedRender *render, uint32_t surface_id, ui
     }
 
     for (i = 0; i < worker->num_renderers; i++) {
-        surface->context.canvas = create_canvas_for_surface(render,
-                                                            surface, worker->renderers[i],
+        surface->context.canvas = create_canvas_for_surface(render, surface, worker->renderers[i],
                                                             width, height, stride,
                                                             surface->context.format, line_0);
         if (surface->context.canvas) { //no need canvas check
@@ -8708,7 +8724,8 @@ static void push_new_primary_surface(RedWorker *worker)
     DisplayChannel *display_channel;
 
     if ((display_channel = worker->display_channel)) {
-        red_channel_client_pipe_add_type(display_channel->common.base.rcc, PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
+        red_channel_client_pipe_add_type(display_channel->common.base.rcc,
+                                         PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
         if (!display_channel->common.base.migrate) {
             red_create_surface_item(worker, 0);
         }
@@ -8992,8 +9009,8 @@ static int display_channel_handle_migrate_glz_dictionary(DisplayChannel *channel
     ring_init(&channel->glz_drawables_inst_to_free);
     pthread_mutex_init(&channel->glz_drawables_inst_to_free_lock, NULL);
     return !!(channel->glz_dict = red_restore_glz_dictionary(channel,
-                                                             migrate_info->glz_dict_id,
-                                                             &migrate_info->glz_dict_restore_data));
+                                                         migrate_info->glz_dict_id,
+                                                         &migrate_info->glz_dict_restore_data));
 }
 
 static int display_channel_handle_migrate_mark(RedChannelClient *rcc)
@@ -9088,7 +9105,8 @@ static int display_channel_handle_message(RedChannelClient *rcc, uint32_t size,
             return FALSE;
         }
         ((DisplayChannel *)rcc->channel)->expect_init = FALSE;
-        return display_channel_init((DisplayChannel *)rcc->channel, (SpiceMsgcDisplayInit *)message);
+        return display_channel_init((DisplayChannel *)rcc->channel,
+                                    (SpiceMsgcDisplayInit *)message);
     default:
         return red_channel_client_handle_message(rcc, size, type, message);
     }
@@ -10415,4 +10433,3 @@ static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_i
 }
 
 #endif
-
-- 
1.7.5.1



More information about the Spice-devel mailing list