summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
AgeCommit message (Collapse)Author
2022-11-19LibGfx: Add pure virtual fallible clone() for Fontsthankyouverycool
2022-11-19LibGfx: Move TTF::Rasterizer to its own filesJulian Offenhäuser
The custom TTF path rasterizer is actually generic enough for it to be used for other fonts. To make this more clear, it now lives on its own in the "Font" directory.
2022-11-15LibGfx: Optimize anti-aliased line drawing and strokingTorstennator
This patch optimizes the drawing of aa-lines by rotating the drawn rectangle to the direction where the line points. That enables us to draw non-straight lines with the proper width. If a aa-line is drawn that is infact a straigt line we now dont plot those lines with multipe rectangles across the line - insted we draw straight lines in one go with just one rectangle of proper size. Stroking of lines has been enhanced to take care of the edges between two lines with drawing the stroke till the intersections of two connected lines.
2022-11-15Userland: Properly define IPC::encode and IPC::decode specializationsTimothy Flynn
In order to avoid the base encode/decode methods from being used (and failing a static assertion), we must be sure to declare/define the custom type implementations as template specializations. After this, LibIPC is no longer sensitive to include order.
2022-11-13LibGfx: Don't require the OS/2 table for ttf filesJulian Offenhäuser
This table seems to only exist for OpenType compatibility. There are some font files, including most embedded fonts in PDF documents, that don't include one. For those cases, we now just zero-initialize one to the largest supported size.
2022-11-13LibGfx: Make the ttf parser recognize files with the "true" tagJulian Offenhäuser
2022-11-06Everywhere: Remove redundant inequality comparison operatorsDaniel Bertalan
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
2022-11-02PixelPaint+LibGfx: Allow resizing images and layersjack gleeson
This PR adds resize ability to PixelPaint as per issue 11862. The previous behaviour was to always rescale the canvas when resizing an image. This adds a checkbox to toggle between rescaling, and resizing which blits the existing canvas to the top left of the new, resized canvas. As part of this, a new ScalingMode is added to LibGfx - None.
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-10-27LibGfx+Everywhere: Make DisjointRectSet work for non-int RectsSam Atkins
For convenience, `DisjointIntRectSet` is an alias for `DisjointRectSet<int>`, and is used everywhere for now.
2022-10-27LibGfx: Move DisjointRectSet code into the header fileSam Atkins
This is in preparation for converting it to a template. No changes here, only moving code around.
2022-10-27LibGfx: Correct Line::to_string() outputSam Atkins
This looks like a copy-paste issue from Rect::to_string().
2022-10-27LibGfx: Make formatting of spatial types work with non-int/floatsSam Atkins
Line, Point, Rect, and Size now all have Formatters that will work with any type that itself has a Formatter.
2022-10-25LibGfx: Make Matrix and VectorN more constexpr-friendlyZaggy1024
This allows the copy constructor of Matrix to be called constexpr, which should allow more values to be compile-time calculated. Likewise, VectorN.data() is now constexpr so that it can be compile-time evaluated.
2022-10-24LibGfx: Make Rect::set_{bottom,right}_without_resize() work for non-intSam Atkins
2022-10-23LibGfx: Make parse_rgba_color use the new double parserdavidot
Since this is used by LibWeb when parsing CSS colors we should not use strtod here.
2022-10-22LibGfx: Mark `AffineTransform<T>::map()` as only working for numeric `T`Sam Atkins
The implementations for these methods is manually defined in the .cpp file for `int` and `float`, meaning that other `T` values would fail - but only once we got to the linking stage. This patch makes the error happen much earlier, so it's more obvious.
2022-10-22LibGfx: Make `Rect<T>` methods work when `T` is not `int` or `float`Sam Atkins
Putting the implementations in the .cpp file meant that they only existed for `IntRect` and `FloatRect`, since those were instantiated at the bottom of the file. Now they work for other types. :^) A couple of places in WindowServer had to be modified to disambiguate between the two `Rect::intersected()` overloads. Co-authored-by: davidot <davidot@serenityos.org>
2022-10-14LibGfx: Implement flood fill algorithm in Bitmap classTimothy Slater
This change implements a flood fill algorithm for the Bitmap class. This will be leveraged by various Tools in PixelPaint. Moving the code into Bitmap reduces the duplication of the algorithm throughout the PixelPaint Tools (currently Bucket Tool and Wand Select). The flood fill function requires you to pass in a threshold value (0 - 100) as well as a lambda for what to do when a pixel gets reached. The lambda is provided an IntPoint representing the coordinates of the pixel that was just reached. The genericized lambda approach allows for a variety of things to be done as the flood algorithm progresses. For example, the Bucket Tool will paint each pixel that gets reached with the fill_color. The Wand Select tool wont actually alter the bitmap itself, instead it uses the reached pixels to alter a selection mask.
2022-10-10Userland: Remove unecessary uses of __serenity__ macroAndrew Kaster
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-10-10LibGfx: Add TintFilterMacDue
This is a very simpler filter that tints an image with a color.
2022-10-07LibGfx: Remove unnecessary divides in MatrixFilterMacDue
2022-10-07LibGfx: Implement SaturateFilterMacDue
This implements the saturate operation as defined in the SVG filter specification. (https://drafts.fxtf.org/filter-effects-1/#feColorMatrixElement)
2022-10-07LibGfx: Add MatrixFilter and convert HueRotateFilter to be oneMacDue
This moves the apply a matrix operation to each [r,g,b] vector in an image to a general class.
2022-10-06LibGfx: Make should_wrap flag default as true on convolution filtersluiz
Currently the default is false, but this is not the best strategy for most filters producing artifacts on the borders, and wrap-around option ends up being better, producing less artifacts.
2022-10-04AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most placesNico Weber
Doesn't use them in libc headers so that those don't have to pull in AK/Platform.h. AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is defined in clang builds as well.) Using AK_COMPILER_GCC simplifies things some. AK_COMPILER_CLANG isn't as much of a win, other than that it's consistent with AK_COMPILER_GCC.
2022-10-04LibGfx: Remove a workaround for clang before 11Nico Weber
This bug has long been fixed.
2022-10-02LibGfx: Implement HueRotateFilterMacDue
This implements a simple and fairly efficient hue rotation filter. It is based off the SVG feColorMatrix "hueRotate" matrix operation. https://drafts.fxtf.org/filter-effects-1/#elementdef-fecolormatrix
2022-10-02LibGfx: Add `[[nodiscard]]` to Matrix operatorsMacDue
2022-10-02LibGfx: Add Matrix::operator*(T scalar)MacDue
2022-10-02LibGfx: Add Matrix::operator+(Matrix const & other)MacDue
2022-10-02LibGfx: Add a way to get the Painter's current 2D translationAndreas Kling
2022-09-24LibGfx: Fix affine transformations in TrueType composite glyphsItamar
This fixes an issue where, when looping over the components of a composite glyph, we used to mutate the affine transformation of the glyph itself when computing the transformations of its components. (AffineTransform::multiply() is non-const).
2022-09-24LibWeb+LibGfx: Move the blit image through 2D transfrom to Gfx::PainterAndreas Kling
Even though this code is obnoxiously slow, it still belongs in LibGfx and should not be hidden away in LibWeb's CanvasRenderingContext2D.
2022-09-18Libraries: Add missing includes, add namespace qualifiersBen Wiederhake
This remained undetected for a long time as HeaderCheck is disabled by default. This commit makes the following file compile again: // file: compile_me.cpp #include <LibDNS/Question.h> // That's it, this was enough to cause a compilation error. Likewise for most other files touched by this commit.
2022-09-17Everywhere: Fix badly-formatted includesBen Wiederhake
2022-09-16LibC: Remove the LibM interface targetTim Schumacher
2022-09-16LibGfx: Change Emoji::emoji_for_code_points to accept const code pointsTimothy Flynn
Span<u32 const> is the type used when converting a constant Vector<u32> to a Span.
2022-09-16LibGfx: Recurse TrueType composite glyphs until a simple glyph is foundEnver Balalic
This fixes a bug in ladybird where it was crashing while rendering characters like ščćž in the Noto Sans Regular font. That font renders those characters as a composite where the caret has numberOfContours = -1. When using the rasterize_impl simple path for that, it would negatively overflow the offsets.
2022-09-16LibGfx: Support getting a bitmap for a region of painterMacDue
This will be needed so we can apply filter effects to the backdrop of an element in LibWeb. This now also allows getting a crop of a bitmap in a different format than the source bitmap. This is for if the painter's bitmap does not have an alpha channel, but you want to ensure the cropped bitmap does.
2022-09-16LibGfx: Add `BrightnessFilter`, `ContrastFilter`, and `OpacityFilter`MacDue
These filters are based off the ones defined in: https://drafts.fxtf.org/filter-effects-1/#supported-filter-functions
2022-09-16LibGfx: Allow applying all color filters with an amountMacDue
This amount can be handled in the filter's implementation or if not it will default to mixing between the new and previous pixel. This behaviour is used for implementing CSS filters that allow stuff like grayscale(70%).
2022-09-16LibWeb+LibGfx: Move premultiplied alpha mixing to color.mixed_with()MacDue
This will be needed for mixing filters in LibGfx (and may be generally useful elsewhere).
2022-09-15LibGfx: Cache vector fonts by family nameAndreas Kling
Instead of just keeping them in an unsorted Vector, which led to increasingly noticeable O(n) lookups, we now cache a list of Typefaces per family name.
2022-09-14LibGfx: Use `memcpy` instead of `fast_u32_copy` for blittingJelle Raaijmakers
In some artificial full screen blitting profiling, I've seen `memcpy` take up about 4% fewer samples each time I measure. It seems like `fast_u32_copy` is not as fast as it'd like to believe.
2022-09-14Everywhere: Fix a variety of typosBrian Gianforcaro
Spelling fixes found by `codespell`.
2022-09-11LibGfx: Templatize `VectorN::length()`Jelle Raaijmakers
This allows us to get a `float` length from an `IntVector3` without needing to convert to `FloatVector3` first.
2022-09-08LibGfx: Add API for loading more directories into Gfx::FontDatabaseAndreas Kling
Also make the font discovery algorithm search subdirectories as well. This will be used by Ladybird to discover more fonts on non-Serenity systems. :^)
2022-09-06LibGfx: Correctly shift pixels during bilinear blendJelle Raaijmakers
Our bilinear scaling logic worked well for upscaling, but during downscaling the bitmap was often shifted one pixel to the bottom right. This is a common problem, described here in more detail: https://bartwronski.com/2021/02/15/bilinear-down-upsampling-pixel-grids-and-that-half-pixel-offset/ Fix it by calculating coordinate shift values that align the pixel's boundaries between the source and target pixels before selecting the source pixels to interpolate.