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:
Andreas Kling 2022-09-24 20:36:06 +02:00
parent 901b80f988
commit 5c6621547c
Notes: sideshowbarker 2024-07-17 06:39:17 +09:00
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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;
};
}