2008-03-20 14:10:17 +03:00
|
|
|
/*
|
2010-05-05 18:37:35 +04:00
|
|
|
* Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
|
2008-03-20 14:10:17 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Artur Wyszynski <harakash@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <KernelExport.h>
|
|
|
|
|
2008-04-06 01:15:43 +04:00
|
|
|
#define __BOOTSPLASH_KERNEL__
|
2010-07-26 00:22:10 +04:00
|
|
|
#ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL
|
2010-10-05 14:31:13 +04:00
|
|
|
# ifdef HAIKU_OFFICIAL_RELEASE
|
|
|
|
# include <boot/images-tm.h>
|
|
|
|
# else
|
|
|
|
# include <boot/images-tm-development.h>
|
|
|
|
# endif
|
2010-07-26 00:22:10 +04:00
|
|
|
#else
|
2010-10-05 14:31:13 +04:00
|
|
|
# include <boot/images-sans-tm.h>
|
2010-07-26 00:22:10 +04:00
|
|
|
#endif
|
2008-04-06 01:15:43 +04:00
|
|
|
|
|
|
|
|
2008-03-20 14:10:17 +03:00
|
|
|
#include <boot_item.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <frame_buffer_console.h>
|
|
|
|
|
2008-04-06 01:15:43 +04:00
|
|
|
#include <boot_splash.h>
|
|
|
|
|
2008-03-20 14:10:17 +03:00
|
|
|
|
|
|
|
//#define TRACE_BOOT_SPLASH 1
|
|
|
|
#ifdef TRACE_BOOT_SPLASH
|
|
|
|
# define TRACE(x...) dprintf(x);
|
|
|
|
#else
|
|
|
|
# define TRACE(x...) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static struct frame_buffer_boot_info *sInfo;
|
2008-04-06 01:15:43 +04:00
|
|
|
static uint8 *sUncompressedIcons;
|
2008-03-20 14:10:17 +03:00
|
|
|
|
2010-05-05 18:37:35 +04:00
|
|
|
|
2008-08-28 20:59:34 +04:00
|
|
|
static void
|
|
|
|
blit8_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
|
|
|
uint16 left, uint16 top)
|
|
|
|
{
|
|
|
|
data += (imageWidth * imageTop + imageLeft);
|
|
|
|
uint8* start = (uint8*)(sInfo->frame_buffer
|
|
|
|
+ sInfo->bytes_per_row * (top + imageTop) + 1 * (left + imageLeft));
|
|
|
|
|
|
|
|
for (int32 y = imageTop; y < imageBottom; y++) {
|
|
|
|
const uint8* src = data;
|
|
|
|
uint8* dst = start;
|
|
|
|
for (int32 x = imageLeft; x < imageRight; x++) {
|
|
|
|
dst[0] = src[0];
|
|
|
|
dst++;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += imageWidth;
|
|
|
|
start = (uint8*)((addr_t)start + sInfo->bytes_per_row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-20 14:10:17 +03:00
|
|
|
static void
|
|
|
|
blit15_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
2008-08-28 20:59:34 +04:00
|
|
|
uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
data += (imageWidth * imageTop + imageLeft) * 3;
|
|
|
|
uint16* start = (uint16*)(sInfo->frame_buffer
|
|
|
|
+ sInfo->bytes_per_row * (top + imageTop)
|
|
|
|
+ 2 * (left + imageLeft));
|
|
|
|
|
|
|
|
for (int32 y = imageTop; y < imageBottom; y++) {
|
|
|
|
const uint8* src = data;
|
|
|
|
uint16* dst = start;
|
|
|
|
for (int32 x = imageLeft; x < imageRight; x++) {
|
|
|
|
dst[0] = ((src[2] >> 3) << 10)
|
|
|
|
| ((src[1] >> 3) << 5)
|
|
|
|
| ((src[0] >> 3));
|
|
|
|
|
|
|
|
dst++;
|
|
|
|
src += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += imageWidth * 3;
|
|
|
|
start = (uint16*)((addr_t)start + sInfo->bytes_per_row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
blit16_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
2008-08-28 20:59:34 +04:00
|
|
|
uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
data += (imageWidth * imageTop + imageLeft) * 3;
|
|
|
|
uint16* start = (uint16*)(sInfo->frame_buffer
|
|
|
|
+ sInfo->bytes_per_row * (top + imageTop) + 2 * (left + imageLeft));
|
|
|
|
|
|
|
|
for (int32 y = imageTop; y < imageBottom; y++) {
|
|
|
|
const uint8* src = data;
|
|
|
|
uint16* dst = start;
|
|
|
|
for (int32 x = imageLeft; x < imageRight; x++) {
|
|
|
|
dst[0] = ((src[2] >> 3) << 11)
|
|
|
|
| ((src[1] >> 2) << 5)
|
|
|
|
| ((src[0] >> 3));
|
|
|
|
|
|
|
|
dst++;
|
|
|
|
src += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += imageWidth * 3;
|
|
|
|
start = (uint16*)((addr_t)start + sInfo->bytes_per_row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
blit24_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
2008-08-28 20:59:34 +04:00
|
|
|
uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
data += (imageWidth * imageTop + imageLeft) * 3;
|
|
|
|
uint8* start = (uint8*)(sInfo->frame_buffer
|
|
|
|
+ sInfo->bytes_per_row * (top + imageTop) + 3 * (left + imageLeft));
|
|
|
|
|
|
|
|
for (int32 y = imageTop; y < imageBottom; y++) {
|
|
|
|
const uint8* src = data;
|
|
|
|
uint8* dst = start;
|
|
|
|
for (int32 x = imageLeft; x < imageRight; x++) {
|
|
|
|
dst[0] = src[0];
|
|
|
|
dst[1] = src[1];
|
|
|
|
dst[2] = src[2];
|
|
|
|
dst += 3;
|
|
|
|
src += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += imageWidth * 3;
|
|
|
|
start = (uint8*)((addr_t)start + sInfo->bytes_per_row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
blit32_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
2008-08-28 20:59:34 +04:00
|
|
|
uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
data += (imageWidth * imageTop + imageLeft) * 3;
|
|
|
|
uint32* start = (uint32*)(sInfo->frame_buffer
|
|
|
|
+ sInfo->bytes_per_row * (top + imageTop) + 4 * (left + imageLeft));
|
|
|
|
|
|
|
|
for (int32 y = imageTop; y < imageBottom; y++) {
|
|
|
|
const uint8* src = data;
|
|
|
|
uint32* dst = start;
|
|
|
|
for (int32 x = imageLeft; x < imageRight; x++) {
|
|
|
|
dst[0] = (src[2] << 16) | (src[1] << 8) | (src[0]);
|
|
|
|
dst++;
|
|
|
|
src += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += imageWidth * 3;
|
|
|
|
start = (uint32*)((addr_t)start + sInfo->bytes_per_row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-28 20:59:34 +04:00
|
|
|
blit_cropped(const uint8* data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
|
|
|
uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
switch (sInfo->depth) {
|
2008-08-28 20:59:34 +04:00
|
|
|
case 8:
|
|
|
|
blit8_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
|
|
|
imageWidth, left, top);
|
|
|
|
return;
|
2008-03-20 14:10:17 +03:00
|
|
|
case 15:
|
|
|
|
blit15_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-08-28 20:59:34 +04:00
|
|
|
imageWidth, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 16:
|
|
|
|
blit16_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-08-28 20:59:34 +04:00
|
|
|
imageWidth, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 24:
|
|
|
|
blit24_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-08-28 20:59:34 +04:00
|
|
|
imageWidth, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 32:
|
|
|
|
blit32_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-08-28 20:59:34 +04:00
|
|
|
imageWidth, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - exported functions
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-05-05 18:37:35 +04:00
|
|
|
boot_splash_init(uint8 *bootSplash)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
TRACE("boot_splash_init: enter\n");
|
|
|
|
|
|
|
|
if (debug_screen_output_enabled())
|
|
|
|
return;
|
|
|
|
|
2008-03-30 15:01:41 +04:00
|
|
|
sInfo = (frame_buffer_boot_info *)get_boot_item(FRAME_BUFFER_BOOT_INFO,
|
|
|
|
NULL);
|
2008-04-06 01:15:43 +04:00
|
|
|
|
2010-05-05 18:37:35 +04:00
|
|
|
sUncompressedIcons = bootSplash;
|
2008-03-20 14:10:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-09 19:25:01 +04:00
|
|
|
void
|
|
|
|
boot_splash_uninit(void)
|
|
|
|
{
|
|
|
|
sInfo = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-20 14:10:17 +03:00
|
|
|
void
|
|
|
|
boot_splash_set_stage(int stage)
|
|
|
|
{
|
|
|
|
TRACE("boot_splash_set_stage: stage=%d\n", stage);
|
|
|
|
|
|
|
|
if (sInfo == NULL || stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX)
|
|
|
|
return;
|
|
|
|
|
2008-04-03 18:24:10 +04:00
|
|
|
int iconsHalfHeight = kSplashIconsHeight / 2;
|
|
|
|
int width = min_c(kSplashIconsWidth, sInfo->width);
|
2008-04-04 23:13:00 +04:00
|
|
|
int height = min_c(kSplashLogoHeight + iconsHalfHeight, sInfo->height);
|
2008-04-03 18:24:10 +04:00
|
|
|
int placementX = max_c(0, min_c(100, kSplashIconsPlacementX));
|
|
|
|
int placementY = max_c(0, min_c(100, kSplashIconsPlacementY));
|
2008-03-20 14:10:17 +03:00
|
|
|
|
2008-04-03 18:24:10 +04:00
|
|
|
int x = (sInfo->width - width) * placementX / 100;
|
2008-04-04 23:13:00 +04:00
|
|
|
int y = kSplashLogoHeight + (sInfo->height - height) * placementY / 100;
|
2008-04-03 18:24:10 +04:00
|
|
|
|
|
|
|
int stageLeftEdge = width * stage / BOOT_SPLASH_STAGE_MAX;
|
|
|
|
int stageRightEdge = width * (stage + 1) / BOOT_SPLASH_STAGE_MAX;
|
2008-03-20 14:10:17 +03:00
|
|
|
|
2008-04-04 23:13:00 +04:00
|
|
|
height = min_c(iconsHalfHeight, sInfo->height);
|
2008-08-28 20:59:34 +04:00
|
|
|
blit_cropped(sUncompressedIcons, stageLeftEdge, 0, stageRightEdge,
|
|
|
|
height, kSplashIconsWidth, x, y);
|
2008-03-20 14:10:17 +03:00
|
|
|
}
|
|
|
|
|