mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
LibWeb: Don't regenerate linear gradient data unless size changes
This is an easy check to add and seems like it makes things a tiny bit smoother.
This commit is contained in:
parent
de5d25ee44
commit
fa5c2183df
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/fa5c2183df Pull-request: https://github.com/SerenityOS/serenity/pull/14977
2 changed files with 11 additions and 4 deletions
|
@ -1612,13 +1612,15 @@ float LinearGradientStyleValue::angle_degrees(Gfx::FloatSize const& gradient_siz
|
|||
|
||||
void LinearGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize const& size) const
|
||||
{
|
||||
m_resolved_data = Painting::resolve_linear_gradient_data(node, size, *this);
|
||||
if (m_resolved.has_value() && m_resolved->size == size)
|
||||
return;
|
||||
m_resolved = ResolvedData { Painting::resolve_linear_gradient_data(node, size, *this), size };
|
||||
}
|
||||
|
||||
void LinearGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const
|
||||
{
|
||||
VERIFY(m_resolved_data.has_value());
|
||||
Painting::paint_linear_gradient(context, dest_rect, *m_resolved_data);
|
||||
VERIFY(m_resolved.has_value());
|
||||
Painting::paint_linear_gradient(context, dest_rect, m_resolved->data);
|
||||
}
|
||||
|
||||
bool InheritStyleValue::equals(StyleValue const& other) const
|
||||
|
|
|
@ -1023,7 +1023,12 @@ private:
|
|||
GradientType m_gradient_type;
|
||||
Repeating m_repeating;
|
||||
|
||||
mutable Optional<Painting::LinearGradientData> m_resolved_data;
|
||||
struct ResolvedData {
|
||||
Painting::LinearGradientData data;
|
||||
Gfx::FloatSize size;
|
||||
};
|
||||
|
||||
mutable Optional<ResolvedData> m_resolved;
|
||||
};
|
||||
|
||||
class InheritStyleValue final : public StyleValue {
|
||||
|
|
Loading…
Reference in a new issue