Age | Commit message (Collapse) | Author |
|
|
|
|
|
This alternate_color can be used when drawing dashed lines to have two
alternating Colors.
|
|
m_data.size() returns a size_t which is a 64-bit type on x86_64. This
resulted in us incorrectly using zero in the PNG header.
|
|
|
|
|
|
|
|
The issue was that size_in_bytes() returns size_t, but the buffer used
a size of the unsigned for itself, which only matched on 32-bit
systems and caused an assert error otherwise.
This fixes a crash on drag in FileManager on non 32-bit systems!
|
|
LibTTF has a concrete dependency on LibGfx for things like Gfx::Bitmap,
and LibGfx has a concrete dependency in the TTF::Font class in
Gfx::FontDatabase. This circular dependency works fine for Serenity and
Lagom Linux builds of the two libraries. It also works fine for static
library builds on Lagom macOS builds.
However, future changes will make Lagom use shared libraries, and
circular library dependencies are not tolerated in macOS.
|
|
Use the new "Accent" color role to emphasize the currently active tab
within a GUI::TabWidget. :^)
|
|
This can be used by GUI widgets to draw attention to a specific part of
the widget, for example the currently active sub-widget component.
|
|
|
|
Without this, a word might be added to a line despite going outside the
rect, due to the glyph spacing between blocks not being considered.
|
|
This was previously required because the whitespace was consumed and
manually added back after the fact, but now that we preserve whitespace,
this breaks wrapping of text with whitespace after it.
|
|
|
|
This converts the TextLayout algorithm from handling just words to
handling blocks of strings. With this model, whitespace is preserved
and inserted as-is, rather than being eaten and then replaced with a
single space (or none, if the whitespace was at the start of the word).
Closes #9032.
|
|
This was breaking many places which didn't expect text to wrap. Now,
the only place where text currently wraps is in GUI::Label.
|
|
To transparently support multi-frame images, all decoder plugins have
already been updated to return their only bitmap for frame(0).
This patch completes the remaining cleanup work by removing the
ImageDecoder::bitmap() API and having all clients call frame() instead.
|
|
Previously, ImageDecoder::create() would return a NonnullRefPtr and
could not "fail", although the returned decoder may be "invalid" which
you then had to check anyway.
The new interface looks like this:
static RefPtr<Gfx::ImageDecoder> try_create(ReadonlyBytes);
This simplifies ImageDecoder since it no longer has to worry about its
validity. Client code gets slightly clearer as well.
|
|
This patch adds a FastBoxBlurFilter to the system. It can be created by
specifying a Bitmap it will work on.
There are two uses implemented:
- apply_single_pass() applys an implementation of a linear-time
box-blur algorithm with the specified radius using a horizontal and a
vertical pass and utilizinga sliding window.
- apply_three_passes() gets a better Gaussian approximation by applying
the filter three times. For this to work the radius of each pass is
calculated to fit Gauss the best.
|
|
This class now contains all the fun bits about laying out text in a
rect. It will handle line wrapping at a certain width, cutting off lines
that don't fit the given rect, and handling text elision.
Painter::draw_text now internally uses this.
Future work here would be not laying out text twice (once actually
preparing the lines to be rendered and once to get the bounding box),
and possibly adding left elision if necessary.
Additionally, this commit makes the Utf32View versions of
Painter::draw_text convert to Utf8View internally. The intention is to
completely remove those versions, but they're kept at the moment to keep
the scope of this PR small.
|
|
This patch changes the semantics of purgeable memory.
- AnonymousVMObject now has a "purgeable" flag. It can only be set when
constructing the object. (Previously, all anonymous memory was
effectively purgeable.)
- AnonymousVMObject now has a "volatile" flag. It covers the entire
range of physical pages. (Previously, we tracked ranges of volatile
pages, effectively making it a page-level concept.)
- Non-volatile objects maintain a physical page reservation via the
committed pages mechanism, to ensure full coverage for page faults.
- When an object is made volatile, it relinquishes any unused committed
pages immediately. If later made non-volatile again, we then attempt
to make a new committed pages reservation. If this fails, we return
ENOMEM to userspace.
mmap() now creates purgeable objects if passed the MAP_PURGEABLE option
together with MAP_ANONYMOUS. anon_create() memory is always purgeable.
|
|
Making a bitmap non-volatile after being volatile may fail to allocate
physical pages after the kernel stole the old pages in a purge.
This is different from the pages being purged, but reallocated. In that
case, they are simply replaced with zero-fill-on-demand pages as if
they were freshly allocated.
|
|
This was a really weird thing to begin with, purgeable bitmaps were
basically regular bitmaps without a physical memory reservation.
Since all the clients of this code ended up populating the bitmaps
with pixels immediately after allocating them anyway, there was no
need to avoid the reservation.
Instead, all Gfx::Bitmaps are now purgeable, in the sense that they
can be marked as volatile or non-volatile.
The only difference here is that allocation failure is surfaced when
we try to create the bitmap instead of during the handling of a
subsequent page fault.
|
|
|
|
This is required by CSS, and implemented based on the CSS standard's
algorithm.
|
|
|
|
|
|
Also mark them as [[nodiscard]].
|
|
|
|
There's no need for this to be a virtual, it's just a font database
lookup and can be done in the Font base class.
|
|
Before this patch, some glyphs had a weird off-by-1 vertical position
which looked really jarring at small font sizes.
This was caused by glyph bitmaps having different heights from each
other. (Each glyph bitmap was minimally sized to fit only the glyph
itself, and then vertically positioned during the paint phase.
Since this vertical positioning was integer based, subpixel precision
was lost and things ended up looking wonky.)
Fix this by making all glyph bitmaps be the same height so we can blit
them at the same integer y position. We use the typographic ascent from
the OS/2 table to transform the glyph coordinates.
The end result is a huge improvement visually. :^)
|
|
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.
Also clean up some stale math includes and improper floatingpoint usage.
|
|
The dither pattern needs to be determined relative to the bitmap
itself, not the clipping rectangle.
Fixes #8780
|
|
Double ampersands (&&) marking in menus is meant to provide a way
to show the ampersand, since using just one would turn it
into a modifier that sets the shortcut for the next character.
Unfortunately, while the first character had a special case to avoid
marking this set, the marking was still calculated
for the second character.
The fix is rather simple: just skip then the following character!
This issue applied only to the visual part of the Menu.
The WindowServer calculation for the shortcut character is working
properly, i.e. ignores escaped ampersands.
|
|
Same vector was cleared up and filled in continuously.
|
|
Before this change PNGWriter::add_chunk used to make a copy of
PNGChunk's ByteBuffer to prepend the size of the data.
With this change, 4-byte space is saved from the beginning and written
at the end of the operation. Avoiding this copy yields significant
speed up.
|
|
|
|
|
|
This is the first step towards reducing the number of copies in
PNGWriter by switching to ByteBuffer as underlying storage.
|
|
This change allows us to select TTF fonts in display settings again :^)
|
|
Thicker lines are drawn by filling rectangles along the path.
Previously these rectangles used the points as their top left corner.
This patch changes it to use the points as the center of the rectangles
which makes the PixelPaint line tool feel a lot more natural. :^)
|
|
|
|
This optimizes the method to no longer compare if width > longest_width
on every iteration, since it's only required on CR/LF or at the end.
|
|
This adds the ALWAYS_INLINE attribute to unicode_view_width. Also, it
cleans up the BitmapFont::view() code a little bit. This should help
performance of this hot code. Because the call to the width() methods is
a virtual dispatch, it doesn't help to inline the width() methods
themselves.
|
|
|
|
|
|
The `float => double => float` round trip seen in a couple of places
might pessimize the code. Even if it's truncated to an int in the end,
it's weird not to use the functions with the `f` suffixes when working
with single precision floats.
|
|
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.
|
|
Previously calculating multiline text width would return invalid value,
this change makes it so that we are returning the longest line width.
We are now also reusing same width() implementation for both UTF-8 and
UTF-32 strings.
|