From 53cc747fd2bdd774bc6f27f8aca5749c664b5cc7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 24 Nov 2019 01:19:06 -0800 Subject: fb: add pitch to fb_fragment_t The put_pixel helpers really needed reworking to properly handle subframe fragments modules like montage will utilize. I had the stride present as it's convenient for a number of modules that maintain a buf pointer as they progress down a row, but the pitch is more applicable to put_pixel for scaling the y coordinate. Now there's both pitch and stride so everyone's happy with what's most convenient for their needs. --- src/fb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/fb.c') diff --git a/src/fb.c b/src/fb.c index 7485800..a20fdd3 100644 --- a/src/fb.c +++ b/src/fb.c @@ -319,9 +319,7 @@ int fb_fragment_slice_single(const fb_fragment_t *fragment, unsigned n_fragments if (yoff >= fragment->height) return 0; - pitch = (fragment->width * 4) + fragment->stride; - - res_fragment->buf = ((void *)fragment->buf) + yoff * pitch; + res_fragment->buf = ((void *)fragment->buf) + yoff * fragment->pitch; res_fragment->x = fragment->x; res_fragment->y = yoff; res_fragment->width = fragment->width; @@ -329,6 +327,7 @@ int fb_fragment_slice_single(const fb_fragment_t *fragment, unsigned n_fragments res_fragment->frame_width = fragment->frame_width; res_fragment->frame_height = fragment->frame_height; res_fragment->stride = fragment->stride; + res_fragment->pitch = fragment->pitch; return 1; } @@ -337,7 +336,6 @@ int fb_fragment_slice_single(const fb_fragment_t *fragment, unsigned n_fragments int fb_fragment_tile_single(const fb_fragment_t *fragment, unsigned tile_size, unsigned num, fb_fragment_t *res_fragment) { unsigned w = fragment->width / tile_size, h = fragment->height / tile_size; - unsigned pitch = (fragment->width * 4) + fragment->stride; unsigned x, y, xoff, yoff; if (w * tile_size < fragment->width) @@ -355,7 +353,7 @@ int fb_fragment_tile_single(const fb_fragment_t *fragment, unsigned tile_size, u xoff = x * tile_size; yoff = y * tile_size; - res_fragment->buf = (void *)fragment->buf + (yoff * pitch) + (xoff * 4); + res_fragment->buf = (void *)fragment->buf + (yoff * fragment->pitch) + (xoff * 4); res_fragment->x = fragment->x + xoff; res_fragment->y = fragment->y + yoff; res_fragment->width = MIN(fragment->width - xoff, tile_size); @@ -363,6 +361,7 @@ int fb_fragment_tile_single(const fb_fragment_t *fragment, unsigned tile_size, u res_fragment->frame_width = fragment->frame_width; res_fragment->frame_height = fragment->frame_height; res_fragment->stride = fragment->stride + ((fragment->width - res_fragment->width) * 4); + res_fragment->pitch = fragment->pitch; return 1; } -- cgit v1.2.3