<p dir="ltr">Yes, <br>
On Jun 18, 2014 11:57 PM, "Pekka Paalanen" <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br>
><br>
> On Wed, 18 Jun 2014 12:38:50 -0700<br>
> Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
> > On Fri, Jun 13, 2014 at 9:14 AM, George Kiagiadakis <<br>
> > <a href="mailto:george.kiagiadakis@collabora.com">george.kiagiadakis@collabora.com</a>> wrote:<br>
> ><br>
> > > This fixes at least the case where you want to do<br>
> > > wl_viewport.set_destination<br>
> > > to resize the surface but without attaching new content in it.<br>
> > > ---<br>
> > >  src/compositor.c | 60<br>
> > > +++++++++++++++++++++++++++++++++++++++++++-------------<br>
> > >  src/compositor.h |  2 ++<br>
> > >  2 files changed, 48 insertions(+), 14 deletions(-)<br>
> > ><br>
> > > diff --git a/src/compositor.c b/src/compositor.c<br>
> > > index 2fbfdbf..973c7e4 100644<br>
> > > --- a/src/compositor.c<br>
> > > +++ b/src/compositor.c<br>
> > > @@ -404,6 +404,7 @@ weston_surface_create(struct weston_compositor<br>
> > > *compositor)<br>
> > >         surface->buffer_viewport.buffer.scale = 1;<br>
> > >         surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);<br>
> > >         surface->buffer_viewport.surface.width = -1;<br>
> > > +       surface->pending.buffer_viewport.changed = 0;<br>
> > >         surface->pending.buffer_viewport = surface->buffer_viewport;<br>
> > >         surface->output = NULL;<br>
> > >         surface->pending.newly_attached = 0;<br>
> > > @@ -1211,13 +1212,12 @@ fixed_round_up_to_int(wl_fixed_t f)<br>
> > >  }<br>
> > ><br>
> > >  static void<br>
> > > -weston_surface_set_size_from_buffer(struct weston_surface *surface)<br>
> > > +weston_surface_calculate_size_from_buffer(struct weston_surface *surface)<br>
> > >  {<br>
> > >         struct weston_buffer_viewport *vp = &surface->buffer_viewport;<br>
> > >         int32_t width, height;<br>
> > ><br>
> > >         if (!surface->buffer_ref.buffer) {<br>
> > > -               surface_set_size(surface, 0, 0);<br>
> > >                 surface->width_from_buffer = 0;<br>
> > >                 surface->height_from_buffer = 0;<br>
> > >                 return;<br>
> > > @@ -1239,14 +1239,24 @@ weston_surface_set_size_from_buffer(struct<br>
> > > weston_surface *surface)<br>
> > ><br>
> > >         surface->width_from_buffer = width;<br>
> > >         surface->height_from_buffer = height;<br>
> > > +}<br>
> > > +<br>
> > > +static void<br>
> > > +weston_surface_update_size(struct weston_surface *surface)<br>
> > > +{<br>
> > > +       struct weston_buffer_viewport *vp = &surface->buffer_viewport;<br>
> > > +       int32_t width, height;<br>
> > > +<br>
> > > +       width = surface->width_from_buffer;<br>
> > > +       height = surface->height_from_buffer;<br>
> > ><br>
> > > -       if (vp->surface.width != -1) {<br>
> > > +       if (width != 0 && vp->surface.width != -1) {<br>
> > >                 surface_set_size(surface,<br>
> > >                                  vp->surface.width, vp->surface.height);<br>
> > >                 return;<br>
> > >         }<br>
> > ><br>
> > > -       if (vp->buffer.src_width != wl_fixed_from_int(-1)) {<br>
> > > +       if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1)) {<br>
> > >                 int32_t w = fixed_round_up_to_int(vp->buffer.src_width);<br>
> > >                 int32_t h = fixed_round_up_to_int(vp->buffer.src_height);<br>
> > ><br>
> > > @@ -1351,6 +1361,7 @@ weston_surface_reset_pending_buffer(struct<br>
> > > weston_surface *surface)<br>
> > >         surface->pending.sx = 0;<br>
> > >         surface-><a href="http://pending.sy">pending.sy</a> = 0;<br>
> > >         surface->pending.newly_attached = 0;<br>
> > > +       surface->pending.buffer_viewport.changed = 0;<br>
> > >  }<br>
> > ><br>
> > >  struct weston_frame_callback {<br>
> > > @@ -1520,7 +1531,7 @@ weston_surface_attach(struct weston_surface *surface,<br>
> > ><br>
> > >         surface->compositor->renderer->attach(surface, buffer);<br>
> > ><br>
> > > -       weston_surface_set_size_from_buffer(surface);<br>
> > > +       weston_surface_calculate_size_from_buffer(surface);<br>
> > >  }<br>
> > ><br>
> ><br>
> > I think we have an issue here.  If a client attaches a new buffer but does<br>
> > not commit for a while, the width/height_from_buffer and width/height will<br>
> > be out of sync.  That said, I think having surface_set_size_from_buffer<br>
> > here was wrong in the first place.  The new surface size should only take<br>
> > over after the commit.  Other than that, the patch looks fine to me.<br>
><br>
> Hmm, but weston_surface_attach() is only called from<br>
> weston_surface_commit() and weston_subsurface_commit_from_cache()...<br>
><br>
> The wl_surface.attach protocol handler is surface_attach() IIRC. Was<br>
> that a confusion?</p>
<p dir="ltr">Yes, I think it was.  In that case, this patch looks good.  Somewhere, I've got a branch that cleans that mess stuff up.<br>
--Jason<br>
><br>
><br>
> Thanks,<br>
> pq<br>
</p>