From bb7bac2d9bfefc739b68f455e92c869c41685c5d Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Mon, 8 Aug 2016 23:12:52 -0700 Subject: [PATCH] add region intersect --- common/pixman-region.h | 3 +++ xrdp/xrdp.h | 5 +++-- xrdp/xrdp_region.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/pixman-region.h b/common/pixman-region.h index 4f781819..9c82c4d9 100644 --- a/common/pixman-region.h +++ b/common/pixman-region.h @@ -67,6 +67,9 @@ pixman_bool_t pixman_region_union (pixman_region16_t *new pixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d, pixman_region16_t *reg_m, pixman_region16_t *reg_s); +pixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg, + pixman_region16_t *reg1, + pixman_region16_t *reg2); pixman_box16_t * pixman_region_rectangles (pixman_region16_t *region, int *n_rects); diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 4e36f0c7..edf88cc4 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -175,8 +175,9 @@ xrdp_region_delete(struct xrdp_region* self); int APP_CC xrdp_region_add_rect(struct xrdp_region* self, struct xrdp_rect* rect); int APP_CC -xrdp_region_subtract_rect(struct xrdp_region* self, - struct xrdp_rect* rect); +xrdp_region_subtract_rect(struct xrdp_region* self, struct xrdp_rect* rect); +int APP_CC +xrdp_region_intersect_rect(struct xrdp_region* self, struct xrdp_rect* rect); int APP_CC xrdp_region_get_rect(struct xrdp_region* self, int index, struct xrdp_rect* rect); diff --git a/xrdp/xrdp_region.c b/xrdp/xrdp_region.c index f943e14f..4da30f9d 100644 --- a/xrdp/xrdp_region.c +++ b/xrdp/xrdp_region.c @@ -91,6 +91,26 @@ xrdp_region_subtract_rect(struct xrdp_region *self, struct xrdp_rect *rect) return 0; } +/*****************************************************************************/ +/* returns error */ +int APP_CC +xrdp_region_intersect_rect(struct xrdp_region* self, struct xrdp_rect* rect) +{ + struct pixman_region16 lreg; + + pixman_region_init_rect(&lreg, rect->left, rect->top, + rect->right - rect->left, + rect->bottom - rect->top); + if (!pixman_region_intersect(self->reg, self->reg, &lreg)) + { + pixman_region_fini(&lreg); + return 1; + } + pixman_region_fini(&lreg); + return 0; +} + + /*****************************************************************************/ /* returns error */ int APP_CC