Commit graph

47149 commits

Author SHA1 Message Date
Nico Weber 3690305794 LibGfx: Implement serialization of CurveTagData 2023-02-19 00:01:44 +01:00
Nico Weber 1ca7f109a1 LibGfx: Implement serialization of CicpTagData 2023-02-19 00:01:44 +01:00
Nico Weber fd590fe55d LibGfx: Implement serialization of ChromaticityTagData 2023-02-19 00:01:44 +01:00
Nico Weber ececea9a1c LibGfx: Implement serialization of ParametricCurveTagData
With this, simple v4 matrix profiles using parametric curves, such as
Compact-ICC-Profiles/profiles/sRGB-v4.icc, can be completely serialized
and the serialized file can be read again by `icc` :^)
2023-02-19 00:01:44 +01:00
Nico Weber 685e2da302 LibGfx: Implement serialization of S15Fixed16ArrayTagData 2023-02-19 00:01:44 +01:00
Nico Weber 931594fce3 LibGfx: Implement serialization of XYZTagData 2023-02-19 00:01:44 +01:00
Nico Weber eb6dccb675 LibGfx: Implement serialization of MultiLocalizedUnicodeTagData 2023-02-19 00:01:44 +01:00
Nico Weber 4a62cf35fc LibGfx: Move MultiLocalizedUnicodeRawRecord to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber 4e72a35398 LibGfx: Add scaffolding for writing tag data
This doesn't deduplicate identical TagDatas yet.

It also doesn't implement actual serialization of TagData yet.
2023-02-19 00:01:44 +01:00
Nico Weber 1457e36b79 LibGfx: Write ICC tag table
All offsets and sizes are set to 0 for now, so this still doesn't
produce a valid icc file. It gets closer, though.
2023-02-19 00:01:44 +01:00
Nico Weber 9bd7048519 LibGfx: Move ICC TagTableEntry to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber 026d9ceaf9 LibGfx: Extract encode_header() function in ICC writing code 2023-02-19 00:01:44 +01:00
Lucas CHOLLET 743b6e8781 LibGfx: Rename format name from jpg to jpeg 2023-02-18 23:56:24 +01:00
Lucas CHOLLET 9c1dbf1ac5 SpiceAgent: Rename ClipboardType::JPG to ClipboardType::JPEG 2023-02-18 23:56:24 +01:00
Lucas CHOLLET 856d0202f2 LibGfx: Rename JPGLoader to JPEGLoader
The patch also contains modifications on several classes, functions or
files that are related to the `JPGLoader`.

Renaming include:
 - JPGLoader{.h, .cpp}
 - JPGImageDecoderPlugin
 - JPGLoadingContext
 - JPG_DEBUG
 - decode_jpg
 - FuzzJPGLoader.cpp
 - Few string literals or texts
2023-02-18 23:56:24 +01:00
Undefine ab298ca106 Kernel: Dont crash if power states gets set to an invalid value 2023-02-18 23:52:20 +01:00
Timothy Flynn b4113536ef LibJS: Use substrings-with-superstrings in Intl.NumberFormat's grouping
To add grouping to a number, we take a string such as "123456.123" and
break it into integer and fraction parts. Then we take the integer part
and break it into locale-specific sized groups to inject the locale's
group separator (e.g. a comma in en-US). We currently create new strings
for each of these groups. Instead, we can use the shared superstring
method to avoid all of that string copying.
2023-02-18 20:00:15 +01:00
Nico Weber a30e364f1a AK: Fix printing of negative FixedPoint values
Fixes #17514 by comparing to 0 before truncating the fractional part.
2023-02-18 19:34:10 +01:00
Timon Kruiper 13f5aa81e3 Kernel/aarch64: Disable memory access alignment check
Even though we currently build all of Userland and the Kernel with the
-mstrict-align flag, the compiler will still emit unaligned memory
accesses. To work around this, we disable the check for now. See
https://github.com/SerenityOS/serenity/issues/17516 for the relevant
issue.
2023-02-18 19:17:21 +01:00
Timon Kruiper 5d587ea562 Kernel/aarch64: Call handle_crash on unknown exceptions
This is useful for debugging, as it will now print out a userspace
backtrace, and optionally also dump the memory regions of the process.
2023-02-18 19:17:21 +01:00
Sam Atkins 6b66e39df4 LibGUI+Userland: Stop returning Layout from Widget::(try_)set_layout()
Nobody uses this return value any more. It also lets us remove a whole
bunch of `(void)` casts. :^)
2023-02-18 16:56:56 +00:00
Sam Atkins 77ad0fdb07 Userland: Specify margins and spacing in the GUI::Layout constructor 2023-02-18 16:56:56 +00:00
Sam Atkins 9561ec15f4 Userland: Use Widget::add_spacer() everywhere 2023-02-18 16:56:56 +00:00
Sam Atkins 43dddafd16 LibGUI: Allow specifying Layout margins and spacing in the constructor
This is comfier than `my_widget->layout()->set_margins(...)`.
2023-02-18 16:56:56 +00:00
Sam Atkins ab6ef53247 LibGUI: Add Widget::add_spacer() wrapper
This just calls Layout::try_add_spacer(), but saves you having to access
the Widget's Layout directly.

We verify that the Widget has a Layout, since it would be a programming
error if we tried to do so without one.
2023-02-18 16:56:56 +00:00
MacDue 6ceb185865 LibGfx: Add ALWAYS_INLINE to Color::mixed_with()/interpolate()
I can see small speedup of about 6-7% with this for some gradient
painting, though Tim has been able to see an ~30% speedup in some
resizing cases so this seems like a worthwhile change.

Co-authored-by: Tim Ledbetter <timledbetter@gmail.com>
2023-02-18 17:10:04 +01:00
MacDue 3cc074c1b0 LibGfx: De-duplicate color interpolation code 2023-02-18 17:10:04 +01:00
MacDue e5a39d134b LibGfx: Move Color::mixed_with() inline
This seems to give a small speedup to gradient painting and removes
Color::mixed_with() (which was 10% of the time) from the profile.
2023-02-18 17:10:04 +01:00
Timothy Flynn 8a94c7a7f7 LibGUI: Skip over grapheme clusters on left/right arrow key presses
Currently, if you use the left/right arrow keys to move over a multi-
code point glyph, we will move through that glyph one code point at a
time. This means you can "pause" your movement in the middle of a glyph
and delete a subsection of a grapheme cluster. This now moves the cursor
across the entire cluster.

Visually, we will need to separately track physical and virtual cursor
positions. That is, when you move across a multi-code point glyph, the
visual cursor should only move one position at a time, while a physical
cursor stores the "real" position in terms of number of code points.

This also converts a couple of ints to auto - these are actually size_t,
and are being passed to functions that expect size_t, so let's not cast
them to ints.
2023-02-18 16:54:46 +01:00
Andreas Kling d0697d350d AK: Fix 64-bit alignment issue in shared-superstring substrings
Thanks to Timothy Flynn for the test!

Fixes #17141
2023-02-18 09:12:46 -05:00
Karol Kosek ba5df46a49 PixelPaint: Propagate errors from making filter settings widgets 2023-02-17 22:45:44 -07:00
Jelle Raaijmakers 4cd3a84c4b AK: Remove unused rehash_for_collision 2023-02-17 22:29:51 -07:00
Jelle Raaijmakers c08d137fcd AK: Reimplement HashTable with smart linear probing
Instead of rehashing on collisions, we use Robin Hood hashing: a simple
linear probe where we keep track of the distance between the bucket and
its ideal position. On insertion, we allow a new bucket to "steal" the
position of "rich" buckets (those near their ideal position) and move
them further down.

On removal, we shift buckets back up into the freed slot, decrementing
their distance while doing so.

This behavior automatically optimizes the number of required probes for
any value, and removes the need for periodic rehashing (except when
expanding the capacity).
2023-02-17 22:29:51 -07:00
Jelle Raaijmakers 8f015a18a5 LibJS: Dereference intrinsic accessor before deleting it
The iterator used to find an intrinsic accessor is used after calling
`HashMap.remove()` on it, which works for our current implementation but
will fall apart when you consider that modifications to the hash map
might invalidate all existing iterators that came from it, as many
implementations do.

Since we're aiming to replace our `HashTable` implementation with
something new, let's fix this first :^)
2023-02-17 22:29:51 -07:00
Jelle Raaijmakers bc76cba7c2 AK: Remove unused HashTable.h include from StringImpl 2023-02-17 22:29:51 -07:00
Ali Mohammad Pur 99d264afbe Shell: Correct the out-of-bounds expansion bailing condition
Also adds a couple (useful) debug prints which helped track down the
problem.
2023-02-18 06:55:46 +03:30
Ali Mohammad Pur d56fbaa7e8 Shell: Allow underscores in normal expansion names 2023-02-18 06:55:46 +03:30
Ali Mohammad Pur a6d77162f4 Shell: Correctly keep track of special parameter length
We were previously treating special expansions (e.g. $#) as zero-length
expansions, which made the shell repeat them literally after expanding
them.
2023-02-18 06:55:46 +03:30
Ali Mohammad Pur 6da438e992 Shell: Clear expansions after committing a word in the POSIX parser 2023-02-18 06:55:46 +03:30
Ali Mohammad Pur 2881bb4c3a Shell: Add support for heredocs to the POSIX parser 2023-02-18 06:55:46 +03:30
Ali Mohammad Pur a5e4bc4faf Shell: Add a '--posix' mode to the 'dump' builtin 2023-02-18 06:55:46 +03:30
Ali Mohammad Pur 4efc632e15 Shell: Allow the heredoc node to act as a redirection too
This will be used in a future commit to implement POSIX sh heredocs.
2023-02-18 06:55:46 +03:30
Ali Mohammad Pur 9c61fed37c AK: Add an input() accessor to GenericLexer
It's sometimes useful to get the input from the lexer instead of wiring
it all the way down to where it's needed.
2023-02-18 06:55:46 +03:30
Nico Weber 7880e11690 icc: Add flags for writing and dumping profiles
This adds three flags to icc:

* --reencode-to=<file> re-serializes a profile to a given file,
  using Gfx::ICC::encode(). This is mainly useful for testing that
  code.

* --dump-to=<file> dumps the raw ICC profile bytes read from the
  input to disk. This is useful for extracting ICC profiles from
  images, and for comparing the raw profile bytes to the profile
  bytes written by --reencode-to=.

If either of these flags is passed, icc by default no longer dumps
the icc data to stdout. To force priting of the data even if either
of these flags is present, this also adds:

* --print, which forces printing ICC contents, even if either or
  both of the icc-data writing flags are present.
2023-02-17 20:05:50 -07:00
Nico Weber 8b8b7b232e LibGfx: Add start of an ICC profile writer
For now, this can write the profile header.

`icc` refuses to dump its contents since the required copyrightTag,
profileDescriptionTag, and required per-device-class tags are missing,
but it looks ok in a hex editor.
2023-02-17 20:05:50 -07:00
Nico Weber e8a2c17f8f LibGfx: Add an accessor for the raw ICC Version minor_and_bugfix byte
This is makes it easier to write this value back out.
2023-02-17 20:05:50 -07:00
Nico Weber 0ab3f45135 LibGfx: Add a XYZ->XYZNumber conversion constructor
This is useful for converting XYZs back to the on-disk format.
2023-02-17 20:05:50 -07:00
Nico Weber 0ca620a286 LibGfx: Move ICC ProfileFileSignature into a constant in BinaryFormat.h
...so that it can be used by ICC writing code too.
2023-02-17 20:05:50 -07:00
Nico Weber 78d849bce2 LibGfx: Make ICCHeader use RenderingIntent enum
No behavior change.
2023-02-17 20:05:50 -07:00
Nico Weber 429467f46c LibGfx: Move ICC on-disk structs to new BinaryFormat.h
Removes some existing code duplication and allows future files to use
these structs too.
2023-02-17 20:05:50 -07:00