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
commit 8c863ad959
Notes: sideshowbarker 2024-07-18 03:46:48 +09:00

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();