aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2021-01-13 16:38:08 +0000
committerToomas Soome <tsoome@FreeBSD.org>2021-01-19 20:15:26 +0000
commit4bbfe4bf08d6d16ae65729bb22159c8dbd1027bd (patch)
tree5cebccd81a6a25a7a9897386374df721d497b8de /stand
parent52e3a7300d817002d3b7f8336ba1716c9c2621a3 (diff)
Diffstat (limited to 'stand')
-rw-r--r--stand/common/gfx_fb.c10
1 files changed, 9 insertions, 1 deletions
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;