diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2022-11-27 13:34:48 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-12-09 16:46:36 +0000 |
commit | 8f58c060fd6095e34ede2a2d1c14caea517636e7 (patch) | |
tree | 03daf3b0697ffab5edbf173bf96e43fdfb389d7d | |
parent | 32fc23a3834ba5c4ecfea3b7c5c4c2126369074c (diff) |
util/region: forbid "shrinking" a region with wlr_region_expand()
The logic isn't correct.
-rw-r--r-- | include/wlr/util/region.h | 4 | ||||
-rw-r--r-- | util/region.c | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/wlr/util/region.h b/include/wlr/util/region.h index c3f1cbe8..948307a1 100644 --- a/include/wlr/util/region.h +++ b/include/wlr/util/region.h @@ -39,8 +39,8 @@ void wlr_region_transform(pixman_region32_t *dst, const pixman_region32_t *src, enum wl_output_transform transform, int width, int height); /** - * Expands the region of `distance`. If `distance` is negative, it shrinks the - * region. + * Expands the region by distance on both axis. distance must be + * a non-negative number. */ void wlr_region_expand(pixman_region32_t *dst, const pixman_region32_t *src, int distance); diff --git a/util/region.c b/util/region.c index a3b13e06..b74c55e5 100644 --- a/util/region.c +++ b/util/region.c @@ -111,6 +111,8 @@ void wlr_region_transform(pixman_region32_t *dst, const pixman_region32_t *src, void wlr_region_expand(pixman_region32_t *dst, const pixman_region32_t *src, int distance) { + assert(distance >= 0); + if (distance == 0) { pixman_region32_copy(dst, src); return; |