summaryrefslogtreecommitdiff
path: root/src/til_fb.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-11-21 20:07:43 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-11-21 20:07:43 -0800
commit5a13b8135ec29adf65a8de492ded3c178deea9e0 (patch)
tree714ec276081546b4b01040a93208ed9e339987f5 /src/til_fb.h
parent63405ab723eada97a195ed1964ca3af78aa5d7da (diff)
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.
Diffstat (limited to 'src/til_fb.h')
-rw-r--r--src/til_fb.h8
1 files 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);
© All Rights Reserved