diff options
author | Loukas Agorgianitis <loukas@agorgianitis.com> | 2025-04-06 12:18:44 +0300 |
---|---|---|
committer | Loukas Agorgianitis <loukas@agorgianitis.com> | 2025-04-24 23:57:20 +0300 |
commit | 356d2fe0d1c607354276ce0219d56cd76618a412 (patch) | |
tree | 207757b654224a90b130c86dbb3c69a78d1c62c2 | |
parent | d1ec45e92ff5e35aaf7882f0aa018998e80ff857 (diff) |
region: add rectf convenience functions
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
-rw-r--r-- | pixman/pixman-region.c | 68 | ||||
-rw-r--r-- | pixman/pixman.h | 23 |
2 files changed, 91 insertions, 0 deletions
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 @@ -402,6 +402,29 @@ PREFIX (_init_rect) (region_type_t * region, } 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) { if (!GOOD_RECT (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 */ @@ -1375,6 +1416,33 @@ PREFIX (_union_rect) (region_type_t *dest, } 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, const region_type_t *reg2) diff --git a/pixman/pixman.h b/pixman/pixman.h index 6645d4c..ff90e13 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -797,6 +797,13 @@ void pixman_region64f_init_rect (pixman_region64f_t * 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, int count); @@ -842,6 +849,14 @@ pixman_bool_t pixman_region64f_intersect_rect (pixman_region64f_t *des 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, int x, @@ -850,6 +865,14 @@ pixman_bool_t pixman_region64f_union_rect (pixman_region64f_t 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, const pixman_region64f_t *reg_s); |