Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jan 2021 20:16:47 GMT
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 4bbfe4bf08d6 - main - loader: comment on rgb_to_color_index()
Message-ID:  <202101192016.10JKGlOa073835@gitrepo.freebsd.org>

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

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

commit 4bbfe4bf08d6d16ae65729bb22159c8dbd1027bd
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2021-01-13 16:38:08 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2021-01-19 20:15:26 +0000

    loader: comment on rgb_to_color_index()
    
    Add small comment block about rgb_to_color_index().
---
 stand/common/gfx_fb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c
index d98e6d1bae4b..08c0f59505f2 100644
--- a/stand/common/gfx_fb.c
+++ b/stand/common/gfx_fb.c
@@ -303,7 +303,13 @@ gfx_fb_color_map(uint8_t index)
 	return (rgb_color_map(index, rmask, 16, gmask, 8, bmask, 0));
 }
 
-/* Get indexed color */
+/*
+ * Get indexed color from RGB. This function is used to write data to video
+ * memory when the adapter is set to use indexed colors.
+ * Since UEFI does only support 32-bit colors, we do not implement it for
+ * UEFI because there is no need for it and we do not have palette array
+ * for UEFI.
+ */
 static uint8_t
 rgb_to_color_index(uint8_t r, uint8_t g, uint8_t b)
 {
@@ -321,8 +327,10 @@ rgb_to_color_index(uint8_t r, uint8_t g, uint8_t b)
 		diff = b - pe8[k].Blue;
 		dist += diff * diff;
 
+		/* Exact match, exit the loop */
 		if (dist == 0)
 			break;
+
 		if (dist < best) {
 			color = k;
 			best = dist;



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