Commit graph

379 commits

Author SHA1 Message Date
Aliaksandr Kalenik
1e05457cd1 LibGfx: Delete unused paint styles
These are no longer used after we've switched to using Skia.
2024-11-11 02:46:35 +01:00
Pavel Shliak
b4e5afa8d5 LibGfx: Remove OffsetPaintStyle 2024-11-11 00:07:11 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Andreas Kling
127ce32d9e LibGfx: Adjust margin between window title/stripes by 1px
This makes it symmetrical with the margin between window icon/title.
2021-01-11 22:15:09 +01:00
asynts
843ebbd2c3 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
Sahan Fernando
9bf76a85c8 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando
6d97b623cd Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Andreas Kling
04c6245fe8 LibGfx: Fail PBM decode if there isn't enough color data in image
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29417
2021-01-11 19:24:54 +01:00
Andreas Kling
2f3b901f7f AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used.

Instead of having valid/invalid states and storing an error in case
it's invalid, a MappedFile is now always valid, and the factory
function that creates it will return an OSError if mapping fails.
2021-01-10 16:49:13 +01:00
Andreas Kling
f35a723f61 Everywhere: Convert a bunch of dbgprintf() to dbgln() 2021-01-10 10:02:20 +01:00
asynts
938e5c7719 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:

The modifications in this commit were automatically made using the
following command:

    find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09 21:11:09 +01:00
Andreas Kling
92fe63fbec LibGfx: Tolerate PNGs with fewer palette entries than possible
We shouldn't reject indexed palette PNGs just because they have fewer
palette entries than the bit depth allows. Instead, we need to check
for OOB palette accesses and fail the decode *then*.
2021-01-06 01:34:25 +01:00
Andreas Kling
7d5a369ac9 LibGfx: Fail PGM decode if there isn't enough color data in image
If we have less pixel color data than we need to fill the image, just
fail the decode.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29127
2021-01-05 15:14:29 +01:00
Emanuele Torre
ec8577ac3c LibGfx+Ports: Add missing newlines at the end of file. 2021-01-03 17:12:50 +01:00
Andreas Kling
7bb18215cb LibGUI: Use String::formatted() and String::number() more 2021-01-03 15:26:47 +01:00
Andreas Kling
05f5d0dda3 LibGfx: Add Gfx::TextAttributes (and use it in GUI::TextDocumentSpan) 2021-01-02 20:57:43 +01:00
Andreas Kling
0bc8d58c3b LibGfx: Add Gfx::Bitmap::create_shareable(format, size)
This helper allocates a shbuf and returns it wrapped in a Bitmap.
2021-01-02 16:57:31 +01:00
Tom
e21cc4cff6 Kernel: Remove MAP_PURGEABLE from mmap
This brings mmap more in line with other operating systems. Prior to
this, it was impossible to request memory that was definitely committed,
instead MAP_PURGEABLE would provide a region that was not actually
purgeable, but also not fully committed, which meant that using such memory
still could cause crashes when the underlying pages could no longer be
allocated.

This fixes some random crashes in low-memory situations where non-volatile
memory is mapped (e.g. malloc, tls, Gfx::Bitmap, etc) but when a page in
these regions is first accessed, there is insufficient physical memory
available to commit a new page.
2021-01-01 23:43:44 +01:00
Andreas Kling
849e2ded24 LibGfx: Tweak color of checkmark in disabled+checked GUI::CheckBox 2021-01-01 23:08:59 +01:00
Stephan Unverwerth
bb27b212de LibGfx: Introduce provisional font interface
Old font functionality has been moved into BitmapFont
and an abstract Font interface has been introduced to
faciliate further development of TTF font integration.
2020-12-31 23:40:27 +01:00
Linus Groh
bbe787a0af Everywhere: Re-format with clang-format-11
Compared to version 10 this fixes a bunch of formatting issues, mostly
around structs/classes with attributes like [[gnu::packed]], and
incorrect insertion of spaces in parameter types ("T &"/"T &&").
I also removed a bunch of // clang-format off/on and FIXME comments that
are no longer relevant - on the other hand it tried to destroy a couple of
neatly formatted comments, so I had to add some as well.
2020-12-31 21:51:00 +01:00
Andreas Kling
acb87cd164 LibGfx: Remove unnecessary assertion in Painter::draw_pixel() 2020-12-31 12:10:01 +01:00
Andreas Kling
412a91d58f LibGfx: Add Gfx::Font::bold_variant() that does a proper font lookup
We previously had a cached bold variant font in Gfx::Font that was very
haphazardly located by filename pattern. This patches replaces that
mechanism with a proper Gfx::FontDatabase lookup for the same font but
with bold weight (700).
2020-12-31 01:51:18 +01:00
Stephan Unverwerth
b4d1390714 LibGFX: Move default_xxx_font() methods from Font to FontDatabase
When we have an abstract font class it makes no sense to keep
these methods in the Font class.
2020-12-30 20:40:30 +01:00
Stephan Unverwerth
a060b6cefd LibTTF: Fix code after rebase 2020-12-30 20:40:30 +01:00
Srimanta Barua
1e1d2cdedf LibTTF: Initial work on parsing and rasterizing composite glyphs.
This doesn't handle every case yet.
2020-12-30 20:40:30 +01:00
Srimanta Barua
bd354bc2ae LibTTF: Reorganized TTF parsing code into LibTTF 2020-12-30 20:40:30 +01:00
Srimanta Barua
22fbe59126 LibGfx: Address awesomekling's comments on API and codestyle 2020-12-30 20:40:30 +01:00
Srimanta Barua
1931535218 LibGfx: Cut down on magic constants in the TTF parser. 2020-12-30 20:40:30 +01:00
Srimanta Barua
186499cc25 LibGfx: Update Painter's bezier curve drawing algorithm.
The new algorithm is an iterative one with an arbitrary threshold for splitting
curves. It splits curves evenly. This should theoretically be less accurate
than the existing recursive approach, but seems to give subjectively better
results in practice.
2020-12-30 20:40:30 +01:00
Srimanta Barua
0e9fb803c8 LibGfx: Finally render simple TTF outlines. 2020-12-30 20:40:30 +01:00
Srimanta Barua
b70c1fe181 LibGfx: Rasterize simple TTF glyphs. 2020-12-30 20:40:30 +01:00
Srimanta Barua
e3b5d2afeb LibGfx: Load glyph definition from "glyf" table for TTF fonts.
CFF fonts don't have "glyf" or "loca", so this code will need to be
extended to handle them.
2020-12-30 20:40:30 +01:00
Srimanta Barua
675237180f LibGfx: Get glyph ID for codepoint, from the CMAP table. 2020-12-30 20:40:30 +01:00
Srimanta Barua
be1586850d LibGfx: Started working on TTF font parser.
I'm planning to make this a minimal-allocation TTF parser. This will
speed up start-up time for applications, but have some overhead for
rasterizing glyphs. Which should be okay, since rasterized glyph bitmaps
should be cached anyway.

This commit just adds the loading of the HEAD table.
2020-12-30 20:40:30 +01:00
asynts
7e62ffbc6e AK+Format: Remove TypeErasedFormatParams& from format function. 2020-12-30 20:33:53 +01:00
Andreas Kling
13594b7146 LibGfx+AK: Make text elision work with multi-byte characters
This was causing WindowServer and Taskbar to crash sometimes when the
stars aligned and we tried cutting off a string ending with "..." right
on top of an emoji. :^)
2020-12-28 23:54:10 +01:00
Andreas Kling
9af33e2e4b LibGfx: Make Painter::draw_text() interpret StringView as UTF-8 2020-12-28 23:54:10 +01:00
Andreas Kling
105eb8e1bc LibGfx: Add FontDatabase::get(family, size, weight)
This function allows you to look up a font by its exact parameters.
2020-12-28 15:53:10 +01:00
Peter Nelson
476911e1f9 LibGfx: fix OOB access in LZW decoder on bad input
This fixes an issue where a corrupted LZW code can result in the first
element of an empty buffer being accessed.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27863
2020-12-28 15:12:29 +01:00
Andreas Kling
92c073a9d1 LIbGUI+LibGfx: Paint focused push buttons with a heavier look
Draw a heavy shadow frame around focused push buttons for emphasis.
For now I've used the ThreedShadow2 color role as it feels dark enough.
2020-12-28 12:41:26 +01:00
Sahan Fernando
d780e2265d LibC: Fix some incorrect printf usages 2020-12-26 10:05:50 +01:00
Linus Groh
d8899ea65b WindowServer: Validate cursor type in SetWindowCursor message handler
Fixes #4536.
2020-12-25 23:07:06 +01:00
Andreas Kling
edf01803cd LibGfx: Make all image decoders reject image sizes above 16384 pixels
Let's just say no to shenanigans by capping images at 16384 pixels both
wide and tall. If a day comes in the future where we need to handle
images larger than this, we can deal with it then.
2020-12-25 00:19:06 +01:00
Andreas Kling
80ae407d73 LibGfx: Always compute the DIB mask shifts and sizes if needed
The pixel decoding logic later on assumes that if we have DIB masks,
we also have shifts and sizes, so we should make sure they are
always computed.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28237
2020-12-23 20:16:53 +01:00
Andreas Kling
cd046fae44 LibGfx: Fail JPEG decode instead of asserting on bogus start-of-scan
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28628
2020-12-23 19:22:15 +01:00
Andreas Kling
0fc8561029 LibGfx: Catch integer overflows in PNG decoder and fail the decode
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28134&sort=reported&q=serenity
2020-12-23 19:04:12 +01:00
Andreas Kling
491a5f5e34 LibGfx: Avoid a ByteBuffer heap allocation in PNG filtering 2020-12-23 18:06:25 +01:00
Andreas Kling
068615fe5e LibGfx: Reject PNG files with invalid filter/interlace methods
Might as well reject these when parsing the IHDR chunk instead of
continuing to load something invalid.
2020-12-23 15:45:59 +01:00