1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

LibGfx: Make Path::bounding_box() and Path::split_lines() const

Use a const_cast internally when segmentizing. As far as clients are
concerned, these are const operations.
This commit is contained in:
Andreas Kling 2021-09-17 13:35:17 +02:00
parent 5726017414
commit 8c863ad959

View file

@ -169,10 +169,10 @@ public:
}; };
const NonnullRefPtrVector<Segment>& segments() const { return m_segments; } const NonnullRefPtrVector<Segment>& segments() const { return m_segments; }
const auto& split_lines() auto& split_lines() const
{ {
if (!m_split_lines.has_value()) { if (!m_split_lines.has_value()) {
segmentize_path(); const_cast<Path*>(this)->segmentize_path();
VERIFY(m_split_lines.has_value()); VERIFY(m_split_lines.has_value());
} }
return m_split_lines.value(); return m_split_lines.value();
@ -184,10 +184,10 @@ public:
m_split_lines.clear(); m_split_lines.clear();
} }
const Gfx::FloatRect& bounding_box() Gfx::FloatRect const& bounding_box() const
{ {
if (!m_bounding_box.has_value()) { if (!m_bounding_box.has_value()) {
segmentize_path(); const_cast<Path*>(this)->segmentize_path();
VERIFY(m_bounding_box.has_value()); VERIFY(m_bounding_box.has_value());
} }
return m_bounding_box.value(); return m_bounding_box.value();