<div dir="ltr">Okay, thanks for the info. Will try to fix them all.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 1, 2016 at 5:51 AM, Oded Gabbay <span dir="ltr"><<a href="mailto:oded.gabbay@gmail.com" target="_blank">oded.gabbay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Jan 22, 2016 at 11:41 AM, <<a href="mailto:spitzak@gmail.com">spitzak@gmail.com</a>> wrote:<br>
><br>
> From: Bill Spitzak <<a href="mailto:spitzak@gmail.com">spitzak@gmail.com</a>><br>
><br>
> This is much more accurate and less blurry. In particular the filtering does<br>
> not change as the image is rotated.<br>
><br>
> Signed-off-by: Bill Spitzak <<a href="mailto:spitzak@gmail.com">spitzak@gmail.com</a>><br>
> ---<br>
>  demos/scale.c | 102 +++++++++++++++++++++++++++++++++++-----------------------<br>
>  1 file changed, 61 insertions(+), 41 deletions(-)<br>
><br>
> diff --git a/demos/scale.c b/demos/scale.c<br>
> index d00307e..0995ad0 100644<br>
> --- a/demos/scale.c<br>
> +++ b/demos/scale.c<br>
> @@ -55,50 +55,70 @@ get_widget (app_t *app, const char *name)<br>
>      return widget;<br>
>  }<br>
><br>
> -static double<br>
> -min4 (double a, double b, double c, double d)<br>
> -{<br>
> -    double m1, m2;<br>
> -<br>
> -    m1 = MIN (a, b);<br>
> -    m2 = MIN (c, d);<br>
> -    return MIN (m1, m2);<br>
> -}<br>
> -<br>
> -static double<br>
> -max4 (double a, double b, double c, double d)<br>
> -{<br>
> -    double m1, m2;<br>
> -<br>
> -    m1 = MAX (a, b);<br>
> -    m2 = MAX (c, d);<br>
> -    return MAX (m1, m2);<br>
> -}<br>
> -<br>
> +/* Figure out the boundary of a diameter=1 circle transformed into an ellipse<br>
> + * by trans. Proof that this is the correct calculation:<br>
> + *<br>
> + * Transform x,y to u,v by this matrix calculation:<br>
> + *<br>
> + *  |u|   |a c| |x|<br>
> + *  |v| = |b d|*|y|<br>
> + *<br>
> + * Horizontal component:<br>
> + *<br>
> + *  u = ax+cy (1)<br>
> + *<br>
> + * For each x,y on a radius-1 circle (p is angle to the point):<br>
> + *<br>
> + *  x^2+y^2 = 1<br>
> + *  x = cos(p)<br>
> + *  y = sin(p)<br>
> + *  dx/dp = -sin(p) = -y<br>
> + *  dy/dp = cos(p) = x<br>
> + *<br>
> + * Figure out derivative of (1) relative to p:<br>
> + *<br>
> + *  du/dp = a(dx/dp) + c(dy/dp)<br>
> + *        = -ay + cx<br>
> + *<br>
> + * The min and max u are when du/dp is zero:<br>
> + *<br>
> + *  -ay + cx = 0<br>
> + *  cx = ay<br>
> + *  c = ay/x  (2)<br>
> + *  y = cx/a  (3)<br>
> + *<br>
> + * Substitute (2) into (1) and simplify:<br>
> + *<br>
> + *  u = ax + ay^2/x<br>
> + *    = a(x^2+y^2)/x<br>
> + *    = a/x (because x^2+y^2 = 1)<br>
> + *  x = a/u (4)<br>
> + *<br>
> + * Substitute (4) into (3) and simplify:<br>
> + *<br>
> + *  y = c(a/u)/a<br>
> + *  y = c/u (5)<br>
> + *<br>
> + * Square (4) and (5) and add:<br>
> + *<br>
> + *  x^2+y^2 = (a^2+c^2)/u^2<br>
> + *<br>
> + * But x^2+y^2 is 1:<br>
> + *<br>
> + *  1 = (a^2+c^2)/u^2<br>
> + *  u^2 = a^2+c^2<br>
> + *  u = hypot(a,c)<br>
> + *<br>
> + * Similarily the max/min of v is at:<br>
> + *<br>
> + *  v = hypot(b,d)<br>
> + *<br>
> + */<br>
>  static void<br>
>  compute_extents (pixman_f_transform_t *trans, double *sx, double *sy)<br>
>  {<br>
> -    double min_x, max_x, min_y, max_y;<br>
> -    pixman_f_vector_t v[4] =<br>
> -    {<br>
> -       { { 1, 1, 1 } },<br>
> -       { { -1, 1, 1 } },<br>
> -       { { -1, -1, 1 } },<br>
> -       { { 1, -1, 1 } },<br>
> -    };<br>
> -<br>
> -    pixman_f_transform_point (trans, &v[0]);<br>
> -    pixman_f_transform_point (trans, &v[1]);<br>
> -    pixman_f_transform_point (trans, &v[2]);<br>
> -    pixman_f_transform_point (trans, &v[3]);<br>
> -<br>
> -    min_x = min4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]);<br>
> -    max_x = max4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]);<br>
> -    min_y = min4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]);<br>
> -    max_y = max4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]);<br>
> -<br>
> -    *sx = (max_x - min_x) / 2.0;<br>
> -    *sy = (max_y - min_y) / 2.0;<br>
> +    *sx = hypot (trans->m[0][0], trans->m[0][1]) / trans->m[2][2];<br>
> +    *sy = hypot (trans->m[1][0], trans->m[1][1]) / trans->m[2][2];<br>
>  }<br>
><br>
>  typedef struct<br>
> --<br>
> 1.9.1<br>
><br>
</div></div>> _______________________________________________<br>
> Pixman mailing list<br>
> <a href="mailto:Pixman@lists.freedesktop.org">Pixman@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/pixman" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/pixman</a><br>
<br>
Reviewed-by: Oded Gabbay <<a href="mailto:oded.gabbay@gmail.com">oded.gabbay@gmail.com</a>><br>
<br>
p.s. if we have additional versions of this patch series, and patches<br>
that got r-b are not modified, then please add my r-b to the patch so<br>
I would know I don't need to spend even a second over that patch.<br>
<br>
Thanks<br>
</blockquote></div><br></div>