mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibGfx: Inline some AffineTransform functions
Asking if an AffineTransform is identity or translate-only can be done inline and avoid the cost of a function call in tight loops.
This commit is contained in:
parent
2dacd1252c
commit
e46deec846
2 changed files with 9 additions and 12 deletions
|
@ -12,16 +12,6 @@
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
bool AffineTransform::is_identity() const
|
|
||||||
{
|
|
||||||
return m_values[0] == 1 && m_values[1] == 0 && m_values[2] == 0 && m_values[3] == 1 && m_values[4] == 0 && m_values[5] == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AffineTransform::is_identity_or_translation() const
|
|
||||||
{
|
|
||||||
return a() == 1 && b() == 0 && c() == 0 && d() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
float AffineTransform::x_scale() const
|
float AffineTransform::x_scale() const
|
||||||
{
|
{
|
||||||
return AK::hypot(m_values[0], m_values[1]);
|
return AK::hypot(m_values[0], m_values[1]);
|
||||||
|
|
|
@ -25,8 +25,15 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_identity() const;
|
[[nodiscard]] bool is_identity() const
|
||||||
bool is_identity_or_translation() const;
|
{
|
||||||
|
return m_values[0] == 1 && m_values[1] == 0 && m_values[2] == 0 && m_values[3] == 1 && m_values[4] == 0 && m_values[5] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool is_identity_or_translation() const
|
||||||
|
{
|
||||||
|
return m_values[0] == 1 && m_values[1] == 0 && m_values[2] == 0 && m_values[3] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue