mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibWeb: Compute StackingContext transform origin only once
When mousing over twitter, 17% of time was spent computing stacking context transform origins. Since this never changes after the stacking context is created, we can cache it and avoid all that work.
This commit is contained in:
parent
901b80f988
commit
5c6621547c
Notes:
sideshowbarker
2024-07-17 06:39:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5c6621547c
|
@ -30,6 +30,7 @@ static void paint_node(Layout::Node const& layout_node, PaintContext& context, P
|
|||
StackingContext::StackingContext(Layout::Box& box, StackingContext* parent)
|
||||
: m_box(box)
|
||||
, m_transform(combine_transformations(m_box.computed_values().transformations()))
|
||||
, m_transform_origin(compute_transform_origin())
|
||||
, m_parent(parent)
|
||||
{
|
||||
VERIFY(m_parent != this);
|
||||
|
@ -316,7 +317,7 @@ void StackingContext::paint(PaintContext& context) const
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::FloatPoint StackingContext::transform_origin() const
|
||||
Gfx::FloatPoint StackingContext::compute_transform_origin() const
|
||||
{
|
||||
auto style_value = m_box.computed_values().transform_origin();
|
||||
// FIXME: respect transform-box property
|
||||
|
|
|
@ -44,13 +44,15 @@ public:
|
|||
private:
|
||||
Layout::Box& m_box;
|
||||
Gfx::FloatMatrix4x4 m_transform;
|
||||
Gfx::FloatPoint m_transform_origin;
|
||||
StackingContext* const m_parent { nullptr };
|
||||
Vector<StackingContext*> m_children;
|
||||
|
||||
void paint_internal(PaintContext&) const;
|
||||
Gfx::FloatMatrix4x4 get_transformation_matrix(CSS::Transformation const& transformation) const;
|
||||
Gfx::FloatMatrix4x4 combine_transformations(Vector<CSS::Transformation> const& transformations) const;
|
||||
Gfx::FloatPoint transform_origin() const;
|
||||
Gfx::FloatPoint transform_origin() const { return m_transform_origin; }
|
||||
Gfx::FloatPoint compute_transform_origin() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue