From ca14c4bf346a200ab8a66be293d8e71d49e09e32 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 19 Apr 2022 13:54:12 -0700 Subject: til_fb: introduce til_fb_fragment_fill() Just adding a convenience function targeting simple overlay use cases where the fragmenter is exploited for producing patterns and the renderer may wish to fill those fragments vs. zero them. A future commit should also really rename til_fb_fragment_zero() to til_fb_fragment_clear() --- src/til_fb.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/til_fb.h b/src/til_fb.h index bc553c6..f441d36 100644 --- a/src/til_fb.h +++ b/src/til_fb.h @@ -90,17 +90,24 @@ static inline int til_fb_fragment_put_pixel_checked(til_fb_fragment_t *fragment, } -/* zero a fragment */ -static inline void til_fb_fragment_zero(til_fb_fragment_t *fragment) +/* fill a fragment with an arbitrary pixel */ +static inline void til_fb_fragment_fill(til_fb_fragment_t *fragment, uint32_t pixel) { void *buf = fragment->buf; + /* TODO: there should be a fast-path for non-divided fragments where there's no stride to skip */ + for (int y = 0; y < fragment->height; y++, buf += fragment->pitch) + memset(buf, pixel, fragment->pitch - fragment->stride); +} + + +/* zero a fragment */ +static inline void til_fb_fragment_zero(til_fb_fragment_t *fragment) +{ if (fragment->zeroed) return; - /* TODO: there should be a fast-path for non-divided fragments where there's no stride to skip */ - for (int y = 0; y < fragment->height; y++, buf += fragment->pitch) - memset(buf, 0, fragment->pitch - fragment->stride); + til_fb_fragment_fill(fragment, 0); fragment->zeroed = 1; } -- cgit v1.2.1