From 5a13b8135ec29adf65a8de492ded3c178deea9e0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 21 Nov 2023 20:07:43 -0800 Subject: til_fb: fixup clipping of til_fb_fragment_copy() Apparently no existing were really taking advantage of this ability. The x,y,w,h parameters are also supposed to impart clip bounds, should they be smaller than the union of the src and dest fragments. --- src/til_fb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/til_fb.h b/src/til_fb.h index d346bd7..9daef63 100644 --- a/src/til_fb.h +++ b/src/til_fb.h @@ -137,10 +137,10 @@ static inline int til_fb_fragment_put_pixel_checked(til_fb_fragment_t *fragment, /* copy a fragment, x,y,width,height are absolute coordinates within the frames, and will be clipped to the overlapping fragment areas */ static inline void til_fb_fragment_copy(til_fb_fragment_t *dest, uint32_t flags, int x, int y, int width, int height, til_fb_fragment_t *src) { - int X = MAX(dest->x, src->x); - int Y = MAX(dest->y, src->y); - int W = MIN(dest->x + dest->width, src->x + src->width) - X; - int H = MIN(dest->y + dest->height, src->y + src->height) - Y; + int X = MAX(MAX(dest->x, src->x), x); + int Y = MAX(MAX(dest->y, src->y), y); + int W = MIN(MIN(dest->x + dest->width, src->x + src->width), x + width) - X; + int H = MIN(MIN(dest->y + dest->height, src->y + src->height), y + height) - Y; assert(W >= 0 && H >= 0); -- cgit v1.2.1