1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 06:15:06 +00:00
Commit graph

486 commits

Author SHA1 Message Date
Lucas CHOLLET
b918dcd4db LibGfx/TGA: Compute the number of pixels with a wider type
Both width and height are stored in an u16 inside the TGA header,
computing the total number of pixel without using another type can
easily lead to overflows.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55309&q=serenity&can=2
2023-07-19 06:52:45 +02:00
Lucas CHOLLET
806808f406 LibGfx: Provide a default implementation for animation-related methods
Most image decoders that we have only support non-animated images,
providing a default implementation for them allows to remove quite some
code.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
7acb656826 LibGfx: Comment ImageDecoderPlugin's interface
This is done as an effort to unify the behavior of every plugin. See
#19893 for more details.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
4291288a31 LibGfx: Remove ImageDecoderPlugin::initialize()
No plugin is currently overriding the default implementation, which is a
no-op. So we can safely delete it.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
3752facfbc LibGfx: Don't assume that image decoder plugin creation succeeds
An image with an incorrect header should fail at this step, so we have
to handle that without crashing.

This should have been done in 7b72bf29.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
38dd4168be LibGfx/ICO: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-17 20:17:08 +01:00
Lucas CHOLLET
5d94bb4fcc LibGfx/PNG: Remove the useless HeaderDecoded state 2023-07-17 06:49:03 +01:00
Lucas CHOLLET
a173275afa LibGfx/PNG: Reject files that doesn't start with a IHDr chunk 2023-07-17 06:49:03 +01:00
Lucas CHOLLET
8d907b6535 LibGfx/PNG: Don't use a loop to read chunks in decode_png_ihdr()
This chunk is the first one, so we can remove that loop.
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
ff6d82c3e7 LibGfx/PNG: Decode the header in create() and remove initialize()
This is done as a part of #19893. As `create()` is now the last user of
`decode_png_ihdr()`, we can easily make it return an `ErrorOr`.
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
07f72b6d41 LibGfx/PNG: Don't try to guess if IHDR has been decoded 2023-07-17 06:49:03 +01:00
Lucas CHOLLET
07d3232f2d LibGfx/PNG: Use PNG specific vocabulary over a generic name 2023-07-17 06:49:03 +01:00
Lucas CHOLLET
0520490577 LibGfx/DDS: Read the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
aa9470880f LibGfx/DDS: Prefer static constexpr Array over Vector<u32> 2023-07-17 06:44:37 +01:00
Lucas CHOLLET
742897519d LibGfx/DDS: Move the code to read the header in its own function 2023-07-17 06:44:37 +01:00
Lucas CHOLLET
76efdaeecd LibGfx/DDS: Save the format in the context
This allows us to simplify the signature of a few functions.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
4cb7573582 LibGfx/DDS: Only use a FixedMemoryStream
This allows us to drop the data pointer in the `DDSLoadingContext`.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
8946c0c104 LibGfx/DDS: Don't double-check the magic number
This is already done in `decode_dds()`.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
c336cef065 LibGfx/BMP: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-17 06:39:57 +01:00
Lucas CHOLLET
7b72bf2910 LibGfx: Don't assume that image decoder plugin creation succeeds
An image with an incorrect header should fail at this step, so we have
to handle that without crashing.
2023-07-17 06:39:57 +01:00
Lucas CHOLLET
35dcd16ea6 LibGfx/TinyVG: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-16 20:39:51 +02:00
MacDue
cf05da131f LibGfx/TinyVG: Close polygon path in OutlineFillPolygon 2023-07-15 21:36:28 +02:00
MacDue
a853f7b133 LibGfx/TinyVG: Map gradients to equivalent SVG gradients 2023-07-15 21:36:28 +02:00
MacDue
fb61082a6c LibGfx/TinyVG: Don't move fill/stroke styles that are used in a loop 2023-07-15 21:36:28 +02:00
MacDue
bebfb81c85 LibGfx/TinyVG: Parse and ignore line_width in paths
TinyVG allows varying the line width along a path, this is not supported
in LibGfx so we just ignore this (but still need to parse the field).
2023-07-15 21:36:28 +02:00
Lucas CHOLLET
500097de82 LibGfx/GIF: Decode the header in create()
Again, header includes the logical screen descriptor here. This is done
as a part of #19893.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
294217586b LibGfx/GIF: Move the code to read the header to its own function
By header, I include the logical screen descriptor here, so all the
information that is not specific to each frame.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
b8bc84a3e8 LibGfx/GIF: Only use a FixedMemoryStream
This allows us to drop the data pointer in the `GIFLoadingContext`.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
1192e46c09 LibGfx/GIF: Don't read the header twice
This is already done in `load_gif_frame_descriptors()`. As the method
`initialize()` is now empty, we can delete it.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
8ef5170bd5 LibGfx/WebP: Remove a typo
:redthakis:
2023-07-15 09:34:07 +02:00
Lucas CHOLLET
4adef05e6d LibGfx/WebP: Decode the first chunk in create()
And remove `initialize()`.

This is done as a part of #19893.
2023-07-15 09:34:07 +02:00
MacDue
57c81c1719 LibGfx: Lazily load TinyVG image data
This matches the behavior of other decoders, and ensures just getting
the size (e.g. for the `file` command) does not read the whole file.
2023-07-14 06:51:05 +02:00
MacDue
753cf04be8 LibGfx: Allow requesting vector graphic frames from ImageDecoder
Only supported for plugins that set is_vector() to true. This returns
the frames as Gfx::VectorGraphics, which allows painting/rasterizing
them with arbitrary transforms and scales.
2023-07-14 06:51:05 +02:00
Lucas CHOLLET
b14d51ba1b LibGfx/QOI: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-14 06:17:12 +02:00
Lucas CHOLLET
5fd1ee0365 LibGfx/QOI: Remove useless parameters from member functions
Both `decode_[header,image]_and_update_context()` used to take a
`Stream&` as parameter, but they are always called with the field
`m_context.stream` so no need to take it as a parameter.
2023-07-14 06:17:12 +02:00
Lucas CHOLLET
1ae772c7d3 LibGfx/JPEG: Decode the header in create()
This is done as a part of #19893.
2023-07-14 06:16:56 +02:00
Lucas CHOLLET
2f125b86aa LibGfx/JPEG: Remove the unused method initialize() 2023-07-14 06:16:56 +02:00
Lucas CHOLLET
92fa1efc76 LibGfx/TGA: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-12 23:37:32 +02:00
Lucas CHOLLET
a05516bb3e LibGfx/TGA: Make TGAImageDecoderPlugin::decode_tga_header() fallible 2023-07-12 23:37:32 +02:00
Lucas CHOLLET
e0ff3fbfad LibGfx/TGA: Default initialize the TGAHeader in the context 2023-07-12 23:37:32 +02:00
Nico Weber
8c13b83a84 LibGfx/PNGWriter: Use a better limit for scanline capactiy
One scanline is width pixels long, not height pixels.

No measurable performance difference, but it annoys me every time I look
at this file.
2023-07-12 07:51:54 +01:00
Lucas CHOLLET
9ff706339b LibGfx/PortableFormat: Read the header during initialization
This is done as a part of #19893.
2023-07-11 14:16:33 +01:00
Lucas CHOLLET
f3ff9c26bc LibGfx/PortableFormat: Simplify the State enum
This enum used to store very precise state about the decoding process,
let's simplify that by only including two steps: HeaderDecoder and
BitmapDecoded.
2023-07-11 14:16:33 +01:00
Lucas CHOLLET
f6ce06d56b LibGfx/PortableFormat: Extract header reading in its own function 2023-07-11 14:16:33 +01:00
Lucas CHOLLET
e72293fbc7 LibGfx/PortableFormat: Remove PortableImageDecoderPlugin::initialize() 2023-07-11 14:16:33 +01:00
Nico Weber
f7f9f1f47f LibGfx/PNG: Make invalid sRGB chunk size non-fatal
https://www.haiku-os.org/images/bg-page.png has a size of 0 for
example.

Just ignoring the chunk instead of assuming that the image is sRGB
and has Perceptual rendering intent matches what libpng does
(cf `png_handle_sRGB()`), so let's do that too.

(All other chunk handlers are still strict about size.)
2023-07-11 15:07:42 +02:00
Lucas CHOLLET
babe924da1 LibGfx: Provide a default implementation for ImageDecoder::initialize
In order to ease the removal of this function, let's provide a no-op
default implementation so decoders can stop implementing it one by one.

First step of #19893
2023-07-09 09:16:28 +01:00
Lucas CHOLLET
35599605c1 LibGfx/BMP: Move some const to the east 2023-07-08 22:56:30 +01:00
Lucas CHOLLET
fd765d2031 LibGfx/ICO: Fix an erroneous condition
This is a remnant of the conversion to `ErrorOr` done in 492d5d7c.
2023-07-08 22:56:30 +01:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00