summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Painter.h
AgeCommit message (Collapse)Author
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-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 directional floating-point scaling to PainterMatthew Olsson
This allows the painter to be scaled separately in both directions, and not just in integer intervals. This is crucial for proper SVG viewBox support. Most bitmap-related things verify the scale to be one as of now.
2021-05-02LibGfx: Unify Rect, Point, and SizeMatthew Olsson
This commit unifies methods and method/param names between the above classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where appropriate. It also renamed the various move_by methods to translate_by, as that more closely matches the transformation terminology.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-11LibGUI+LibGfx: Collapse the '&' from Alt shortcuts in tooltip textsAndreas Kling
Also resolve a FIXME about using GUI::Label auto-sizing since we're changing this code and it simplifies what we're doing. Fixes #6219.
2021-04-09LibGfx: Add a Gfx::TextAlignment parameter to Painter::draw_ui_text()Andreas Kling
2021-04-09LibGfx: Adjust parameter order for Painter::draw_ui_text()Andreas Kling
Let's put the rect first so it's the same as draw_text().
2021-04-05LibGfx: Add Gfx::Painter::draw_ui_text()Andreas Kling
This function draw text while interpreting "&" as "underline the next character" and "&&" as "&".
2021-03-06LibWeb: Make CSS background image painting respect destination origin and ↵Mihai Parparita
transparency It was previously using draw_tiled_bitmap, which always aligns the tiles with the global origin and does not respect the alpha of the source. Switch to a new Painter::blit_tiled helper which uses Painter::blit under the hood, which has more correct behavior.
2021-02-25LibGUI: Improve IconView rubberband performanceTom
Rather than invalidating the entire window, which is very expensive on the transparent desktop widget, just invalidate the areas that actually need updating.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-13LibGfx: Enable Painter::blit to apply opacity and mix alpha channelsTom
This enables us to properly render windows that use both opacity and alpha channels.
2021-02-09WindowServer: Implement simple window shadowsTom
This implements simple window shadows around most windows, including tooltips. Because this method uses a bitmap for the shadow bits, it is limited to rectangular window frames. For non-rectangular window frames we'll need to implement a more sophisticated algorithm.
2021-01-22LibGfx: Add a draw_scaled_bitmap() variant that takes a FloatRect as src_rectNico Weber
Consider draw_scaled_bitmap({0, 0, 10, 10}, source, {0, 0, 5, 5}). Imagine wanting to split that up into two calls, like e.g. the compositor when redrawing the background with damage rects. You really want to be able to say draw_scaled_bitmap({0, 0, 5, 10}, source, {0, 0, 2.5, 5}) but up to now you couldn't. Now you can. This makes painting very low-res images (such as tile.png) in mode "stretch" work much better.
2021-01-22LibGfx: Remove Painter::blit_scaled() in favor of Painter::draw_scaled_bitmap()Nico Weber
draw_scaled_bitmap() has a clearer API (just source and dest rects -- blit_scaled() took those and scale factors and then ignored width and height on the source rect and it was less clear what it was supposed to do), and they do mostly the same thing. The draw_scaled_bitmap() API takes an IntRect as source rect, so it's currently not always possible to split a big draw_scaled_bitmap() into two (or more) smaller draw_scaled_bitmap() calls that do the same thing -- that'd require FloatRects. The compositor kind of wants this to be possible, but there's already a FIXME about this not looking quite right with the previous approach either. draw_scaled_bitmap() handles transparent sources, so after this change wallpapers with transparency will be blended instead of copied. But that seems fine, and if not, the Right Fix for that is to remove the alpha channel from wallpapers after loading them anyways. As an added bonus, draw_scaled_bitmap() already handles display scale, so this fixes window server asserts for background images that are shown as "stretch" (#5017). The window server still asserts for "tile" and "offset" for now though. Calling draw_scaled_bitmap() here exposed a bug in it fixed by #5041. Before that is merged, this change here will cause smearing on the background image when moving windows around.
2021-01-20LibGfx/Painter: Keep translation and clip_rect in logical coordinatesNico Weber
Moves Painter away from general affine transport support a bit, but this scale factor business does feel like it's a bit different. This is conceptually cleaner (everything should use logical coordinates as much as possible), and it means the code in GUI::Painter() will work without changes due to that, but the draw function implementations overall get a bit murkier (draw_rect() becomes nicer though). Still, feels like the right direction. No behavior change.
2021-01-20LibGfx: Give Bitmap a scale factorNico Weber
Gfx::Bitmap can now store its scale factor. Normally it's 1, but in high dpi mode it can be 2. If a Bitmap with a scale factor of 2 is blitted to a Painter with scale factor of 2, the pixels can be copied over without any resampling. (When blitting a Bitmap with a scale factor of 1 to a Painter with scale factor of 2, the Bitmap is painted at twice its width and height at paint time. Blitting a Bitmap with a scale factor of 2 to a Painter with scale factor 1 is not supported.) A Bitmap with scale factor of 2 reports the same width() and height() as one with scale factor 1. That's important because many places in the codebase use a bitmap's width() and height() to layout Widgets, and all widget coordinates are in logical coordinates as well, per Documentation/HighDPI.md. Bitmap grows physical_width() / physical_height() to access the actual pixel size. Update a few callers that work with pixels to call this instead. Make Painter's constructor take its scale factor from the target bitmap that's passed in, and update its various blit() methods to handle blitting a 2x bitmap to a 2x painter. This allows removing some gnarly code in Compositor. (In return, put some new gnarly code in LibGfxScaleDemo to preserve behavior there.) No intended behavior change.
2021-01-17LibGfx: Make Painter take the scale factor as constructor argumentNico Weber
I want to give Bitmap an intrinsic scale factor and this is a step in that direction. No behavior change.
2021-01-15LibGfx: Make Painter::draw_rect() scale-awareNico Weber
Needed for the window server minimize animation. draw_rect() can't just call draw_line() because that isn't draw_op()-aware. The draw_op()-awareness in Painter looks a bit ad-hoc, but that's for another day.
2021-01-12LibGfx: Make it possible to apply an (integer) scale to a PainterNico Weber
This adds a scale factor to Painter, which will be used for HighDPI support. It's also a step towards general affine transforms on Painters. All of Painter's public API takes logical coordinates, while some internals deal with physical coordinates now. If scale == 1, logical and physical coordinates are the same. For scale == 2, a 200x100 bitmap would be covered by a logical {0, 0, 100, 50} rect, while its physical size would be {0, 0, 200, 100}. Most of Painter's functions just assert that scale() == 1 is for now, but most functions called by WindowServer are updated to handle arbitrary (integer) scale. Also add a new Demo "LibGfxScaleDemo" that covers the converted functions and that can be used to iteratively add scaling support to more functions. To make Painter's interface deal with logical coordinates only, make translation() and clip_rect() non-public.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling