diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-12 18:07:35 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-12 18:15:04 -0700 |
commit | bc9b657747095dc84266578f457b821f669e15d8 (patch) | |
tree | d67e372929825c4e9cf6d62909215d4f95a48455 /src | |
parent | 3329e547a21dbacc757984e1ec266721f9c49e44 (diff) |
modules/checkers: minor cosmetic changes to fragmenter
Trivial changes to improve some naming / scoping, done while
investigating a bug.
Nothing functionally changed
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/checkers/checkers.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index d12a99d..8875824 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -191,34 +191,41 @@ static void checkers_destroy_context(til_module_context_t *context) */ int checkers_fragment_tile_single(const til_fb_fragment_t *fragment, unsigned tile_size, unsigned number, til_fb_fragment_t *res_fragment) { - unsigned w = fragment->width / tile_size, h = fragment->height / tile_size; - unsigned tiled_w = w * tile_size, tiled_h = h * tile_size; + unsigned numw = fragment->width / tile_size, numh = fragment->height / tile_size; unsigned x, y, xoff, yoff, xshift = 0, yshift = 0; assert(fragment); assert(res_fragment); - /* Detect the need for fractional tiles on both axis and shift the fragments - * to keep the overall checkered output centered. This complicates res_fragment.{x,y,width,height} - * calculations for the peripheral checker tiles as those must clip when shifted. - */ - if (tiled_w < fragment->width) { - tiled_w += tile_size; - xshift = (tiled_w - fragment->width) >> 1; - w++; - } + { + unsigned tiled_w = numw * tile_size; + unsigned tiled_h = numh * tile_size; + + /* Detect the need for fractional tiles on both axis and shift the fragments + * to keep the overall checkered output centered. + * + * This complicates res_fragment.{x,y,width,height} calculations for the + * peripheral checker tiles as those must clip when shifted. + */ + + if (tiled_w < fragment->width) { + tiled_w += tile_size; + xshift = (tiled_w - fragment->width) >> 1; + numw++; + } - if (tiled_h < fragment->height) { - tiled_h += tile_size; - yshift = (tiled_h - fragment->height) >> 1; - h++; + if (tiled_h < fragment->height) { + tiled_h += tile_size; + yshift = (tiled_h - fragment->height) >> 1; + numh++; + } } - y = number / w; - if (y >= h) + y = number / numw; + if (y >= numh) return 0; - x = number - (y * w); + x = number - (y * numw); xoff = x * tile_size; yoff = y * tile_size; |