[Spice-devel] [PATCH 10/18] worker: move dcc_free_glz_drawable_instance
Frediano Ziglio
fziglio at redhat.com
Wed Nov 18 08:17:29 PST 2015
From: Marc-André Lureau <marcandre.lureau at gmail.com>
---
server/dcc-encoders.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
server/red_worker.c | 50 ++------------------------------------------------
server/red_worker.h | 3 +++
3 files changed, 52 insertions(+), 48 deletions(-)
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 90d0ce0..305d17e 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -425,3 +425,50 @@ void marshaller_add_compressed(SpiceMarshaller *m,
comp_buf = comp_buf->send_next;
} while (max);
}
+
+/* Remove from the to_free list and the instances_list.
+ When no instance is left - the RedGlzDrawable is released too. (and the qxl drawable too, if
+ it is not used by Drawable).
+ NOTE - 1) can be called only by the display channel that created the drawable
+ 2) it is assumed that the instance was already removed from the dictionary*/
+void dcc_free_glz_drawable_instance(DisplayChannelClient *dcc,
+ GlzDrawableInstanceItem *instance)
+{
+ DisplayChannel *display_channel = DCC_TO_DC(dcc);
+ RedWorker *worker = display_channel->common.worker;
+ RedGlzDrawable *glz_drawable;
+
+ spice_return_if_fail(instance);
+ spice_return_if_fail(instance->glz_drawable);
+
+ glz_drawable = instance->glz_drawable;
+
+ spice_return_if_fail(glz_drawable->dcc == dcc);
+ spice_return_if_fail(glz_drawable->instances_count > 0);
+
+ ring_remove(&instance->glz_link);
+ glz_drawable->instances_count--;
+
+ // when the remove callback is performed from the channel that the
+ // drawable belongs to, the instance is not added to the 'to_free' list
+ if (ring_item_is_linked(&instance->free_link)) {
+ ring_remove(&instance->free_link);
+ }
+
+ if (ring_is_empty(&glz_drawable->instances)) {
+ spice_return_if_fail(glz_drawable->instances_count == 0);
+
+ Drawable *drawable = glz_drawable->drawable;
+
+ if (drawable) {
+ ring_remove(&glz_drawable->drawable_link);
+ }
+ red_drawable_unref(worker, glz_drawable->red_drawable,
+ glz_drawable->group_id);
+ dcc->glz_drawable_count--;
+ if (ring_item_is_linked(&glz_drawable->link)) {
+ ring_remove(&glz_drawable->link);
+ }
+ free(glz_drawable);
+ }
+}
diff --git a/server/red_worker.c b/server/red_worker.c
index 9231ab5..9318a43 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -571,8 +571,8 @@ static inline void set_surface_release_info(QXLReleaseInfoExt *release_info_ext,
release_info_ext->group_id = group_id;
}
-static void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
- uint32_t group_id)
+void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
+ uint32_t group_id)
{
QXLReleaseInfoExt release_info_ext;
@@ -2006,52 +2006,6 @@ static void fill_base(SpiceMarshaller *base_marshaller, Drawable *drawable)
spice_marshall_DisplayBase(base_marshaller, &base);
}
-/* Remove from the to_free list and the instances_list.
- When no instance is left - the RedGlzDrawable is released too. (and the qxl drawable too, if
- it is not used by Drawable).
- NOTE - 1) can be called only by the display channel that created the drawable
- 2) it is assumed that the instance was already removed from the dictionary*/
-void dcc_free_glz_drawable_instance(DisplayChannelClient *dcc,
- GlzDrawableInstanceItem *glz_drawable_instance)
-{
- DisplayChannel *display_channel = DCC_TO_DC(dcc);
- RedWorker *worker = display_channel->common.worker;
- RedGlzDrawable *glz_drawable;
-
- spice_assert(glz_drawable_instance);
- spice_assert(glz_drawable_instance->glz_drawable);
-
- glz_drawable = glz_drawable_instance->glz_drawable;
-
- spice_assert(glz_drawable->dcc == dcc);
- spice_assert(glz_drawable->instances_count);
-
- ring_remove(&glz_drawable_instance->glz_link);
- glz_drawable->instances_count--;
- // when the remove callback is performed from the channel that the
- // drawable belongs to, the instance is not added to the 'to_free' list
- if (ring_item_is_linked(&glz_drawable_instance->free_link)) {
- ring_remove(&glz_drawable_instance->free_link);
- }
-
- if (ring_is_empty(&glz_drawable->instances)) {
- spice_assert(!glz_drawable->instances_count);
-
- Drawable *drawable = glz_drawable->drawable;
-
- if (drawable) {
- ring_remove(&glz_drawable->drawable_link);
- }
- red_drawable_unref(worker, glz_drawable->red_drawable,
- glz_drawable->group_id);
- dcc->glz_drawable_count--;
- if (ring_item_is_linked(&glz_drawable->link)) {
- ring_remove(&glz_drawable->link);
- }
- free(glz_drawable);
- }
-}
-
static void red_display_handle_glz_drawables_to_free(DisplayChannelClient* dcc)
{
RingItem *ring_link;
diff --git a/server/red_worker.h b/server/red_worker.h
index c64dcaf..063840d 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -22,6 +22,7 @@
#include <errno.h>
#include "red_common.h"
#include "red_dispatcher.h"
+#include "red_parse_qxl.h"
#define NUM_SURFACES 10000
@@ -111,6 +112,8 @@ QXLInstance* red_worker_get_qxl(RedWorker *worker);
RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
RedChannel* red_worker_get_display_channel(RedWorker *worker);
clockid_t red_worker_get_clockid(RedWorker *worker);
+void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
+ uint32_t group_id);
RedChannel *red_worker_new_channel(RedWorker *worker, int size,
const char *name,
--
2.4.3
More information about the Spice-devel
mailing list