Commit graph

150 commits

Author SHA1 Message Date
Matthew Olsson
22f0953fe2 LibWeb: Begin SVG element support
This commit starts adding a basic SVG element. Currently, svg elements
have support for the width and height properties, as well as the stroke,
stroke-width, and fill properties. The only child element supported
is the path element, as most other graphical elements are just shorthand
for paths.
2020-07-26 14:53:43 +02:00
AnotherTest
9d349ac646 LibGfx: Add a generic Matrix variant 2020-07-25 02:13:43 +02:00
AnotherTest
2d96437bbb LibGfx: Add Matrix4x4::elements() getters 2020-07-25 02:13:43 +02:00
Nico Weber
3f45e9ab1e Lagom: Add LibGemini, LibGfx
They are dependencies of LibWeb and might be useful for
running test-web on GitHub actions one day.
2020-07-23 23:02:28 +02:00
Andreas Kling
d7be3faab5 LibGfx: Add an "opacity" argument to Painter::draw_scaled_bitmap()
This API is not super perfect as it merely overrides the source alpha
on all source pixels instead of blending the alpha values. There is
room for improvement here for sure.
2020-07-23 20:32:39 +02:00
Nullspeak
51b2b0d5e5 WindowServer: New title bar vars for themes
The theming system can now control title bar height, title button
size, title stripe color and the title text shadow color.
The implemented theme metrics system could be later extended to LibGUI
to allow themes to change widget padding, border width, etc.
2020-07-17 23:19:08 +02:00
stelar7
d871301fd9 LibGfx: Set correct frame type on JPEG images 2020-07-16 17:52:54 +02:00
Tom
7498024805 LibGfx: Minor IntRect::shatter and FloatRect::shatter optimization
All the shards always intersect unless they're empty.
So rather than checking for intersection, just check
whether they're empty or not.
2020-07-15 00:09:28 +02:00
devashish
4924b86b2a LibGfx+JPGLoader: Print failure message for progressive JPEGs 2020-06-28 16:56:59 +02:00
devashish
1eb338ab71 LibGfx+JPGLoader: Fix decoding outside of LibWeb
The DC reset interval was initialized to garbage :)
2020-06-27 18:33:11 +02:00
Hüseyin ASLITÜRK
dc5b73c43a LibGfx: Add PGM image file type support 2020-06-27 13:01:27 +02:00
Andreas Kling
dc22e59a1a LibGfx: Teach AffineTransform how to rotate and multiply 2020-06-26 18:27:12 +02:00
devashish
4b19b99b36 JPGLoader: Move JPGLoader internal structs and #defines to JPGLoader.cpp 2020-06-23 13:51:19 +02:00
devashish
a8b00780a8 LibGfx: Integrate JPEG decoder with rest of the system
This patch adds functions like `load_jpeg` to JPGLoader to make the
JPEG decoder conform to the API that bitmap loader uses :^)
2020-06-23 13:51:19 +02:00
Devashish
8b71b839fa LibGfx+LibWeb: Add JPEG decoder and integrate with LibWeb
This patch adds support for JPEG decoding. The JPEG decoder is capable
of handling standard 2x1 horizontal, 2x1 vertical and quartered chroma
subsampling. The implemented Inverse DCT performs with a decent speed.

As of interchange formats, since we tend to ignore the metadata in APPn
markers, the decoder can handle any format compatible with JFIF, which
includes EXIFs and sometimes WebMs too. The decoder does not support
progressive JPEGs yet.
2020-06-23 13:51:19 +02:00
Andreas Kling
e3782a7f99 ImageDecoder: Add a new service for out-of-process image decoding :^)
The new ImageDecoder service (available for members of "image" via
/tmp/portal/image) allows you to decode images in a separate process.

This will allow programs to confidently load untrusted images, since
the bulk of the security concerns are sandboxed to a separate process.

The only API right now is a synchronous IPC DecodeImage() call that
takes a shbuf with encoded image data and returns a shared buffer and
metadata for the decoded image.

It also comes with a very simple library for interfacing with the
ImageDecoder service: LibImageDecoderClient. The name is a bit of a
mouthful but I guess we can rename it later if we think of something
nicer to call it.

There's obviously a bit of overhead to spawning a separate process
for every image decode, so this is mostly only appropriate for
untrusted images (e.g stuff downloaded from the web) and not necessary
for trusted local images (e.g stuff in /res)
2020-06-22 21:47:00 +02:00
Hüseyin ASLITÜRK
326032b138 LibGfx: Add PPM image file type support 2020-06-22 18:11:22 +02:00
Paul Roukema
82a75bcf5f LibGfx: Prefer the largest image in the file when loading an ICO
Since the current image handling APIs don't provide a way to handle a
file which can contain multiple images, we just pick the largest one.
This gives the best chance of a good looking result.
2020-06-21 17:41:52 +02:00
Paul Roukema
b1e3f728a1 LibGfx: Add support for uncompressed/classic ICO files
This add support to the ICO file decoder for loading uncompressed bitmap icon files.
 It is limited to 32-bit color icons, no 4/8/16 bit or paletted formats yet.
 This is in addition to the PNG compressed ICO format support  added previously.
 With this we can now load the favicons for github, google and twitter.
2020-06-21 17:41:52 +02:00
Paul Roukema
140581d0c3 LibGfx: Initial support for ICO image files.
This adds support for loading the first image from ICO format images only if they are PNG encoded.
This is useful for loading favicons, which are sometimes PNGs with an ICO extension and sometimes actual ICO files.
In particular we can now load the favicon from new.ycombinator.com
2020-06-21 17:41:52 +02:00
Hüseyin ASLITÜRK
9ab82c0ee5 LibGfx: Add PBM image file type support 2020-06-21 16:42:46 +02:00
Matthew Olsson
4e093a7c23 LibGfx: Add BMP loader
Adds an *almost fully featured BMP loader to process .bmp files.

Features:
- All header formats are supported
- Full RLE4/8/24 support
- Color scaling (e.g. distributing a 5-bit color throughout the 8-bit
color spectrum, so 5-bit white is still 0xffffff)
- Full BITMASK/ALPHABITMASK support

*Not included:
- 1D Huffman compression. Good luck actually finding a bmp in the wild
that uses this
- Use of any field in the V4/V5 header. Color spaces? Endpoints? No
thanks :)

This loader was tested with the images at
https://entropymine.com/jason/bmpsuite/bmpsuite/html/bmpsuite.html. This
loader correctly displays 81 out of the 90 total images (for reference,
firefox displays 64 correctly). Note that not rendering the images at
the bottom is counted as displaying correctly.
2020-06-21 10:08:25 +02:00
Hüseyin ASLITÜRK
49c801f7fd LibGfx: Fix color alfa for transparent color in GIFLoader 2020-06-18 16:35:57 +02:00
Hüseyin ASLITÜRK
56158a4281 LibGfx: Add a new Bitmap::is_path_a_supported_image_format() method
Move the image file detection code to the File class to prevent code duplication.
2020-06-15 22:42:23 +02:00
Andreas Kling
d51c1c136e LibGfx: Painter::draw_line() can just return early if alpha == 0 2020-06-13 20:38:36 +02:00
Andreas Kling
3bba163574 LibGfx: Add Color::Transparent as a named color 2020-06-13 20:03:19 +02:00
Paul Roukema
b6147de1cb LibGfx: Implement support for decoding interlaced PNGs
This adds support for decoding the Adam7 interlacing used in some PNGs.
Notably this includes many of the images (such as the eyes) used in the acid2 test :^)
Note that the HTML engine still doesn't understand the <object> tag well enough to show the eyes on the test.
2020-06-13 19:47:43 +02:00
Paul Roukema
76553f9f06 LibGfx: Fix PNG decoder handling of 16-bit RGB images 2020-06-13 19:47:43 +02:00
Andreas Kling
bc5a862cbe LibGfx: Silence debug spam in the PNG decoder 2020-06-13 15:37:10 +02:00
Andreas Kling
dc0ed5c860 LibGfx: Don't keep an unused GIF decoder plugin in failed ImageDecoders
If we can't decode the input data, just have a null decoder. In this
state we simply return a null bitmap and whatever empty values make
sense for each API.

This way, we don't try to decode the same thing over and over since
it's not gonna work anyway. :^)
2020-06-13 15:29:29 +02:00
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
thankyouverycool
5a71a57435 LibGfx: Return paint_button() earlier and replace overdrawn rect
Return StylePainter::paint_button() before color initializations
when possible and replace an overdrawn rect in paint_button_new()
with more explicit shadow lines. Also standardize some comments.
2020-06-11 16:56:17 +02:00
Andreas Kling
fea77abcf6 LibGfx: Fail PNG decoding on invalid scanline filter
Only filter types 0 thru 4 are valid.
2020-06-11 16:27:54 +02:00
Andreas Kling
d59a308c7e LibGfx: Minor tweaks in PNG decoder 2020-06-11 16:27:54 +02:00
thankyouverycool
9940a7f6de LibGfx: Return correct color for palette.hover_highlight()
Now correctly returns HoverHighlight instead of ThreedHighlight.
2020-06-10 21:50:33 +02:00
thankyouverycool
c8acd7d5bf LibGfx: Visual enhancement to buttons
This adds a "shine" effect to the bottom-right edges of pressed
and checked buttons, complementing the sunken shadow already
present at top-left and creating greater illusion of depth.

It is similar to the effect used in classic Windows and is
theme agnostic in Serenity, but produces the best result when
ThreedHighlight is a radiant color of Button.
2020-06-10 19:21:43 +02:00
Andreas Kling
3aca84a299 LibGfx: Use size_t for the Streamer offset and sizes 2020-06-10 18:59:58 +02:00
Andreas Kling
116cf92156 LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Andreas Kling
43951f18e7 LibGfx: Add FloatSize::to_int_size() 2020-06-10 08:49:41 +02:00
Sergey Bugaev
fc481552f5 LibIPC+LibGfx+IPCCompiler: Drop some unused includes 2020-06-08 13:58:32 +02:00
Andreas Kling
ba6a77f281 LibGfx: Make Painter::add_clip_rect() use logical coordinates
It was really confusing that add_clip_rect() didn't apply transforms
to the new clip rect, but instead interpreted it as an absolute rect.

This makes web pages with <iframe> render correctly when scrolled.

Something might break from this, but we'll find it soon enough. :^)
2020-06-06 19:36:40 +02:00
Sergey Bugaev
f49e83c565 LibGfx: Fix debug-printing colors
The operator has to live in the namespace Gfx.
2020-06-02 21:49:47 +02:00
Andreas Kling
8ea4375d4a LibGfx: Templatize some of the scanline unpacking code 2020-06-02 19:28:55 +02:00
Andreas Kling
19587934f3 LibGfx: Consolidate some types in the PNG decoder 2020-06-02 19:28:55 +02:00
Andreas Kling
7be9cf8d36 LibGfx: Add ImageDecoder factory overload for ByteBuffers 2020-06-01 21:32:54 +02:00
Andreas Kling
d0eb35e5c3 LibGfx: Use a bit of constexpr in Color
This avoids a bunch of strlen()'s when we're parsing web colors.
2020-05-30 17:47:50 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Sergey Bugaev
602c3fdb3a AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath.

This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
8520d3a425 LibGfx: Add Painter::fill_ellipse() 2020-05-24 23:30:12 +02:00
Hüseyin ASLITÜRK
8b3bd1a54b LibGfx: Font, extend fonts to 384 character to support LatinExtendedA 2020-05-21 01:19:42 +02:00