1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibWeb: Convert gradient painting to new pixel units

Co-authored-by: MacDue <macdue@dueutil.tech>
This commit is contained in:
Sam Atkins 2022-11-25 17:11:09 +00:00 committed by Linus Groh
parent 7c8eecbaa5
commit 9d1f30b533
3 changed files with 41 additions and 39 deletions

View file

@ -1870,13 +1870,13 @@ void LinearGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::F
{
if (m_resolved.has_value() && m_resolved->size == size)
return;
m_resolved = ResolvedData { Painting::resolve_linear_gradient_data(node, size, *this), size };
m_resolved = ResolvedData { Painting::resolve_linear_gradient_data(node, size.to_type<CSSPixels>(), *this), size };
}
void LinearGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const
{
VERIFY(m_resolved.has_value());
Painting::paint_linear_gradient(context, dest_rect, m_resolved->data);
Painting::paint_linear_gradient(context, dest_rect.to_type<DevicePixels>(), m_resolved->data);
}
Gfx::FloatPoint PositionValue::resolved(Layout::Node const& node, Gfx::FloatRect const& rect) const
@ -2158,7 +2158,7 @@ void RadialGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::F
if (m_resolved.has_value() && m_resolved->gradient_size == gradient_size)
return;
m_resolved = ResolvedData {
Painting::resolve_radial_gradient_data(node, gradient_size, *this),
Painting::resolve_radial_gradient_data(node, gradient_size.to_type<CSSPixels>(), *this),
gradient_size,
center,
};
@ -2178,7 +2178,7 @@ bool RadialGradientStyleValue::equals(StyleValue const& other) const
void RadialGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const
{
VERIFY(m_resolved.has_value());
Painting::paint_radial_gradient(context, dest_rect, m_resolved->data, m_resolved->center.to_rounded<int>(), m_resolved->gradient_size);
Painting::paint_radial_gradient(context, dest_rect.to_type<DevicePixels>(), m_resolved->data, m_resolved->center.to_rounded<DevicePixels>(), m_resolved->gradient_size);
}
DeprecatedString ConicGradientStyleValue::to_deprecated_string() const
@ -2214,7 +2214,7 @@ void ConicGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::Fl
void ConicGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const
{
VERIFY(m_resolved.has_value());
Painting::paint_conic_gradient(context, dest_rect, m_resolved->data, m_resolved->position.to_rounded<int>());
Painting::paint_conic_gradient(context, dest_rect.to_type<DevicePixels>(), m_resolved->data, context.rounded_device_point(m_resolved->position.to_type<CSSPixels>()));
}
bool ConicGradientStyleValue::equals(StyleValue const& other) const