summaryrefslogtreecommitdiff
path: root/src/fb.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-09-25 18:47:25 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-09-25 20:54:34 -0700
commitd9db2680298c01a82b768dc19e75bf4f2ef1b56e (patch)
tree1e52d4cbfa4747bc0cb8f405881d5575a0db9b7e /src/fb.h
parentdb9cc3ab1037ed98d2c6c9dbf44c60d08ca696c2 (diff)
fb: track zeroed state in fb_fragment_t
This adds a bit flag for tracking if the fragment has been zeroed since its last flip/present. When a fresh frame comes back from flipping, its zeroed state is reset to false. When fb_fragment_zero() is called, it checks if zeroed is true, and skips the zeroing if so. If zeroed is false, fb_fragment_zero() will zero the fragment and set the zeroed flag to 1. This change is preparatory for layering the output of modules in a compositing fashion. Not all modules are amenable to being used as upper layers, since they inherently fill the screen with new pixels every frame. Those modules make good bottom or bg layers. Other modules perform fb_fragment_zero() every frame and add relatively few pixels atop a clean slate. These modules make good candidates for upper layers where this change becomes relevant.
Diffstat (limited to 'src/fb.h')
-rw-r--r--src/fb.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fb.h b/src/fb.h
index 300c134..d9914df 100644
--- a/src/fb.h
+++ b/src/fb.h
@@ -19,6 +19,7 @@ typedef struct fb_fragment_t {
unsigned stride; /* number of bytes from the end of one row to the start of the next */
unsigned pitch; /* number of bytes separating y from y + 1, including any padding */
unsigned number; /* this fragment's number as produced by fragmenting */
+ unsigned zeroed:1; /* if this fragment has been zeroed since last flip */
} fb_fragment_t;
/* This is a page handle object for page flip submission/life-cycle.
@@ -92,9 +93,14 @@ static inline void fb_fragment_zero(fb_fragment_t *fragment)
{
void *buf = fragment->buf;
+ 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);
+
+ fragment->zeroed = 1;
}
#endif
© All Rights Reserved