aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2024-02-16 03:54:04 +0000
committerWarner Losh <imp@FreeBSD.org>2024-02-16 03:59:23 +0000
commit0fd98b8a7691b4f11e1bfbcb53a3a7c68d7c1fb7 (patch)
tree2d3b149c896cd28a89bedf3d63653558505ee76b
parenta8f8c53761c4b0436c9d546ebe046003f1b3d88f (diff)
downloadsrc-0fd98b8a7691b4f11e1bfbcb53a3a7c68d7c1fb7.tar.gz
src-0fd98b8a7691b4f11e1bfbcb53a3a7c68d7c1fb7.zip
loader: Move drawer.lua over to gfx table.
Drawer.lua is the only bit of lua code in the base that uses any of the functons moved from the loader table to the gfx table. Move the main code to using the gfx dispatch. Add compat code for running on old loaders that creates the newer-style gfx table with the term_* functions we call in it populated. This will even work on the super old versions of the loader that don't have them (we'll still skip using them). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43908
-rw-r--r--stand/lua/drawer.lua25
1 files changed, 19 insertions, 6 deletions
diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua
index 2dcf7d5de0f8..a009b78164df 100644
--- a/stand/lua/drawer.lua
+++ b/stand/lua/drawer.lua
@@ -47,6 +47,19 @@ local frame_size
local default_shift
local shift
+-- Make this code compatible with older loader binaries. We moved the term_*
+-- functions from loader to the gfx. if we're running on an older loader that
+-- has these functions, create aliases for them in gfx. The loader binary might
+-- be so old as to not have them, but in that case, we want to copy the nil
+-- values. The new loader will provide loader.* versions of all the gfx.*
+-- functions for backwards compatibility, so we only define the functions we use
+-- here.
+if gfx == nil then
+ gfx = {}
+ gfx.term_drawrect = loader.term_drawrect
+ gfx.term_putimage = loader.term_putimage
+end
+
local function menuEntryName(drawing_menu, entry)
local name_handler = menu_name_handlers[entry.entry_type]
@@ -225,8 +238,8 @@ local function drawframe()
x = x + shift.x
y = y + shift.y
- if core.isFramebufferConsole() and loader.term_drawrect ~= nil then
- loader.term_drawrect(x, y, x + w, y + h)
+ if core.isFramebufferConsole() and gfx.term_drawrect ~= nil then
+ gfx.term_drawrect(x, y, x + w, y + h)
return true
end
@@ -312,9 +325,9 @@ local function drawbrand()
end
if core.isFramebufferConsole() and
- loader.term_putimage ~= nil and
+ gfx.term_putimage ~= nil and
branddef.image ~= nil then
- if loader.term_putimage(branddef.image, 1, 1, 0, 7, 0)
+ if gfx.term_putimage(branddef.image, 1, 1, 0, 7, 0)
then
return true
end
@@ -363,14 +376,14 @@ local function drawlogo()
end
if core.isFramebufferConsole() and
- loader.term_putimage ~= nil and
+ gfx.term_putimage ~= nil and
logodef.image ~= nil then
local y1 = 15
if logodef.image_rl ~= nil then
y1 = logodef.image_rl
end
- if loader.term_putimage(logodef.image, x, y, 0, y + y1, 0)
+ if gfx.term_putimage(logodef.image, x, y, 0, y + y1, 0)
then
return true
end