screenshot will work with legacy boot, thanks to blackosx

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-05-25 06:22:00 +03:00
parent a2b8d1217f
commit ad209ac209
5 changed files with 28 additions and 10 deletions

View File

@ -1580,7 +1580,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
EntriesPosY = ((UGAHeight - (int)(LAYOUT_TOTAL_HEIGHT * ThemeX.Scale)) >> 1) + (int)(ThemeX.LayoutBannerOffset * ThemeX.Scale) + (ThemeX.TextHeight << 1);
VisibleHeight = ((UGAHeight - EntriesPosY) / ThemeX.TextHeight) - InfoLines.size() - 2;/* - GlobalConfig.PruneScrollRows; */
VisibleHeight = ((UGAHeight - EntriesPosY) / ThemeX.TextHeight) - InfoLines.size() - 2;
//DBG("MENU_FUNCTION_INIT 1 EntriesPosY=%d VisibleHeight=%d\n", EntriesPosY, VisibleHeight);
if ( Entries[0].getREFIT_INPUT_DIALOG() ) {
REFIT_INPUT_DIALOG& entry = (REFIT_INPUT_DIALOG&)Entries[0];
@ -1601,7 +1601,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
//MenuWidth = 80; // minimum
MenuWidth = (int)(LAYOUT_TEXT_WIDTH * ThemeX.Scale); //500
if (!TitleImage.Image.isEmpty()) {
if (!TitleImage.isEmpty()) {
if (MenuWidth > (INTN)(UGAWidth - (int)(TITLEICON_SPACING * ThemeX.Scale) - TitleImage.Image.GetWidth())) {
MenuWidth = UGAWidth - (int)(TITLEICON_SPACING * ThemeX.Scale) - TitleImage.Image.GetWidth() - 2;
}
@ -1623,18 +1623,23 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
DrawTextXY(Title, (UGAWidth >> 1), EntriesPosY - ThemeX.TextHeight * 2, X_IS_CENTER);
}
if (!TitleImage.Image.isEmpty()) {
if (!TitleImage.isEmpty()) {
INTN FilmXPos = (INTN)(EntriesPosX - (TitleImage.Image.GetWidth() + (int)(TITLEICON_SPACING * ThemeX.Scale)));
INTN FilmYPos = (INTN)EntriesPosY;
TitleImage.Image.Draw(FilmXPos, FilmYPos); //TODO - account night and svg
bool free;
XImage *tImage = TitleImage.GetBest(!Daylight, &free);
// TitleImage.Image.Draw(FilmXPos, FilmYPos); //TODO - account night and svg
// update FilmPlace only if not set by InitAnime
if (FilmC->FilmPlace.Width == 0 || FilmC->FilmPlace.Height == 0) {
FilmC->FilmPlace.XPos = FilmXPos;
FilmC->FilmPlace.YPos = FilmYPos;
FilmC->FilmPlace.Width = TitleImage.Image.GetWidth();
FilmC->FilmPlace.Height = TitleImage.Image.GetHeight();
FilmC->FilmPlace.Width = tImage->GetWidth();
FilmC->FilmPlace.Height = tImage->GetHeight();
}
tImage->Draw(FilmXPos, FilmYPos);
if (free) delete tImage;
}
if (InfoLines.size() > 0) {

View File

@ -47,7 +47,6 @@ VOID REFIT_MENU_SCREEN::UpdateFilm()
DBG("FrameTime=%lld\n", FilmC->FrameTime);
DBG("Path=%ls\n", FilmC->Path.wc_str());
DBG("LastFrame=%lld\n\n", FilmC->LastFrameID());
}
if (TimeDiff(FilmC->LastDraw, Now) < (UINTN)FilmC->FrameTime) return;
@ -95,13 +94,24 @@ const XImage& FILM::GetImage(INTN Index) const
return NullImage;
}
const XImage& FILM::GetImage() const
const XImage& FILM::GetImage(bool *free) const
{
/*
* for SVG anime we have to generate new XImage using CurrentFrame as an argument
product(IconToAnime.ImageSVG, CurrentFrame, method); -- ImageSVG will be changed?
or
XImage *frame = IconToAnime.GetBest(!Daylight, free, CurrentFrame, method);
return frame;
*
*/
for (size_t i = 0; i < Frames.size(); ++i) {
if (Frames[i].getIndex() == CurrentFrame) {
if (free) *free = false;
return Frames[i].getImage();
}
}
if (free) *free = false;
return NullImage;
}

View File

@ -56,7 +56,7 @@ public:
void SetIndex(INTN Index) { Id = Index; }
const XImage& GetImage(INTN Index) const;
const XImage& GetImage() const;
const XImage& GetImage(bool *free = nullptr) const;
void AddFrame(XImage* Frame, INTN Index); //IndexedImage will be created
size_t Size() { return Frames.size(); }
INTN LastFrameID() { return LastIndex; }

View File

@ -257,7 +257,7 @@ XImage* XIcon::GetBest(bool night, bool *free)
float Width = sImage->width * Scale;
int iWidth = (int)(Width + 0.5f);
int iHeight = (int)(Height + 0.5f);
XImage* NewImage = new XImage(iWidth, iHeight); //TODO doing new ximage we have to delete it after use
XImage* NewImage = new XImage(iWidth, iHeight); //TODO creating new XImage we have to delete it after use
if (sImage->shapes == NULL) {
if (free) *free = true;
return NewImage;

View File

@ -562,6 +562,9 @@ EFI_STATUS egScreenShot(VOID)
XStringW Name = SWPrintf("EFI\\CLOVER\\misc\\screenshot%lld.png", Index);
if (!FileExists(SelfRootDir, Name.wc_str())) {
Status = egSaveFile(SelfRootDir, Name.wc_str(), FileData, FileDataLength);
if (EFI_ERROR(Status))
Status = egSaveFile(NULL, Name.wc_str(), FileData, FileDataLength);
if (!EFI_ERROR(Status)) {
break;
}