summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-04-19 13:54:12 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-04-19 15:31:31 -0700
commitca14c4bf346a200ab8a66be293d8e71d49e09e32 (patch)
tree1408ada97b8710d0bf244e9b8c250e99410feb2b /src
parent4e52861bb580ac41eaf8df2dd4c99029c3706cf3 (diff)
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()
Diffstat (limited to 'src')
-rw-r--r--src/til_fb.h17
1 files 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;
}
© All Rights Reserved