Commit graph

100 commits

Author SHA1 Message Date
Hüseyin ASLITÜRK
840a64e2f9 LibGfx: Painter, extend fonts to 384 character to support LatinExtendedA
Replace codepoint variable type from char to u32.
2020-05-21 01:19:42 +02:00
Andreas Kling
0272bbb4fb LibGfx: Add UTF-32 version of the text painting code paths
There's a large amount of code duplication here right now, which will
need to be reduced.
2020-05-17 22:35:25 +02:00
Andreas Kling
bc6f469544 LibGfx: Let's make it Font::width(Utf32View) 2020-05-17 22:35:25 +02:00
Andreas Kling
35875b68f5 LibGfx: Add Font::width(u32* codepoints, size_t)
This allows you to measure the width of a UTF-32 sequence.
2020-05-17 22:35:25 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
fbda28248a LibGfx+IPCCompiler: Add IPC encoders for Color and ShareableBitmap 2020-05-12 19:04:03 +02:00
Andreas Kling
3775983dfe LibIPC+LibGfx: Templatize IPC encoding as well as decoding
Now most classes dictate how they are serialized and deserialized when
transmitted across LibIPC sockets. This also makes the IPC compiler
a bit simpler. :^)
2020-05-12 18:49:24 +02:00
Ben Wiederhake
ebe47de0b2 LibGfx: Eliminate conditional branch in dither
In theory, this should make dithering a teensy bit faster.
2020-05-11 09:47:32 +02:00
Linus Groh
0669dbcf5d LibGfx: Add support for dashed lines
Non-configurable for now.
2020-05-10 19:41:00 +02:00
Andreas Kling
fce0cf18e3 LibGfx: Make buttons slightly chunkier on the top/left side 2020-05-10 14:24:20 +02:00
Linus Groh
59d00e5df6 LibGfx: Replace 'bool dotted' with a LineStyle::{Solid,Dotted} enum
Just a bool is insufficient as we'll have to support dashed lines as well.
2020-05-10 13:34:59 +02:00
Linus Groh
da42279171 LibGfx: Fix dotted lines with thickness > 1
If we just skip every second pixel, we still get a solid line if each
"pixel" is wider than 1!
Now we skip the same amount of pixels as the line is thick.
2020-05-10 13:34:59 +02:00
Andreas Kling
9e74793ce2 LibGUI+LibGfx: Paint scollbar tracks with a dithered pattern
Instead of a solid color, we now paint the track/gutter of scrollbars
using a 2-color dither pattern for a pleasant millennium feel. :^)
2020-05-10 01:02:06 +02:00
Linus Groh
9e0beebdf5 LibGfx: Fix build with FILL_PATH_DEBUG enabled 2020-05-09 23:41:30 +02:00
AnotherTest
6f15f23a40 LibGfx: Add Path::close_all_subpaths()
Unlike Path::close() which closes only the last subpath (if possible),
this closure mechanism closes _all_ available subpaths.
2020-05-09 23:25:39 +02:00
Peter Nelson
b1fee13904 LibGfx: Implement GIFImageDecoderPlugin animation methods
GIFImageDecoderPlugin now lazily decodes GIF frames as they are
requested.
2020-05-09 12:01:59 +02:00
Peter Nelson
ddc4eb7be0 LibGfx: Optimise LZWDecoder
Various optimisations to speed up LZWDecoder
- Take advantage of the fact that we add new codes in the order they are
  discovered so no need to store the code as part of a separate
  CodeTableEntry structure. Instead we store directly store vectors of
  colors and the code is the index into the vector.
- Cache current table capacity to avoid calling pow2 every time.
- Prevent some unnecessary vector copies by returning by reference from
  get_output.
2020-05-09 12:01:59 +02:00
Peter Nelson
d22bb92764 LibGfx: Add support for animated images to ImageDecoder{Plugin}
Adds methods to determine whether an image is animated, how many times
the animation loops, the number of frames, and to get individual frames.

Implements stubs of these methods for PNGImageDecoderPlugin and
GIFImageDecoderPlugin.
2020-05-09 12:01:59 +02:00
Hüseyin ASLITÜRK
e68a08ad7c LibGfx: Add new methods to Font to avoid embedded values in FontEditor 2020-05-09 10:00:13 +02:00
AnotherTest
88738aefa3 LibGfx: Revert #2154 and properly handle simple polygons
The existing scanline method works just fine, and only needs the points
to be available as floats.
This commit reverts the complex polygon mitigation, and instead fixes
the rasterization process to avoid generating complex polygons because
of precision issues.
2020-05-08 19:39:38 +02:00
AnotherTest
677568e3d4 LibGfx: Handle filling complex shapes better
This allows the painter to render filled complex shapes better, by
constructing a path graph for (interesting) intersecting lines and
omitting lines from the containing segments if they are detected
to take no part in defining the edges of a shape.

This approach would still fail if there are multiple logical shapes
that are confined to the collection of lines.
For instance, two polygons intersecting each other in a way that one
vertex of polygon A ends up inside polygon B.
we would detect that polygon A's edges are part of the shape
(technically correct) even though they are not a part of polygon B at
all.
2020-05-08 12:49:15 +02:00
Linus Groh
9dbab2d05e Misc: Replace "String(string_view)" with "string_view.to_string()"
StringView::to_string() was added in 917ccb1 but not actually used
anywhere yet.
2020-05-06 19:28:59 +02:00
AnotherTest
f54b41f748 LibGfx: Implement filling paths
There are some imperfections with intersecting edges (because the main
algorithm used is scanline, and that is not geared towards drawing
complex shapes), however, it behaves mostly fine for normal use :^)
2020-05-06 14:50:29 +02:00
Andreas Kling
1061127ca7 LibGfx: Add missing FloatRect function implementations
These are just clones of the Rect equivalents.
2020-05-05 18:53:34 +02:00
Andreas Kling
b7339745d0 LibGfx: Add a naive "rgba(r,g,b,a)" color parser
It's not very whitespace tolerant but it works.
2020-05-05 15:50:28 +02:00
AnotherTest
0a55679de4 LibWeb: Add canvas.quadraticCurveTo()
Also adds a test, and removes debug spam ™️
2020-05-05 09:21:07 +02:00
AnotherTest
9f3f98d4c0 LibGfx: Add Painter::draw_quadratic_bezier_curve()
Also adds a QuadraticBezierCurveTo mode to Gfx::Path
2020-05-05 09:21:07 +02:00
LepkoQQ
c7f0de14b5 LibGfx: Decode paletted and grayscale images with 1/2/4 bit depth
When dealing with png data that has less than 8 bits per pixel, round
up to the next byte when allocating per row buffers and streamers. This
fixes decoding odd sized PNGs with less than 8 bits per pixel.

Also added a test page with some odd sized palleted PNGs.
2020-05-02 01:28:18 +02:00
Andreas Kling
888e35f0fe AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-30 11:43:25 +02:00
Andreas Kling
17e76b4760 LibGfx: Add Color::to_string_without_alpha()
This simply returns an "#rrggbb" string and ignores the alpha value.
2020-04-29 15:31:45 +02:00
LepkoQQ
e5a598414f LibGfx: PNGLoader support for grayscale images with alpha. 2020-04-26 20:29:17 +02:00
LepkoQQ
d009df074f LibGfx: PNGLoader support for grayscale images with 8/16bpp. 2020-04-26 20:29:17 +02:00
Hüseyin ASLITÜRK
c9c1d1fae0 LibGUI: Create thumnail for gif files 2020-04-26 18:44:20 +02:00
Peter Nelson
5adf4901df LibGfx: Fix crash on decoding small gifs
The LZW decode step will now copy and pad LZW data out to 4 bytes if there are
less than 4 bytes remaining in the buffer. This means it will now also work when
the total size of the LZW image data is less than 4 bytes.
2020-04-25 18:37:13 +02:00
Andreas Kling
9c772a64a1 LibGfx: Don't proceed with GIF format sniffing if stream read fails 2020-04-25 17:03:40 +02:00
Peter Nelson
4cb765e520 LibGfx: Remove unnecessary casts 2020-04-25 16:49:09 +02:00
Peter Nelson
76cbfe1c38 LibGfx: Minor changes to adhere to code style guidelines 2020-04-25 16:49:09 +02:00
Peter Nelson
a1c0eb1e1d LibGfx: Remove debug output 2020-04-25 16:49:09 +02:00
Peter Nelson
9a2c8102cd LibGfx: Use content sniffing to choose which ImageDecoder plugin to use 2020-04-25 16:49:09 +02:00
Peter Nelson
2cd9716b38 LibGfx: Add a sniff method to ImageDecoder and implement for GIF and PNG
The sniff method is intended to be used for content sniffing. It should be a
cheap test to rapidly rule out whether a candidate image can be successfully
decoded. For the GIF and PNG implementations it simply attempts to decode the
image header, returning true if successful and false if not.
2020-04-25 16:49:09 +02:00
Peter Nelson
df0d6e241c LibGfx: Extract GIF header decoding into separate function 2020-04-25 16:49:09 +02:00
Peter Nelson
d5af7b220c LibGfx: implement remaining GIFImageDecoderPlugin methods 2020-04-25 16:49:09 +02:00
Peter Nelson
e06518211b LibGfx: decode first frame of GIF LZW data
Also:
- Define the GIFLoadingContext structure.
- The load_gif_impl function now returns load operation success, and takes a
  reference to a GIFLoadingContext as input.
- Implement GIFImageDecoderPlugin::bitmap which calls onto load_gif_impl.
2020-04-25 16:49:09 +02:00
Peter Nelson
9c2a675c38 LibGfx: Implement GIF LZW decoding
Add an LZWDecoder class that can decode GIF LZW data.
2020-04-25 16:49:09 +02:00
Andreas Kling
f0cac83243 WindowServer+LibGfx: Make window borders 1px thicker 2020-04-23 14:37:13 +02:00
Andreas Kling
4393a2a96d LibGfx: Let the PNG decoder fail if the header is missing or too short 2020-04-19 17:48:43 +02:00
Stephan Unverwerth
cbcf317e76 LibGfx: Fix draw_triangle() clipping calculations 2020-04-18 13:24:34 +02:00
Stephan Unverwerth
2dcc38d7bf LibGfx: Add Vector3 and Matrix4x4 classes
This adds two templated 3D math classes. They have already been typedf'd
as FloatVector3, DoubleVector3, FloatMatrix4x4 and DoubleMatrix4x4
2020-04-18 12:28:54 +02:00
Stephan Unverwerth
acd4676803 LibGfx: Add draw_triangle() for drawing filled triangles 2020-04-18 12:28:54 +02:00
Andreas Kling
ecd900b4b4 LibGfx: Add FloatPoint::to_int_point() 2020-04-16 21:11:13 +02:00