Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jun 2025 15:21:49 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: abdbd85d1b6a - main - lualoader: adapt builtin brand/logo definitions as well
Message-ID:  <202506181521.55IFLnjk004560@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=abdbd85d1b6af892c18eaae0330a146b01ff6712

commit abdbd85d1b6af892c18eaae0330a146b01ff6712
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-06-18 15:12:54 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-06-18 15:21:37 +0000

    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 9d5417737489..1c03ed93f00a 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506181521.55IFLnjk004560>