mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
bootloader & kernel: Unify computation of splash logo and icons placement.
Removes some more code duplication. Change-Id: I9423be740015bef996b77bf2c30652fdadbd8a50
This commit is contained in:
parent
029e447bde
commit
de8d5cfb5f
51
headers/private/kernel/boot/platform/generic/video_splash.h
Normal file
51
headers/private/kernel/boot/platform/generic/video_splash.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024, Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef GENERIC_VIDEO_SPLASH_H
|
||||||
|
#define GENERIC_VIDEO_SPLASH_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
compute_splash_logo_placement(uint32 screenWidth, uint32 screenHeight,
|
||||||
|
int& width, int& height, int& x, int& y)
|
||||||
|
{
|
||||||
|
uint16 iconsHalfHeight = kSplashIconsHeight / 2;
|
||||||
|
|
||||||
|
width = min_c(kSplashLogoWidth, screenWidth);
|
||||||
|
height = min_c(uint32(kSplashLogoHeight) + iconsHalfHeight,
|
||||||
|
screenHeight);
|
||||||
|
int placementX = max_c(0, min_c(100, kSplashLogoPlacementX));
|
||||||
|
int placementY = max_c(0, min_c(100, kSplashLogoPlacementY));
|
||||||
|
|
||||||
|
x = (screenWidth - width) * placementX / 100;
|
||||||
|
y = (screenHeight - height) * placementY / 100;
|
||||||
|
|
||||||
|
height = min_c(kSplashLogoHeight, screenHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
compute_splash_icons_placement(uint32 screenWidth, uint32 screenHeight,
|
||||||
|
int& width, int& height, int& x, int& y)
|
||||||
|
{
|
||||||
|
uint16 iconsHalfHeight = kSplashIconsHeight / 2;
|
||||||
|
|
||||||
|
width = min_c(kSplashIconsWidth, screenWidth);
|
||||||
|
height = min_c(uint32(kSplashLogoHeight) + iconsHalfHeight,
|
||||||
|
screenHeight);
|
||||||
|
int placementX = max_c(0, min_c(100, kSplashIconsPlacementX));
|
||||||
|
int placementY = max_c(0, min_c(100, kSplashIconsPlacementY));
|
||||||
|
|
||||||
|
x = (screenWidth - width) * placementX / 100;
|
||||||
|
y = kSplashLogoHeight + (screenHeight - height)
|
||||||
|
* placementY / 100;
|
||||||
|
|
||||||
|
height = min_c(iconsHalfHeight, screenHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* GENERIC_VIDEO_SPLASH_H */
|
@ -13,7 +13,9 @@
|
|||||||
#include <boot/kernel_args.h>
|
#include <boot/kernel_args.h>
|
||||||
#include <boot/platform/generic/video.h>
|
#include <boot/platform/generic/video.h>
|
||||||
#include <boot/platform/generic/video_blitter.h>
|
#include <boot/platform/generic/video_blitter.h>
|
||||||
|
|
||||||
#include <boot/images.h>
|
#include <boot/images.h>
|
||||||
|
#include <boot/platform/generic/video_splash.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -159,22 +161,9 @@ video_display_splash(addr_t frameBuffer)
|
|||||||
// TODO: support 4-bit indexed version of the images!
|
// TODO: support 4-bit indexed version of the images!
|
||||||
|
|
||||||
// render splash logo
|
// render splash logo
|
||||||
uint16 iconsHalfHeight = kSplashIconsHeight / 2;
|
int width, height, x, y;
|
||||||
|
compute_splash_logo_placement(gKernelArgs.frame_buffer.width, gKernelArgs.frame_buffer.height,
|
||||||
int width = min_c(kSplashLogoWidth, gKernelArgs.frame_buffer.width);
|
width, height, x, y);
|
||||||
int height = min_c(kSplashLogoHeight + iconsHalfHeight,
|
|
||||||
gKernelArgs.frame_buffer.height);
|
|
||||||
int placementX = max_c(0, min_c(100, kSplashLogoPlacementX));
|
|
||||||
int placementY = max_c(0, min_c(100, kSplashLogoPlacementY));
|
|
||||||
|
|
||||||
int x = (gKernelArgs.frame_buffer.width - width) * placementX / 100;
|
|
||||||
int y = (gKernelArgs.frame_buffer.height - height) * placementY / 100;
|
|
||||||
|
|
||||||
height = min_c(kSplashLogoHeight, gKernelArgs.frame_buffer.height);
|
|
||||||
switch (gKernelArgs.frame_buffer.depth) {
|
|
||||||
case 8:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
video_blit_image(frameBuffer, uncompressedLogo, width, height,
|
video_blit_image(frameBuffer, uncompressedLogo, width, height,
|
||||||
kSplashLogoWidth, x, y);
|
kSplashLogoWidth, x, y);
|
||||||
|
|
||||||
@ -182,6 +171,7 @@ video_display_splash(addr_t frameBuffer)
|
|||||||
|
|
||||||
const uint8* lowerHalfIconImage;
|
const uint8* lowerHalfIconImage;
|
||||||
uncompressedSize = kSplashIconsWidth * kSplashIconsHeight;
|
uncompressedSize = kSplashIconsWidth * kSplashIconsHeight;
|
||||||
|
const uint16 iconsHalfHeight = kSplashIconsHeight / 2;
|
||||||
switch (gKernelArgs.frame_buffer.depth) {
|
switch (gKernelArgs.frame_buffer.depth) {
|
||||||
case 8:
|
case 8:
|
||||||
// pointer into the lower half of the icons image data
|
// pointer into the lower half of the icons image data
|
||||||
@ -212,18 +202,9 @@ video_display_splash(addr_t frameBuffer)
|
|||||||
|
|
||||||
// render initial (grayed out) icons
|
// render initial (grayed out) icons
|
||||||
// the grayed out version is the lower half of the icons image
|
// the grayed out version is the lower half of the icons image
|
||||||
|
compute_splash_icons_placement(gKernelArgs.frame_buffer.width, gKernelArgs.frame_buffer.height,
|
||||||
|
width, height, x, y);
|
||||||
|
|
||||||
width = min_c(kSplashIconsWidth, gKernelArgs.frame_buffer.width);
|
|
||||||
height = min_c(kSplashLogoHeight + iconsHalfHeight,
|
|
||||||
gKernelArgs.frame_buffer.height);
|
|
||||||
placementX = max_c(0, min_c(100, kSplashIconsPlacementX));
|
|
||||||
placementY = max_c(0, min_c(100, kSplashIconsPlacementY));
|
|
||||||
|
|
||||||
x = (gKernelArgs.frame_buffer.width - width) * placementX / 100;
|
|
||||||
y = kSplashLogoHeight + (gKernelArgs.frame_buffer.height - height)
|
|
||||||
* placementY / 100;
|
|
||||||
|
|
||||||
height = min_c(iconsHalfHeight, gKernelArgs.frame_buffer.height);
|
|
||||||
video_blit_image(frameBuffer, lowerHalfIconImage, width, height,
|
video_blit_image(frameBuffer, lowerHalfIconImage, width, height,
|
||||||
kSplashIconsWidth, x, y);
|
kSplashIconsWidth, x, y);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#define __BOOTSPLASH_KERNEL__
|
#define __BOOTSPLASH_KERNEL__
|
||||||
#include <boot/images.h>
|
#include <boot/images.h>
|
||||||
#include <boot/platform/generic/video_blitter.h>
|
#include <boot/platform/generic/video_blitter.h>
|
||||||
|
#include <boot/platform/generic/video_splash.h>
|
||||||
|
|
||||||
#include <boot_item.h>
|
#include <boot_item.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@ -70,20 +71,13 @@ boot_splash_set_stage(int stage)
|
|||||||
if (sInfo == NULL || stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX)
|
if (sInfo == NULL || stage < 0 || stage >= BOOT_SPLASH_STAGE_MAX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int iconsHalfHeight = kSplashIconsHeight / 2;
|
int width, height, x, y;
|
||||||
int width = min_c(kSplashIconsWidth, sInfo->width);
|
compute_splash_icons_placement(sInfo->width, sInfo->height,
|
||||||
int height = min_c(kSplashLogoHeight + iconsHalfHeight, sInfo->height);
|
width, height, x, y);
|
||||||
int placementX = max_c(0, min_c(100, kSplashIconsPlacementX));
|
|
||||||
int placementY = max_c(0, min_c(100, kSplashIconsPlacementY));
|
|
||||||
|
|
||||||
int x = (sInfo->width - width) * placementX / 100;
|
|
||||||
int y = kSplashLogoHeight + (sInfo->height - height) * placementY / 100;
|
|
||||||
|
|
||||||
int stageLeftEdge = width * stage / BOOT_SPLASH_STAGE_MAX;
|
int stageLeftEdge = width * stage / BOOT_SPLASH_STAGE_MAX;
|
||||||
int stageRightEdge = width * (stage + 1) / BOOT_SPLASH_STAGE_MAX;
|
int stageRightEdge = width * (stage + 1) / BOOT_SPLASH_STAGE_MAX;
|
||||||
|
|
||||||
height = min_c(iconsHalfHeight, sInfo->height);
|
|
||||||
|
|
||||||
BlitParameters params;
|
BlitParameters params;
|
||||||
params.from = sUncompressedIcons;
|
params.from = sUncompressedIcons;
|
||||||
params.fromWidth = kSplashIconsWidth;
|
params.fromWidth = kSplashIconsWidth;
|
||||||
@ -98,4 +92,3 @@ boot_splash_set_stage(int stage)
|
|||||||
|
|
||||||
blit(params, sInfo->depth);
|
blit(params, sInfo->depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user