mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
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.
This commit is contained in:
parent
6177424fa6
commit
ed774253b6
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user