2008-03-20 14:10:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2008, Haiku, Inc. All Rights Reserved.
|
|
|
|
* 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__
|
2008-03-20 14:10:17 +03:00
|
|
|
#include <boot/images.h>
|
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
|
|
|
|
|
|
|
static void
|
|
|
|
blit15_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop,
|
|
|
|
uint16 imageRight, uint16 imageBottom, uint16 imageWidth,
|
2008-04-03 18:24:10 +04:00
|
|
|
const uint8 *palette, 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-04-03 18:24:10 +04:00
|
|
|
const uint8 *palette, 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-04-03 18:24:10 +04:00
|
|
|
const uint8 *palette, 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-04-03 18:24:10 +04:00
|
|
|
const uint8 *palette, 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
|
|
|
|
blit_cropped(const uint8* data, const uint8* indexedData,
|
|
|
|
uint16 imageLeft, uint16 imageTop, uint16 imageRight, uint16 imageBottom,
|
2008-04-03 18:24:10 +04:00
|
|
|
uint16 imageWidth, const uint8 *palette, uint16 left, uint16 top)
|
2008-03-20 14:10:17 +03:00
|
|
|
{
|
|
|
|
switch (sInfo->depth) {
|
|
|
|
case 15:
|
|
|
|
blit15_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-04-03 18:24:10 +04:00
|
|
|
imageWidth, palette, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 16:
|
|
|
|
blit16_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-04-03 18:24:10 +04:00
|
|
|
imageWidth, palette, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 24:
|
|
|
|
blit24_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-04-03 18:24:10 +04:00
|
|
|
imageWidth, palette, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
case 32:
|
|
|
|
blit32_cropped(data, imageLeft, imageTop, imageRight, imageBottom,
|
2008-04-03 18:24:10 +04:00
|
|
|
imageWidth, palette, left, top);
|
2008-03-20 14:10:17 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - exported functions
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2008-04-06 01:15:43 +04:00
|
|
|
boot_splash_init(uint8 *boot_splash)
|
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
|
|
|
|
|
|
|
sUncompressedIcons = boot_splash;
|
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-04-06 01:15:43 +04:00
|
|
|
blit_cropped(sUncompressedIcons, NULL, stageLeftEdge, 0, stageRightEdge,
|
2008-04-04 23:13:00 +04:00
|
|
|
height, kSplashIconsWidth, NULL, x, y);
|
2008-03-20 14:10:17 +03:00
|
|
|
}
|
|
|
|
|