From a59229c5513e73348c87bcfc5cc4b39a31012437 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 28 Apr 2022 01:46:10 -0700 Subject: til_fb: introduce a fragment texture source Idea here is to provide texture sources for obtaining pixel colors at the til_fb_put_pixel/fill drawing API, making it possible for at least overlayable modules to serve as mask/stencil operators where their drawn areas are populated by the contents of another fragment produced dynamically, potentially by other modules altogether. This commit adds a texture=modulename option to the compose module for specifying if a texture should be used when compositing, excepting and defaulting to "none" for disabling texturing. A future commit should expand this compose option to accept a potential list of modules for composing the texture in the same way as the main layers= list functions. Something this all immediately makes clear is the need for a better settings syntax, probably in the form of all module setting specifiers optionally being followed by a squence of settings, with support for escaping to handle nested situations. --- src/til_fb.c | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/til_fb.c') diff --git a/src/til_fb.c b/src/til_fb.c index eb14e27..f6a71a8 100644 --- a/src/til_fb.c +++ b/src/til_fb.c @@ -399,17 +399,20 @@ int til_fb_fragment_slice_single(const til_fb_fragment_t *fragment, unsigned n_f if (yoff >= fragment->height) return 0; - res_fragment->buf = fragment->buf + yoff * fragment->pitch; - res_fragment->x = fragment->x; - res_fragment->y = yoff; - res_fragment->width = fragment->width; - res_fragment->height = MIN(fragment->height - yoff, slice); - res_fragment->frame_width = fragment->frame_width; - res_fragment->frame_height = fragment->frame_height; - res_fragment->stride = fragment->stride; - res_fragment->pitch = fragment->pitch; - res_fragment->number = number; - res_fragment->cleared = fragment->cleared; + *res_fragment = (til_fb_fragment_t){ + .texture = fragment->texture, + .buf = fragment->buf + yoff * fragment->pitch, + .x = fragment->x, + .y = yoff, + .width = fragment->width, + .height = MIN(fragment->height - yoff, slice), + .frame_width = fragment->frame_width, + .frame_height = fragment->frame_height, + .stride = fragment->stride, + .pitch = fragment->pitch, + .number = number, + .cleared = fragment->cleared, + }; return 1; } @@ -435,17 +438,20 @@ int til_fb_fragment_tile_single(const til_fb_fragment_t *fragment, unsigned tile xoff = x * tile_size; yoff = y * tile_size; - res_fragment->buf = fragment->buf + (yoff * fragment->pitch) + (xoff); - res_fragment->x = fragment->x + xoff; - res_fragment->y = fragment->y + yoff; - res_fragment->width = MIN(fragment->width - xoff, tile_size); - res_fragment->height = MIN(fragment->height - yoff, tile_size); - res_fragment->frame_width = fragment->frame_width; - res_fragment->frame_height = fragment->frame_height; - res_fragment->stride = fragment->stride + (fragment->width - res_fragment->width); - res_fragment->pitch = fragment->pitch; - res_fragment->number = number; - res_fragment->cleared = fragment->cleared; + *res_fragment = (til_fb_fragment_t){ + .texture = fragment->texture, + .buf = fragment->buf + (yoff * fragment->pitch) + (xoff), + .x = fragment->x + xoff, + .y = fragment->y + yoff, + .width = MIN(fragment->width - xoff, tile_size), + .height = MIN(fragment->height - yoff, tile_size), + .frame_width = fragment->frame_width, + .frame_height = fragment->frame_height, + .stride = fragment->stride + (fragment->width - MIN(fragment->width - xoff, tile_size)), + .pitch = fragment->pitch, + .number = number, + .cleared = fragment->cleared, + }; return 1; } -- cgit v1.2.1