[Spice-devel] [RFC v4 04/62] server/red_worker: introduce {display, cursor}_connected

Alon Levy alevy at redhat.com
Wed May 4 23:02:29 PDT 2011


On Tue, May 03, 2011 at 01:53:34AM +0200, Marc-André Lureau wrote:
> perhaps rename xxx_connected() -> xxx_is_connected() for consistency
> 

done.

> On Tue, Apr 26, 2011 at 12:54 PM, Alon Levy <alevy at redhat.com> wrote:
> > Instead of checking for worker->{display,cursor}_channel directly.
> > ---
> >  server/red_worker.c |   55 ++++++++++++++++++++++++++++++++++----------------
> >  1 files changed, 37 insertions(+), 18 deletions(-)
> >
> > diff --git a/server/red_worker.c b/server/red_worker.c
> > index 834ba3c..8f7443b 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;
> >     }
> >
> > @@ -1184,7 +1196,7 @@ static inline void red_pipe_add_drawable(RedWorker *worker, Drawable *drawable)
> >
> >  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 +1206,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 +1220,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 +1240,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 +1250,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 +1358,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 +1673,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 +2281,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 +2557,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 +4138,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 +4193,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 +4233,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 +4411,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 +8425,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 +8526,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 +8570,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.4
> >
> > _______________________________________________
> > 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