From ed774253b6d0459fa13e68a959a2db33153b27a0 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 12 Nov 2015 18:21:27 +0100 Subject: [PATCH] demo: fix corner case in scout_gfx/icon_painter.h The original version of the icon painter would reach beyong the texture boundaries for textures of even width and height, and when painting an icon with the width or height of the texture. In this case, p3 would be set to the same value as p2. However, the code expects p3 to lie within the middle rectangle. However, in this corner case, the middle rectangle is actually empty. So no pixel can lie within it. Hence, p3 is positioned by one pixel to the left outside the middle rectangle, which violates the assumptions when calculating the clipping and texture offsets. The patch fixes the problem by reducing the size of the right column by one pixel. This ensures that exists always a non-zero middle rectangle. --- repos/demo/include/scout_gfx/icon_painter.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/demo/include/scout_gfx/icon_painter.h b/repos/demo/include/scout_gfx/icon_painter.h index 991a49fd1..e3db0da1f 100644 --- a/repos/demo/include/scout_gfx/icon_painter.h +++ b/repos/demo/include/scout_gfx/icon_painter.h @@ -195,8 +195,8 @@ class Icon_painter int const y4 = y1 + rect.h() - 1; int const x2 = x1 + icon_w/2; int const y2 = y1 + icon_h/2; - int const x3 = Genode::max(x4 - (int)icon_w/2, x2); - int const y3 = Genode::max(y4 - (int)icon_h/2, y2); + int const x3 = Genode::max(x4 - (int)icon_w/2 + 1, x2); + int const y3 = Genode::max(y4 - (int)icon_h/2 + 1, y2); int const tx1 = 0; int const ty1 = 0; @@ -204,8 +204,8 @@ class Icon_painter int const ty4 = icon_h - 1; int const tx2 = icon_w/2; int const ty2 = icon_h/2; - int const tx3 = Genode::max(tx4 - (int)icon_w/2, tx2); - int const ty3 = Genode::max(ty4 - (int)icon_h/2, ty2); + int const tx3 = Genode::max(tx4 - (int)icon_w/2 + 1, tx2); + int const ty3 = Genode::max(ty4 - (int)icon_h/2 + 1, ty2); TPT const *src = icon.pixel() + icon_w*ty1; unsigned char const *src_a = icon.alpha() + icon_w*ty1;