video: Drop #ifdefs from console_truetype

Use if() instead to reduce the number of build paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-06-01 10:22:32 -06:00 committed by Tom Rini
parent a6c4f18894
commit 7432f68c53

View file

@ -154,33 +154,33 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
end = line + met->font_size * vid_priv->line_length; end = line + met->font_size * vid_priv->line_length;
switch (vid_priv->bpix) { switch (vid_priv->bpix) {
#ifdef CONFIG_VIDEO_BPP8
case VIDEO_BPP8: { case VIDEO_BPP8: {
u8 *dst; u8 *dst;
for (dst = line; dst < (u8 *)end; ++dst) if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
*dst = clr; for (dst = line; dst < (u8 *)end; ++dst)
*dst = clr;
}
break; break;
} }
#endif
#ifdef CONFIG_VIDEO_BPP16
case VIDEO_BPP16: { case VIDEO_BPP16: {
u16 *dst = line; u16 *dst = line;
for (dst = line; dst < (u16 *)end; ++dst) if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
*dst = clr; for (dst = line; dst < (u16 *)end; ++dst)
*dst = clr;
}
break; break;
} }
#endif
#ifdef CONFIG_VIDEO_BPP32
case VIDEO_BPP32: { case VIDEO_BPP32: {
u32 *dst = line; u32 *dst = line;
for (dst = line; dst < (u32 *)end; ++dst) if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
*dst = clr; for (dst = line; dst < (u32 *)end; ++dst)
*dst = clr;
}
break; break;
} }
#endif
default: default:
return -ENOSYS; return -ENOSYS;
} }
@ -317,52 +317,52 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
end = dst; end = dst;
} }
break; break;
#ifdef CONFIG_VIDEO_BPP16
case VIDEO_BPP16: { case VIDEO_BPP16: {
uint16_t *dst = (uint16_t *)line + xoff; uint16_t *dst = (uint16_t *)line + xoff;
int i; int i;
for (i = 0; i < width; i++) { if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
int val = *bits; for (i = 0; i < width; i++) {
int out; int val = *bits;
int out;
if (vid_priv->colour_bg) if (vid_priv->colour_bg)
val = 255 - val; val = 255 - val;
out = val >> 3 | out = val >> 3 |
(val >> 2) << 5 | (val >> 2) << 5 |
(val >> 3) << 11; (val >> 3) << 11;
if (vid_priv->colour_fg) if (vid_priv->colour_fg)
*dst++ |= out; *dst++ |= out;
else else
*dst++ &= out; *dst++ &= out;
bits++; bits++;
}
end = dst;
} }
end = dst;
break; break;
} }
#endif
#ifdef CONFIG_VIDEO_BPP32
case VIDEO_BPP32: { case VIDEO_BPP32: {
u32 *dst = (u32 *)line + xoff; u32 *dst = (u32 *)line + xoff;
int i; int i;
for (i = 0; i < width; i++) { if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
int val = *bits; for (i = 0; i < width; i++) {
int out; int val = *bits;
int out;
if (vid_priv->colour_bg) if (vid_priv->colour_bg)
val = 255 - val; val = 255 - val;
out = val | val << 8 | val << 16; out = val | val << 8 | val << 16;
if (vid_priv->colour_fg) if (vid_priv->colour_fg)
*dst++ |= out; *dst++ |= out;
else else
*dst++ &= out; *dst++ &= out;
bits++; bits++;
}
end = dst;
} }
end = dst;
break; break;
} }
#endif
default: default:
free(data); free(data);
return -ENOSYS; return -ENOSYS;
@ -405,33 +405,33 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
line = start; line = start;
for (row = ystart; row < yend; row++) { for (row = ystart; row < yend; row++) {
switch (vid_priv->bpix) { switch (vid_priv->bpix) {
#ifdef CONFIG_VIDEO_BPP8
case VIDEO_BPP8: { case VIDEO_BPP8: {
uint8_t *dst = line; uint8_t *dst = line;
for (i = 0; i < pixels; i++) if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
*dst++ = clr; for (i = 0; i < pixels; i++)
*dst++ = clr;
}
break; break;
} }
#endif
#ifdef CONFIG_VIDEO_BPP16
case VIDEO_BPP16: { case VIDEO_BPP16: {
uint16_t *dst = line; uint16_t *dst = line;
for (i = 0; i < pixels; i++) if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
*dst++ = clr; for (i = 0; i < pixels; i++)
*dst++ = clr;
}
break; break;
} }
#endif
#ifdef CONFIG_VIDEO_BPP32
case VIDEO_BPP32: { case VIDEO_BPP32: {
uint32_t *dst = line; uint32_t *dst = line;
for (i = 0; i < pixels; i++) if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
*dst++ = clr; for (i = 0; i < pixels; i++)
*dst++ = clr;
}
break; break;
} }
#endif
default: default:
return -ENOSYS; return -ENOSYS;
} }