mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +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
2 changed files with 5 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue