From 1c01c975d4ae2ff0489180291fdc7a887039dae8 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 27 Dec 2008 06:44:47 +0000 Subject: ported (modified) r815 from voker_dev git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@912 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- drv_generic_graphic.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c index afab559..5c864e3 100644 --- a/drv_generic_graphic.c +++ b/drv_generic_graphic.c @@ -177,7 +177,7 @@ static void drv_generic_graphic_blit(const int row, const int col, const int hei static RGBA drv_generic_graphic_blend(const int row, const int col) { - int l; + int l, o; RGBA p; RGBA ret; @@ -185,9 +185,29 @@ static RGBA drv_generic_graphic_blend(const int row, const int col) ret.G = BL_COL.G; ret.B = BL_COL.B; ret.A = 0xff; - for (l = LAYERS - 1; l >= 0; l--) { + + /* find first opaque layer */ + /* layers below are fully covered */ + o = LAYERS - 1; + for (l = 0; l < LAYERS; l++) { + p = drv_generic_graphic_FB[l][row * LCOLS + col]; + if (p.A == 255) { + o = l; + break; + } + } + + for (l = o; l >= 0; l--) { p = drv_generic_graphic_FB[l][row * LCOLS + col]; - if (p.A > 0) { + switch (p.A) { + case 0: + break; + case 255: + ret.R = p.R; + ret.G = p.G; + ret.B = p.B; + break; + default: ret.R = (p.R * p.A + ret.R * (255 - p.A)) / 255; ret.G = (p.G * p.A + ret.G * (255 - p.A)) / 255; ret.B = (p.B * p.A + ret.B * (255 - p.A)) / 255; -- cgit v1.2.3