pixman: Branch 'master' - 7 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 25 14:16:34 UTC 2025
pixman/meson.build | 1
pixman/pixman-image.c | 24 +++++
pixman/pixman-private.h | 4
pixman/pixman-region.c | 135 +++++++++++++++++++++++-------
pixman/pixman-region16.c | 3
pixman/pixman-region32.c | 3
pixman/pixman-region64f.c | 50 +++++++++++
pixman/pixman-utils.c | 37 ++++++++
pixman/pixman.c | 18 ++++
pixman/pixman.h | 185 ++++++++++++++++++++++++++++++++++++++++++
test/meson.build | 1
test/region-fractional-test.c | 125 ++++++++++++++++++++++++++++
12 files changed, 556 insertions(+), 30 deletions(-)
New commits:
commit 0b9f7facf7fd82c13b86794ae0b5bbd67d1f0722
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Thu Apr 24 20:50:46 2025 +0300
test/region: add fractional region tests
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/test/meson.build b/test/meson.build
index e652956..eca2ad5 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -30,6 +30,7 @@ tests = [
'radial-invalid',
'pdf-op-test',
'region-test',
+ 'region-fractional-test',
'combiner-test',
'scaling-crash-test',
'alpha-loop',
diff --git a/test/region-fractional-test.c b/test/region-fractional-test.c
new file mode 100644
index 0000000..43fb6c5
--- /dev/null
+++ b/test/region-fractional-test.c
@@ -0,0 +1,125 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "utils.h"
+
+int
+main ()
+{
+ pixman_region64f_t r1;
+ pixman_region64f_t r2;
+ pixman_region64f_t r3;
+ pixman_box64f_t boxes[] = {
+ { 10, 10, 20, 20 },
+ { 30, 30, 30, 40 },
+ { 50, 45, 60, 44 },
+ };
+ pixman_box64f_t boxes2[] = {
+ { 2, 6, 7, 6 },
+ { 4, 1, 6, 7 },
+ };
+ pixman_box64f_t boxes3[] = {
+ { 2, 6, 7, 6 },
+ { 4, 1, 6, 1 },
+ };
+ int i, j;
+ pixman_box64f_t *b;
+ pixman_image_t *image, *fill;
+ pixman_color_t white = {
+ 0xffff,
+ 0xffff,
+ 0xffff,
+ 0xffff
+ };
+
+ prng_srand (0);
+
+ /* This used to go into an infinite loop before pixman-region.c
+ * was fixed to not use explict "short" variables
+ */
+ pixman_region64f_init_rect (&r1, 0, 0, 20, 64000);
+ pixman_region64f_init_rect (&r2, 0, 0, 20, 64000);
+ pixman_region64f_init_rect (&r3, 0, 0, 20, 64000);
+
+ pixman_region64f_subtract (&r1, &r2, &r3);
+
+
+ /* This would produce a region containing an empty
+ * rectangle in it. Such regions are considered malformed,
+ * but using an empty rectangle for initialization should
+ * work.
+ */
+ pixman_region64f_init_rects (&r1, boxes, 3);
+
+ b = pixman_region64f_rectangles (&r1, &i);
+
+ assert (i == 1);
+
+ while (i--)
+ {
+ assert (b[i].x1 < b[i].x2);
+ assert (b[i].y1 < b[i].y2);
+ }
+
+ /* This would produce a rectangle containing the bounding box
+ * of the two rectangles. The correct result is to eliminate
+ * the broken rectangle.
+ */
+ pixman_region64f_init_rects (&r1, boxes2, 2);
+
+ b = pixman_region64f_rectangles (&r1, &i);
+
+ assert (i == 1);
+
+ assert (b[0].x1 == 4);
+ assert (b[0].y1 == 1);
+ assert (b[0].x2 == 6);
+ assert (b[0].y2 == 7);
+
+ /* This should produce an empty region */
+ pixman_region64f_init_rects (&r1, boxes3, 2);
+
+ b = pixman_region64f_rectangles (&r1, &i);
+
+ assert (i == 0);
+
+ fill = pixman_image_create_solid_fill (&white);
+ for (i = 0; i < 100; i++)
+ {
+ int image_size = 128;
+
+ pixman_region64f_init (&r1);
+
+ /* Add some random rectangles */
+ for (j = 0; j < 64; j++)
+ pixman_region64f_union_rect (&r1, &r1,
+ prng_rand_n (image_size),
+ prng_rand_n (image_size),
+ prng_rand_n (25),
+ prng_rand_n (25));
+
+ /* Clip to image size */
+ pixman_region64f_init_rect (&r2, 0, 0, image_size, image_size);
+ pixman_region64f_intersect (&r1, &r1, &r2);
+ pixman_region64f_fini (&r2);
+
+ /* render region to a1 mask */
+ image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL, 0);
+ pixman_image_set_clip_region64f (image, &r1);
+ pixman_image_composite64f (PIXMAN_OP_SRC,
+ fill, NULL, image,
+ 0, 0, 0, 0, 0, 0,
+ image_size, image_size);
+ pixman_region64f_init_from_image (&r2, image);
+
+ pixman_image_unref (image);
+
+ assert (pixman_region64f_equal (&r1, &r2));
+ pixman_region64f_fini (&r1);
+ pixman_region64f_fini (&r2);
+
+ }
+ pixman_image_unref (fill);
+
+ return 0;
+}
commit 9879f6cfc40b4ef3bdca4ee9aaedacff8fb87244
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Thu Apr 24 20:49:39 2025 +0300
region: add image clip and composite functions for fractional regions
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 72796fc..d089cb1 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -613,6 +613,30 @@ pixman_image_set_clip_region (pixman_image_t * image,
return result;
}
+PIXMAN_EXPORT pixman_bool_t
+pixman_image_set_clip_region64f (pixman_image_t * image,
+ const pixman_region64f_t *region)
+{
+ image_common_t *common = (image_common_t *)image;
+ pixman_bool_t result;
+
+ if (region)
+ {
+ if ((result = pixman_region32_copy_from_region64f (&common->clip_region, region)))
+ image->common.have_clip_region = TRUE;
+ }
+ else
+ {
+ _pixman_image_reset_clip_region (image);
+
+ result = TRUE;
+ }
+
+ image_property_changed (image);
+
+ return result;
+}
+
PIXMAN_EXPORT void
pixman_image_set_has_client_clip (pixman_image_t *image,
pixman_bool_t client_clip)
diff --git a/pixman/pixman.c b/pixman/pixman.c
index 2b408c6..1d77f8e 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -739,6 +739,24 @@ pixman_image_composite (pixman_op_t op,
mask_x, mask_y, dest_x, dest_y, width, height);
}
+PIXMAN_EXPORT void
+pixman_image_composite64f (pixman_op_t op,
+ pixman_image_t * src,
+ pixman_image_t * mask,
+ pixman_image_t * dest,
+ double src_x,
+ double src_y,
+ double mask_x,
+ double mask_y,
+ double dest_x,
+ double dest_y,
+ double width,
+ double height)
+{
+ pixman_image_composite32 (op, src, mask, dest, src_x, src_y,
+ mask_x, mask_y, dest_x, dest_y, width, height);
+}
+
PIXMAN_EXPORT pixman_bool_t
pixman_blt (uint32_t *src_bits,
uint32_t *dst_bits,
diff --git a/pixman/pixman.h b/pixman/pixman.h
index ff90e13..7a3dff8 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -1192,6 +1192,10 @@ PIXMAN_API
pixman_bool_t pixman_image_set_clip_region32 (pixman_image_t *image,
const pixman_region32_t *region);
+PIXMAN_API
+pixman_bool_t pixman_image_set_clip_region64f (pixman_image_t *image,
+ const pixman_region64f_t *region);
+
PIXMAN_API
void pixman_image_set_has_client_clip (pixman_image_t *image,
pixman_bool_t clien_clip);
@@ -1348,6 +1352,20 @@ void pixman_image_composite32 (pixman_op_t op,
int32_t width,
int32_t height);
+PIXMAN_API
+void pixman_image_composite64f (pixman_op_t op,
+ pixman_image_t *src,
+ pixman_image_t *mask,
+ pixman_image_t *dest,
+ double src_x,
+ double src_y,
+ double mask_x,
+ double mask_y,
+ double dest_x,
+ double dest_y,
+ double width,
+ double height);
+
/* Executive Summary: This function is a no-op that only exists
* for historical reasons.
*
commit d1eb2680de195daf9e61b5135aac38dca02301c9
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Thu Apr 24 20:47:12 2025 +0300
region: add pixman_region32_copy_from_region64f utility function
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index f377ce3..1416eb4 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -884,6 +884,10 @@ pixman_bool_t
pixman_region32_copy_from_region16 (pixman_region32_t *dst,
const pixman_region16_t *src);
+pixman_bool_t
+pixman_region32_copy_from_region64f (pixman_region32_t *dst,
+ const pixman_region64f_t *src);
+
pixman_bool_t
pixman_region16_copy_from_region32 (pixman_region16_t *dst,
const pixman_region32_t *src);
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index 302cd0c..b171af9 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -303,6 +303,43 @@ pixman_region32_copy_from_region16 (pixman_region32_t *dst,
return retval;
}
+pixman_bool_t
+pixman_region32_copy_from_region64f (pixman_region32_t *dst,
+ const pixman_region64f_t *src)
+{
+ int n_boxes, i;
+ pixman_box64f_t *boxes64f;
+ pixman_box32_t *boxes32;
+ pixman_box32_t tmp_boxes[N_TMP_BOXES];
+ pixman_bool_t retval;
+
+ boxes64f = pixman_region64f_rectangles (src, &n_boxes);
+
+ if (n_boxes > N_TMP_BOXES)
+ boxes32 = pixman_malloc_ab (n_boxes, sizeof (pixman_box32_t));
+ else
+ boxes32 = tmp_boxes;
+
+ if (!boxes32)
+ return FALSE;
+
+ for (i = 0; i < n_boxes; ++i)
+ {
+ boxes32[i].x1 = boxes64f[i].x1;
+ boxes32[i].y1 = boxes64f[i].y1;
+ boxes32[i].x2 = boxes64f[i].x2;
+ boxes32[i].y2 = boxes64f[i].y2;
+ }
+
+ pixman_region32_fini (dst);
+ retval = pixman_region32_init_rects (dst, boxes32, n_boxes);
+
+ if (boxes32 != tmp_boxes)
+ free (boxes32);
+
+ return retval;
+}
+
/* This function is exported for the sake of the test suite and not part
* of the ABI.
*/
commit 356d2fe0d1c607354276ce0219d56cd76618a412
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Sun Apr 6 12:18:44 2025 +0300
region: add rectf convenience functions
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index d43be96..849f615 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -401,6 +401,29 @@ PREFIX (_init_rect) (region_type_t * region,
region->data = NULL;
}
+PIXMAN_EXPORT void
+PREFIX (_init_rectf) (region_type_t * region,
+ double x,
+ double y,
+ double width,
+ double height)
+{
+ region->extents.x1 = x;
+ region->extents.y1 = y;
+ region->extents.x2 = x + width;
+ region->extents.y2 = y + height;
+
+ if (!GOOD_RECT (®ion->extents))
+ {
+ if (BAD_RECT (®ion->extents))
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
+ PREFIX (_init) (region);
+ return;
+ }
+
+ region->data = NULL;
+}
+
PIXMAN_EXPORT void
PREFIX (_init_with_extents) (region_type_t *region, const box_type_t *extents)
{
@@ -1344,6 +1367,24 @@ PREFIX(_intersect_rect) (region_type_t *dest,
return PREFIX(_intersect) (dest, source, ®ion);
}
+PIXMAN_EXPORT pixman_bool_t
+PREFIX(_intersect_rectf) (region_type_t *dest,
+ const region_type_t *source,
+ double x, double y,
+ double width,
+ double height)
+{
+ region_type_t region;
+
+ region.data = NULL;
+ region.extents.x1 = x;
+ region.extents.y1 = y;
+ region.extents.x2 = x + width;
+ region.extents.y2 = y + height;
+
+ return PREFIX(_intersect) (dest, source, ®ion);
+}
+
/* Convenience function for performing union of region with a
* single rectangle
*/
@@ -1374,6 +1415,33 @@ PREFIX (_union_rect) (region_type_t *dest,
return PREFIX (_union) (dest, source, ®ion);
}
+PIXMAN_EXPORT pixman_bool_t
+PREFIX (_union_rectf) (region_type_t *dest,
+ const region_type_t *source,
+ double x,
+ double y,
+ double width,
+ double height)
+{
+ region_type_t region;
+
+ region.extents.x1 = x;
+ region.extents.y1 = y;
+ region.extents.x2 = x + width;
+ region.extents.y2 = y + height;
+
+ if (!GOOD_RECT (®ion.extents))
+ {
+ if (BAD_RECT (®ion.extents))
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
+ return PREFIX (_copy) (dest, source);
+ }
+
+ region.data = NULL;
+
+ return PREFIX (_union) (dest, source, ®ion);
+}
+
PIXMAN_EXPORT pixman_bool_t
PREFIX (_union) (region_type_t * new_reg,
const region_type_t *reg1,
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 6645d4c..ff90e13 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -796,6 +796,13 @@ void pixman_region64f_init_rect (pixman_region64f_t *
unsigned int width,
unsigned int height);
+PIXMAN_API
+void pixman_region64f_init_rectf (pixman_region64f_t *region,
+ double x,
+ double y,
+ double width,
+ double height);
+
PIXMAN_API
pixman_bool_t pixman_region64f_init_rects (pixman_region64f_t *region,
const pixman_box64f_t *boxes,
@@ -841,6 +848,14 @@ pixman_bool_t pixman_region64f_intersect_rect (pixman_region64f_t *des
unsigned int width,
unsigned int height);
+PIXMAN_API
+pixman_bool_t pixman_region64f_intersect_rectf (pixman_region64f_t *dest,
+ const pixman_region64f_t *source,
+ double x,
+ double y,
+ double width,
+ double height);
+
PIXMAN_API
pixman_bool_t pixman_region64f_union_rect (pixman_region64f_t *dest,
const pixman_region64f_t *source,
@@ -849,6 +864,14 @@ pixman_bool_t pixman_region64f_union_rect (pixman_region64f_t
unsigned int width,
unsigned int height);
+PIXMAN_API
+pixman_bool_t pixman_region64f_union_rectf (pixman_region64f_t *dest,
+ const pixman_region64f_t *source,
+ double x,
+ double y,
+ double width,
+ double height);
+
PIXMAN_API
pixman_bool_t pixman_region64f_subtract (pixman_region64f_t *reg_d,
const pixman_region64f_t *reg_m,
commit d1ec45e92ff5e35aaf7882f0aa018998e80ff857
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Sun Apr 6 12:09:41 2025 +0300
region: add fractional implementation based on 64bit floating point numbers
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/meson.build b/pixman/meson.build
index fd41288..a91c73e 100644
--- a/pixman/meson.build
+++ b/pixman/meson.build
@@ -97,6 +97,7 @@ pixman_files = files(
'pixman-radial-gradient.c',
'pixman-region16.c',
'pixman-region32.c',
+ 'pixman-region64f.c',
'pixman-riscv.c',
'pixman-solid-fill.c',
'pixman-timer.c',
diff --git a/pixman/pixman-region64f.c b/pixman/pixman-region64f.c
new file mode 100644
index 0000000..fb8cc5a
--- /dev/null
+++ b/pixman/pixman-region64f.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2008 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
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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.
+ *
+ * Author: Soren Sandmann <sandmann at redhat.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <pixman-config.h>
+#endif
+
+#include "pixman-private.h"
+
+#include <stdlib.h>
+
+typedef pixman_box64f_t box_type_t;
+typedef pixman_region64f_data_t region_data_type_t;
+typedef pixman_region64f_t region_type_t;
+typedef double primitive_t;
+typedef int64_t overflow_int_t;
+
+typedef struct {
+ double x, y;
+} point_type_t;
+
+#define PREFIX(x) pixman_region64f##x
+
+#define PIXMAN_REGION_MAX INT32_MAX
+#define PIXMAN_REGION_MIN INT32_MIN
+
+#define PRINT_SPECIFIER "%f"
+
+#include "pixman-region.c"
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 12532fa..6645d4c 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -754,6 +754,150 @@ void pixman_region32_reset (pixman_region32_t
PIXMAN_API
void pixman_region32_clear (pixman_region32_t *region);
+/*
+ * 64 bit fractional regions
+ */
+typedef struct pixman_region64f_data pixman_region64f_data_t;
+typedef struct pixman_box64f pixman_box64f_t;
+typedef struct pixman_rectangle64f pixman_rectangle64f_t;
+typedef struct pixman_region64f pixman_region64f_t;
+
+struct pixman_region64f_data {
+ long size;
+ long numRects;
+/* pixman_box64f_t rects[size]; in memory but not explicitly declared */
+};
+
+struct pixman_rectangle64f
+{
+ double x, y;
+ double width, height;
+};
+
+struct pixman_box64f
+{
+ double x1, y1, x2, y2;
+};
+
+struct pixman_region64f
+{
+ pixman_box64f_t extents;
+ pixman_region64f_data_t *data;
+};
+
+/* creation/destruction */
+PIXMAN_API
+void pixman_region64f_init (pixman_region64f_t *region);
+
+PIXMAN_API
+void pixman_region64f_init_rect (pixman_region64f_t *region,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_init_rects (pixman_region64f_t *region,
+ const pixman_box64f_t *boxes,
+ int count);
+
+PIXMAN_API
+void pixman_region64f_init_with_extents (pixman_region64f_t *region,
+ const pixman_box64f_t *extents);
+
+PIXMAN_API
+void pixman_region64f_init_from_image (pixman_region64f_t *region,
+ pixman_image_t *image);
+
+PIXMAN_API
+void pixman_region64f_fini (pixman_region64f_t *region);
+
+
+/* manipulation */
+PIXMAN_API
+void pixman_region64f_translate (pixman_region64f_t *region,
+ int x,
+ int y);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_copy (pixman_region64f_t *dest,
+ const pixman_region64f_t *source);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_intersect (pixman_region64f_t *new_reg,
+ const pixman_region64f_t *reg1,
+ const pixman_region64f_t *reg2);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_union (pixman_region64f_t *new_reg,
+ const pixman_region64f_t *reg1,
+ const pixman_region64f_t *reg2);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_intersect_rect (pixman_region64f_t *dest,
+ const pixman_region64f_t *source,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_union_rect (pixman_region64f_t *dest,
+ const pixman_region64f_t *source,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_subtract (pixman_region64f_t *reg_d,
+ const pixman_region64f_t *reg_m,
+ const pixman_region64f_t *reg_s);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_inverse (pixman_region64f_t *new_reg,
+ const pixman_region64f_t *reg1,
+ const pixman_box64f_t *inv_rect);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_contains_point (const pixman_region64f_t *region,
+ int x,
+ int y,
+ pixman_box64f_t *box);
+
+PIXMAN_API
+pixman_region_overlap_t pixman_region64f_contains_rectangle(const pixman_region64f_t *region,
+ const pixman_box64f_t *prect);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_empty (const pixman_region64f_t *region);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_not_empty (const pixman_region64f_t *region);
+
+PIXMAN_API
+pixman_box64f_t * pixman_region64f_extents (const pixman_region64f_t *region);
+
+PIXMAN_API
+int pixman_region64f_n_rects (const pixman_region64f_t *region);
+
+PIXMAN_API
+pixman_box64f_t * pixman_region64f_rectangles (const pixman_region64f_t *region,
+ int *n_rects);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_equal (const pixman_region64f_t *region1,
+ const pixman_region64f_t *region2);
+
+PIXMAN_API
+pixman_bool_t pixman_region64f_selfcheck (pixman_region64f_t *region);
+
+PIXMAN_API
+void pixman_region64f_reset (pixman_region64f_t *region,
+ const pixman_box64f_t *box);
+
+PIXMAN_API
+void pixman_region64f_clear (pixman_region64f_t *region);
/* Copy / Fill / Misc */
commit 9b0c996e8fe324d9939c51f3b0b1337f12bde8d5
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Sun Apr 6 12:03:45 2025 +0300
region: make print specifier parametric
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 5102f0e..d43be96 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -346,7 +346,11 @@ PREFIX (_print) (region_type_t *rgn)
rects = PIXREGION_RECTS (rgn);
fprintf (stderr, "num: %d size: %d\n", num, size);
- fprintf (stderr, "extents: %d %d %d %d\n",
+ fprintf (stderr, "extents: "
+ PRINT_SPECIFIER " "
+ PRINT_SPECIFIER " "
+ PRINT_SPECIFIER " "
+ PRINT_SPECIFIER "\n",
rgn->extents.x1,
rgn->extents.y1,
rgn->extents.x2,
@@ -354,7 +358,10 @@ PREFIX (_print) (region_type_t *rgn)
for (i = 0; i < num; i++)
{
- fprintf (stderr, "%d %d %d %d \n",
+ fprintf (stderr, PRINT_SPECIFIER " "
+ PRINT_SPECIFIER " "
+ PRINT_SPECIFIER " "
+ PRINT_SPECIFIER " \n",
rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
}
diff --git a/pixman/pixman-region16.c b/pixman/pixman-region16.c
index 7a4e5ab..ff7b038 100644
--- a/pixman/pixman-region16.c
+++ b/pixman/pixman-region16.c
@@ -47,6 +47,8 @@ typedef struct {
#define PIXMAN_REGION_MAX INT16_MAX
#define PIXMAN_REGION_MIN INT16_MIN
+#define PRINT_SPECIFIER "%d"
+
#include "pixman-region.c"
/* This function exists only to make it possible to preserve the X ABI -
diff --git a/pixman/pixman-region32.c b/pixman/pixman-region32.c
index b102582..fbaa216 100644
--- a/pixman/pixman-region32.c
+++ b/pixman/pixman-region32.c
@@ -45,4 +45,6 @@ typedef struct {
#define PIXMAN_REGION_MAX INT32_MAX
#define PIXMAN_REGION_MIN INT32_MIN
+#define PRINT_SPECIFIER "%d"
+
#include "pixman-region.c"
commit 96746cd45b76310fa15e5fe682f695e387a333de
Author: Loukas Agorgianitis <loukas at agorgianitis.com>
Date: Sun Apr 6 11:48:16 2025 +0300
region: add parametric primitive type to generalize implementation details
Signed-off-by: Loukas Agorgianitis <loukas at agorgianitis.com>
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index d75e519..5102f0e 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -572,7 +572,7 @@ pixman_coalesce (region_type_t * region, /* Region to coalesce */
box_type_t *prev_box; /* Current box in previous band */
box_type_t *cur_box; /* Current box in current band */
int numRects; /* Number rectangles in both bands */
- int y2; /* Bottom of current band */
+ primitive_t y2; /* Bottom of current band */
/*
* Figure out how many rectangles are in the band.
@@ -658,8 +658,8 @@ static inline pixman_bool_t
pixman_region_append_non_o (region_type_t * region,
box_type_t * r,
box_type_t * r_end,
- int y1,
- int y2)
+ primitive_t y1,
+ primitive_t y2)
{
box_type_t *next_rect;
int new_rects;
@@ -741,8 +741,8 @@ typedef pixman_bool_t (*overlap_proc_ptr) (region_type_t *region,
box_type_t * r1_end,
box_type_t * r2,
box_type_t * r2_end,
- int y1,
- int y2);
+ primitive_t y1,
+ primitive_t y2);
static pixman_bool_t
pixman_op (region_type_t * new_reg, /* Place to store result */
@@ -762,8 +762,8 @@ pixman_op (region_type_t * new_reg, /* Place to store result
box_type_t *r2; /* Pointer into 2d region */
box_type_t *r1_end; /* End of 1st region */
box_type_t *r2_end; /* End of 2d region */
- int ybot; /* Bottom of intersection */
- int ytop; /* Top of intersection */
+ primitive_t ybot; /* Bottom of intersection */
+ primitive_t ytop; /* Top of intersection */
region_data_type_t *old_data; /* Old data for new_reg */
int prev_band; /* Index of start of
* previous band in new_reg */
@@ -771,10 +771,10 @@ pixman_op (region_type_t * new_reg, /* Place to store result
* band in new_reg */
box_type_t * r1_band_end; /* End of current band in r1 */
box_type_t * r2_band_end; /* End of current band in r2 */
- int top; /* Top of non-overlapping band */
- int bot; /* Bottom of non-overlapping band*/
- int r1y1; /* Temps for r1->y1 and r2->y1 */
- int r2y1;
+ primitive_t top; /* Top of non-overlapping band */
+ primitive_t bot; /* Bottom of non-overlapping band*/
+ primitive_t r1y1; /* Temps for r1->y1 and r2->y1 */
+ primitive_t r2y1;
int new_size;
int numRects;
@@ -1110,11 +1110,11 @@ pixman_region_intersect_o (region_type_t *region,
box_type_t * r1_end,
box_type_t * r2,
box_type_t * r2_end,
- int y1,
- int y2)
+ primitive_t y1,
+ primitive_t y2)
{
- int x1;
- int x2;
+ primitive_t x1;
+ primitive_t x2;
box_type_t * next_rect;
next_rect = PIXREGION_TOP (region);
@@ -1262,12 +1262,12 @@ pixman_region_union_o (region_type_t *region,
box_type_t * r1_end,
box_type_t * r2,
box_type_t * r2_end,
- int y1,
- int y2)
+ primitive_t y1,
+ primitive_t y2)
{
box_type_t *next_rect;
- int x1; /* left and right side of current union */
- int x2;
+ primitive_t x1; /* left and right side of current union */
+ primitive_t x2;
critical_if_fail (y1 < y2);
critical_if_fail (r1 != r1_end && r2 != r2_end);
@@ -1467,8 +1467,8 @@ quick_sort_rects (
box_type_t rects[],
int numRects)
{
- int y1;
- int x1;
+ primitive_t y1;
+ primitive_t x1;
int i, j;
box_type_t *r;
@@ -1833,11 +1833,11 @@ pixman_region_subtract_o (region_type_t * region,
box_type_t * r1_end,
box_type_t * r2,
box_type_t * r2_end,
- int y1,
- int y2)
+ primitive_t y1,
+ primitive_t y2)
{
box_type_t * next_rect;
- int x1;
+ primitive_t x1;
x1 = r1->x1;
@@ -2066,7 +2066,7 @@ PREFIX (_inverse) (region_type_t * new_reg, /* Destination region */
* Return @end if no such box exists.
*/
static box_type_t *
-find_box_for_y (box_type_t *begin, box_type_t *end, int y)
+find_box_for_y (box_type_t *begin, box_type_t *end, primitive_t y)
{
box_type_t *mid;
@@ -2120,7 +2120,7 @@ PREFIX (_contains_rectangle) (const region_type_t * region,
box_type_t * pbox_end;
int part_in, part_out;
int numRects;
- int x, y;
+ primitive_t x, y;
GOOD (region);
@@ -2571,8 +2571,8 @@ static inline box_type_t *
bitmap_addrect (region_type_t *reg,
box_type_t *r,
box_type_t **first_rect,
- int rx1, int ry1,
- int rx2, int ry2)
+ primitive_t rx1, primitive_t ry1,
+ primitive_t rx2, primitive_t ry2)
{
if ((rx1 < rx2) && (ry1 < ry2) &&
(!(reg->data->numRects &&
diff --git a/pixman/pixman-region16.c b/pixman/pixman-region16.c
index da4719e..7a4e5ab 100644
--- a/pixman/pixman-region16.c
+++ b/pixman/pixman-region16.c
@@ -35,6 +35,7 @@
typedef pixman_box16_t box_type_t;
typedef pixman_region16_data_t region_data_type_t;
typedef pixman_region16_t region_type_t;
+typedef int primitive_t;
typedef int32_t overflow_int_t;
typedef struct {
diff --git a/pixman/pixman-region32.c b/pixman/pixman-region32.c
index 68b456b..b102582 100644
--- a/pixman/pixman-region32.c
+++ b/pixman/pixman-region32.c
@@ -33,6 +33,7 @@
typedef pixman_box32_t box_type_t;
typedef pixman_region32_data_t region_data_type_t;
typedef pixman_region32_t region_type_t;
+typedef int primitive_t;
typedef int64_t overflow_int_t;
typedef struct {
More information about the xorg-commit
mailing list