1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:38:10 +00:00
serenity/Userland/Libraries/LibGfx
Daniel Bertalan c6fafd3e90 AK+Userland: Add generic AK::abs() function and use it
Previously, in LibGFX's `Point` class, calculated distances were passed
to the integer `abs` function, even if the stored type was a float. This
caused the value to unexpectedly be truncated. Luckily, this API was not
used with floating point types, but that can change in the future, so
why not fix it now :^)

Since we are in C++, we can use function overloading to make things
easy, and to automatically use the right version.

This is even better than the LibC/LibM functions, as using a bit of
hackery, they are able to be constant-evaluated. They use compiler
intrinsics, so they do not depend on external code and the compiler can
emit the most optimized code by default.

Since we aren't using the C++ standard library's trick of importing
everything into the `AK` namespace, this `abs` function cannot be
exported to the global namespace, as the names would clash.
2021-07-08 10:11:00 +02:00
..
Filters LibGfx: Unify Rect, Point, and Size 2021-05-02 22:48:06 +02:00
AffineTransform.cpp LibGfx: Add some helper methods to AffineTransform 2021-05-02 22:48:06 +02:00
AffineTransform.h LibGfx: Add some helper methods to AffineTransform 2021-05-02 22:48:06 +02:00
Bitmap.cpp LibGfx+LibGUI+WindowServer: Use move() on Core::AnonymousBuffer more 2021-07-07 18:02:43 +02:00
Bitmap.h LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::Bitmap 2021-05-24 13:31:01 +02:00
BitmapFont.cpp LibGfx: BitmapFont: Handle '\r' and '\n' when calculating text width 2021-07-07 20:29:29 +02:00
BitmapFont.h LibGfx: BitmapFont: Handle '\r' and '\n' when calculating text width 2021-07-07 20:29:29 +02:00
BMPLoader.cpp AK: Rename Vector::append(Vector) => Vector::extend(Vector) 2021-06-12 13:24:45 +02:00
BMPLoader.h Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
BMPWriter.cpp LibGfx/BMPWriter: Add support for V3 & V4 DIB headers 2021-07-05 00:43:00 +02:00
BMPWriter.h LibGfx/BMPWriter: Add support for V3 & V4 DIB headers 2021-07-05 00:43:00 +02:00
CharacterBitmap.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
CharacterBitmap.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ClassicStylePainter.cpp Revert "Userland: static vs non-static constexpr variables" 2021-05-21 10:30:52 +01:00
ClassicStylePainter.h Everywhere: Add missing comma between copyright year and name 2021-04-29 00:59:26 +02:00
ClassicWindowTheme.cpp LibGfx: Remove Gfx::FontDatabase::default_bold_font() 2021-05-20 20:55:29 +02:00
ClassicWindowTheme.h LibGfx: Fix classic theme frame transparency check 2021-07-05 12:29:14 +02:00
CMakeLists.txt LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
Color.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Color.h LibGfx: remove constexpr, add noexcept on interpolate method 2021-05-27 00:01:38 +04:30
DDSLoader.cpp LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
DDSLoader.h LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
DisjointRectSet.cpp LibGfx: Unify Rect, Point, and Size 2021-05-02 22:48:06 +02:00
DisjointRectSet.h WindowServer: Add basic virtual desktop support 2021-07-03 12:27:23 +02:00
Emoji.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Emoji.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Font.h Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
FontDatabase.cpp LibTTF: Make TTF::Font loading API return error strings 2021-07-04 21:34:26 +02:00
FontDatabase.h LibGfx+WindowServer: Have WindowServer broadcast system font settings 2021-05-21 20:15:51 +02:00
Forward.h LibGfx: Add a Line class and a Rect<T>::RelativeLocation class 2021-06-20 14:57:26 +02:00
Gamma.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
GIFLoader.cpp AK: Rename Vector::append(Vector) => Vector::extend(Vector) 2021-06-12 13:24:45 +02:00
GIFLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ICOLoader.cpp LibGfx: Switch to modern dbgln logging in ICOLoader 2021-05-29 21:46:16 +04:30
ICOLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ImageDecoder.cpp LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
ImageDecoder.h AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
JPGLoader.cpp LibGfx: Make JPGLoader iterate components deterministically 2021-05-31 17:26:11 +01:00
JPGLoader.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
Line.h LibGfx: Add a Line class and a Rect<T>::RelativeLocation class 2021-06-20 14:57:26 +02:00
Matrix.h LibGfx/Matrix: Add inverse() and friends 2021-05-24 00:33:18 +01:00
Matrix4x4.h Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Orientation.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Painter.cpp LibGfx: Small improvements to fill_rect_with_checkerboard() 2021-07-07 13:01:20 +02:00
Painter.h LibGfx: Add helper for painting a rounded rect with equal corner radii 2021-06-04 19:11:45 +02:00
Palette.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
Palette.h LibGUI+HackStudio: Make gutter a first class element 2021-06-13 12:33:15 +01:00
Path.cpp LibGfx: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Path.h LibGfx: Add Path::clear 2021-05-25 00:24:09 +04:30
PBMLoader.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
PBMLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
PGMLoader.cpp LibGfx: Change "white_space" => "whitespace" 2021-05-09 09:59:22 +02:00
PGMLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
PNGLoader.cpp LibGfx: Replace if constexpr (PNG_DEBUG) printf() with dbgln_if() 2021-05-31 17:43:54 +01:00
PNGLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
PNGWriter.cpp AK: Rename Vector::append(Vector) => Vector::extend(Vector) 2021-06-12 13:24:45 +02:00
PNGWriter.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Point.cpp LibGfx: Convert Point to east-const style 2021-06-16 21:53:10 +02:00
Point.h AK+Userland: Add generic AK::abs() function and use it 2021-07-08 10:11:00 +02:00
PortableImageLoaderCommon.h LibGfx: Change "white_space" => "whitespace" 2021-05-09 09:59:22 +02:00
PPMLoader.cpp LibGfx: Change "white_space" => "whitespace" 2021-05-09 09:59:22 +02:00
PPMLoader.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Rect.cpp LibGfx: Add a Line class and a Rect<T>::RelativeLocation class 2021-06-20 14:57:26 +02:00
Rect.h LibGfx: Add a Line class and a Rect<T>::RelativeLocation class 2021-06-20 14:57:26 +02:00
ShareableBitmap.cpp LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::Bitmap 2021-05-24 13:31:01 +02:00
ShareableBitmap.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Size.cpp LibGfx: Add a bunch of [[nodiscard]] to Size 2021-06-16 21:53:10 +02:00
Size.h LibGfx: Add a bunch of [[nodiscard]] to Size 2021-06-16 21:53:10 +02:00
StandardCursor.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Streamer.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
StylePainter.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
StylePainter.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
SystemTheme.cpp LibGfx: Remove unused current_system_theme() function 2021-05-20 22:12:42 +02:00
SystemTheme.h LibGUI+HackStudio: Make gutter a first class element 2021-06-13 12:33:15 +01:00
TextAlignment.h LibGfx: Add missing TextAlignment::BottomLeft 2021-05-21 08:04:31 +02:00
TextAttributes.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
TextDirection.cpp Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
TextDirection.h Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
TextElision.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Triangle.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Triangle.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Typeface.cpp Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Typeface.h Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Vector2.h LibGfx: Don't constexpr functions returning Strings 2021-06-24 17:35:49 +04:30
Vector3.h LibGfx: Don't constexpr functions returning Strings 2021-06-24 17:35:49 +04:30
Vector4.h LibGfx: Don't constexpr functions returning Strings 2021-06-24 17:35:49 +04:30
WindowTheme.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
WindowTheme.h WindowServer+LibGfx: Automatic "modified" markers in window titles 2021-05-01 19:42:29 +02:00