mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 10:05:32 +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
|
@ -35,6 +35,11 @@ public:
|
|||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
if (transform.is_identity_or_translation()) {
|
||||
translate(transform.e(), transform.f());
|
||||
draw_scaled_bitmap(dst_rect, bitmap, src_rect, opacity, scaling_mode);
|
||||
translate(-transform.e(), -transform.f());
|
||||
if (transform.is_identity_or_translation_or_scale()) {
|
||||
draw_scaled_bitmap(transform.map(dst_rect.to_type<float>()).to_rounded<int>(), bitmap, src_rect, opacity, scaling_mode);
|
||||
} else {
|
||||
// The painter has an affine transform, we have to draw through it!
|
||||
|
||||
|
|
Loading…
Reference in a new issue