scroll engine calculate stringsize only when scroll line updated

we calculate the size of the scrolling line every scroll update
the line data doesn't ever change without a call to update
instead calculate the string size when the line is updated
re-use this value while scrolling the line

in theory the current font could change but in practice
I can't find a case when the string size needs to be updated
that the scroll engine isn't already updating the line

if this is later an issue we can recalculate the stringsize each time
the line is finished scrolling which still saves quite a few calculations

Other:
I don't think we have any targets with pixel counts exceeding 65535 pixels
where unsigned short stringsize will be an issue

Change-Id: I83d6374377ed648d9a320d4fd69f9d6a17095b0c
This commit is contained in:
William Wilgus 2024-12-19 12:28:07 -05:00 committed by William Wilgus
parent f179fc1079
commit 660fa3ffdc
3 changed files with 33 additions and 27 deletions

View file

@ -684,7 +684,7 @@ static bool LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
cwidth = font_get(vp->font)->maxwidth;
/* get width (pixels) of the string */
LCDFN(getstringsize)(string, &w, &h);
font_getstringsize(string, &w, &h, vp->font);
height = h;
y = y * (linebased ? height : 1);
@ -713,6 +713,8 @@ static bool LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
/* copy contents to the line buffer */
strmemccpy(s->linebuffer, string, sizeof(s->linebuffer));
s->line_stringsize = w;
/* scroll bidirectional or forward only depending on the string width */
if ( LCDFN(scroll_info).bidir_limit ) {
s->bidir = w < (vp->width) *