Re: [Spice-devel] [PATCH v2 2/2] Add DisplayChannelPrivate struct

2016-09-16 Thread Frediano Ziglio
> 
> On Thu, 2016-09-15 at 15:06 -0500, Jonathon Jongsma wrote:
> > On Thu, 2016-09-15 at 11:22 -0500, Jonathon Jongsma wrote:
> > > Move all of the DisplayChannel data memembers into a private
> > > struct
...

> > > @@ -783,11 +787,13 @@ static void handle_dev_oom(void *opaque,
> > > void
> > > *payload)
> > >  display_channel_free_some(worker->display_channel);
> > >  red_qxl_flush_resources(worker->qxl);
> > >  }
> > > +#if FIXME
> > >  spice_debug("OOM2 #draw=%u, #glz_draw=%u current %u pipes
> > > %u",
> > >  display->drawable_count,
> > >  display->encoder_shared_data.glz_drawable_count,
> > >  display->current_size,
> > >  red_channel_sum_pipes_size(display_red_channel));
> > > +#endif
> 
> I am ok to remove these debugs, do you have an idea how to fix them
> 

I would add a display_channel_debug_oom function.
I'll try to send some fixup.

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH v2 2/2] Add DisplayChannelPrivate struct

2016-09-16 Thread Pavel Grunt
On Thu, 2016-09-15 at 15:06 -0500, Jonathon Jongsma wrote:
> On Thu, 2016-09-15 at 11:22 -0500, Jonathon Jongsma wrote:
> > Move all of the DisplayChannel data memembers into a private
> > struct
> > to
> > encapsulate things better. This necessitated a few new 'public'
> > methods
> > and a small bit of refactoring to avoid poking into DisplayChannel
> > internals from too many places. The DisplayChannel and the
> > DisplayChannelClient are still far too intertwined to completely
> > avoid
> > accessing private data, so at the moment the private struct is
> > defined
> > in display-channel.h and the DisplayChannelClient implementation
> > still accesses it sometimes.
> > ---
> >  server/dcc-send.c|  16 +--
> >  server/dcc.c |  33 ++---
> >  server/display-channel.c | 314 
> > -
> > --
> >  server/display-channel.h |  13 +-
> >  server/red-worker.c  |   6 +
> >  server/stream.c  |  53 
> >  6 files changed, 227 insertions(+), 208 deletions(-)
> > 
> > diff --git a/server/dcc-send.c b/server/dcc-send.c
> > index 0afa25c..0635afa 100644
> > --- a/server/dcc-send.c
> > +++ b/server/dcc-send.c
> > @@ -96,7 +96,7 @@ static int
> > is_surface_area_lossy(DisplayChannelClient *dcc, uint32_t
> > surface_id,
> >  
> >  spice_return_val_if_fail(display_channel_validate_surface(dis
> > pla
> > y, surface_id), FALSE);
> >  
> > -surface = >surfaces[surface_id];
> > +surface = >priv->surfaces[surface_id];
> >  surface_lossy_region = >priv-
> > > surface_client_lossy_region[surface_id];
> > 
> >  
> >  if (!area) {
> > @@ -208,13 +208,13 @@ static void
> > red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
> >  io_image->descriptor.flags |=
> > SPICE_IMAGE_FLAGS_CACHE_ME;
> >  dcc->priv->send_data.pixmap_cache_items[dcc-
> > >priv-
> > > send_data.num_pixmap_cache_items++] =
> > 
> >   
> >    
> >    image->descriptor.id;
> > -stat_inc_counter(reds, display_channel-
> > > add_to_cache_counter, 1);
> > 
> > +stat_inc_counter(reds, display_channel->priv-
> > > add_to_cache_counter, 1);
> > 
> >  }
> >  }
> >  }
> >  
> >  if (!(io_image->descriptor.flags &
> > SPICE_IMAGE_FLAGS_CACHE_ME))
> > {
> > -stat_inc_counter(reds, display_channel-
> > >non_cache_counter,
> > 1);
> > +stat_inc_counter(reds, display_channel->priv-
> > > non_cache_counter, 1);
> > 
> >  }
> >  }
> >  
> > @@ -385,7 +385,7 @@ static FillBitsType
> > fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
> >  dcc->priv->send_data.pixmap_cache_items[dcc->priv-
> > > send_data.num_pixmap_cache_items++] =
> > 
> >  image.descriptor.id;
> >  if (can_lossy || !lossy_cache_item) {
> > -if (!display->enable_jpeg || lossy_cache_item) {
> > +if (!display->priv->enable_jpeg ||
> > lossy_cache_item)
> > {
> >  image.descriptor.type =
> > SPICE_IMAGE_TYPE_FROM_CACHE;
> >  } else {
> >  // making sure, in multiple monitor scenario,
> > that lossy items that
> > @@ -397,7 +397,7 @@ static FillBitsType
> > fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
> >   _palette_out,
> > _palette_out);
> >  spice_assert(bitmap_palette_out == NULL);
> >  spice_assert(lzplt_palette_out == NULL);
> > -stat_inc_counter(reds, display-
> > >cache_hits_counter,
> > 1);
> > +stat_inc_counter(reds, display->priv-
> > > cache_hits_counter, 1);
> > 
> >  pthread_mutex_unlock(>priv->pixmap_cache-
> > > lock);
> > 
> >  return FILL_BITS_TYPE_CACHE;
> >  } else {
> > @@ -420,7 +420,7 @@ static FillBitsType
> > fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
> >  return FILL_BITS_TYPE_SURFACE;
> >  }
> >  
> > -surface = >surfaces[surface_id];
> > +surface = >priv->surfaces[surface_id];
> >  image.descriptor.type = SPICE_IMAGE_TYPE_SURFACE;
> >  image.descriptor.flags = 0;
> >  image.descriptor.width = surface->context.width;
> > @@ -1862,7 +1862,7 @@ static void
> > display_channel_marshall_migrate_data(RedChannelClient *rcc,
> >  spice_marshaller_add(base_marshaller,
> >   (uint8_t *)_data,
> > sizeof(display_data) - sizeof(uint32_t));
> >  display_channel_marshall_migrate_data_surfaces(dcc,
> > base_marshaller,
> > -   display_channe
> > l-
> > > enable_jpeg);
> > 
> > +   display_channe
> > l-
> > > priv->enable_jpeg);
> > 
> >  }
> >  
> >  static void display_channel_marshall_pixmap_sync(RedChannelClient
> > *rcc,
> > @@ 

Re: [Spice-devel] [PATCH v2 2/2] Add DisplayChannelPrivate struct

2016-09-15 Thread Jonathon Jongsma
On Thu, 2016-09-15 at 11:22 -0500, Jonathon Jongsma wrote:
> Move all of the DisplayChannel data memembers into a private struct
> to
> encapsulate things better. This necessitated a few new 'public'
> methods
> and a small bit of refactoring to avoid poking into DisplayChannel
> internals from too many places. The DisplayChannel and the
> DisplayChannelClient are still far too intertwined to completely
> avoid
> accessing private data, so at the moment the private struct is
> defined
> in display-channel.h and the DisplayChannelClient implementation
> still accesses it sometimes.
> ---
>  server/dcc-send.c|  16 +--
>  server/dcc.c |  33 ++---
>  server/display-channel.c | 314 -
> --
>  server/display-channel.h |  13 +-
>  server/red-worker.c  |   6 +
>  server/stream.c  |  53 
>  6 files changed, 227 insertions(+), 208 deletions(-)
> 
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 0afa25c..0635afa 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -96,7 +96,7 @@ static int
> is_surface_area_lossy(DisplayChannelClient *dcc, uint32_t surface_id,
>  
>  spice_return_val_if_fail(display_channel_validate_surface(displa
> y, surface_id), FALSE);
>  
> -surface = >surfaces[surface_id];
> +surface = >priv->surfaces[surface_id];
>  surface_lossy_region = >priv-
> >surface_client_lossy_region[surface_id];
>  
>  if (!area) {
> @@ -208,13 +208,13 @@ static void
> red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
>  io_image->descriptor.flags |=
> SPICE_IMAGE_FLAGS_CACHE_ME;
>  dcc->priv->send_data.pixmap_cache_items[dcc->priv-
> >send_data.num_pixmap_cache_items++] =
>  
>    image->descriptor.id;
> -stat_inc_counter(reds, display_channel-
> >add_to_cache_counter, 1);
> +stat_inc_counter(reds, display_channel->priv-
> >add_to_cache_counter, 1);
>  }
>  }
>  }
>  
>  if (!(io_image->descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME))
> {
> -stat_inc_counter(reds, display_channel->non_cache_counter,
> 1);
> +stat_inc_counter(reds, display_channel->priv-
> >non_cache_counter, 1);
>  }
>  }
>  
> @@ -385,7 +385,7 @@ static FillBitsType
> fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
>  dcc->priv->send_data.pixmap_cache_items[dcc->priv-
> >send_data.num_pixmap_cache_items++] =
>  image.descriptor.id;
>  if (can_lossy || !lossy_cache_item) {
> -if (!display->enable_jpeg || lossy_cache_item) {
> +if (!display->priv->enable_jpeg || lossy_cache_item)
> {
>  image.descriptor.type =
> SPICE_IMAGE_TYPE_FROM_CACHE;
>  } else {
>  // making sure, in multiple monitor scenario,
> that lossy items that
> @@ -397,7 +397,7 @@ static FillBitsType
> fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
>   _palette_out,
> _palette_out);
>  spice_assert(bitmap_palette_out == NULL);
>  spice_assert(lzplt_palette_out == NULL);
> -stat_inc_counter(reds, display->cache_hits_counter,
> 1);
> +stat_inc_counter(reds, display->priv-
> >cache_hits_counter, 1);
>  pthread_mutex_unlock(>priv->pixmap_cache-
> >lock);
>  return FILL_BITS_TYPE_CACHE;
>  } else {
> @@ -420,7 +420,7 @@ static FillBitsType
> fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
>  return FILL_BITS_TYPE_SURFACE;
>  }
>  
> -surface = >surfaces[surface_id];
> +surface = >priv->surfaces[surface_id];
>  image.descriptor.type = SPICE_IMAGE_TYPE_SURFACE;
>  image.descriptor.flags = 0;
>  image.descriptor.width = surface->context.width;
> @@ -1862,7 +1862,7 @@ static void
> display_channel_marshall_migrate_data(RedChannelClient *rcc,
>  spice_marshaller_add(base_marshaller,
>   (uint8_t *)_data,
> sizeof(display_data) - sizeof(uint32_t));
>  display_channel_marshall_migrate_data_surfaces(dcc,
> base_marshaller,
> -   display_channel-
> >enable_jpeg);
> +   display_channel-
> >priv->enable_jpeg);
>  }
>  
>  static void display_channel_marshall_pixmap_sync(RedChannelClient
> *rcc,
> @@ -2148,7 +2148,7 @@ static void
> marshall_qxl_drawable(RedChannelClient *rcc,
>  if (item->stream && red_marshall_stream_data(rcc, m, item)) {
>  return;
>  }
> -if (display->enable_jpeg)
> +if (display->priv->enable_jpeg)
>  marshall_lossy_qxl_drawable(rcc, m, dpi);
>  else
>  marshall_lossless_qxl_drawable(rcc, m, dpi);
> diff --git a/server/dcc.c b/server/dcc.c
>