From 29c6d9ee9d5f3cc69e3f7b263afabcc07e78cd51 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 18 Aug 2017 08:23:13 +0200 Subject: [PATCH] gems: reset 'Nitpicker_buffer' to gray, not black This improves the output quality of antialiased lines onto a transparent nitpicker buffer. For antialiased graphics operations, the initial color leaks through. Leaking 50% gray is better than leaking black, in particular when drawing white lines. --- repos/gems/include/gems/nitpicker_buffer.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/repos/gems/include/gems/nitpicker_buffer.h b/repos/gems/include/gems/nitpicker_buffer.h index d12d615f70..034e98919a 100644 --- a/repos/gems/include/gems/nitpicker_buffer.h +++ b/repos/gems/include/gems/nitpicker_buffer.h @@ -90,7 +90,9 @@ struct Nitpicker_buffer ram(ram), rm(rm), nitpicker(nitpicker), mode(Genode::max(1UL, size.w()), Genode::max(1UL, size.h()), nitpicker.mode().format()) - { } + { + reset_surface(); + } /** * Constructor @@ -131,7 +133,20 @@ struct Nitpicker_buffer { Genode::size_t const num_pixels = pixel_surface().size().count(); Genode::memset(alpha_surface().addr(), 0, num_pixels); - Genode::memset(pixel_surface().addr(), 0, num_pixels*sizeof(Pixel_rgb888)); + + /* + * Initialize color buffer with 50% gray + * + * We do not use black to limit the bleeding of black into antialiased + * drawing operations applied onto an initially transparent background. + */ + Pixel_surface pixels = pixel_surface(); + Pixel_rgb888 *dst = pixels.addr(); + + Pixel_rgb888 const gray(127, 127, 127, 255); + + for (unsigned n = pixels.size().count(); n; n--) + *dst++ = gray; } template