Add stubs for property_changed virtual functions
[profile/ivi/pixman.git] / pixman / pixman-linear-gradient.c
1 /*
2  * Copyright © 2000 SuSE, Inc.
3  * Copyright © 2007 Red Hat, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of SuSE not be used in advertising or
10  * publicity pertaining to distribution of the software without specific,
11  * written prior permission.  SuSE makes no representations about the
12  * suitability of this software for any purpose.  It is provided "as is"
13  * without express or implied warranty.
14  *
15  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #include <config.h>
24 #include <stdlib.h>
25 #include "pixman-private.h"
26
27 static source_pict_class_t
28 linear_gradient_classify (pixman_image_t *image,
29                           int             x,
30                           int             y,
31                           int             width,
32                           int             height)
33 {
34     linear_gradient_t *linear = (linear_gradient_t *)image;
35     pixman_vector_t   v;
36     pixman_fixed_32_32_t l;
37     pixman_fixed_48_16_t dx, dy, a, b, off;
38     pixman_fixed_48_16_t factors[4];
39     int      i;
40     
41     image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
42     
43     dx = linear->p2.x - linear->p1.x;
44     dy = linear->p2.y - linear->p1.y;
45     l = dx * dx + dy * dy;
46     if (l)
47     {
48         a = (dx << 32) / l;
49         b = (dy << 32) / l;
50     }
51     else
52     {
53         a = b = 0;
54     }
55     
56     off = (-a * linear->p1.x
57            -b * linear->p1.y) >> 16;
58     
59     for (i = 0; i < 3; i++)
60     {
61         v.vector[0] = pixman_int_to_fixed ((i % 2) * (width  - 1) + x);
62         v.vector[1] = pixman_int_to_fixed ((i / 2) * (height - 1) + y);
63         v.vector[2] = pixman_fixed_1;
64         
65         if (image->common.transform)
66         {
67             if (!pixman_transform_point_3d (image->common.transform, &v))
68             {
69                 image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
70                 
71                 return image->source.class;
72             }
73         }
74         
75         factors[i] = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
76     }
77     
78     if (factors[2] == factors[0])
79         image->source.class = SOURCE_IMAGE_CLASS_HORIZONTAL;
80     else if (factors[1] == factors[0])
81         image->source.class = SOURCE_IMAGE_CLASS_VERTICAL;
82
83     return image->source.class;
84 }
85
86 static void
87 linear_gradient_property_changed (pixman_image_t *image)
88 {
89     
90 }
91
92 PIXMAN_EXPORT pixman_image_t *
93 pixman_image_create_linear_gradient (pixman_point_fixed_t         *p1,
94                                      pixman_point_fixed_t         *p2,
95                                      const pixman_gradient_stop_t *stops,
96                                      int                           n_stops)
97 {
98     pixman_image_t *image;
99     linear_gradient_t *linear;
100     
101     return_val_if_fail (n_stops >= 2, NULL);
102     
103     image = _pixman_image_allocate();
104     
105     if (!image)
106         return NULL;
107     
108     linear = &image->linear;
109     
110     if (!_pixman_init_gradient (&linear->common, stops, n_stops))
111     {
112         free (image);
113         return NULL;
114     }
115     
116     linear->p1 = *p1;
117     linear->p2 = *p2;
118     
119     image->type = LINEAR;
120     image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
121     image->common.classify = linear_gradient_classify;
122     image->common.property_changed = linear_gradient_property_changed;
123
124     linear_gradient_property_changed (image);
125     
126     return image;
127 }