mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibGfx: Add ability to get a bounding box from a Path
This commit is contained in:
parent
4155de2572
commit
236eeb6fb1
Notes:
sideshowbarker
2024-07-19 01:56:32 +09:00
Author: https://github.com/mattco98
Commit: 236eeb6fb1
Pull-request: https://github.com/SerenityOS/serenity/pull/3730
Reviewed-by: https://github.com/awesomekling
2 changed files with 43 additions and 4 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -174,13 +175,22 @@ public:
|
|||
const NonnullRefPtrVector<Segment>& segments() const { return m_segments; }
|
||||
const auto& split_lines()
|
||||
{
|
||||
if (m_split_lines.has_value())
|
||||
return m_split_lines.value();
|
||||
segmentize_path();
|
||||
ASSERT(m_split_lines.has_value());
|
||||
if (!m_split_lines.has_value()) {
|
||||
segmentize_path();
|
||||
ASSERT(m_split_lines.has_value());
|
||||
}
|
||||
return m_split_lines.value();
|
||||
}
|
||||
|
||||
const Gfx::FloatRect& bounding_box()
|
||||
{
|
||||
if (!m_bounding_box.has_value()) {
|
||||
segmentize_path();
|
||||
ASSERT(m_bounding_box.has_value());
|
||||
}
|
||||
return m_bounding_box.value();
|
||||
}
|
||||
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
|
@ -199,6 +209,7 @@ private:
|
|||
NonnullRefPtrVector<Segment> m_segments {};
|
||||
|
||||
Optional<Vector<SplitLineSegment>> m_split_lines {};
|
||||
Optional<Gfx::FloatRect> m_bounding_box;
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Path& path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue