Commit Graph

192 Commits

Author SHA1 Message Date
Tobias Christiansen
bd2b17a70e LibGfx: Replace ellipse drawing algorithm
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-23 18:28:27 +02:00
Marcus Nilsson
ee48dac300 Bitmap: Don't call Bitmap::create with width/height equal to 0
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-22 13:26:08 +02:00
Tobias Christiansen
155d876c44 LibGfx: Support alpha in rendering methods for border-radius
The methods used in displaying border-radius were ignoring alpha.
2021-05-22 00:21:02 +02:00
Andreas Kling
bb23e61fbf LibGfx+WindowServer: Have WindowServer broadcast system font settings
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-21 20:15:51 +02:00
Linus Groh
d60ebbbba6 Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96.

Booting the system no longer worked after these changes.
2021-05-21 10:30:52 +01:00
Lenny Maiorani
800ea8ea96 Userland: static vs non-static constexpr variables
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-21 10:07:06 +01:00
Linus Groh
9dd3203cc6 LibGfx: Add missing TextAlignment::BottomLeft 2021-05-21 08:04:31 +02:00
Andreas Kling
1150e9fe79 LibGfx: Remove unused current_system_theme() function 2021-05-20 22:12:42 +02:00
Tobias Christiansen
8b63c2a10e LibGfx: Add Painter::draw_circle_arc_intersecting()
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-20 22:08:02 +02:00
Tobias Christiansen
819e0e0440 LibGfx: Add Painter::fill_rect_with_rounded_corners()
This paints a rectangle with rounded corners each specified by a
radius.
2021-05-20 22:08:02 +02:00
Andreas Kling
8a6c37deef LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20 20:55:29 +02:00
Andreas Kling
6a012ad79f LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
2021-05-20 20:55:29 +02:00
Gunnar Beutner
d954c11f66 Everywhere: Add missing includes for <AK/OwnPtr.h>
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-19 21:36:57 +02:00
Matthew Olsson
fbe712e265 LibGfx: Rename RotationDirection members
Left => CounterClockwise
Right => Clockwise

Makes much more sense for a rotation
2021-05-18 16:35:23 +02:00
stelar7
24c5b0e81c LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
Linus Groh
0aab774343 Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
Gunnar Beutner
24376e7759 LibGfx: Avoid copying ByteBuffers while loading PNG images
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-16 17:49:42 +02:00
Andreas Kling
07850ccf51 LibGfx: Fix incorrect origin for checkerboard pattern fills
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-15 11:21:55 +02:00
Jelle Raaijmakers
5864aab87a LibGfx/Vector*: Implement Formatters 2021-05-15 00:41:30 +01:00
Stephan Unverwerth
c2d84efaae LibGfx+Demos: Make Matrix4x4 a true alias for Matrix<4,T>
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-13 22:24:42 +02:00
Stephan Unverwerth
0833db0874 LibGfx: Make Matrix class consistently row-major
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-13 22:24:42 +02:00
Stephan Unverwerth
aff6426000 LibGfx: Add Vector2 class 2021-05-13 08:34:26 +02:00
Stephan Unverwerth
077c340ea2 LibGfx: Add component wise * and / operators to Vector3 and Vector4 2021-05-13 08:34:26 +02:00
Valtteri Koskivuori
cb74f7992a LibGfx: Implement Bitmap::cropped()
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-11 10:18:29 +01:00
Andreas Kling
353a831c8c WindowServer: Compute final window title before passing to WM clients
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-10 00:02:05 +02:00
Egor Ananyin
782dc348fd LibGfx: Fix clipping in fill_ellipse
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-09 16:14:01 +01:00
Andreas Kling
6998fa5c54 LibGfx: Change "white_space" => "whitespace"
Whitespace is one word. :^)
2021-05-09 09:59:22 +02:00
Hendiadyoin1
1424c4651f LibGfx: Constexpr Matrices and Vectors 2021-05-08 10:13:22 +02:00
Stephan Unverwerth
09f850728a LibGfx: Add some missing operators to Vector3 Vector4 and Matrix4x4 2021-05-08 10:13:22 +02:00
Stephan Unverwerth
0c5d61ae88 LibGfx: Add Vector4 class 2021-05-08 10:13:22 +02:00
Stephan Unverwerth
b0e5e78a01 LibGfx: Mark Vector3 class final 2021-05-08 10:13:22 +02:00
Andreas Kling
eb05931ab5 LibGfx: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Andreas Kling
381dcca2f6 Revert "LibGfx: Add directional floating-point scaling to Painter"
This reverts commit ff76a5b8d2.
2021-05-03 16:37:05 +02:00
Andreas Kling
f43adb816e Revert "LibGfx: Re-add missing bounds-checks to Painter::draw_rect"
This reverts commit 4cf5514672.
2021-05-03 16:36:57 +02:00
Matthew Olsson
4cf5514672 LibGfx: Re-add missing bounds-checks to Painter::draw_rect
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-03 08:19:39 +02:00
Matthew Olsson
790908ffc3 LibGfx: Add scaling methods to Bitmap 2021-05-02 22:48:06 +02:00
Matthew Olsson
4233b69ecf Color: Add interpolate method 2021-05-02 22:48:06 +02:00
Matthew Olsson
ff76a5b8d2 LibGfx: Add directional floating-point scaling to Painter
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-02 22:48:06 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
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-05-02 22:48:06 +02:00
Matthew Olsson
ac238b3bd6 LibGfx: Add some helper methods to AffineTransform
Also makes some basic getters ALWAYS_INLINE and [[nodiscard]], as well
as fixing as error with the map method.
2021-05-02 22:48:06 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Andreas Kling
20dd5735ce WindowServer+LibGfx: Automatic "modified" markers in window titles
You can now add the string "[*]" to a window title and it will be
replaced with " (*)" if the window is modified, and with "" otherwise.
2021-05-01 19:42:29 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Idan Horowitz
115b445dab LibGfx: Add basic support for bidirectional text rendering
This adds a *very* simplified version of the UNICODE BIDIRECTIONAL
ALGORITHM (https://www.unicode.org/reports/tr9/), that can render most
bidirectional text but also produces awkward results in a large amount
of edge cases, and as such, this should probably be replaced with a
fully spec compliant implementation at some point.
2021-04-29 10:36:23 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Linus Groh
5459c744f1 Everywhere: Add missing comma between copyright year and name 2021-04-29 00:59:26 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
thankyouverycool
cc7744f6ca LibGfx+FontEditor: Account for raw width when painting glyphs
Fixes hidden glyphs being painted in editor and map, and '?'
subsitute glyphs being overdrawn in the system.
2021-04-23 11:08:11 +02:00
Matthew Olsson
fcd3b9a0df Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00