Commit graph

248 commits

Author SHA1 Message Date
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
Peter Elliott
01bff0141e Piano: Highlight pressed key in roll widget 2020-10-12 19:41:53 +02:00
Matthew Olsson
236eeb6fb1 LibGfx: Add ability to get a bounding box from a Path 2020-10-10 23:28:41 +02:00
asynts
3b601cd4bd LibGfx: Add formatter for Rect. 2020-10-09 20:52:17 +02:00
Luke
52c31bb743 LibGfx+FontEditor+Fonts: Add "mean line" value to all fonts
The main inspiration behind this was to have a correct ex CSS unit.
The mean line is based off what it shows in the CSS Values and Units
Level 4 specification, section 6.1.1.

https://www.w3.org/TR/css-values-4/#font-relative-lengths
2020-10-05 20:05:40 +02:00
Nico Weber
ef1b21004f Everywhere: Fix typos
Mostly in comments, but sprintf() now prints "August" instead of
"Auguest" so that's something.
2020-10-02 16:03:17 +02:00
Tom
7399874479 AK: Add trivial structure validation to SharedBuffer
If we're sharing buffers, we only want to share trivial structures
as anything else could potentially share internal pointers, which
most likely is going to cause problems due to different address
spaces.

Fix the GUI::SystemTheme structure, which was not trivial, which
is now caught at compile time.

Fixes #3650
2020-10-02 15:38:07 +02:00
Luke
c0d9daadb0 LibGfx: Fix cut off CSS color names 2020-09-29 09:20:33 +02:00
Tibor Nagy
7ab04ea31a LibGfx: Add painting transparency grids to StylePainter 2020-09-26 00:00:08 +02:00
Ben Wiederhake
ede5dbd7b3 Meta+LibC through LibHTTP: Make clang-format-10 clean
Why break at LibHTTP? Because "Meta+Libraries" would be insanely large,
and breaking between LibHTTP and LibJS makes the commits roughly evenly large.
2020-09-25 21:18:17 +02:00
Peter Elliott
253ab7536a Base: Add the PlaceholderText attribute to themes 2020-09-21 20:15:10 +02:00
asynts
7d1b22bbb1 LibGfx+JPGLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
d050dede7a LibGfx+ICOLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
0f5b42ac80 LibGfx+GIFLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
5056d8bb20 LibGfx+Font: Use OutputFileStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
Andreas Kling
606c0e1672 LibGfx: Move vertically centered text down slightly based on baseline
To make slightly more aesthetically pleasing use of the vertical space,
we now move all vertically centered text lines down by half the amount
of space below the font's baseline.

This is probably not the "correct" way to do this, but it does make
things look nicer with some of our fonts already.
2020-09-19 19:16:22 +02:00
Andreas Kling
5f8a9d348d LibGfx: Add a helper to check if a TextAlignment is vertically centered 2020-09-19 19:16:22 +02:00
Andreas Kling
95eeb321f9 LibGfx+FontEditor+Base: Add "baseline" value to all fonts
This does nothing at the moment but will soon allow us to improve the
vertical positioning of text.
2020-09-19 19:16:22 +02:00
Andreas Kling
e2f32b8f9d LibCore: Make Core::Object properties more dynamic
Instead of everyone overriding save_to() and set_property() and doing
a pretty asymmetric job of implementing the various properties, let's
add a bit of structure here.

Object properties are now represented by a Core::Property. Properties
are registered with a getter and setter (optional) in constructors.
I've added some convenience macros for creating and registering
properties, but this does still feel a bit bulky. We'll have to
iterate on this and see where it goes.
2020-09-15 21:46:26 +02:00
Andreas Kling
e78cf6c590 LibGfx+LibGUI: Allow setting tab text alignment with set_property() 2020-09-14 19:55:17 +02:00
Andreas Kling
609108f6b3 LibGfx: Remove unused file FloatPoint.h 2020-09-13 21:41:45 +02:00
Peter Nelson
d366e996dd LibGfx: restructure Bitmap ctor to expect an alloc'd backing store
Moves Bitmap backing store creation to the static create() methods.
This backing store is then passed into the Bitmap constructor. This
allows us correctly return nullptr from create() in the event that
memory allocation fails.
2020-09-12 20:26:14 +02:00
Peter Nelson
06eea59a65 LibGfx: return clone from frame() instead of underlying framebuffer
This prevents frame() from modifying the contents of the same bitmap
that was returned from previous calls to frame()
2020-09-12 20:26:14 +02:00
Peter Nelson
16ebbde26f LibGfx: add Bitmap::clone() method 2020-09-12 20:26:14 +02:00
Ben Wiederhake
e3101c74c6 LibGUI: Use new Bitmap::minimum_pitch method
Also, make sure that the painter actually draws on a RGB(A) bitmap.

Closes #3460.
2020-09-12 11:35:41 +02:00
Ben Wiederhake
bd6390d8cb LibGfx: Validate size of incoming shared bitmap
Errors like this became more likely due to the 'optimized' memory usage.
Also, this prevents the WindowServer from being killed by a goofy program
sharing an incomplete bitmap, and likely some other scenarios.
2020-09-12 00:13:29 +02:00
Ben Wiederhake
9c3a33762b LibGfx: Saner memory usage of indexed bitmaps
Indexed bitmaps used to allocate four times the required amount of memory.

Also, we should acknowledge that the underlying data is not always RGBA32,
and instead cast it only when the true type is known.
2020-09-12 00:13:29 +02:00
Ben Wiederhake
d6673b384e LibGfx: Remove redundant bits() method
In all circumstances, this returned exactly the same thing as scanline_u8(),
so let's just remove the silly detour.

This does not add any new dependency on Bitmap-internals, because that already existed.
2020-09-12 00:13:29 +02:00
Ben Wiederhake
e550df6467 LibGfx: Don't blindly trust file-internal offset
This also touches the return type of dib_size(), because kjdsfg
2020-09-12 00:13:29 +02:00
Ben Wiederhake
a098046309 LibGfx: Nicer error reporting for bitmap allocation 2020-09-12 00:13:29 +02:00
Ben Wiederhake
52a797afdb LibGfx: Protect against over-large bitmaps 2020-09-12 00:13:29 +02:00
Andreas Kling
1a2b626746 LibGUI+LibGfx: Move check box painting to Gfx::StylePainter
This will allow us to render check boxes from other places. :^)
2020-09-11 18:42:43 +02:00
Andreas Kling
0f9be82826 LibGfx: Move StandardCursor enum to LibGfx
This enum existed both in LibGUI and WindowServer which was silly and
error-prone.
2020-09-10 19:25:13 +02:00
Devashish Jaiswal
2a3166e523
JPGLoader: Check existence of Huffman tables in scan header segment (#3442)
DC and AC table IDs read in the scan header segment weren't validated
against the IDs of Huffman tables read in the DHT segment. This caused
an OOB read when a Huffman table was accessed using the ID read in the
scan header segment. Furthermore, the decoder now replaces the old DC
or AC table if a redefinition has been found prior to the scan header.

Fixes #3439.
2020-09-10 11:20:04 +02:00
Tom
607c78336b LibGfx: Add ability to draw inverted rectangles 2020-09-08 10:45:35 +02:00
Andreas Kling
08f1ea3e45 LibGfx: Make fill_rect_with_dither_pattern() skip transparent colors
Maybe this should do full blending, but for now at least skip source
pixels that have zero alpha.
2020-09-01 23:55:35 +02:00
Peter Nelson
259f8541fc LibGfx: implement GIF RestorePrevious frame disposal mode 2020-08-31 18:54:44 +02:00
Peter Nelson
c3ee5e3451 LibGfx: clear previous GIF frame to transparent instead of whole image 2020-08-31 18:54:44 +02:00
Andreas Kling
95ed363b15 LibGfx: Fix Lagom build (possible uninitialized variable warnings) 2020-08-30 10:40:40 +02:00
Peter Nelson
b742d593dd LibGfx: use Gfx::Color instead of local struct for GIF colour map 2020-08-30 10:27:36 +02:00
Peter Nelson
c8eccc00b1 LibGfx: only cache last decoded GIF frame
GIFLoader now uses a single frame buffer to cache the last decoded
frame. This drastically reduces memory usage at the small expense of
re-decoding frames on each loop.
2020-08-30 10:27:36 +02:00
Peter Nelson
786872e4c9 LibGfx: add support for interlaced GIFs 2020-08-30 10:27:36 +02:00
Peter Nelson
1341025da7 LibGfx: correctly handle GIF frame disposal modes
RestoreBackground disposal mode is now a transparent fill to allow
background to show through.

RestorePrevious disposal mode now restores the previous frame.
2020-08-30 10:27:36 +02:00