[PATCH weston] Simply the matrix calculation for zooming

Jasper St. Pierre jstpierre at mecheye.net
Fri Apr 25 14:14:27 PDT 2014


I fully support any patch that removes the phrase "modelview".


On Fri, Apr 25, 2014 at 5:07 PM, Kristian Høgsberg <hoegsberg at gmail.com>wrote:

> On Fri, Apr 25, 2014 at 01:19:37PM +0100, Neil Roberts wrote:
> > In order to apply the zoom transformation to the output matrix, Weston
> was
> > doing the following:
> >
> > • Create a temporary matrix to hold the translation
> > • Invert the translation matrix using weston_matrix_invert into
> >   another temporary matrix
> > • Scale that matrix by the scale factor
> > • Multiply the current matrix with the temporary matrix
> >
> > Using weston_matrix_invert to invert a translation matrix is over the
> top.
> > Instead we can just negate the values we pass to weston_matrix_translate.
> > Matrix multiplication is associative so creating a temporary matrix to
> hold the
> > scale and translation transform should be equivalent to just applying
> them
> > directly to the output matrix.
>
> Heh, nice clean up, that always looked like it was too complicated for its
> own good.  Patch applied.
>
> Kristian
>
> > ---
> >  src/compositor.c | 13 ++++---------
> >  1 file changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/src/compositor.c b/src/compositor.c
> > index fd2decb..f836cf7 100644
> > --- a/src/compositor.c
> > +++ b/src/compositor.c
> > @@ -3186,8 +3186,6 @@ WL_EXPORT void
> >  weston_output_update_matrix(struct weston_output *output)
> >  {
> >       float magnification;
> > -     struct weston_matrix camera;
> > -     struct weston_matrix modelview;
> >
> >       weston_matrix_init(&output->matrix);
> >       weston_matrix_translate(&output->matrix,
> > @@ -3202,14 +3200,11 @@ weston_output_update_matrix(struct weston_output
> *output)
> >
> >       if (output->zoom.active) {
> >               magnification = 1 / (1 - output->zoom.spring_z.current);
> > -             weston_matrix_init(&camera);
> > -             weston_matrix_init(&modelview);
> >               weston_output_update_zoom(output);
> > -             weston_matrix_translate(&camera, output->zoom.trans_x,
> > -                                     -output->zoom.trans_y, 0);
> > -             weston_matrix_invert(&modelview, &camera);
> > -             weston_matrix_scale(&modelview, magnification,
> magnification, 1.0);
> > -             weston_matrix_multiply(&output->matrix, &modelview);
> > +             weston_matrix_translate(&output->matrix,
> -output->zoom.trans_x,
> > +                                     output->zoom.trans_y, 0);
> > +             weston_matrix_scale(&output->matrix, magnification,
> > +                                 magnification, 1.0);
> >       }
> >
> >       output->dirty = 0;
> > --
> > 1.9.0
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>



-- 
  Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140425/d847dbba/attachment.html>


More information about the wayland-devel mailing list