2 * Copyright © 2000 SuSE, Inc.
3 * Copyright © 2007 Red Hat, Inc.
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.
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.
25 #include "pixman-private.h"
28 radial_gradient_property_changed (pixman_image_t *image)
30 image->common.get_scanline_32 = (scanFetchProc)pixmanFetchSourcePict;
31 image->common.get_scanline_64 = (scanFetchProc)_pixman_image_get_scanline_64_generic;
34 PIXMAN_EXPORT pixman_image_t *
35 pixman_image_create_radial_gradient (pixman_point_fixed_t *inner,
36 pixman_point_fixed_t *outer,
37 pixman_fixed_t inner_radius,
38 pixman_fixed_t outer_radius,
39 const pixman_gradient_stop_t *stops,
42 pixman_image_t *image;
43 radial_gradient_t *radial;
45 return_val_if_fail (n_stops >= 2, NULL);
47 image = _pixman_image_allocate();
52 radial = &image->radial;
54 if (!_pixman_init_gradient (&radial->common, stops, n_stops))
62 radial->c1.x = inner->x;
63 radial->c1.y = inner->y;
64 radial->c1.radius = inner_radius;
65 radial->c2.x = outer->x;
66 radial->c2.y = outer->y;
67 radial->c2.radius = outer_radius;
68 radial->cdx = pixman_fixed_to_double (radial->c2.x - radial->c1.x);
69 radial->cdy = pixman_fixed_to_double (radial->c2.y - radial->c1.y);
70 radial->dr = pixman_fixed_to_double (radial->c2.radius - radial->c1.radius);
71 radial->A = (radial->cdx * radial->cdx
72 + radial->cdy * radial->cdy
73 - radial->dr * radial->dr);
75 image->common.property_changed = radial_gradient_property_changed;
77 radial_gradient_property_changed (image);