pixel operations

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-01 20:07:57 +03:00
parent 5f037cc29a
commit 5b84f64f61
8 changed files with 114 additions and 102 deletions

View File

@ -4999,6 +4999,8 @@ finish:
Status = ThemeX.GetThemeTagSettings((void*)DictPointer);
if (EFI_ERROR (Status)) {
DBG ("Config theme error: %s\n", strerror(Status));
} else {
ThemeX.FillByDir();
}
}
}

View File

@ -47,7 +47,7 @@
#define DBG(...) DebugLog(DEBUG_BOOT_SCREEN, __VA_ARGS__)
#endif
STATIC EG_PIXEL grayBackgroundPixel = { 0xBF, 0xBF, 0xBF, 0xFF };
STATIC const EG_PIXEL grayBackgroundPixel = { 0xBF, 0xBF, 0xBF, 0xFF };
STATIC UINT8 grayAppleLogo[] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x5F, 0x08, 0x06, 0x00, 0x00, 0x00, 0x7F, 0x47, 0x40,
@ -415,7 +415,7 @@ STATIC UINT8 grayAppleLogo[] = {
0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, 0x82,
};
STATIC EG_PIXEL blackBackgroundPixel = { 0x00, 0x00, 0x00, 0xFF };
STATIC const EG_PIXEL blackBackgroundPixel = { 0x00, 0x00, 0x00, 0xFF };
STATIC UINT8 whiteAppleLogo[] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x67, 0x08, 0x06, 0x00, 0x00, 0x00, 0x9E, 0x85, 0x65,
@ -730,10 +730,14 @@ CONST CHAR16 *CustomBootModeToStr(IN UINT8 Mode)
EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry)
{
EG_PIXEL *backgroundPixel = (EG_PIXEL *)&Entry->BootBgColor;
EG_PIXEL thePixel = {0,0,0,0};
EG_IMAGE *logo = NULL;
INTN screenWidth, screenHeight;
UINT8 customBoot = Entry->CustomBoot;
if (backgroundPixel == NULL) {
backgroundPixel = &thePixel;
}
if (OSFLAG_ISUNSET(Entry->Flags, OSFLAG_USEGRAPHICS)) {
DBG("Custom boot screen not used because entry has unset use graphics\n");
return EFI_ABORTED;
@ -756,18 +760,14 @@ EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry)
case CUSTOM_BOOT_APPLE:
// Gray on gray apple
logo = egDecodePNG(grayAppleLogo, sizeof(grayAppleLogo), TRUE);
if (backgroundPixel == NULL) {
backgroundPixel = &grayBackgroundPixel;
}
thePixel = grayBackgroundPixel;
DBG("Custom boot is using apple logo\n");
break;
case CUSTOM_BOOT_ALT_APPLE:
// Alternate white on black apple
logo = egDecodePNG(whiteAppleLogo, sizeof(whiteAppleLogo), TRUE);
if (backgroundPixel == NULL) {
backgroundPixel = &blackBackgroundPixel;
}
thePixel = blackBackgroundPixel;
DBG("Custom boot is using alternate logo\n");
break;
@ -779,9 +779,7 @@ EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry)
case CUSTOM_BOOT_USER:
// Custom user logo
if (logo != NULL) {
if (backgroundPixel == NULL) {
backgroundPixel = &grayBackgroundPixel;
}
thePixel = grayBackgroundPixel;
DBG("Custom boot is using custom logo\n");
break;
}

View File

@ -478,76 +478,80 @@ void XTheme::InitSelection() //for PNG theme
if (!SelectionImages[0].isEmpty()) { //already presents
return;
}
// load small selection image
if (!TypeSVG && SelectionImages[2].isEmpty()){
SelectionImages[2].LoadXImage(ThemeDir, SelectionSmallFileName);
}
if (!TypeSVG && SelectionImages[2].isEmpty()){
// SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL);
// SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons
if (Daylight) {
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_selection_small), ACCESS_EMB_SIZE(emb_selection_small));
} else {
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_small), ACCESS_EMB_SIZE(emb_dark_selection_small));
}
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); //why???
}
//cut or extend the image by Compose
/* SelectionImages[2] = egEnsureImageSize(SelectionImages[2],
row1TileSize, row1TileSize, &MenuBackgroundPixel);
if (SelectionImages[2] == NULL) {
return;
} */
// load big selection image
if (!TypeSVG && SelectionImages[0].isEmpty()) {
SelectionImages[0].LoadXImage(ThemeDir, SelectionBigFileName);
// SelectionImages[0].EnsureImageSize(row0TileSize, row0TileSize, &MenuBackgroundPixel);
}
if (!TypeSVG && SelectionImages[0].isEmpty()) {
// calculate big selection image from small one
// SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG);
if (Daylight) {
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_selection_big), ACCESS_EMB_SIZE(emb_selection_big));
} else {
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big));
}
// SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (TypeSVG) {
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL);
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG);
if (SelectionImages[0].isEmpty()) {
SelectionImages[2].setEmpty();
return;
SelectionImages[0] = SelectionImages[2]; //use same selection if OnTop for example
}
} else {
// load small selection image
if (SelectionImages[2].isEmpty()){
SelectionImages[2].LoadXImage(ThemeDir, SelectionSmallFileName);
}
if (SelectionImages[2].isEmpty()){
// SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL);
// SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons
if (Daylight) {
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_selection_small), ACCESS_EMB_SIZE(emb_selection_small));
} else {
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_small), ACCESS_EMB_SIZE(emb_dark_selection_small));
}
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); //why???
}
//cut or extend the image by Compose
/* SelectionImages[2] = egEnsureImageSize(SelectionImages[2],
row1TileSize, row1TileSize, &MenuBackgroundPixel);
if (SelectionImages[2] == NULL) {
return;
} */
// load big selection image
if (SelectionImages[0].isEmpty()) {
SelectionImages[0].LoadXImage(ThemeDir, SelectionBigFileName);
// SelectionImages[0].EnsureImageSize(row0TileSize, row0TileSize, &MenuBackgroundPixel);
}
if (SelectionImages[0].isEmpty()) {
// calculate big selection image from small one
// SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG);
if (Daylight) {
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_selection_big), ACCESS_EMB_SIZE(emb_selection_big));
} else {
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big));
}
// SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
//CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
BlueBackgroundPixel = StdBackgroundPixel;
if (SelectionImages[0].isEmpty()) {
SelectionImages[2].setEmpty();
return;
}
// if (SelectionOnTop) {
// SelectionImages[0]->HasAlpha = TRUE; // TODO ?
// SelectionImages[2]->HasAlpha = TRUE;
// }
}
// if (SelectionOnTop) {
// SelectionImages[0]->HasAlpha = TRUE; // TODO ?
// SelectionImages[2]->HasAlpha = TRUE;
// }
}
// BootCampStyle indicator image
if (BootCampStyle) {
// load indicator selection image
if (!TypeSVG && SelectionImages[4].isEmpty()) {
SelectionImages[4].LoadXImage(ThemeDir, SelectionIndicatorName);
}
if (!SelectionImages[4].isEmpty()) {
SelectionImages[4].FromPNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator));
if (SelectionImages[4].isEmpty()) {
SelectionImages[4].FromPNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator));
}
INTN ScaledIndicatorSize = (INTN)(INDICATOR_SIZE * Scale);
// SelectionImages[4].EnsureImageSize(ScaledIndicatorSize, ScaledIndicatorSize, &MenuBackgroundPixel);
SelectionImages[4].EnsureImageSize(ScaledIndicatorSize, ScaledIndicatorSize, MenuBackgroundPixel);
if (SelectionImages[4].isEmpty()) {
// SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &StdBackgroundPixel);
SelectionImages[4] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
SelectionImages[4].Fill(StdBackgroundPixel);
}
// SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &MenuBackgroundPixel);
SelectionImages[5] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
SelectionImages[5].Fill(MenuBackgroundPixel);
}
/*
@ -567,34 +571,41 @@ void XTheme::InitSelection() //for PNG theme
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_checkbox_checked)
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_dark_font_data)
Status = Buttons[0].LoadXImage(ThemeDir, "radio_button");
if (EFI_ERROR(Status)) {
Buttons[0].FromPNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button));
}
Status = Buttons[1].LoadXImage(ThemeDir, "radio_button_selected");
if (EFI_ERROR(Status)) {
Buttons[1].FromPNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected));
}
Status = Buttons[2].LoadXImage(ThemeDir, "checkbox");
if (EFI_ERROR(Status)) {
Buttons[2].FromPNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox));
}
Status = Buttons[3].LoadXImage(ThemeDir, "checkbox_checked");
if (EFI_ERROR(Status)) {
Buttons[3].FromPNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked));
if (!TypeSVG) { //SVG theme already parsed buttons
Status = Buttons[0].LoadXImage(ThemeDir, "radio_button");
if (EFI_ERROR(Status)) {
Buttons[0].FromPNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button));
}
Status = Buttons[1].LoadXImage(ThemeDir, "radio_button_selected");
if (EFI_ERROR(Status)) {
Buttons[1].FromPNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected));
}
Status = Buttons[2].LoadXImage(ThemeDir, "checkbox");
if (EFI_ERROR(Status)) {
Buttons[2].FromPNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox));
}
Status = Buttons[3].LoadXImage(ThemeDir, "checkbox_checked");
if (EFI_ERROR(Status)) {
Buttons[3].FromPNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked));
}
} else {
Buttons[0] = GetIcon("radio_button");
Buttons[1] = GetIcon("radio_button_selected");
Buttons[2] = GetIcon("checkbox");
Buttons[3] = GetIcon("checkbox_checked");
}
// non-selected background images
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff };
if (!SelectionBigFileName.isEmpty()) {
if (!TypeSVG && !SelectionBigFileName.isEmpty()) {
BackgroundPixel = { 0x00, 0x00, 0x00, 0x00 };
} else if (DarkEmbedded || TypeSVG) {
BackgroundPixel = { 0x33, 0x33, 0x33, 0xff };
} else {
BackgroundPixel = { 0x33, 0x33, 0x33, 0x00 };
} else { //for example embedded daylight
BackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff };
}
SelectionImages[1] = XImage(row0TileSize, row0TileSize);
SelectionImages[1].Fill(BackgroundPixel);
SelectionImages[3] = XImage(row1TileSize, row1TileSize);

View File

@ -38,7 +38,7 @@
#define __LIBEG_LIBEG_H__
#ifndef USE_XTHEME
#define USE_XTHEME 0
#define USE_XTHEME 1
#endif
#ifdef __cplusplus
@ -497,7 +497,7 @@ VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN P
VOID PrepareFont(VOID);
VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height);
#if USE_XTHEME
VOID egClearScreen(IN void *Color);
VOID egClearScreen(IN const void *Color);
#else
VOID egClearScreen(IN EG_PIXEL *Color);
#endif

View File

@ -515,8 +515,9 @@ VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable)
// Drawing to the screen
//
#if USE_XTHEME
VOID egClearScreen(IN void *Color)
VOID egClearScreen(IN const void *Color)
{
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColor = *(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Color;
if (!egHasGraphics)
return;
@ -524,10 +525,10 @@ VOID egClearScreen(IN void *Color)
// EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same
// layout, and the header from TianoCore actually defines them
// to be the same type.
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Color, EfiBltVideoFill,
GraphicsOutput->Blt(GraphicsOutput, &FillColor, EfiBltVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
} else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)Color, EfiUgaVideoFill,
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)&FillColor, EfiUgaVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
}
}

View File

@ -514,16 +514,16 @@ extern INTN row1TileSize;
#endif
extern const INTN BCSMargin;
#if USE_XTHEME
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueBackgroundPixel;
//extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkBackgroundPixel;
//extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel;
#else

View File

@ -4564,7 +4564,7 @@ VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN
XImage TmpBuffer(Width, Height);
// TmpBuffer.CopyScaled(Background, 1.f);
INTN X = XPos - (Width >> 1); //X_IS_CENTRE
TmpBuffer.CopyRect(Background, X, YPos);
TmpBuffer.CopyRect(Background, X, YPos); //a part of BackGround image
TmpBuffer.DrawWithoutCompose(X, YPos);
// TmpBuffer.Draw(X, YPos, 0, true);
}

View File

@ -81,15 +81,15 @@ BOOLEAN AllowGraphicsMode;
EG_RECT BannerPlace; // default ctor called, so it's zero
#if USE_XTHEME
EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueBackgroundPixel = { 0x7f, 0x0f, 0x0f, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL EmbeddedBackgroundPixel = { 0xaa, 0xaa, 0xaa, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel = { 66, 66, 66, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL EmbeddedBackgroundPixel = { 0xaa, 0xaa, 0xaa, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel = { 66, 66, 66, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
#else