From abdbd85d1b6af892c18eaae0330a146b01ff6712 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 18 Jun 2025 10:12:54 -0500 Subject: [PATCH] lualoader: adapt builtin brand/logo definitions as well While these should be moved to the new format, it wasn't my intention to force them over immediately. Downstreams may embed their own brands in drawer.lua, and we shouldn't break them for something like this. Move adapt_fb_shim() up and use it for preloaded definitions to avoid forcing the matter for now. Perhaps in the future we'll start writing out warnings for those that do need adapted. Reported by: 0x1eef on IRC --- stand/lua/drawer.lua | 68 ++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index 9d541773748..1c03ed93f00 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -101,6 +101,39 @@ local function processFile(gfxname) return true end +-- Backwards compatibility shims for previous FreeBSD versions, please document +-- new additions +local function adapt_fb_shim(def) + -- In FreeBSD 14.x+, we have improved framebuffer support in the loader + -- and some graphics may have images that we can actually draw on the + -- screen. Those graphics may come with shifts that are distinct from + -- the ASCII version, so we move both ascii and image versions into + -- their own tables. + if not def.ascii then + def.ascii = { + image = def.graphic, + requires_color = def.requires_color, + shift = def.shift, + } + end + if def.image then + assert(not def.fb, + "Unrecognized graphic definition format") + + -- Legacy images may have adapted a shift from the ASCII + -- version, or perhaps we just didn't care enough to adjust it. + -- Steal the shift. + def.fb = { + image = def.image, + width = def.image_rl, + shift = def.shift, + } + end + + def.adapted = true + return def +end + local function getBranddef(brand) if brand == nil then return nil @@ -123,6 +156,8 @@ local function getBranddef(brand) end branddef = branddefs[brand] + elseif not branddef.adapted then + adapt_fb_shim(branddef) end return branddef @@ -150,6 +185,8 @@ local function getLogodef(logo) end logodef = logodefs[logo] + elseif not logodef.adapted then + adapt_fb_shim(logodef) end return logodef @@ -511,37 +548,6 @@ drawer.default_bw_logodef = 'orbbw' -- drawer module in case it's a filesystem issue. drawer.default_fallback_logodef = 'none' --- Backwards compatibility shims for previous FreeBSD versions, please document --- new additions -local function adapt_fb_shim(def) - -- In FreeBSD 14.x+, we have improved framebuffer support in the loader - -- and some graphics may have images that we can actually draw on the - -- screen. Those graphics may come with shifts that are distinct from - -- the ASCII version, so we move both ascii and image versions into - -- their own tables. - if not def.ascii then - def.ascii = { - image = def.graphic, - requires_color = def.requires_color, - shift = def.shift, - } - end - if def.image then - assert(not def.fb, - "Unrecognized graphic definition format") - - -- Legacy images may have adapted a shift from the ASCII - -- version, or perhaps we just didn't care enough to adjust it. - -- Steal the shift. - def.fb = { - image = def.image, - width = def.image_rl, - shift = def.shift, - } - end - return def -end - function drawer.addBrand(name, def) branddefs[name] = adapt_fb_shim(def) end