Make the pixman_transform_point_3d() function public
[profile/ivi/pixman.git] / pixman / pixman-utils.c
1 /*
2  * Copyright © 2000 SuSE, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of SuSE not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  SuSE makes no representations about the
11  * suitability of this software for any purpose.  It is provided "as is"
12  * without express or implied warranty.
13  *
14  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
16  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
19  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  *
21  * Author:  Keith Packard, SuSE, Inc.
22  */
23
24 #include "pixman.h"
25 #include "pixman-private.h"
26
27 pixman_bool_t
28 pixman_transform_point_3d (pixman_transform_t *transform,
29                            pixman_vector_t *vector)
30 {
31     pixman_vector_t             result;
32     int                         i, j;
33     pixman_fixed_32_32_t        partial;
34     pixman_fixed_48_16_t        v;
35
36     for (j = 0; j < 3; j++)
37     {
38         v = 0;
39         for (i = 0; i < 3; i++)
40         {
41             partial = ((pixman_fixed_48_16_t) transform->matrix[j][i] *
42                        (pixman_fixed_48_16_t) vector->vector[i]);
43             v += partial >> 16;
44         }
45
46         if (v > pixman_max_fixed_48_16 || v < pixman_min_fixed_48_16)
47             return FALSE;
48
49         result.vector[j] = (pixman_fixed_48_16_t) v;
50     }
51     
52     if (!result.vector[2])
53         return FALSE;
54     
55     *vector = result;
56     return TRUE;
57 }