diff options
author | Karol Kosek <krkk@serenityos.org> | 2022-07-10 00:18:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-10 15:01:07 +0200 |
commit | b5420b8a9add6559d812971a70d6eaec04bb8dd4 (patch) | |
tree | f77f43f1939be51f55c61f0ddcc5dc57293f8d16 /AK/SIMDExtras.h | |
parent | 98a90d79de57fa7690ed68cee5af32c22bfa3fbe (diff) | |
download | serenity-b5420b8a9add6559d812971a70d6eaec04bb8dd4.zip |
LibGfx: Implement PNG filtering on write
Is it another great upgrade to our PNG encoder like in 9aafaec259?
Well, not really - it's not a 2x or 55x improvement like you saw there,
but still it saves something:
- a screenshot of a blank Serenity desktop dropped from about 45 KiB
to 40 KiB.
- re-encoding NASA photo of the Earth to PNG again saves about 25%
(16.5 MiB -> 12.3 MiB), compared to not using filters.
[1]: https://commons.wikimedia.org/wiki/File:The_Blue_Marble_(remastered).jpg
Diffstat (limited to 'AK/SIMDExtras.h')
-rw-r--r-- | AK/SIMDExtras.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/AK/SIMDExtras.h b/AK/SIMDExtras.h index dac25d456d..eba20f2b97 100644 --- a/AK/SIMDExtras.h +++ b/AK/SIMDExtras.h @@ -37,6 +37,18 @@ ALWAYS_INLINE static constexpr u32x4 expand4(u32 u) // Casting template<typename TSrc> +ALWAYS_INLINE static u8x4 to_u8x4(TSrc v) +{ + return __builtin_convertvector(v, u8x4); +} + +template<typename TSrc> +ALWAYS_INLINE static u16x4 to_u16x4(TSrc v) +{ + return __builtin_convertvector(v, u16x4); +} + +template<typename TSrc> ALWAYS_INLINE static u32x4 to_u32x4(TSrc v) { return __builtin_convertvector(v, u32x4); |