mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +00:00
LibTTF: Fix glyph rasterizer coverage calculation
This commit is contained in:
parent
1fb1279cfd
commit
b807d51598
1 changed files with 7 additions and 5 deletions
|
@ -320,17 +320,19 @@ void Rasterizer::draw_line(Gfx::FloatPoint p0, Gfx::FloatPoint p1)
|
||||||
m_data[line_offset + x0i + 1] += directed_dy * area;
|
m_data[line_offset + x0i + 1] += directed_dy * area;
|
||||||
} else {
|
} else {
|
||||||
float dydx = 1.0 / dxdy;
|
float dydx = 1.0 / dxdy;
|
||||||
|
if (dydx < 0)
|
||||||
|
dydx = -dydx;
|
||||||
|
|
||||||
float x0_right = 1.0 - (x0 - x0_floor);
|
float x0_right = 1.0 - (x0 - x0_floor);
|
||||||
u32 x1_floor_i = floor(x1);
|
u32 x1_floor_i = floor(x1);
|
||||||
float area_upto_here = 0.5 * x0_right * x0_right * dydx;
|
float area_upto_here = 0.5 * x0_right * x0_right * dydx;
|
||||||
m_data[line_offset + x0i] += direction * area_upto_here;
|
m_data[line_offset + x0i] += direction * area_upto_here;
|
||||||
for (u32 x = x0i + 1; x < x1_floor_i; x++) {
|
for (u32 x = x0i + 1; x < x1_floor_i; x++) {
|
||||||
x0_right += 1.0;
|
m_data[line_offset + x] += direction * dydx;
|
||||||
float total_area_here = 0.5 * x0_right * x0_right * dydx;
|
area_upto_here += dydx;
|
||||||
m_data[line_offset + x] += direction * (total_area_here - area_upto_here);
|
|
||||||
area_upto_here = total_area_here;
|
|
||||||
}
|
}
|
||||||
m_data[line_offset + x1_floor_i] += direction * (dy - area_upto_here);
|
float remaining_area = (dy - area_upto_here);
|
||||||
|
m_data[line_offset + x1_floor_i] += direction * remaining_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
x_cur = x_next;
|
x_cur = x_next;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue