37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// GFX 全局图形上下文,避免每次绘制都传递 GOP 参数
|
|
|
|
#include <graphics/context.h>
|
|
|
|
gfx_context g_gfx;
|
|
draw_target g_draw_target;
|
|
|
|
void gfx_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP) {
|
|
g_gfx.GOP = GOP;
|
|
g_gfx.hr = GOP->Mode->Info->HorizontalResolution;
|
|
g_gfx.vr = GOP->Mode->Info->VerticalResolution;
|
|
g_gfx.base = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) GOP->Mode->FrameBufferBase;
|
|
|
|
g_draw_target.buf = g_gfx.base;
|
|
g_draw_target.w = g_gfx.hr;
|
|
g_draw_target.h = g_gfx.vr;
|
|
}
|
|
|
|
void gfx_clear(void) {
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL black = {0, 0, 0, 0};
|
|
uefi_call_wrapper(g_gfx.GOP->Blt, 10,
|
|
g_gfx.GOP, &black, EfiBltVideoFill,
|
|
(UINTN)0, (UINTN)0, (UINTN)0, (UINTN)0,
|
|
(UINTN)g_gfx.hr, (UINTN)g_gfx.vr, (UINTN)0);
|
|
}
|
|
|
|
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, SUINT32 w, SUINT32 h) {
|
|
g_draw_target.buf = buf;
|
|
g_draw_target.w = w;
|
|
g_draw_target.h = h;
|
|
}
|
|
|
|
void draw_set_default_target(void) {
|
|
g_draw_target.buf = g_gfx.base;
|
|
g_draw_target.w = g_gfx.hr;
|
|
g_draw_target.h = g_gfx.vr;
|
|
} |