[Spice-devel] [PATCH 4/4] server/red_worker: introduce {display, cursor}_connected

Marc-André Lureau marcandre.lureau at gmail.com
Tue Mar 29 10:33:44 PDT 2011


ack

On Sun, Mar 27, 2011 at 9:03 PM, Alon Levy <alevy at redhat.com> wrote:
> Instead of checking for worker->{display,cursor}_channel directory.
^^^ s/directory/directly

> ---
>  server/red_worker.c |   56 ++++++++++++++++++++++++++++++++++----------------
>  1 files changed, 38 insertions(+), 18 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 834ba3c..95170e1 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -1170,9 +1170,21 @@ static inline void red_handle_drawable_surfaces_client_synced(RedWorker *worker,
>     red_add_surface_image(worker, drawable->surface_id);
>  }
>
> +static int display_connected(RedWorker *worker)
> +{
> +    return (worker->display_channel && red_channel_is_connected(
> +        &worker->display_channel->common.base));
> +}
> +
> +static int cursor_connected(RedWorker *worker)
> +{
> +    return (worker->cursor_channel && red_channel_is_connected(
> +        &worker->cursor_channel->common.base));
> +}
> +
>  static inline void red_pipe_add_drawable(RedWorker *worker, Drawable *drawable)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>
> @@ -1182,9 +1194,10 @@ static inline void red_pipe_add_drawable(RedWorker *worker, Drawable *drawable)
>     red_channel_pipe_add(&worker->display_channel->common.base, &drawable->pipe_item);
>  }
>
> +// TODO: this can only be meaningful if it becomes most advanced tail from clients.
>  static inline void red_pipe_add_drawable_to_tail(RedWorker *worker, Drawable *drawable)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>     drawable->refs++;
> @@ -1194,7 +1207,7 @@ static inline void red_pipe_add_drawable_to_tail(RedWorker *worker, Drawable *dr
>  static inline void red_pipe_add_drawable_after(RedWorker *worker, Drawable *drawable,
>                                                Drawable *pos_after)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>
> @@ -1208,7 +1221,7 @@ static inline void red_pipe_add_drawable_after(RedWorker *worker, Drawable *draw
>
>  static inline PipeItem *red_pipe_get_tail(RedWorker *worker)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return NULL;
>     }
>
> @@ -1228,7 +1241,7 @@ static inline void red_pipe_remove_drawable(RedWorker *worker, Drawable *drawabl
>
>  static inline void red_pipe_add_image_item(RedWorker *worker, ImageItem *item)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>     item->refs++;
> @@ -1238,7 +1251,7 @@ static inline void red_pipe_add_image_item(RedWorker *worker, ImageItem *item)
>  static inline void red_pipe_add_image_item_after(RedWorker *worker, ImageItem *item,
>                                                  PipeItem *pos)
>  {
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>     item->refs++;
> @@ -1346,7 +1359,7 @@ static inline void red_destroy_surface_item(RedWorker *worker, uint32_t surface_
>     SurfaceDestroyItem *destroy;
>     RedChannel *channel;
>
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>     worker->display_channel->surface_client_created[surface_id] = FALSE;
> @@ -1661,7 +1674,7 @@ static void red_clear_surface_drawables_from_pipe(RedWorker *worker, int surface
>     PipeItem *item;
>     int x;
>
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>
> @@ -2269,11 +2282,11 @@ static void red_detach_streams_behind(RedWorker *worker, QRegion *region)
>
>  static void red_streams_update_clip(RedWorker *worker, Drawable *drawable)
>  {
> -    DisplayChannel *channel;
> +    DisplayChannel *channel = worker->display_channel;
>     Ring *ring;
>     RingItem *item;
>
> -    if (!(channel = worker->display_channel)) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>
> @@ -2545,7 +2558,7 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream)
>  {
>     ASSERT(stream->current);
>
> -    if (!worker->display_channel || !IS_LOW_BANDWIDTH()) {
> +    if (!display_connected(worker) || !IS_LOW_BANDWIDTH()) {
>         return;
>     }
>
> @@ -4126,9 +4139,16 @@ static CursorItem *get_cursor_item(RedWorker *worker, RedCursorCmd *cmd, uint32_
>
>  void qxl_process_cursor(RedWorker *worker, RedCursorCmd *cursor_cmd, uint32_t group_id)
>  {
> -    CursorItem *item = get_cursor_item(worker, cursor_cmd, group_id);
> +    CursorItem *item;
>     int cursor_show = FALSE;
>
> +    if (!cursor_connected(worker)) {
> +        red_put_cursor_cmd(cursor_cmd);
> +        free(cursor_cmd);
> +        return;
> +    }
> +    item = get_cursor_item(worker, cursor_cmd, group_id);
> +
>     switch (cursor_cmd->type) {
>     case QXL_CURSOR_SET:
>         worker->cursor_visible = cursor_cmd->u.set.visible;
> @@ -4174,7 +4194,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
>     int n = 0;
>
>     *ring_is_empty = FALSE;
> -    while (!worker->cursor_channel || worker->cursor_channel->common.base.pipe_size <= max_pipe_size) {
> +    while (!cursor_connected(worker) || worker->cursor_channel->common.base.pipe_size <= max_pipe_size) {
>         if (!worker->qxl->st->qif->get_cursor_command(worker->qxl, &ext_cmd)) {
>             *ring_is_empty = TRUE;
>             if (worker->repoll_cursor_ring < CMD_RING_POLL_RETRIES) {
> @@ -4214,7 +4234,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
>     uint64_t start = red_now();
>
>     *ring_is_empty = FALSE;
> -    while (!worker->display_channel || worker->display_channel->common.base.pipe_size <= max_pipe_size) {
> +    while (!display_connected(worker) || worker->display_channel->common.base.pipe_size <= max_pipe_size) {
>         if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
>             *ring_is_empty = TRUE;;
>             if (worker->repoll_cmd_ring < CMD_RING_POLL_RETRIES) {
> @@ -4392,7 +4412,7 @@ static void red_add_surface_image(RedWorker *worker, int surface_id)
>
>     surface = &worker->surfaces[surface_id];
>
> -    if (!worker->display_channel || !surface->context.canvas) {
> +    if (!display_connected(worker) || !surface->context.canvas) {
>         return;
>     }
>
> @@ -8406,7 +8426,7 @@ static inline void __red_create_surface_item(RedWorker *worker, int surface_id,
>     RedSurface *surface;
>     SurfaceCreateItem *create;
>
> -    if (!worker->display_channel) {
> +    if (!display_connected(worker)) {
>         return;
>     }
>
> @@ -8507,7 +8527,7 @@ static inline void flush_display_commands(RedWorker *worker)
>         int sleep_count = 0;
>         for (;;) {
>             red_channel_push(&worker->display_channel->common.base);
> -            if (!worker->display_channel ||
> +            if (!display_connected(worker) ||
>                  worker->display_channel->common.base.pipe_size <= MAX_PIPE_SIZE) {
>                 break;
>             }
> @@ -8551,7 +8571,7 @@ static inline void flush_cursor_commands(RedWorker *worker)
>         int sleep_count = 0;
>         for (;;) {
>             red_channel_push(&worker->cursor_channel->common.base);
> -            if (!worker->cursor_channel ||
> +            if (!cursor_connected(worker) ||
>                                         worker->cursor_channel->common.base.pipe_size <= MAX_PIPE_SIZE) {
>                 break;
>             }
> --
> 1.7.4.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Marc-André Lureau


More information about the Spice-devel mailing list