From c5b6fb679416544b1c5cd1d4d55eeaa0d11fd405 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 14 Jun 2023 12:34:37 -0700 Subject: modules/roto: trivial simplification of render loop Maybe earlier versions used the absolute coordinates in the frame, but the current code doesn't make use of this and simply needs to confine itself into the WxH of the fragment. --- src/modules/roto/roto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index 322b967..8564870 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -213,7 +213,7 @@ static void roto_render_fragment(til_module_context_t *context, til_stream_t *st roto_context_t *ctxt = (roto_context_t *)context; til_fb_fragment_t *fragment = *fragment_ptr; - int x, y, frame_width = fragment->frame_width, frame_height = fragment->frame_height; + int frame_width = fragment->frame_width, frame_height = fragment->frame_height; int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; uint32_t *buf = fragment->buf; @@ -230,12 +230,12 @@ static void roto_render_fragment(til_module_context_t *context, til_stream_t *st y_cos_r = FIXED_MULT(-FIXED_NEW(frame_height / 2) + FIXED_NEW(fragment->y), cos_r); y_sin_r = FIXED_MULT(-FIXED_NEW(frame_height / 2) + FIXED_NEW(fragment->y), sin_r); - for (y = fragment->y; y < fragment->y + fragment->height; y++) { + for (int y = 0; y < fragment->height; y++) { x_cos_r = x_cos_r_init; x_sin_r = x_sin_r_init; - for (x = fragment->x; x < fragment->x + fragment->width; x++, buf++) { + for (int x = 0; x < fragment->width; x++, buf++) { *buf = bilerp_color(texture, ctxt->palette, x_sin_r - y_cos_r, y_sin_r + x_cos_r); x_cos_r += cos_r; -- cgit v1.2.3