diff options
author | Simon Ser <contact@emersion.fr> | 2023-04-11 21:58:51 +0200 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2023-07-09 01:48:29 +0000 |
commit | 672f67db96a1e8b1d80f64b9ba286220ca475ec8 (patch) | |
tree | ba8015de7fe40cfd9b3aab7002375cabdec4415d | |
parent | 48d5df1f3772a08a929dcb3b2fe4d7b1853223c9 (diff) |
Add pixman_region{,32}_empty()
Inverse of pixman_region32_not_empty().
Most of the time, callers want to check whether a region is empty,
not whether a region is not empty. This results in code with
double-negatives such as !pixman_region32_not_empty(), which is
confusing to read.
Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r-- | pixman/pixman-region.c | 8 | ||||
-rw-r--r-- | pixman/pixman.c | 4 | ||||
-rw-r--r-- | pixman/pixman.h | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c index a2daa27..537d5fb 100644 --- a/pixman/pixman-region.c +++ b/pixman/pixman-region.c @@ -2387,6 +2387,14 @@ PREFIX (_contains_point) (const region_type_t * region, } PIXMAN_EXPORT int +PREFIX (_empty) (const region_type_t * region) +{ + GOOD (region); + + return(PIXREGION_NIL (region)); +} + +PIXMAN_EXPORT int PREFIX (_not_empty) (const region_type_t * region) { GOOD (region); diff --git a/pixman/pixman.c b/pixman/pixman.c index 17015a8..82ec236 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -182,7 +182,7 @@ clip_general_image (pixman_region32_t * region, return FALSE; } } - else if (!pixman_region32_not_empty (clip)) + else if (pixman_region32_empty (clip)) { return FALSE; } @@ -277,7 +277,7 @@ _pixman_compute_composite_region32 (pixman_region32_t * region, { return FALSE; } - if (!pixman_region32_not_empty (region)) + if (pixman_region32_empty (region)) return FALSE; if (dest_image->common.alpha_map->common.have_clip_region) { diff --git a/pixman/pixman.h b/pixman/pixman.h index 2cd875b..e6b235c 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -582,6 +582,9 @@ pixman_region_overlap_t pixman_region_contains_rectangle (const pixman_region16_ const pixman_box16_t *prect); PIXMAN_API +pixman_bool_t pixman_region_empty (const pixman_region16_t *region); + +PIXMAN_API pixman_bool_t pixman_region_not_empty (const pixman_region16_t *region); PIXMAN_API @@ -723,6 +726,9 @@ pixman_region_overlap_t pixman_region32_contains_rectangle (const pixman_region3 const pixman_box32_t *prect); PIXMAN_API +pixman_bool_t pixman_region32_empty (const pixman_region32_t *region); + +PIXMAN_API pixman_bool_t pixman_region32_not_empty (const pixman_region32_t *region); PIXMAN_API |