From fe220c247813c269ff4c167518b32db9f6839663 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 1 Feb 2019 12:57:06 +0100 Subject: use cairo for darkify --- fb-gui.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'fb-gui.c') diff --git a/fb-gui.c b/fb-gui.c index d62bc87..c17a953 100644 --- a/fb-gui.c +++ b/fb-gui.c @@ -245,36 +245,11 @@ void shadow_merge_rgbdata(int x, int y, int pixels, int weight, void shadow_darkify(int x1, int x2, int y1,int y2, int percent) { - unsigned char *ptr; - int x,y,h; - - if (x2 < x1) - h = x2, x2 = x1, x1 = h; - if (y2 < y1) - h = y2, y2 = y1, y1 = h; - - if (x1 < 0) - x1 = 0; - if (x2 >= swidth) - x2 = swidth; - - if (y1 < 0) - y1 = 0; - if (y2 >= sheight) - y2 = sheight; - - percent = percent * 256 / 100; - - for (y = y1; y <= y2; y++) { - sdirty[y]++; - ptr = shadow[y]; - ptr += 4*x1; - x = 4*(x2-x1+1); - while (x-- > 0) { - *ptr = (*ptr * percent) >> 8; - ptr++; - } - } + cairo_rectangle(context, x1, y1, + x2 - x1 + 1, + y2 - y1 + 1); + cairo_set_source_rgba(context, 0, 0, 0, percent * 0.01); + cairo_fill(context); } void shadow_reverse(int x1, int x2, int y1,int y2) -- cgit