[fix] Draw effect target
This commit is contained in:
@@ -1,15 +1,37 @@
|
||||
// GFX 存在的意义是什么?
|
||||
// 每一次想要draw pixel,都需要传入GOP的各种参数,
|
||||
// 加入 GFX 后,GOP 的context就是全局的,可以直接用
|
||||
// 而不用显示传递参数到draw的函数里
|
||||
|
||||
#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};
|
||||
g_gfx.GOP->Blt(g_gfx.GOP, &black, EfiBltVideoFill, 0, 0, 0, 0, g_gfx.hr, g_gfx.vr, 0);
|
||||
}
|
||||
|
||||
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, unsigned int w, unsigned int 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;
|
||||
}
|
||||
Reference in New Issue
Block a user