forked from len0rd/rockbox
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:
parent
f179fc1079
commit
660fa3ffdc
3 changed files with 33 additions and 27 deletions
|
@ -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) *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue