mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:07:43 +00:00
SharedGraphics: Add missing clipping in draw_line().
This commit is contained in:
parent
dd931f136e
commit
3198639730
1 changed files with 8 additions and 0 deletions
|
@ -270,6 +270,10 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color)
|
||||||
return;
|
return;
|
||||||
if (point1.y() > point2.y())
|
if (point1.y() > point2.y())
|
||||||
swap(point1, point2);
|
swap(point1, point2);
|
||||||
|
if (point1.y() > m_clip_rect.bottom())
|
||||||
|
return;
|
||||||
|
if (point2.y() < m_clip_rect.top())
|
||||||
|
return;
|
||||||
int min_y = max(point1.y(), m_clip_rect.top());
|
int min_y = max(point1.y(), m_clip_rect.top());
|
||||||
int max_y = min(point2.y(), m_clip_rect.bottom());
|
int max_y = min(point2.y(), m_clip_rect.bottom());
|
||||||
for (int y = min_y; y <= max_y; ++y)
|
for (int y = min_y; y <= max_y; ++y)
|
||||||
|
@ -287,6 +291,10 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color)
|
||||||
return;
|
return;
|
||||||
if (point1.x() > point2.x())
|
if (point1.x() > point2.x())
|
||||||
swap(point1, point2);
|
swap(point1, point2);
|
||||||
|
if (point1.x() > m_clip_rect.right())
|
||||||
|
return;
|
||||||
|
if (point2.x() < m_clip_rect.left())
|
||||||
|
return;
|
||||||
int min_x = max(point1.x(), m_clip_rect.left());
|
int min_x = max(point1.x(), m_clip_rect.left());
|
||||||
int max_x = min(point2.x(), m_clip_rect.right());
|
int max_x = min(point2.x(), m_clip_rect.right());
|
||||||
auto* pixels = m_target->scanline(point1.y());
|
auto* pixels = m_target->scanline(point1.y());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue