Commit graph

290 commits

Author SHA1 Message Date
devashish
4d7ba50dc7 JPGLoader: Move bogus JPEGs to a different directory 2020-11-29 16:22:04 +01:00
devashish
f107c70652 JPGLoader: Use HashMap instead of Vector for storing components
The JPEG spec allows component IDs to be chosen arbitrarily from the
interval [0, 255]. Storing components in a vector corrupts the decoder
when component IDs are not in the range 0-3. Normally, encoders don't
use IDs outside of that range because JPEG doesn't support more than
4 channels. But since there is a chance that a spec compliant JPEG
would have component IDs outside of [0-3], we should consider replacing
the vector, which enforces serial component access based on component
IDs, with a HashMap<u8, ComponentSpec>.
2020-11-29 16:22:04 +01:00
Nico Weber
ec4c2f971b Lagom: Make BMP fuzzer look like the other image loader fuzzers 2020-11-26 09:59:46 +01:00
BenJilks
216385084b LibGfx: Add BMPWriter
This utility allows you to create a BMP file from a bitmap
2020-11-22 16:07:00 +01:00
Nico Weber
700fe315cf LibGfx: Make some GIFLoader magic numbers a bit less magic
No behavior change.
2020-11-20 21:17:58 +01:00
Nico Weber
967c82c1be LibGfx: Put GIFLoader logging behind GIF_DEBUG 2020-11-20 21:17:58 +01:00
Nico Weber
ebfc21509a LibGfx: De-constexpr Gamma.h
__builtin_sqrtf() isn't constexpr in clang.
2020-11-20 21:17:58 +01:00
Sahan Fernando
1b9a85e4f1 LibGfx: Use gamma-corrected interpolation for color gradients
Switch over to gamma-aware interpolation. This causes color gradients
to not look so dark in the middle. SIMD optimized code is provided for
sse1 enabled builds.

Fixes #1342.
2020-11-19 21:24:20 +01:00
Nico Weber
7042490e41 LibGfx: Bounds check component indices before using them in JPGLoader
With this, I don't see any crashes in 10 min of fuzzing (but still
get OOMs).
2020-11-19 21:21:45 +01:00
Nico Weber
a8318b15a7 LibGfx: Check for read failures after every read in jpg loader
This doesn't fix all the issues found by the fuzzer, but it fixes
many of them. When running this

    Meta/Lagom/Fuzzers/FuzzJPGLoader -jobs=24 -workers=24 \
        ../Base/res/html/misc/jpgsuite_files/

for 10 minutes on my machine, the fuzzer foudn 2 crashers, but after
this change it finds just ... 2. But with different stacks!

This just fixes ASSERT()s, so it's not security critical, but
ASSERT()s still crash the programs decoding JPGs, and crashing
less is nice even if it's not a security concern.
2020-11-19 21:21:45 +01:00
Nico Weber
129a0666cb LibGfx: Put remaining jpg logging behind JPG_DEBUG
...except for one happy-case log line which is removed wholesale.
2020-11-19 21:21:45 +01:00
Nico Weber
3749e167b4 LibGfx: Move JPGLoader to a more regular JPG_DEBUG macro as used elsewhere 2020-11-19 21:21:45 +01:00
Nico Weber
9ea709e1f3 LibGfx: Put PPM logs behind (default-off) PPM_DEBUG 2020-11-19 14:04:35 +01:00
Andreas Kling
9ffdb71111 LibGfx: Don't leak malloc memory in cloned fonts
Fixes #4083.
2020-11-15 11:35:07 +01:00
Linus Groh
5b68ea8dde LibGfx: Make Bitmap path handling case insensitive
Bitmap::is_path_a_supported_image_format() and Bitmap::load_from_file()
now check the file extension with CaseSensitivity::CaseInsensitive.

This fixes a couple of inconsistencies, for example would
FileSystemModel::icon_for() recognize image files uppercase extensions
but couldn't create thumbnails for them (any attempt to create a bitmap
from such files would fail).
2020-11-14 10:11:26 +01:00
Andreas Kling
69518bd178 LibGfx: Fail PPM decode if there's not enough pixel data in the input
Fixes #3820.
2020-11-13 12:01:32 +01:00
Andreas Kling
f234b8c129 LibGfx: Add missing stream error handling in GIF frame descriptor parse
If we try to read a sentinel byte but the stream is fresh out of data,
we have to take care of the stream error and bail out right away, or
we'll hit an assertion when exiting the function soon after.

Fixes #3486.
2020-11-13 12:01:29 +01:00
Andreas Kling
c0aa455f76 LibGfx: Refuse to decode PNG images with geometry outside i32 bounds
Just fail the decode immediately when encountering an IHDR chunk with
width and/or height larger than the maximum i32 value.

Fixes #3818.
Fixes #3819.
2020-11-13 12:01:25 +01:00
AnotherTest
705ad670f3 LibGfx: Add methods to serialise and deserialise a Bitmap
Unlike `to_shared_buffer()` and co, these methods do *not* require extra
metadata about the bitmap.
2020-11-08 21:46:13 +01:00
Peter Nelson
e23daa90a3 LibGfx: remove debug printfs from GIFLoader 2020-11-08 21:40:47 +01:00
Peter Nelson
fa57083552 LibGfx: gracefully handle GIFs with frame decode errors
GIFLoader now tracks the state of errors during the decoding process
and will fall back to displaying the first frame of the GIF if any of
the subsequent frames fail to decode.
2020-11-08 21:40:47 +01:00
Andreas Kling
508063ef85 LibGfx: Remove debug spam about successful font lookups 2020-11-07 14:23:31 +01:00
Andreas Kling
70eaadc1cd LibGfx: Load the system default fonts by name
Instead of loading them by absolute path, that is.
2020-11-04 21:21:52 +01:00
Brendan Coles
fb5ea8a212 WindowServer+LibGfx: Add Gfx::StandardCursor::Hidden cursor 2020-11-02 20:58:07 +01:00
Andreas Kling
ee21a724c7 LibGfx: Add some more assertions to Gfx::Bitmap
Let's also be paranoid about get_pixel() since we started worrying
about set_pixel(). :^)
2020-11-02 11:01:00 +01:00
Peter Nelson
23c4f1a3d4 LibGfx: assert Bitmap::set_pixel does not write out of bounds 2020-11-01 20:13:25 +01:00
Peter Nelson
5567408bab LibGfx: add bounds checking before set_pixel call in GIF decoder
This fixes a crash when a GIF frame extends beyond the limits of the
logical screen, causing writes past the end of the frame buffer
2020-11-01 20:13:25 +01:00
Andreas Kling
982e066100 LibGfx: Move FontDatabase from LibGUI to LibGfx
Not sure why I put this into LibGUI in the first place.
2020-10-31 13:56:21 +01:00
Uma Sankar Yedida
9ccae7a908 WindowServer+LibGfx: Added Crosshair cursor 2020-10-30 19:10:15 +01:00
Andreas Kling
3ec19ae4b6 LibGUI+LibGfx+WindowServer: Auto-generate disabled action icons :^)
This patch adds a simple filter that makes button and menu item icons
have that "'90s disabled" look when disabled. It's pretty awesome.
2020-10-27 21:25:40 +01:00
Andreas Kling
b7dfa83223 LibGUI+LibGfx: Improve focus rect appearance
Draw a dotted focus rect to make it stand out more. Also make it much
larger on regular text-only GUI::Buttons.
2020-10-26 21:01:45 +01:00
Nico Weber
63dcd59fa5 LibGfx: Make Color formattable 2020-10-26 18:55:36 +01:00
Andreas Kling
9d347352a1 LibGfx+LibGUI+Clients: Make fonts findable by their qualified name
The qualified name of a font is "<Family> <Size> <Weight>". You can
get the QN of a Font via the Font::qualified_name() API, and you can
get any system font by QN from the GUI::FontDatabase. :^)
2020-10-25 21:18:18 +01:00
Andreas Kling
b1eeb15129 LibGfx: Handle TextAlignment::BottomRight in do_draw_text() 2020-10-25 11:50:38 +01:00
Andreas Kling
80b77cec38 LibGfx+FontEditor+Fonts: Add family, size and weight metadata to fonts
This makes finding fonts from the same family much less difficult. :^)
2020-10-25 10:12:03 +01:00
Andreas Kling
5abc03db0d Fonts: Rename font files consistently
Font files are now all named like this:

    <Family><Weight><Size>.font

This will make it much easier/sane to perform font lookup.
2020-10-25 10:12:03 +01:00
Andreas Kling
20ca3d4a99 LibGfx+WindowServer: Handle taller window title fonts better
If the window title font is taller than the theme's specified title
height, compute the title height based on the font instead. :^)
2020-10-24 00:26:13 +02:00
Andreas Kling
3c5da01f94 LibGUI+LibGfx+Base: Make tooltips color theme aware :^)
Also tweak the default tooltip color to be more bright and yellow!
2020-10-23 12:01:14 +02:00
Andreas Kling
9f118e3a26 LibGfx: Filled checked toolbar buttons with a dither pattern
This makes them stand out a bit from buttons that are being pressed
(but not checked.)
2020-10-23 11:37:35 +02:00
Tom
a823d2a962 LibGfx: Add colors for highlight-searching to palette and themes 2020-10-22 15:23:45 +02:00
Tom
f239fbaa58 LibGfx: Reduce code duplication in Painter::draw_text
Use the same logic for all variants for Painter::draw_text. Also,
add an overload that allows taking a callback function for custom
gylph drawing. This allows drawing some glyphs differently in the
correct location when drawing more complex strings (e.g. multi-line,
elisions, etc).
2020-10-22 15:23:45 +02:00
Lenny Maiorani
d1fe6a0b53
Everywhere: Redundant inline specifier on constexpr functions (#3807)
Problem:
- `constexpr` functions are decorated with the `inline` specifier
  keyword. This is redundant because `constexpr` functions are
  implicitly `inline`.
- [dcl.constexpr], §7.1.5/2 in the C++11 standard): "constexpr
  functions and constexpr constructors are implicitly inline (7.1.2)".

Solution:
- Remove the redundant `inline` keyword.
2020-10-20 18:08:13 +02:00
Matthew L. Curry
5d5c32cec1 Style: Remove uses of NULL, substituting nullptr 2020-10-13 13:52:52 +02:00
AnotherTest
93f4388e45 LibGfx+PixelPaint: Fix distortions in convolutions with size != 4 or 5 2020-10-12 20:04:48 +02:00
Tom
95434d70ed LibGfx: Allow specifying a separate source bitmap for Filter::apply
By allowing to specify a separate source bitmap when calling Filter::apply
the same filter can be applied to multiple areas, and also doesn't need
to use a temporary bitmap. This also enables us to apply the filter to
multiple regions properly, even if they are (almost) adjacent.

If no separate source bitmap is supplied then a temporary bitmap is still
necessary.
2020-10-12 20:04:48 +02:00
Tom
6ad6c4ffad LibGfx: Add overloads to Rect's shrink/inflate that accept a Size<T> 2020-10-12 20:04:48 +02:00
Tom
da8d87c297 LibGfx: Make Filter::Parameters more light-weight
By moving the Bitmap and Rect out of Filter::Parameters we can re-use
the parameters more efficiently, allowing the filter to be applied
to many bitmaps without having to re-create the filter every time.
2020-10-12 20:04:48 +02:00
Tom
6188c6e8a3 LibGfx: Add GenericConvolutionFilter::ApplyCache
Add an overload of GenericConvolutionFilter::apply that can be used
with a GenericConvolutionFilter::ApplyCache instance to avoid having
to allocate a temporary bitmap every time the filter is being applied.
2020-10-12 20:04:48 +02:00
Tom
a2bffc850a LibGfx: Add Size::contains 2020-10-12 20:04:48 +02:00
Tom
8af02fc8b3 LibGfx: Move filters from PixelPaint into LibGfx
This allows re-using the same filters outside of PixelPaint.
2020-10-12 20:04:48 +02:00