aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-08-28 12:15:06 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-08-28 12:15:06 -0700
commit7843b240080ab04f9b0d56c8ee5b7f3271b9c94f (patch)
tree62523200c9739342adbda9ba2fdad26e0bbec088 /com32/lib
parent72fd5d37e68617c3bdd7aff56f519a1e5c9d8817 (diff)
downloadsyslinux-elf-7843b240080ab04f9b0d56c8ee5b7f3271b9c94f.tar.gz
syslinux-elf-7843b240080ab04f9b0d56c8ee5b7f3271b9c94f.tar.xz
syslinux-elf-7843b240080ab04f9b0d56c8ee5b7f3271b9c94f.zip
Add alpha-blending function in preparation for proper RGBA text.
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/sys/vesa/drawtxt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/com32/lib/sys/vesa/drawtxt.c b/com32/lib/sys/vesa/drawtxt.c
index 67130631..94634b03 100644
--- a/com32/lib/sys/vesa/drawtxt.c
+++ b/com32/lib/sys/vesa/drawtxt.c
@@ -29,6 +29,20 @@
#include "vesa.h"
#include "video.h"
+/*
+ * Linear alpha blending. Useless for anything that's actually
+ * depends on color accuracy (because of gamma), but it's fine for
+ * what we want.
+ *
+ * This algorithm is exactly equivalent to (alpha*fg+(255-alpha)*bg)/255
+ * for all 8-bit values, but is substantially faster.
+ */
+static inline uint8_t alpha(uint8_t fg, uint8_t bg, uint8_t alpha)
+{
+ unsigned int tmp = 1 + alpha*fg + (255-alpha)*bg;
+ return (tmp + (tmp >> 8)) >> 8;
+}
+
static void vesacon_update_characters(int row, int col, int nrows, int ncols)
{
const int height = __vesacon_font_height;