From a10b0e7e136116cea95d6717f119d92599491f27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sun, 3 May 2009 00:59:36 -0400 Subject: [PATCH] Duplicate some code that was shared between radial and conical gradients. It is going to live in separate files. --- pixman/pixman-radial-gradient.c | 7 ++++ pixman/pixman-source.c | 82 +++++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/pixman/pixman-radial-gradient.c b/pixman/pixman-radial-gradient.c index 40c76ce..19853e3 100644 --- a/pixman/pixman-radial-gradient.c +++ b/pixman/pixman-radial-gradient.c @@ -31,6 +31,13 @@ radial_gradient_property_changed (pixman_image_t *image) image->common.get_scanline_64 = (scanFetchProc)_pixman_image_get_scanline_64_generic; } +static void +radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width, + uint32_t *buffer, uint32_t *mask, uint32_t maskBits) +{ + +} + PIXMAN_EXPORT pixman_image_t * pixman_image_create_radial_gradient (pixman_point_fixed_t *inner, pixman_point_fixed_t *outer, diff --git a/pixman/pixman-source.c b/pixman/pixman-source.c index fbb0a77..d3dce87 100644 --- a/pixman/pixman-source.c +++ b/pixman/pixman-source.c @@ -47,7 +47,6 @@ pixmanFetchGradient(gradient_t *gradient, int x, int y, int width, if (pict->common.type == LINEAR) { assert (0); } else { - /* * In the radial gradient problem we are given two circles (c₁,r₁) and * (c₂,r₂) that define the gradient itself. Then, for any point p, we @@ -162,34 +161,34 @@ pixmanFetchGradient(gradient_t *gradient, int x, int y, int width, * * t = (-2·B ± ⎷(B² - 4·A·C)) / 2·A */ - /* radial or conical */ - pixman_bool_t affine = TRUE; - double cx = 1.; - double cy = 0.; - double cz = 0.; - double rx = x + 0.5; - double ry = y + 0.5; - double rz = 1.; - - if (pict->common.transform) { - pixman_vector_t v; - /* reference point is the center of the pixel */ - v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2; - v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2; - v.vector[2] = pixman_fixed_1; - if (!pixman_transform_point_3d (pict->common.transform, &v)) - return; - - cx = pict->common.transform->matrix[0][0]/65536.; - cy = pict->common.transform->matrix[1][0]/65536.; - cz = pict->common.transform->matrix[2][0]/65536.; - rx = v.vector[0]/65536.; - ry = v.vector[1]/65536.; - rz = v.vector[2]/65536.; - affine = pict->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1; - } - if (pict->common.type == RADIAL) { + /* radial or conical */ + pixman_bool_t affine = TRUE; + double cx = 1.; + double cy = 0.; + double cz = 0.; + double rx = x + 0.5; + double ry = y + 0.5; + double rz = 1.; + + if (pict->common.transform) { + pixman_vector_t v; + /* reference point is the center of the pixel */ + v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2; + v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2; + v.vector[2] = pixman_fixed_1; + if (!pixman_transform_point_3d (pict->common.transform, &v)) + return; + + cx = pict->common.transform->matrix[0][0]/65536.; + cy = pict->common.transform->matrix[1][0]/65536.; + cz = pict->common.transform->matrix[2][0]/65536.; + rx = v.vector[0]/65536.; + ry = v.vector[1]/65536.; + rz = v.vector[2]/65536.; + affine = pict->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1; + } + radial_gradient_t *radial = (radial_gradient_t *)pict; if (affine) { while (buffer < end) { @@ -275,6 +274,33 @@ pixmanFetchGradient(gradient_t *gradient, int x, int y, int width, } } } else /* SourcePictTypeConical */ { + /* radial or conical */ + pixman_bool_t affine = TRUE; + double cx = 1.; + double cy = 0.; + double cz = 0.; + double rx = x + 0.5; + double ry = y + 0.5; + double rz = 1.; + + if (pict->common.transform) { + pixman_vector_t v; + /* reference point is the center of the pixel */ + v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2; + v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2; + v.vector[2] = pixman_fixed_1; + if (!pixman_transform_point_3d (pict->common.transform, &v)) + return; + + cx = pict->common.transform->matrix[0][0]/65536.; + cy = pict->common.transform->matrix[1][0]/65536.; + cz = pict->common.transform->matrix[2][0]/65536.; + rx = v.vector[0]/65536.; + ry = v.vector[1]/65536.; + rz = v.vector[2]/65536.; + affine = pict->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1; + } + conical_gradient_t *conical = (conical_gradient_t *)pict; double a = conical->angle/(180.*65536); if (affine) { -- 2.7.4