From 7d85665d0f66c194de64918e56169031e068e850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 18 Mar 2008 13:14:18 +0000 Subject: [PATCH] * Give boot stages a more meaningful name, make the max stage count known. * Calculate icon offset from stage in splash.cpp, remove hard coded placement values. Draw only icon, not the whole image from top/left to right of icon. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24439 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/splash.h | 16 +++++++------ src/system/kernel/main.c | 14 +++++------ src/system/kernel/splash.cpp | 36 +++++++--------------------- 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/headers/private/kernel/boot/splash.h b/headers/private/kernel/boot/splash.h index dcd71110c2..6db530fd49 100644 --- a/headers/private/kernel/boot/splash.h +++ b/headers/private/kernel/boot/splash.h @@ -35,13 +35,15 @@ extern "C" { #endif enum { - BOOT_SPLASH_STAGE_1 = 0, - BOOT_SPLASH_STAGE_2, - BOOT_SPLASH_STAGE_3, - BOOT_SPLASH_STAGE_4, - BOOT_SPLASH_STAGE_5, - BOOT_SPLASH_STAGE_6, - BOOT_SPLASH_STAGE_7 + BOOT_SPLASH_STAGE_1_INIT_MODULES = 0, + BOOT_SPLASH_STAGE_2_BOOTSTRAP_FS, + BOOT_SPLASH_STAGE_3_INIT_DEVICES, + BOOT_SPLASH_STAGE_4_MOUNT_BOOT_FS, + BOOT_SPLASH_STAGE_5_INIT_CPU_MODULES, + BOOT_SPLASH_STAGE_6_INIT_VM_MODULES, + BOOT_SPLASH_STAGE_7_RUN_BOOT_SCRIPT, + + BOOT_SPLASH_STAGE_MAX // keep this at the end }; status_t boot_splash_fb_init(struct kernel_args *args); diff --git a/src/system/kernel/main.c b/src/system/kernel/main.c index d24d9fef52..bf18af5b19 100644 --- a/src/system/kernel/main.c +++ b/src/system/kernel/main.c @@ -226,7 +226,7 @@ main2(void *unused) boot_splash_fb_init(&sKernelArgs); TRACE("Init modules\n"); - boot_splash_set_stage(BOOT_SPLASH_STAGE_1); + boot_splash_set_stage(BOOT_SPLASH_STAGE_1_INIT_MODULES); module_init(&sKernelArgs); // ToDo: the preloaded image debug data is placed in the kernel args, and @@ -250,11 +250,11 @@ main2(void *unused) /* bootstrap all the filesystems */ TRACE("Bootstrap file systems\n"); - boot_splash_set_stage(BOOT_SPLASH_STAGE_2); + boot_splash_set_stage(BOOT_SPLASH_STAGE_2_BOOTSTRAP_FS); vfs_bootstrap_file_systems(); TRACE("Init Device Manager\n"); - boot_splash_set_stage(BOOT_SPLASH_STAGE_3); + boot_splash_set_stage(BOOT_SPLASH_STAGE_3_INIT_DEVICES); device_manager_init(&sKernelArgs); TRACE("Add preloaded old-style drivers\n"); @@ -266,15 +266,15 @@ main2(void *unused) int_init_post_device_manager(&sKernelArgs); TRACE("Mount boot file system\n"); - boot_splash_set_stage(BOOT_SPLASH_STAGE_4); + boot_splash_set_stage(BOOT_SPLASH_STAGE_4_MOUNT_BOOT_FS); vfs_mount_boot_file_system(&sKernelArgs); // CPU specific modules may now be available - boot_splash_set_stage(BOOT_SPLASH_STAGE_5); + boot_splash_set_stage(BOOT_SPLASH_STAGE_5_INIT_CPU_MODULES); cpu_init_post_modules(&sKernelArgs); TRACE("vm_init_post_modules\n"); - boot_splash_set_stage(BOOT_SPLASH_STAGE_6); + boot_splash_set_stage(BOOT_SPLASH_STAGE_6_INIT_VM_MODULES); vm_init_post_modules(&sKernelArgs); TRACE("debug_init_post_modules\n"); @@ -283,7 +283,7 @@ main2(void *unused) TRACE("device_manager_init_post_modules\n"); device_manager_init_post_modules(&sKernelArgs); - boot_splash_set_stage(BOOT_SPLASH_STAGE_7); + boot_splash_set_stage(BOOT_SPLASH_STAGE_7_RUN_BOOT_SCRIPT); // start the init process { const char *shellArgs[] = {"/bin/sh", "/boot/beos/system/boot/Bootscript", NULL}; diff --git a/src/system/kernel/splash.cpp b/src/system/kernel/splash.cpp index 959e2172db..35630db5df 100644 --- a/src/system/kernel/splash.cpp +++ b/src/system/kernel/splash.cpp @@ -335,37 +335,17 @@ boot_splash_set_stage(int stage) if (!sBootSplash.enabled) return; + if (stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX) + return; + + // TODO: Use placement info from images.h int x = sBootSplash.width / 2 - iconsWidth / 2; int y = sBootSplash.height / 2 - splashHeight / 2; y = y + splashHeight; - - int stageOffset = 0; - switch (stage) { - case BOOT_SPLASH_STAGE_1: - stageOffset = 32; - break; - case BOOT_SPLASH_STAGE_2: - stageOffset = 74; - break; - case BOOT_SPLASH_STAGE_3: - stageOffset = 116; - break; - case BOOT_SPLASH_STAGE_4: - stageOffset = 158; - break; - case BOOT_SPLASH_STAGE_5: - stageOffset = 200; - break; - case BOOT_SPLASH_STAGE_6: - stageOffset = 242; - break; - case BOOT_SPLASH_STAGE_7: - default: - stageOffset = iconsWidth; - break; - } - boot_splash_fb_blit_cropped(iconsImage, 0, 0, stageOffset, 32, - iconsWidth, iconsHeight, iconsPalette, x, y ); + int stageLeftEdge = iconsWidth * stage / BOOT_SPLASH_STAGE_MAX; + int stageRightEdge = iconsWidth * (stage + 1) / BOOT_SPLASH_STAGE_MAX; + boot_splash_fb_blit_cropped(iconsImage, stageLeftEdge, 0, + stageRightEdge, 32, iconsWidth, iconsHeight, iconsPalette, x, y ); }