Skip to content

Commit 6b09b5e

Browse files
committed
get_splashscreeen: add assertions
1 parent a657bc7 commit 6b09b5e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/video_display.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,14 @@ struct video_frame *get_splashscreen()
630630
{
631631
struct video_desc desc;
632632

633-
desc.width = 512;
634-
desc.height = 512;
635-
desc.color_spec = RGBA;
633+
enum {
634+
FBUF_W = 512,
635+
FBUF_H = 512,
636+
FBUF_CS = RGBA,
637+
};
638+
desc.width = FBUF_W;
639+
desc.height = FBUF_H;
640+
desc.color_spec = (codec_t) FBUF_CS;
636641
desc.interlacing = PROGRESSIVE;
637642
desc.fps = 1;
638643
desc.tile_count = 1;
@@ -641,6 +646,10 @@ struct video_frame *get_splashscreen()
641646

642647
const char *data = splash_data;
643648
memset(frame->tiles[0].data, 0, frame->tiles[0].data_len);
649+
// center the pixture; framebuffer size must be greater or equal
650+
// the splash size
651+
_Static_assert(splash_width >= FBUF_W && splash_height >= FBUF_H,
652+
"framebuffer smaller than splash size");
644653
for (unsigned int y = 0; y < splash_height; ++y) {
645654
char *line = frame->tiles[0].data;
646655
line += vc_get_linesize(frame->tiles[0].width,
@@ -649,6 +658,7 @@ struct video_frame *get_splashscreen()
649658
line += vc_get_linesize(
650659
(frame->tiles[0].width - splash_width)/2,
651660
frame->color_spec);
661+
_Static_assert((codec_t) FBUF_CS == RGBA, "RGBA is expected");
652662
for (unsigned int x = 0; x < splash_width; ++x) {
653663
HEADER_PIXEL(data,line);
654664
line += 4;

0 commit comments

Comments
 (0)