[PATCH 19/20] dix: reduce the work done by ApplySoftening

Simon Thum simon.thum at gmx.de
Wed Apr 20 16:05:20 PDT 2011


On 04/20/2011 08:28 AM, Peter Hutterer wrote:
> We can modify fdx/fdy in-place rather than requiring dx/dy as well. And the
> decision to soften can be made in the caller (unless decided by the velocity
> state).
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/ptrveloc.c |   31 ++++++++++++++++---------------
>  1 files changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
> index f4fcd39..0741604 100644
> --- a/dix/ptrveloc.c
> +++ b/dix/ptrveloc.c
> @@ -712,21 +712,21 @@ ApplySimpleSoftening(int prev_delta, int delta)
>  }
>  
>  
> +/**
> + * Soften the delta based on previous deltas stored in vel.
> + *
> + * @param[in,out] fdx Delta X, modified in-place.
> + * @param[in,out] fdx Delta Y, modified in-place.
> + */
>  static void
>  ApplySoftening(
>          DeviceVelocityPtr vel,
> -        int dx,
> -        int dy,
>          float* fdx,
> -        float* fdy,
> -        BOOL do_soften)
> +        float* fdy)
>  {
> -    if (do_soften && vel->use_softening) {
> -        *fdx = ApplySimpleSoftening(vel->last_dx, dx);
> -        *fdy = ApplySimpleSoftening(vel->last_dy, dy);
> -    } else {
> -        *fdx = dx;
> -        *fdy = dy;
> +    if (vel->use_softening) {
> +        *fdx = ApplySimpleSoftening(vel->last_dx, *fdx);
> +        *fdy = ApplySimpleSoftening(vel->last_dy, *fdy);
>      }
>  }
>  
> @@ -1122,7 +1122,7 @@ acceleratePointerPredictable(
>      ValuatorMask* val,
>      CARD32 evtime)
>  {
> -    float fdx, fdy, tmp, mult; /* no need to init */
> +    float tmp, mult; /* no need to init */
>      int dx = 0, dy = 0, tmpi;
>      DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
>      Bool soften = TRUE;
> @@ -1157,10 +1157,11 @@ acceleratePointerPredictable(
>                                              (float)dev->ptrfeed->ctrl.den);
>  
>              if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
> -                ApplySoftening(velocitydata,
> -                               dx, dy,
> -                               &fdx, &fdy,
> -                               (mult > 1.0f) && soften);
> +                float fdx = dx,
> +                      fdy = dy;
> +
> +                if (mult > 1.0f && soften)
> +                    ApplySoftening(velocitydata, &fdx, &fdy);
>                  ApplyConstantDeceleration(velocitydata, &fdx, &fdy);
>  
>                  /* Calculate the new delta (with accel) and drop it back
Reviewed-by: Simon Thum <simon.thum at gmx.de>

Cheers,

Simon



More information about the xorg-devel mailing list