summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
AgeCommit message (Collapse)Author
2021-05-31LibGfx: Replace if constexpr (PNG_DEBUG) printf() with dbgln_if()Linus Groh
The debug console seems more appropriate than stdout here.
2021-05-31LibGfx: Make JPGLoader iterate components deterministicallysin-ack
JPGLoader used to store component information in a HashTable, indexed by the ID assigned by the JPEG file. This was fine for most purposes, however after f89e8fb7 this was revealed to be a flawed implementation which causes non-deterministic iteration over components. This issue was previously masked by a perfect storm of int_hash being stable for the integer values 0, 1 and 2; and AK::HashTable having just the right amount of buckets for the components to be ordered correctly after being hashed with int_hash. However, after f89e8fb7, malloc_good_size was used for determining the amount of space for allocation; this caused the ordering of the components to change, and images started showing up with the red and blue channels reversed. The issue was finally determined to be inconsistent ordering after randomly changing the order of the components caused Huffman decoding to fail. This was the result of about 10 hours of hair-pulling and repeatedly doing full rebuilds due to bisecting between commits that touched AK. Gunnar, I like you, but please don't make me go through this again. :^) Credits to Andrew Kaster, bgianf, CxByte and Gunnar for the debugging help.
2021-05-30LibGfx: Load correct durations for gifsBen Wiederhake
The wrong shift effectively set the upper byte to 0, meaning that durations longer than 255 centiseconds (2.55 seconds) were wrapped around. See serenity-fuzz-corpora for an example.
2021-05-29LibGfx: Switch to modern dbgln logging in ICOLoaderIdan Horowitz
2021-05-29LibGfx: Reject ICOs with height == NumericLimits<i32>::min()Idan Horowitz
Bitmap files use negative height values to signify that the image should be rendered top down, but if the height value equals to the minimum value, negating it to get the actual height results in UB.
2021-05-29Everywhere: Use s.unverwerth@serenityos.org :^)Stephan Unverwerth
2021-05-28LibGfx: Make sure we use unique class namesGunnar Beutner
Previously there were different definitions for classes with the same name. This is a violation of the C++ ODR.
2021-05-27LibGfx: Copy into a u32 in LZWDecoder::next_code() instead of castingAndrew Kaster
This results in unaligned reads sometimes, depending on the layout of the underlying buffer. Caught by UBSAN.
2021-05-27LibGfx: remove constexpr, add noexcept on interpolate methodSamuel Kelemen
This removes `constexpr` from the interpolate method in Color.h and adds `noexcept`. The roundf call cannot be constexpr on clang. This is the only incompatibility preventing serenity from building under clang. I tested this on OSX Big Sur 11.3 and 11.3.1, and everything works with this change.
2021-05-25LibGfx: Add Color::from_cmykMatthew Olsson
2021-05-25LibGfx: Add Path::clearMatthew Olsson
2021-05-24LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::BitmapJean-Baptiste Boric
Instead of using a low-level, proprietary API inside LibGfx, let's use Core::AnonymousBuffer which already abstracts anon_fd and offers a higher-level API too.
2021-05-24LibGfx+Base: Tweak bitmap fonts to ensure glyph data is 4-byte alignedAndreas Kling
When building userland with UBSAN enabled (#7434), we were getting spammed to death by unaligned access errors. Fix these by adding 2 bytes of padding to the FontFileHeader struct, and adjusting all our font files to match the new format. :^)
2021-05-24LibGfx/Matrix: Add inverse() and friendsJelle Raaijmakers
Matrix inversion comes in quite handy in 3D projections, so let's add `Matrix<N,T>.inverse()`. To support matrix inversion, the following methods are added: * `Matrix.first_minor()` See: https://en.wikipedia.org/wiki/Minor_(linear_algebra) * `Matrix.adjugate()` See: https://en.wikipedia.org/wiki/Adjugate_matrix * `Matrix.determinant()` See: https://en.wikipedia.org/wiki/Determinant * `Matrix.inverse()` See: https://en.wikipedia.org/wiki/Invertible_matrix * `Matrix.operator/()` To support easy matrix division :-) Code loosely based on an implementation listed here: https://www.geeksforgeeks.org/adjoint-inverse-matrix/
2021-05-23LibGfx: Replace ellipse drawing algorithmTobias Christiansen
The new one is way more naive and not as fancy as the old one, but it doesn't crash when trying to draw circles. This algorithm just sweeps the angles required by the call, makes sure each segment is at most 1 (pixel) long and just uses the standard parameterization to find the coordinates of each point on the ellipse.
2021-05-22Bitmap: Don't call Bitmap::create with width/height equal to 0Marcus Nilsson
With very small bitmaps and small scale factor, such as tile.png, the type conversion in the call to Bitmap:create would cause width or height to be 0. Fixes #7352
2021-05-22LibGfx: Support alpha in rendering methods for border-radiusTobias Christiansen
The methods used in displaying border-radius were ignoring alpha.
2021-05-21LibGfx+WindowServer: Have WindowServer broadcast system font settingsAndreas Kling
Instead of everybody getting their system fonts from Gfx::FontDatabase (where it's all hardcoded), they now get it from WindowServer. These are then plumbed into the usual Gfx::FontDatabase places so that the old default_font() and default_fixed_width_font() APIs keep working.
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-21LibGfx: Add missing TextAlignment::BottomLeftLinus Groh
2021-05-20LibGfx: Remove unused current_system_theme() functionAndreas Kling
2021-05-20LibGfx: Add Painter::draw_circle_arc_intersecting()Tobias Christiansen
This adds a function to draw a circle specified by a center point ( relative to the given Rect) and a radius. The circle arc is only drawn inside the specified Rect as to allow for circle arc segments. Technically this was already possible using draw_elliptical_arc(), but the algorithm is quite involved and lead to wonky arcs when trying to draw circle arc segments.
2021-05-20LibGfx: Add Painter::fill_rect_with_rounded_corners()Tobias Christiansen
This paints a rectangle with rounded corners each specified by a radius.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()Andreas Kling
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_font()Andreas Kling
Instead use default_font().bold_variant() in cases where we want a bold variant of the default font. :^)
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
2021-05-18LibGfx: Rename RotationDirection membersMatthew Olsson
Left => CounterClockwise Right => Clockwise Makes much more sense for a rotation
2021-05-18LibGfx: Add support for DDS imagesstelar7
2021-05-17Everywhere: Fix a bunch of typosLinus Groh
2021-05-16LibGfx: Avoid copying ByteBuffers while loading PNG imagesGunnar Beutner
This wasn't much of a problem before because copying the ByteBuffer merely copied the RefPtr but now that ByteBuffer behaves like Vector this causes unnecessary allocations.
2021-05-15LibGfx: Fix incorrect origin for checkerboard pattern fillsAndreas Kling
The checkerboard pattern used in transparency backgrounds was sometimes misaligned with the grid. This happened because it was incorrectly anchoring the pattern to the clipped rect instead of the global grid of the underlying paint target.
2021-05-15LibGfx/Vector*: Implement FormattersJelle Raaijmakers
2021-05-13LibGfx+Demos: Make Matrix4x4 a true alias for Matrix<4,T>Stephan Unverwerth
Matrix4x4 was defined as a derived class of Matrix<N,T> before. Furthermore, some code was duplicated and it was overall just messy. This commit turns Matrix4x4 into a simple alias for Matrix<4,T>.
2021-05-13LibGfx: Make Matrix class consistently row-majorStephan Unverwerth
Matrix elements were interpreted in different ways. This makes it definitely row-major, allowing initialization via initializer list in a standard scientific order. Also matrix multiplication now happens in the correct order and accessing elements happens as m_elements[row][column].
2021-05-13LibGfx: Add Vector2 classStephan Unverwerth
2021-05-13LibGfx: Add component wise * and / operators to Vector3 and Vector4Stephan Unverwerth
2021-05-11LibGfx: Implement Bitmap::cropped()Valtteri Koskivuori
This cuts a region of a bitmap specified by the provided Gfx::IntRect and returns it. Areas outside of the bounds of the original bitmap are filled in with black.
2021-05-10WindowServer: Compute final window title before passing to WM clientsAndreas Kling
We were not substituting the window modified marker ("[*]") in the title strings we were sending to WM clients. This caused the Taskbar to show pre-substitution window titles for the Text Editor application. This patch moves the window title resolution to Window::compute_title() which is then used throughout.
2021-05-09LibGfx: Fix clipping in fill_ellipseEgor Ananyin
fill_ellipse used to clip the bounding box, so instead of drawing a part of an ellipse it drew a smaller ellipse. This commit fixes this behaviour.
2021-05-09LibGfx: Change "white_space" => "whitespace"Andreas Kling
Whitespace is one word. :^)
2021-05-08LibGfx: Constexpr Matrices and VectorsHendiadyoin1
2021-05-08LibGfx: Add some missing operators to Vector3 Vector4 and Matrix4x4Stephan Unverwerth
2021-05-08LibGfx: Add Vector4 classStephan Unverwerth
2021-05-08LibGfx: Mark Vector3 class finalStephan Unverwerth
2021-05-07LibGfx: Convert StringBuilder::appendf() => AK::FormatAndreas Kling
2021-05-03Revert "LibGfx: Add directional floating-point scaling to Painter"Andreas Kling
This reverts commit ff76a5b8d2e4dfe007c20a1376cb6862a2c2dbe0.
2021-05-03Revert "LibGfx: Re-add missing bounds-checks to Painter::draw_rect"Andreas Kling
This reverts commit 4cf5514672409dcec11a4069b075f996a30e93cb.
2021-05-03LibGfx: Re-add missing bounds-checks to Painter::draw_rectMatthew Olsson
This commit adds a draw_physical_line method, which is the exact same as draw_line, except it's parameters are already transformed and scaled. This is used by both draw_line and draw_rect, as a slight optimization to save some work. It also fixed draw_rect not checking whether it should draw the lines before drawing them.
2021-05-02LibGfx: Add scaling methods to BitmapMatthew Olsson