OpenCanopy: Require minimum resolution

This commit is contained in:
Marvin Häuser 2021-05-01 17:18:16 +02:00
parent 823fceeebd
commit fa2e072d35
3 changed files with 19 additions and 3 deletions

View File

@ -18,7 +18,7 @@ typedef struct GUI_KEY_CONTEXT_ GUI_KEY_CONTEXT;
GUI_OUTPUT_CONTEXT *
GuiOutputConstruct (
VOID
IN UINT32 Scale
);
EFI_STATUS

View File

@ -811,7 +811,7 @@ GuiLibConstruct (
INT64 CursorX;
INT64 CursorY;
mOutputContext = GuiOutputConstruct ();
mOutputContext = GuiOutputConstruct (GuiContext->Scale);
if (mOutputContext == NULL) {
DEBUG ((DEBUG_WARN, "OCUI: Failed to initialise output\n"));
return EFI_UNSUPPORTED;

View File

@ -15,6 +15,9 @@
#include "../GuiIo.h"
#define MIN_RESOLUTION_HORIZONTAL 640U
#define MIN_RESOLUTION_VERTICAL 480U
struct GUI_OUTPUT_CONTEXT_ {
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
};
@ -45,7 +48,7 @@ InternalGuiOutputLocateGop (
GUI_OUTPUT_CONTEXT *
GuiOutputConstruct (
VOID
IN UINT32 Scale
)
{
// TODO: alloc on the fly?
@ -58,6 +61,19 @@ GuiOutputConstruct (
return NULL;
}
if (Gop->Mode->Info->HorizontalResolution < MIN_RESOLUTION_HORIZONTAL * Scale
|| Gop->Mode->Info->VerticalResolution < MIN_RESOLUTION_VERTICAL * Scale) {
DEBUG ((
DEBUG_INFO,
"OCUI: Expected at least %dx%d for resolution, actual %dx%d\n",
MIN_RESOLUTION_HORIZONTAL * Scale,
MIN_RESOLUTION_VERTICAL * Scale,
Context.Gop->Mode->Info->HorizontalResolution,
Context.Gop->Mode->Info->VerticalResolution
));
return NULL;
}
Context.Gop = Gop;
return &Context;
}