summaryrefslogtreecommitdiff
path: root/framebuffer/fb_plotters.h
diff options
context:
space:
mode:
Diffstat (limited to 'framebuffer/fb_plotters.h')
-rw-r--r--framebuffer/fb_plotters.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/framebuffer/fb_plotters.h b/framebuffer/fb_plotters.h
index c06ad2961..33a929b5c 100644
--- a/framebuffer/fb_plotters.h
+++ b/framebuffer/fb_plotters.h
@@ -47,7 +47,24 @@ bool fb_plotters_bitmap_tile(int x, int y,
colour bg,
struct content *content));
-colour fb_plotters_ablend(colour pixel, colour scrpixel);
+/* alpha blend two pixels together */
+static inline colour fb_plotters_ablend(colour pixel, colour scrpixel)
+{
+ int opacity = (pixel >> 24) & 0xFF;
+ int r,g,b;
+
+ r = (((pixel & 0xFF) * opacity) >> 8) +
+ (((scrpixel & 0xFF) * (0xFF - opacity)) >> 8);
+
+ g = ((((pixel & 0xFF00) >> 8) * opacity) >> 8) +
+ ((((scrpixel & 0xFF00) >> 8) * (0xFF - opacity)) >> 8);
+
+ b = ((((pixel & 0xFF0000) >> 16) * opacity) >> 8) +
+ ((((scrpixel & 0xFF0000) >> 16) * (0xFF - opacity)) >> 8);
+
+ return r | (g << 8) | (b << 16);
+}
+
bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty);