mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibGfx: Ensure last subpath is closed by Path::close_all_subpaths()
This commit is contained in:
parent
6b40271b95
commit
3d755a57b6
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/3d755a57b6 Pull-request: https://github.com/SerenityOS/serenity/pull/19610
@ -144,11 +144,7 @@ void Path::close_all_subpaths()
|
||||
Optional<FloatPoint> cursor, start_of_subpath;
|
||||
bool is_first_point_in_subpath { false };
|
||||
|
||||
auto segment_count = m_segments.size();
|
||||
for (size_t i = 0; i < segment_count; i++) {
|
||||
// Note: We need to use m_segments[i] as append_segment() may invalidate any references.
|
||||
switch (m_segments[i]->type()) {
|
||||
case Segment::Type::MoveTo: {
|
||||
auto close_previous_subpath = [&] {
|
||||
if (cursor.has_value() && !is_first_point_in_subpath) {
|
||||
// This is a move from a subpath to another
|
||||
// connect the two ends of this subpath before
|
||||
@ -158,6 +154,14 @@ void Path::close_all_subpaths()
|
||||
append_segment<MoveSegment>(cursor.value());
|
||||
append_segment<LineSegment>(start_of_subpath.value());
|
||||
}
|
||||
};
|
||||
|
||||
auto segment_count = m_segments.size();
|
||||
for (size_t i = 0; i < segment_count; i++) {
|
||||
// Note: We need to use m_segments[i] as append_segment() may invalidate any references.
|
||||
switch (m_segments[i]->type()) {
|
||||
case Segment::Type::MoveTo: {
|
||||
close_previous_subpath();
|
||||
is_first_point_in_subpath = true;
|
||||
cursor = m_segments[i]->point();
|
||||
break;
|
||||
@ -177,6 +181,9 @@ void Path::close_all_subpaths()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_segments.last()->type() != Segment::Type::MoveTo)
|
||||
close_previous_subpath();
|
||||
}
|
||||
|
||||
DeprecatedString Path::to_deprecated_string() const
|
||||
|
Loading…
Reference in New Issue
Block a user