Back to index

lightning-sunbird  0.9+nobinonly
ictransform.c
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2000 SuSE, Inc.
00003  *
00004  * Permission to use, copy, modify, distribute, and sell this software and its
00005  * documentation for any purpose is hereby granted without fee, provided that
00006  * the above copyright notice appear in all copies and that both that
00007  * copyright notice and this permission notice appear in supporting
00008  * documentation, and that the name of SuSE not be used in advertising or
00009  * publicity pertaining to distribution of the software without specific,
00010  * written prior permission.  SuSE makes no representations about the
00011  * suitability of this software for any purpose.  It is provided "as is"
00012  * without express or implied warranty.
00013  *
00014  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
00015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
00016  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00017  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
00018  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
00019  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00020  *
00021  * Author:  Keith Packard, SuSE, Inc.
00022  */
00023 
00024 #include "icint.h"
00025 
00026 #define MAX_FIXED_48_16         ((xFixed_48_16) 0x7fffffff)
00027 #define MIN_FIXED_48_16         (-((xFixed_48_16) 1 << 31))
00028 
00029 int
00030 pixman_transform_point (pixman_transform_t       *transform,
00031                 pixman_vector_t    *vector)
00032 {
00033     pixman_vector_t      result;
00034     int                  i, j;
00035     xFixed_32_32    partial;
00036     xFixed_48_16    v;
00037 
00038     for (j = 0; j < 3; j++)
00039     {
00040        v = 0;
00041        for (i = 0; i < 3; i++)
00042        {
00043            partial = ((xFixed_48_16) transform->matrix[j][i] * 
00044                      (xFixed_48_16) vector->vector[i]);
00045            v += partial >> 16;
00046        }
00047        if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
00048            return 0;
00049        result.vector[j] = (xFixed) v;
00050     }
00051     if (!result.vector[2])
00052        return 0;
00053     for (j = 0; j < 2; j++)
00054     {
00055        partial = (xFixed_48_16) result.vector[j] << 16;
00056        v = partial / result.vector[2];
00057        if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
00058            return 0;
00059        vector->vector[j] = (xFixed) v;
00060     }
00061     vector->vector[2] = xFixed1;
00062     return 1;
00063 }
00064