From c43c3628935722f489d5e5359413dbb17d4c4a44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sat, 2 May 2009 21:06:23 -0400 Subject: [PATCH] Split radial gradient images into pixman-radial-gradient.c --- pixman/Makefile.am | 1 + pixman/pixman-image.c | 44 -------------------------- pixman/pixman-radial-gradient.c | 70 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 pixman/pixman-radial-gradient.c diff --git a/pixman/Makefile.am b/pixman/Makefile.am index c4d27cb..cad1f39 100644 --- a/pixman/Makefile.am +++ b/pixman/Makefile.am @@ -19,6 +19,7 @@ libpixman_1_la_SOURCES = \ pixman-source.c \ pixman-solid-fill.c \ pixman-linear-gradient.c \ + pixman-radial-gradient.c \ pixman-transformed.c \ pixman-transformed-accessors.c \ pixman-utils.c \ diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 99388ed..ce087f3 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -300,50 +300,6 @@ pixman_image_unref (pixman_image_t *image) /* Constructors */ PIXMAN_EXPORT pixman_image_t * -pixman_image_create_radial_gradient (pixman_point_fixed_t *inner, - pixman_point_fixed_t *outer, - pixman_fixed_t inner_radius, - pixman_fixed_t outer_radius, - const pixman_gradient_stop_t *stops, - int n_stops) -{ - pixman_image_t *image; - radial_gradient_t *radial; - - return_val_if_fail (n_stops >= 2, NULL); - - image = _pixman_image_allocate(); - - if (!image) - return NULL; - - radial = &image->radial; - - if (!_pixman_init_gradient (&radial->common, stops, n_stops)) - { - free (image); - return NULL; - } - - image->type = RADIAL; - - radial->c1.x = inner->x; - radial->c1.y = inner->y; - radial->c1.radius = inner_radius; - radial->c2.x = outer->x; - radial->c2.y = outer->y; - radial->c2.radius = outer_radius; - radial->cdx = pixman_fixed_to_double (radial->c2.x - radial->c1.x); - radial->cdy = pixman_fixed_to_double (radial->c2.y - radial->c1.y); - radial->dr = pixman_fixed_to_double (radial->c2.radius - radial->c1.radius); - radial->A = (radial->cdx * radial->cdx - + radial->cdy * radial->cdy - - radial->dr * radial->dr); - - return image; -} - -PIXMAN_EXPORT pixman_image_t * pixman_image_create_conical_gradient (pixman_point_fixed_t *center, pixman_fixed_t angle, const pixman_gradient_stop_t *stops, diff --git a/pixman/pixman-radial-gradient.c b/pixman/pixman-radial-gradient.c new file mode 100644 index 0000000..b1e617d --- /dev/null +++ b/pixman/pixman-radial-gradient.c @@ -0,0 +1,70 @@ +/* + * Copyright © 2000 SuSE, Inc. + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include "pixman-private.h" + +PIXMAN_EXPORT pixman_image_t * +pixman_image_create_radial_gradient (pixman_point_fixed_t *inner, + pixman_point_fixed_t *outer, + pixman_fixed_t inner_radius, + pixman_fixed_t outer_radius, + const pixman_gradient_stop_t *stops, + int n_stops) +{ + pixman_image_t *image; + radial_gradient_t *radial; + + return_val_if_fail (n_stops >= 2, NULL); + + image = _pixman_image_allocate(); + + if (!image) + return NULL; + + radial = &image->radial; + + if (!_pixman_init_gradient (&radial->common, stops, n_stops)) + { + free (image); + return NULL; + } + + image->type = RADIAL; + + radial->c1.x = inner->x; + radial->c1.y = inner->y; + radial->c1.radius = inner_radius; + radial->c2.x = outer->x; + radial->c2.y = outer->y; + radial->c2.radius = outer_radius; + radial->cdx = pixman_fixed_to_double (radial->c2.x - radial->c1.x); + radial->cdy = pixman_fixed_to_double (radial->c2.y - radial->c1.y); + radial->dr = pixman_fixed_to_double (radial->c2.radius - radial->c1.radius); + radial->A = (radial->cdx * radial->cdx + + radial->cdy * radial->cdy + - radial->dr * radial->dr); + + return image; +} + -- 2.7.4