diff options
Diffstat (limited to 'src/fb.c')
-rw-r--r-- | src/fb.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -342,3 +342,37 @@ int fb_fragment_divide_single(const fb_fragment_t *fragment, unsigned n_fragment return 1; } + + +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) + w++; + + if (h * tile_size < fragment->height) + h++; + + y = num / w; + if (y >= h) + return 0; + + x = num - (y * w); + + xoff = x * tile_size; + yoff = y * tile_size; + + res_fragment->buf = (void *)fragment->buf + (yoff * pitch) + (xoff * 4); + 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) * 4); + + return 1; +} |