[PATCH 06/20] dix: document GetDirection

Simon Thum simon.thum at gmx.de
Wed Apr 20 14:10:17 PDT 2011


On 04/20/2011 08:28 AM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/ptrveloc.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
> index fafbbb0..d37d1d9 100644
> --- a/dix/ptrveloc.c
> +++ b/dix/ptrveloc.c
> @@ -506,7 +506,13 @@ DoGetDirection(int dx, int dy){
>  #define DIRECTION_CACHE_RANGE 5
>  #define DIRECTION_CACHE_SIZE (DIRECTION_CACHE_RANGE*2+1)
>  
> -/* cache DoGetDirection(). */
> +/* cache DoGetDirection().
> + * To avoid excessive use of direction calculation, cache the values for
> + * [-5..5] for both x/y. Anything outside of that is calcualted on the fly.
> + *
> + * @return A bitmask for N, NE, S, SE, etc. indicating the directions for
> + * this movement.
> + */
>  static int
>  GetDirection(int dx, int dy){
>      static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
Reviewed-by: Simon Thum <simon.thum at gmx.de>

Since high-precision (i.e. high-dx/dy) devices become more common, you
might want to increase the range to avoid those atan2()s, or shift back
into range. Precision isn't paramount here.

Cheers,

Simon



More information about the xorg-devel mailing list