Commit Graph

22 Commits

Author SHA1 Message Date
Andreas Kling
c69b266e43 LibGfx: Add fast path for multiply() with identity transforms
This is a no-op, and exiting early is useful as it cuts time spent in
AffineTransform::multiply() from 3% to 2% when hovering links on
ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
e46deec846 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.
2024-03-02 13:00:09 +01:00
Andreas Kling
2dacd1252c LibGfx: Add fast paths for identity/translate-only transforms
This shrinks time spent in AffineTransform::map() from 3.3% to 1.6%
when hovering links on ziglang.org.
2024-03-02 13:00:09 +01:00
MacDue
9ecc78db1b LibGfx: Add AffineTransform::determinant() 2023-07-14 06:51:05 +02:00
Jelle Raaijmakers
f391ccfe53 LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last
column's coordinate still inside the rectangle, or `left + width - 1`.
This is called 'endpoint inclusive' and does not make a lot of sense for
`Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would
return 4 as its right side. This same problem exists for `.bottom()`.

This changes `Gfx::Rect` to be endpoint exclusive, which gives us the
nice property that `width = right - left` and `height = bottom - top`.
It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly
the same.

All users of `Gfx::Rect` have been updated accordingly.
2023-05-23 12:35:42 +02:00
Andreas Kling
a77accf3f4 LibGfx: Add AffineTransform::rotation()
Extracts the rotation from a 2D matrix.
2023-04-27 07:24:53 +02:00
MacDue
b8d1fae31f LibGfx: Add AffineTransform::skew_radians() 2023-04-12 07:40:22 +02:00
MacDue
27fae78335 Meta+Userland: Pass Gfx::IntSize by value
Just two ints like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
e011eafd37 Meta+Userland: Pass Gfx::FloatPoint by value
Just a small 8-byte value like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Hendiadyoin1
db0ba9f647 LibGfx: Use some AK/Math helpers in AffineTransform
This makes us use AK::sincos and AK::hypot
2022-05-07 20:25:39 +02:00
Hendiadyoin1
5fd49b9d9f LibGfx: Avoid some unnecessary Rounding in AffineTransform and Color
Casts suffice in these cases.
(Assuming standard rounding mode)
2022-05-07 20:25:39 +02:00
Andreas Kling
b4c3882d9c LibGfx: Add AffineTransform::is_identity_or_translation()
This will allow us to implement fast paths in cases where a simple
translation can be handled faster than a full affine transform.
2022-04-10 21:35:55 +02:00
Andreas Kling
2af8bb14d7 LibGfx: Add AffineTransform::map_to_quad(Rect)
Unlike map(Rect) which returns a Rect, mapping a Rect to a Quad allows
us to represent the actual result of mapping all four corners of the
Rect through the matrix.
2022-04-07 17:06:02 +02:00
Andreas Kling
85327e6b5d LibWeb: Fix broken AffineTransform::map() implementation
When opening canvas-rotate.html on my host machine, I noticed that
the rotation was going the other way.. :^)
2022-04-07 04:01:57 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Simon Wanner
9c97bd0de4 LibGfx: Add AffineTransform::inverse 2022-03-18 18:51:42 +01:00
Daniel Bertalan
f14a4994b0 Everywhere: Don't promote float to double where not needed
The `float => double => float` round trip seen in a couple of places
might pessimize the code. Even if it's truncated to an int in the end,
it's weird not to use the functions with the `f` suffixes when working
with single precision floats.
2021-07-08 10:11:00 +02:00
Matthew Olsson
ac238b3bd6 LibGfx: Add some helper methods to AffineTransform
Also makes some basic getters ALWAYS_INLINE and [[nodiscard]], as well
as fixing as error with the map method.
2021-05-02 22:48:06 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00