aboutsummaryrefslogtreecommitdiff
path: root/pixman
diff options
context:
space:
mode:
Diffstat (limited to 'pixman')
-rw-r--r--pixman/configure.ac2
-rw-r--r--pixman/pixman/pixman-image.c1
-rw-r--r--pixman/pixman/pixman-linear-gradient.c193
-rw-r--r--pixman/pixman/pixman-private.h2
-rw-r--r--pixman/pixman/pixman-radial-gradient.c7
-rw-r--r--pixman/pixman/pixman-solid-fill.c3
6 files changed, 88 insertions, 120 deletions
diff --git a/pixman/configure.ac b/pixman/configure.ac
index a4e5e9316..c723337a9 100644
--- a/pixman/configure.ac
+++ b/pixman/configure.ac
@@ -54,7 +54,7 @@ AC_PREREQ([2.57])
m4_define([pixman_major], 0)
m4_define([pixman_minor], 19)
-m4_define([pixman_micro], 5)
+m4_define([pixman_micro], 7)
m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro])
diff --git a/pixman/pixman/pixman-image.c b/pixman/pixman/pixman-image.c
index 17d87216e..ac7bccc5d 100644
--- a/pixman/pixman/pixman-image.c
+++ b/pixman/pixman/pixman-image.c
@@ -48,7 +48,6 @@ _pixman_init_gradient (gradient_t * gradient,
gradient->n_stops = n_stops;
gradient->stop_range = 0xffff;
- gradient->common.class = SOURCE_IMAGE_CLASS_UNKNOWN;
return TRUE;
}
diff --git a/pixman/pixman/pixman-linear-gradient.c b/pixman/pixman/pixman-linear-gradient.c
index 20a8b7827..9ccb688ff 100644
--- a/pixman/pixman/pixman-linear-gradient.c
+++ b/pixman/pixman/pixman-linear-gradient.c
@@ -1,3 +1,4 @@
+/* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */
/*
* Copyright © 2000 SuSE, Inc.
* Copyright © 2007 Red Hat, Inc.
@@ -37,58 +38,58 @@ linear_gradient_classify (pixman_image_t *image,
int width,
int height)
{
+ source_image_t *source = (source_image_t *)image;
linear_gradient_t *linear = (linear_gradient_t *)image;
pixman_vector_t v;
pixman_fixed_32_32_t l;
- pixman_fixed_48_16_t dx, dy, a, b, off;
- pixman_fixed_48_16_t factors[4];
- int i;
-
- image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
+ pixman_fixed_48_16_t dx, dy;
+ double inc;
+ source_image_class_t class;
- dx = linear->p2.x - linear->p1.x;
- dy = linear->p2.y - linear->p1.y;
+ class = SOURCE_IMAGE_CLASS_UNKNOWN;
- l = dx * dx + dy * dy;
-
- if (l)
+ if (source->common.transform)
{
- a = (dx << 32) / l;
- b = (dy << 32) / l;
+ /* projective transformation */
+ if (source->common.transform->matrix[2][0] != 0 ||
+ source->common.transform->matrix[2][1] != 0 ||
+ source->common.transform->matrix[2][2] == 0)
+ {
+ return class;
+ }
+
+ v.vector[0] = source->common.transform->matrix[0][1];
+ v.vector[1] = source->common.transform->matrix[1][1];
+ v.vector[2] = source->common.transform->matrix[2][2];
}
else
{
- a = b = 0;
+ v.vector[0] = 0;
+ v.vector[1] = pixman_fixed_1;
+ v.vector[2] = pixman_fixed_1;
}
- off = (-a * linear->p1.x
- -b * linear->p1.y) >> 16;
-
- for (i = 0; i < 3; i++)
- {
- v.vector[0] = pixman_int_to_fixed ((i % 2) * (width - 1) + x);
- v.vector[1] = pixman_int_to_fixed ((i / 2) * (height - 1) + y);
- v.vector[2] = pixman_fixed_1;
+ dx = linear->p2.x - linear->p1.x;
+ dy = linear->p2.y - linear->p1.y;
- if (image->common.transform)
- {
- if (!pixman_transform_point_3d (image->common.transform, &v))
- {
- image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
+ l = dx * dx + dy * dy;
- return image->source.class;
- }
- }
+ if (l == 0)
+ return class;
- factors[i] = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
- }
+ /*
+ * compute how much the input of the gradient walked changes
+ * when moving vertically through the whole image
+ */
+ inc = height * (double) pixman_fixed_1 * pixman_fixed_1 *
+ (dx * v.vector[0] + dy * v.vector[1]) /
+ (v.vector[2] * (double) l);
- if (factors[2] == factors[0])
- image->source.class = SOURCE_IMAGE_CLASS_HORIZONTAL;
- else if (factors[1] == factors[0])
- image->source.class = SOURCE_IMAGE_CLASS_VERTICAL;
+ /* check that casting to integer would result in 0 */
+ if (-1 < inc && inc < 1)
+ class = SOURCE_IMAGE_CLASS_HORIZONTAL;
- return image->source.class;
+ return class;
}
static void
@@ -101,7 +102,7 @@ linear_gradient_get_scanline_32 (pixman_image_t *image,
{
pixman_vector_t v, unit;
pixman_fixed_32_32_t l;
- pixman_fixed_48_16_t dx, dy, a, b, off;
+ pixman_fixed_48_16_t dx, dy;
gradient_t *gradient = (gradient_t *)image;
source_image_t *source = (source_image_t *)image;
linear_gradient_t *linear = (linear_gradient_t *)image;
@@ -136,31 +137,31 @@ linear_gradient_get_scanline_32 (pixman_image_t *image,
l = dx * dx + dy * dy;
- if (l != 0)
+ if (l == 0 || unit.vector[2] == 0)
{
- a = (dx << 32) / l;
- b = (dy << 32) / l;
- off = (-a * linear->p1.x
- -b * linear->p1.y) >> 16;
- }
-
- if (l == 0 || (unit.vector[2] == 0 && v.vector[2] == pixman_fixed_1))
- {
- pixman_fixed_48_16_t inc, t;
-
/* affine transformation only */
- if (l == 0)
+ pixman_fixed_32_32_t t, next_inc;
+ double inc;
+
+ if (l == 0 || v.vector[2] == 0)
{
t = 0;
inc = 0;
}
else
{
- t = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
- inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
+ double invden, v2;
+
+ invden = pixman_fixed_1 * (double) pixman_fixed_1 /
+ (l * (double) v.vector[2]);
+ v2 = v.vector[2] * (1. / pixman_fixed_1);
+ t = ((dx * v.vector[0] + dy * v.vector[1]) -
+ (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
+ inc = (dx * unit.vector[0] + dy * unit.vector[1]) * invden;
}
+ next_inc = 0;
- if (source->class == SOURCE_IMAGE_CLASS_VERTICAL)
+ if (((pixman_fixed_32_32_t )(inc * width)) == 0)
{
register uint32_t color;
@@ -170,81 +171,52 @@ linear_gradient_get_scanline_32 (pixman_image_t *image,
}
else
{
- if (!mask)
- {
- while (buffer < end)
- {
- *buffer++ = _pixman_gradient_walker_pixel (&walker, t);
-
- t += inc;
- }
- }
- else
+ int i;
+
+ i = 0;
+ while (buffer < end)
{
- while (buffer < end)
+ if (!mask || *mask++)
{
- if (*mask++)
- *buffer = _pixman_gradient_walker_pixel (&walker, t);
-
- buffer++;
- t += inc;
+ *buffer = _pixman_gradient_walker_pixel (&walker,
+ t + next_inc);
}
+ i++;
+ next_inc = inc * i;
+ buffer++;
}
}
}
else
{
/* projective transformation */
- pixman_fixed_48_16_t t;
-
- if (source->class == SOURCE_IMAGE_CLASS_VERTICAL)
- {
- register uint32_t color;
+ double t;
- if (v.vector[2] == 0)
- {
- t = 0;
- }
- else
- {
- pixman_fixed_48_16_t x, y;
+ t = 0;
- x = ((pixman_fixed_48_16_t) v.vector[0] << 16) / v.vector[2];
- y = ((pixman_fixed_48_16_t) v.vector[1] << 16) / v.vector[2];
- t = ((a * x + b * y) >> 16) + off;
- }
-
- color = _pixman_gradient_walker_pixel (&walker, t);
- while (buffer < end)
- *buffer++ = color;
- }
- else
+ while (buffer < end)
{
- while (buffer < end)
+ if (!mask || *mask++)
{
- if (!mask || *mask++)
+ if (v.vector[2] != 0)
{
- if (v.vector[2] == 0)
- {
- t = 0;
- }
- else
- {
- pixman_fixed_48_16_t x, y;
- x = ((pixman_fixed_48_16_t)v.vector[0] << 16) / v.vector[2];
- y = ((pixman_fixed_48_16_t)v.vector[1] << 16) / v.vector[2];
- t = ((a * x + b * y) >> 16) + off;
- }
-
- *buffer = _pixman_gradient_walker_pixel (&walker, t);
- }
+ double invden, v2;
- ++buffer;
+ invden = pixman_fixed_1 * (double) pixman_fixed_1 /
+ (l * (double) v.vector[2]);
+ v2 = v.vector[2] * (1. / pixman_fixed_1);
+ t = ((dx * v.vector[0] + dy * v.vector[1]) -
+ (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
+ }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
+ *buffer = _pixman_gradient_walker_pixel (&walker, t);
}
+
+ ++buffer;
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
}
}
}
@@ -282,7 +254,6 @@ pixman_image_create_linear_gradient (pixman_point_fixed_t * p1,
linear->p2 = *p2;
image->type = LINEAR;
- image->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
image->common.classify = linear_gradient_classify;
image->common.property_changed = linear_gradient_property_changed;
diff --git a/pixman/pixman/pixman-private.h b/pixman/pixman/pixman-private.h
index e756bdbed..b0faf2c08 100644
--- a/pixman/pixman/pixman-private.h
+++ b/pixman/pixman/pixman-private.h
@@ -65,7 +65,6 @@ typedef enum
{
SOURCE_IMAGE_CLASS_UNKNOWN,
SOURCE_IMAGE_CLASS_HORIZONTAL,
- SOURCE_IMAGE_CLASS_VERTICAL,
} source_image_class_t;
typedef source_image_class_t (*classify_func_t) (pixman_image_t *image,
@@ -112,7 +111,6 @@ struct image_common
struct source_image
{
image_common_t common;
- source_image_class_t class;
};
struct solid_fill
diff --git a/pixman/pixman/pixman-radial-gradient.c b/pixman/pixman/pixman-radial-gradient.c
index bc4a13412..2d9e46a39 100644
--- a/pixman/pixman/pixman-radial-gradient.c
+++ b/pixman/pixman/pixman-radial-gradient.c
@@ -290,10 +290,11 @@ radial_gradient_get_scanline_32 (pixman_image_t *image,
db = dot (unit.vector[0], unit.vector[1], 0,
radial->delta.x, radial->delta.y, 0);
- c = dot (v.vector[0], v.vector[1], -radial->c1.radius,
+ c = dot (v.vector[0], v.vector[1],
+ -((pixman_fixed_48_16_t) radial->c1.radius),
v.vector[0], v.vector[1], radial->c1.radius);
- dc = dot (2 * v.vector[0] + unit.vector[0],
- 2 * v.vector[1] + unit.vector[1],
+ dc = dot (2 * (pixman_fixed_48_16_t) v.vector[0] + unit.vector[0],
+ 2 * (pixman_fixed_48_16_t) v.vector[1] + unit.vector[1],
0,
unit.vector[0], unit.vector[1], 0);
ddc = 2 * dot (unit.vector[0], unit.vector[1], 0,
diff --git a/pixman/pixman/pixman-solid-fill.c b/pixman/pixman/pixman-solid-fill.c
index 89dcfe3b6..afff3c479 100644
--- a/pixman/pixman/pixman-solid-fill.c
+++ b/pixman/pixman/pixman-solid-fill.c
@@ -66,7 +66,7 @@ solid_fill_classify (pixman_image_t *image,
int width,
int height)
{
- return (image->source.class = SOURCE_IMAGE_CLASS_HORIZONTAL);
+ return SOURCE_IMAGE_CLASS_HORIZONTAL;
}
static void
@@ -109,7 +109,6 @@ pixman_image_create_solid_fill (pixman_color_t *color)
img->solid.color_32 = color_to_uint32 (color);
img->solid.color_64 = color_to_uint64 (color);
- img->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
img->common.classify = solid_fill_classify;
img->common.property_changed = solid_fill_property_changed;