1 /*
2 * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Artur Wyszynski <harakash@gmail.com>
7 */
8
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <unistd.h>
14
15 #include <KernelExport.h>
16
17 #define __BOOTSPLASH_KERNEL__
18 #include <boot/images.h>
19 #include <boot/platform/generic/video_blitter.h>
20 #include <boot/platform/generic/video_splash.h>
21
22 #include <boot_item.h>
23 #include <debug.h>
24 #include <frame_buffer_console.h>
25
26 #include <boot_splash.h>
27
28
29 //#define TRACE_BOOT_SPLASH 1
30 #ifdef TRACE_BOOT_SPLASH
31 # define TRACE(x...) dprintf(x);
32 #else
33 # define TRACE(x...) ;
34 #endif
35
36
37 static struct frame_buffer_boot_info *sInfo;
38 static uint8 *sUncompressedIcons;
39
40
41 // #pragma mark - exported functions
42
43
44 void
boot_splash_init(uint8 * bootSplash)45 boot_splash_init(uint8 *bootSplash)
46 {
47 TRACE("boot_splash_init: enter\n");
48
49 if (debug_screen_output_enabled())
50 return;
51
52 sInfo = (frame_buffer_boot_info *)get_boot_item(FRAME_BUFFER_BOOT_INFO,
53 NULL);
54
55 sUncompressedIcons = bootSplash;
56 }
57
58
59 void
boot_splash_uninit(void)60 boot_splash_uninit(void)
61 {
62 sInfo = NULL;
63 }
64
65
66 void
boot_splash_set_stage(int stage)67 boot_splash_set_stage(int stage)
68 {
69 TRACE("boot_splash_set_stage: stage=%d\n", stage);
70
71 if (sInfo == NULL || stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX)
72 return;
73
74 int width, height, x, y;
75 compute_splash_icons_placement(sInfo->width, sInfo->height,
76 width, height, x, y);
77
78 int stageLeftEdge = width * stage / BOOT_SPLASH_STAGE_MAX;
79 int stageRightEdge = width * (stage + 1) / BOOT_SPLASH_STAGE_MAX;
80
81 BlitParameters params;
82 params.from = sUncompressedIcons;
83 params.fromWidth = kSplashIconsWidth;
84 params.fromLeft = stageLeftEdge;
85 params.fromTop = 0;
86 params.fromRight = stageRightEdge;
87 params.fromBottom = height;
88 params.to = (uint8*)sInfo->frame_buffer;
89 params.toBytesPerRow = sInfo->bytes_per_row;
90 params.toLeft = stageLeftEdge + x;
91 params.toTop = y;
92
93 blit(params, sInfo->depth);
94 }
95