1a886f802SAxel Dörfler /*
218654db6SAxel Dörfler * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
3a886f802SAxel Dörfler * Distributed under the terms of the MIT License.
4a886f802SAxel Dörfler *
5a886f802SAxel Dörfler * Authors:
6a886f802SAxel Dörfler * Artur Wyszynski <harakash@gmail.com>
7a886f802SAxel Dörfler */
8a886f802SAxel Dörfler
9a886f802SAxel Dörfler
10a886f802SAxel Dörfler #include <stdio.h>
11a886f802SAxel Dörfler #include <stdlib.h>
12a886f802SAxel Dörfler #include <string.h>
13a886f802SAxel Dörfler #include <unistd.h>
14a886f802SAxel Dörfler
15a886f802SAxel Dörfler #include <KernelExport.h>
16a886f802SAxel Dörfler
17d0fc7c65SStephan Aßmus #define __BOOTSPLASH_KERNEL__
1889fa2a85SPhilippe Houdoin #include <boot/images.h>
19029e447bSAugustin Cavalier #include <boot/platform/generic/video_blitter.h>
20*de8d5cfbSAugustin Cavalier #include <boot/platform/generic/video_splash.h>
21d0fc7c65SStephan Aßmus
22a886f802SAxel Dörfler #include <boot_item.h>
23a886f802SAxel Dörfler #include <debug.h>
24a886f802SAxel Dörfler #include <frame_buffer_console.h>
25a886f802SAxel Dörfler
26d0fc7c65SStephan Aßmus #include <boot_splash.h>
27d0fc7c65SStephan Aßmus
28a886f802SAxel Dörfler
29a886f802SAxel Dörfler //#define TRACE_BOOT_SPLASH 1
30a886f802SAxel Dörfler #ifdef TRACE_BOOT_SPLASH
31a886f802SAxel Dörfler # define TRACE(x...) dprintf(x);
32a886f802SAxel Dörfler #else
33a886f802SAxel Dörfler # define TRACE(x...) ;
34a886f802SAxel Dörfler #endif
35a886f802SAxel Dörfler
36a886f802SAxel Dörfler
37a886f802SAxel Dörfler static struct frame_buffer_boot_info *sInfo;
38d0fc7c65SStephan Aßmus static uint8 *sUncompressedIcons;
39a886f802SAxel Dörfler
4018654db6SAxel Dörfler
41a886f802SAxel Dörfler // #pragma mark - exported functions
42a886f802SAxel Dörfler
43a886f802SAxel Dörfler
44a886f802SAxel Dörfler void
boot_splash_init(uint8 * bootSplash)4518654db6SAxel Dörfler boot_splash_init(uint8 *bootSplash)
46a886f802SAxel Dörfler {
47a886f802SAxel Dörfler TRACE("boot_splash_init: enter\n");
48a886f802SAxel Dörfler
49a886f802SAxel Dörfler if (debug_screen_output_enabled())
50a886f802SAxel Dörfler return;
51a886f802SAxel Dörfler
526328832fSAxel Dörfler sInfo = (frame_buffer_boot_info *)get_boot_item(FRAME_BUFFER_BOOT_INFO,
536328832fSAxel Dörfler NULL);
54d0fc7c65SStephan Aßmus
5518654db6SAxel Dörfler sUncompressedIcons = bootSplash;
56a886f802SAxel Dörfler }
57a886f802SAxel Dörfler
58a886f802SAxel Dörfler
59a886f802SAxel Dörfler void
boot_splash_uninit(void)60383a9ac4SIngo Weinhold boot_splash_uninit(void)
61383a9ac4SIngo Weinhold {
62383a9ac4SIngo Weinhold sInfo = NULL;
63383a9ac4SIngo Weinhold }
64383a9ac4SIngo Weinhold
65383a9ac4SIngo Weinhold
66383a9ac4SIngo Weinhold void
boot_splash_set_stage(int stage)67a886f802SAxel Dörfler boot_splash_set_stage(int stage)
68a886f802SAxel Dörfler {
69a886f802SAxel Dörfler TRACE("boot_splash_set_stage: stage=%d\n", stage);
70a886f802SAxel Dörfler
71a886f802SAxel Dörfler if (sInfo == NULL || stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX)
72a886f802SAxel Dörfler return;
73a886f802SAxel Dörfler
74*de8d5cfbSAugustin Cavalier int width, height, x, y;
75*de8d5cfbSAugustin Cavalier compute_splash_icons_placement(sInfo->width, sInfo->height,
76*de8d5cfbSAugustin Cavalier width, height, x, y);
7764379118SStephan Aßmus
7864379118SStephan Aßmus int stageLeftEdge = width * stage / BOOT_SPLASH_STAGE_MAX;
7964379118SStephan Aßmus int stageRightEdge = width * (stage + 1) / BOOT_SPLASH_STAGE_MAX;
80a886f802SAxel Dörfler
81029e447bSAugustin Cavalier BlitParameters params;
82029e447bSAugustin Cavalier params.from = sUncompressedIcons;
83029e447bSAugustin Cavalier params.fromWidth = kSplashIconsWidth;
84029e447bSAugustin Cavalier params.fromLeft = stageLeftEdge;
85029e447bSAugustin Cavalier params.fromTop = 0;
86029e447bSAugustin Cavalier params.fromRight = stageRightEdge;
87029e447bSAugustin Cavalier params.fromBottom = height;
88029e447bSAugustin Cavalier params.to = (uint8*)sInfo->frame_buffer;
89029e447bSAugustin Cavalier params.toBytesPerRow = sInfo->bytes_per_row;
90029e447bSAugustin Cavalier params.toLeft = stageLeftEdge + x;
91029e447bSAugustin Cavalier params.toTop = y;
92029e447bSAugustin Cavalier
93029e447bSAugustin Cavalier blit(params, sInfo->depth);
94a886f802SAxel Dörfler }
95