[Spice-devel] [PATCH 12/18] worker: move drawable_draw

Frediano Ziglio fziglio at redhat.com
Tue Nov 24 01:18:18 PST 2015


Merged. My previous patch was wrong, I swapped too functions.

Here you are the correct reduced patch


--- before.c	2015-11-24 04:57:16.510149998 +0000
+++ after.c	2015-11-24 04:50:41.998140049 +0000
@@ -1035,38 +1035,38 @@
     drawable->tree_item.base.type = TREE_ITEM_TYPE_DRAWABLE;
     region_init(&drawable->tree_item.base.rgn);
     ring_init(&drawable->pipes);
     ring_init(&drawable->glz_ring);
     drawable->process_commands_generation = process_commands_generation;
     drawable->group_id = group_id;
 
     return drawable;
 }
 
-static void remove_depended_item(DependItem *item)
+static void depended_item_remove(DependItem *item)
 {
-    spice_assert(item->drawable);
-    spice_assert(ring_item_is_linked(&item->ring_item));
+    spice_return_if_fail(item->drawable);
+    spice_return_if_fail(ring_item_is_linked(&item->ring_item));
 
     item->drawable = NULL;
     ring_remove(&item->ring_item);
 }
 
 static void drawable_remove_dependencies(DisplayChannel *display, Drawable *drawable)
 {
     int x;
     int surface_id;
 
     for (x = 0; x < 3; ++x) {
         surface_id = drawable->surface_deps[x];
         if (surface_id != -1 && drawable->depend_items[x].drawable) {
-            remove_depended_item(&drawable->depend_items[x]);
+            depended_item_remove(&drawable->depend_items[x]);
         }
     }
 }
 
 static void drawable_unref_surface_deps(DisplayChannel *display, Drawable *drawable)
 {
     int x;
     int surface_id;
 
     for (x = 0; x < 3; ++x) {
@@ -1094,51 +1094,48 @@
     region_destroy(&drawable->tree_item.base.rgn);
 
     drawable_remove_dependencies(display, drawable);
     drawable_unref_surface_deps(display, drawable);
     display_channel_surface_unref(display, drawable->surface_id);
 
     RING_FOREACH_SAFE(item, next, &drawable->glz_ring) {
         SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->drawable = NULL;
         ring_remove(item);
     }
+    if (drawable->red_drawable) {
     red_drawable_unref(COMMON_CHANNEL(display)->worker, drawable->red_drawable, drawable->group_id);
+    }
     drawable_free(display, drawable);
     display->drawable_count--;
 }
 
-static void surface_flush(DisplayChannel *display, int surface_id, SpiceRect *rect)
-{
-    display_channel_draw(display, rect, surface_id);
-}
-
-static void red_flush_source_surfaces(DisplayChannel *display, Drawable *drawable)
+static void drawable_deps_draw(DisplayChannel *display, Drawable *drawable)
 {
     int x;
     int surface_id;
 
     for (x = 0; x < 3; ++x) {
         surface_id = drawable->surface_deps[x];
         if (surface_id != -1 && drawable->depend_items[x].drawable) {
-            remove_depended_item(&drawable->depend_items[x]);
-            surface_flush(display, surface_id, &drawable->red_drawable->surfaces_rects[x]);
+            depended_item_remove(&drawable->depend_items[x]);
+            display_channel_draw(display, &drawable->red_drawable->surfaces_rects[x], surface_id);
         }
     }
 }
 
 void drawable_draw(DisplayChannel *display, Drawable *drawable)
 {
     RedSurface *surface;
     SpiceCanvas *canvas;
     SpiceClip clip = drawable->red_drawable->clip;
 
-    red_flush_source_surfaces(display, drawable);
+    drawable_deps_draw(display, drawable);
 
     surface = &display->surfaces[drawable->surface_id];
     canvas = surface->context.canvas;
     spice_return_if_fail(canvas);
 
     image_cache_aging(&display->image_cache);
 
     region_add(&surface->draw_dirty_region, &drawable->red_drawable->bbox);
 
     switch (drawable->red_drawable->type) {
@@ -1510,20 +1507,27 @@
 } SurfaceDestroyItem;
 
 typedef struct UpgradeItem {
     PipeItem base;
     int refs;
     Drawable *drawable;
     SpiceClipRects *rects;
 } UpgradeItem;
 
 
+void                       display_channel_draw                      (DisplayChannel *display,
+                                                                      const SpiceRect *area,
+                                                                      int surface_id);
+void                       display_channel_draw_till                 (DisplayChannel *display,
+                                                                      const SpiceRect *area,
+                                                                      int surface_id,
+                                                                      Drawable *last);
 void                       display_channel_free_some                 (DisplayChannel *display);
 void                       display_channel_set_stream_video          (DisplayChannel *display,
                                                                       int stream_video);
 int                        display_channel_get_streams_timeout       (DisplayChannel *display);
 void                       display_channel_compress_stats_print      (const DisplayChannel *display);
 void                       display_channel_compress_stats_reset      (DisplayChannel *display);
 Drawable *                 display_channel_drawable_try_new          (DisplayChannel *display,
                                                                       int group_id,
                                                                       int process_commands_generation);
 void                       display_channel_drawable_unref            (DisplayChannel *display, Drawable *drawable);
@@ -1654,20 +1658,21 @@
         region_add(rgn, data->rects + i);
     }
 }
 
 void current_remove_drawable(DisplayChannel *display, Drawable *item);
 void red_pipes_remove_drawable(Drawable *drawable);
 void current_remove(DisplayChannel *display, TreeItem *item);
 void detach_streams_behind(DisplayChannel *display, QRegion *region, Drawable *drawable);
 void drawable_draw(DisplayChannel *display, Drawable *item);
 void current_remove_all(DisplayChannel *display, int surface_id);
+void drawables_init(DisplayChannel *display);
 
 #endif /* DISPLAY_CHANNEL_H_ */
 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
    Copyright (C) 2009 Red Hat, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
@@ -1795,23 +1800,20 @@
 } BitmapDataType;
 
 typedef struct BitmapData {
     BitmapDataType type;
     uint64_t id; // surface id or cache item id
     SpiceRect lossy_rect;
 } BitmapData;
 
 static inline int validate_surface(DisplayChannel *display, uint32_t surface_id);
 
-static void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int surface_id);
-static void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, int surface_id,
-                                      Drawable *last);
 static inline void display_begin_send_message(RedChannelClient *rcc);
 static void red_create_surface(DisplayChannel *display, uint32_t surface_id, uint32_t width,
                                uint32_t height, int32_t stride, uint32_t format,
                                void *line_0, int data_is_valid, int send_client);
 
 QXLInstance* red_worker_get_qxl(RedWorker *worker)
 {
     spice_return_val_if_fail(worker != NULL, NULL);
 
     return worker->qxl;
@@ -2401,21 +2403,21 @@
 {
     RedSurface *surface;
     RingItem *ring_item;
 
     surface = &display->surfaces[surface_id];
 
     while ((ring_item = ring_get_tail(&surface->depend_on_me))) {
         Drawable *drawable;
         DependItem *depended_item = SPICE_CONTAINEROF(ring_item, DependItem, ring_item);
         drawable = depended_item->drawable;
-        surface_flush(display, drawable->surface_id, &drawable->red_drawable->bbox);
+        display_channel_draw(display, &drawable->red_drawable->bbox, drawable->surface_id);
     }
 
     return TRUE;
 }
 
 static inline void add_to_surface_dependency(DisplayChannel *display, int depend_on_surface_id,
                                              DependItem *depend_item, Drawable *drawable)
 {
     RedSurface *surface;
 

Frediano


More information about the Spice-devel mailing list