mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibGfx: Add shortcut to draw_scaled_bitmap_with_transform()
for scales
Using `draw_scaled_bitmap()` for simple scales is almost always better than using `draw_scaled_bitmap_with_transform()` which does not respect the scaling mode.
This commit is contained in:
parent
f7bf14605c
commit
a5442ad70d
Notes:
sideshowbarker
2024-07-17 18:13:59 +09:00
Author: https://github.com/MacDue
Commit: a5442ad70d
Pull-request: https://github.com/SerenityOS/serenity/pull/24465
Issue: https://github.com/SerenityOS/serenity/issues/24252
Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 7 additions and 4 deletions
|
@ -35,6 +35,11 @@ public:
|
||||||
return m_values[0] == 1 && m_values[1] == 0 && m_values[2] == 0 && m_values[3] == 1;
|
return m_values[0] == 1 && m_values[1] == 0 && m_values[2] == 0 && m_values[3] == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool is_identity_or_translation_or_scale() const
|
||||||
|
{
|
||||||
|
return m_values[1] == 0 && m_values[2] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
void map(float unmapped_x, float unmapped_y, float& mapped_x, float& mapped_y) const;
|
void map(float unmapped_x, float unmapped_y, float& mapped_x, float& mapped_y) const;
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Arithmetic T>
|
||||||
|
|
|
@ -2447,10 +2447,8 @@ void Painter::draw_text_run(FloatPoint baseline_start, Utf8View const& string, F
|
||||||
|
|
||||||
void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap const& bitmap, FloatRect const& src_rect, AffineTransform const& transform, float opacity, Painter::ScalingMode scaling_mode)
|
void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap const& bitmap, FloatRect const& src_rect, AffineTransform const& transform, float opacity, Painter::ScalingMode scaling_mode)
|
||||||
{
|
{
|
||||||
if (transform.is_identity_or_translation()) {
|
if (transform.is_identity_or_translation_or_scale()) {
|
||||||
translate(transform.e(), transform.f());
|
draw_scaled_bitmap(transform.map(dst_rect.to_type<float>()).to_rounded<int>(), bitmap, src_rect, opacity, scaling_mode);
|
||||||
draw_scaled_bitmap(dst_rect, bitmap, src_rect, opacity, scaling_mode);
|
|
||||||
translate(-transform.e(), -transform.f());
|
|
||||||
} else {
|
} else {
|
||||||
// The painter has an affine transform, we have to draw through it!
|
// The painter has an affine transform, we have to draw through it!
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue