small cleanup putsxyofs()

store the vp local rather than using current_viewport
use the flags directly rather storing them

Change-Id: I93391acff4745aae3d5d7e695c0eabd6dbeabb11
This commit is contained in:
William Wilgus 2024-12-21 19:11:02 -05:00
parent 8091477f8d
commit 632e72273d

View file

@ -386,26 +386,27 @@ static void LCDFN(mono_bmp_part_helper)(const unsigned char *src, int src_x,
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{ {
unsigned short *ucs; unsigned short *ucs;
font_lock(LCDFN(current_viewport)->font, true); struct viewport *vp = LCDFN(current_viewport);
struct font* pf = font_get(LCDFN(current_viewport)->font); font_lock(vp->font, true);
int vp_flags = LCDFN(current_viewport)->flags; struct font* pf = font_get(vp->font);
int rtl_next_non_diac_width, last_non_diacritic_width; int rtl_next_non_diac_width, last_non_diacritic_width;
if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0) if ((vp->flags & VP_FLAG_ALIGNMENT_MASK) != 0)
{ {
int w; int w;
LCDFN(getstringsize)(str, &w, NULL); font_getstringsize(str, &w, NULL, vp->font);
/* center takes precedence */ /* center takes precedence */
if (vp_flags & VP_FLAG_ALIGN_CENTER) if (vp->flags & VP_FLAG_ALIGN_CENTER)
{ {
x = ((LCDFN(current_viewport)->width - w)/ 2) + x; x = ((vp->width - w)/ 2) + x;
if (x < 0) if (x < 0)
x = 0; x = 0;
} }
else else
{ {
x = LCDFN(current_viewport)->width - w - x; x = vp->width - w - x;
x += ofs; x += ofs;
ofs = 0; ofs = 0;
} }
@ -430,7 +431,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
int width, base_width, base_ofs = 0; int width, base_width, base_ofs = 0;
const unsigned short next_ch = ucs[1]; const unsigned short next_ch = ucs[1];
if (x >= LCDFN(current_viewport)->width) if (x >= vp->width)
break; break;
is_diac = is_diacritic(*ucs, &is_rtl); is_diac = is_diacritic(*ucs, &is_rtl);
@ -493,13 +494,13 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
* buffer using OR, and then draw the final bitmap instead of the * buffer using OR, and then draw the final bitmap instead of the
* chars, without touching the drawmode * chars, without touching the drawmode
**/ **/
int drawmode = LCDFN(current_viewport)->drawmode; int drawmode = vp->drawmode;
LCDFN(current_viewport)->drawmode = DRMODE_FG; vp->drawmode = DRMODE_FG;
base_ofs = (base_width - width) / 2; base_ofs = (base_width - width) / 2;
bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height); bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height);
LCDFN(current_viewport)->drawmode = drawmode; vp->drawmode = drawmode;
} }
else else
{ {
@ -522,33 +523,33 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
} }
} }
} }
font_lock(LCDFN(current_viewport)->font, false); font_lock(vp->font, false);
} }
#else /* BOOTLOADER */ #else /* BOOTLOADER */
/* put a string at a given pixel position, skipping first ofs pixel columns */ /* put a string at a given pixel position, skipping first ofs pixel columns */
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{ {
unsigned short *ucs; unsigned short *ucs;
struct font* pf = font_get(LCDFN(current_viewport)->font); struct viewport *vp = LCDFN(current_viewport);
int vp_flags = LCDFN(current_viewport)->flags; struct font* pf = font_get(vp->font);
const unsigned char *bits; const unsigned char *bits;
int width; int width;
if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0) if ((vp->flags & VP_FLAG_ALIGNMENT_MASK) != 0)
{ {
int w; int w;
LCDFN(getstringsize)(str, &w, NULL); font_getstringsize(str, &w, NULL, vp->font);
/* center takes precedence */ /* center takes precedence */
if (vp_flags & VP_FLAG_ALIGN_CENTER) if (vp->flags & VP_FLAG_ALIGN_CENTER)
{ {
x = ((LCDFN(current_viewport)->width - w)/ 2) + x; x = ((vp->width - w)/ 2) + x;
if (x < 0) if (x < 0)
x = 0; x = 0;
} }
else else
{ {
x = LCDFN(current_viewport)->width - w - x; x = vp->width - w - x;
x += ofs; x += ofs;
ofs = 0; ofs = 0;
} }
@ -568,7 +569,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{ {
const unsigned short next_ch = ucs[1]; const unsigned short next_ch = ucs[1];
if (x >= LCDFN(current_viewport)->width) if (x >= vp->width)
break; break;
/* Get proportional width and glyph bits */ /* Get proportional width and glyph bits */