diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2017-01-02 02:10:19 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2017-01-02 02:10:19 -0800 |
commit | 7d4b2e75627b7966eb3186b9c3a43eb3b39d6fbc (patch) | |
tree | 15b1b1cdda63cba6f8a158e1c28ba2e9b6969d33 /modules/roto | |
parent | 8afcb565979ea3b6c7ef200a7b653cf26e365e72 (diff) |
roto: skip lerp of identical colors
With the current checkerboard pattern the majority of the interpolation
being performed is pointless.
Of course with a more complex texture this won't be as beneficial, but for
now it makes a significant FPS improvement.
Diffstat (limited to 'modules/roto')
-rw-r--r-- | modules/roto/roto.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/roto/roto.c b/modules/roto/roto.c index bf92df4..a7d1750 100644 --- a/modules/roto/roto.c +++ b/modules/roto/roto.c @@ -92,8 +92,22 @@ static uint32_t bilerp_color(uint8_t texture[256][256], color_t *palette, int tx } } - n_color = lerp_color(&palette[nw], &palette[ne], x_alpha); - s_color = lerp_color(&palette[sw], &palette[se], x_alpha); + /* Skip interpolation of same colors, a substantial optimization with plain textures like the checker pattern */ + if (nw == ne) { + if (ne == sw && sw == se) { + return (FIXED_TO_INT(palette[sw].r) << 16) | (FIXED_TO_INT(palette[sw].g) << 8) | FIXED_TO_INT(palette[sw].b); + } + n_color = palette[nw]; + } else { + n_color = lerp_color(&palette[nw], &palette[ne], x_alpha); + } + + if (sw == se) { + s_color = palette[sw]; + } else { + s_color = lerp_color(&palette[sw], &palette[se], x_alpha); + } + color = lerp_color(&n_color, &s_color, y_alpha); return (FIXED_TO_INT(color.r) << 16) | (FIXED_TO_INT(color.g) << 8) | FIXED_TO_INT(color.b); |