mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibGfx: Prevent out-of-bounds accumulation in PathRasterizer
Negative accumulation on the right-hand side of the accumulation bitmap would wrap around to the left, causing a negative start for certain lines which resulted in horizontal streaks of lower alpha values. Prevent this by not writing out of bounds :^) Fixes #18394
This commit is contained in:
parent
8dc55f5fda
commit
0e8ef1b886
1 changed files with 2 additions and 1 deletions
|
@ -102,7 +102,8 @@ void PathRasterizer::draw_line(Gfx::FloatPoint p0, Gfx::FloatPoint p1)
|
||||||
// If x0 and x1 are within the same pixel, then area to the right is (1 - (mid(x0, x1) - x0_floor)) * dy
|
// If x0 and x1 are within the same pixel, then area to the right is (1 - (mid(x0, x1) - x0_floor)) * dy
|
||||||
float area = .5f * (x0 + x1) - x0_floor;
|
float area = .5f * (x0 + x1) - x0_floor;
|
||||||
m_data[line_offset + x0_floor_i] += directed_dy * (1.f - area);
|
m_data[line_offset + x0_floor_i] += directed_dy * (1.f - area);
|
||||||
m_data[line_offset + x0_floor_i + 1] += directed_dy * area;
|
if (x0_floor_i + 1 < static_cast<u32>(m_size.width()))
|
||||||
|
m_data[line_offset + x0_floor_i + 1] += directed_dy * area;
|
||||||
} else {
|
} else {
|
||||||
float x0_right = 1.f - (x0 - x0_floor);
|
float x0_right = 1.f - (x0 - x0_floor);
|
||||||
u32 x1_floor_i = floorf(x1);
|
u32 x1_floor_i = floorf(x1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue