git: 4bbfe4bf08d6 - main - loader: comment on rgb_to_color_index()

Toomas Soome tsoome at FreeBSD.org
Tue Jan 19 20:16:48 UTC 2021


The branch main has been updated by tsoome:

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

commit 4bbfe4bf08d6d16ae65729bb22159c8dbd1027bd
Author:     Toomas Soome <tsoome at FreeBSD.org>
AuthorDate: 2021-01-13 16:38:08 +0000
Commit:     Toomas Soome <tsoome at 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;


More information about the dev-commits-src-all mailing list