Commit Graph

81354 Commits

Author SHA1 Message Date
Benjamin Otte
65e02a3bae Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix shadows some more

Closes #6896

See merge request GNOME/gtk!7526
2024-07-30 14:48:34 +00:00
Benjamin Otte
defc4d335e gpu: Fix shadows some more
It turns out the "step" variable could up as 0 when p.y ~= 3.0 ||
p.y ~= r.y - 3.0
That was not enough to trigger it though because if "start" and "end"
were the same value, the "y <= end" check in the loop would immediately
terminate it.

However, if start + epsilon == end so that end != start but (end - start)
/ 7 == 0, then step would end up as 0 and the loop would never
terminate.

And if that happened, it would bring down GPUs.
So recode this whole machinery to make it impossible to infloop.

Fixes #6896
2024-07-30 16:09:38 +02:00
Benjamin Otte
bdcfcfa5b9 Merge branch 'wip/otte/for-main' into 'main'
gpu: Draw proper shadows again

Closes #6888

See merge request GNOME/gtk!7518
2024-07-30 00:19:37 +00:00
Benjamin Otte
4a94c91772 gpu: Don't blur tiny blur radii
We get those wrong, and there's not really a visual effect.

And since we do a check anyway, just disallow them and treat them as
unblurred.
2024-07-30 01:50:56 +02:00
Benjamin Otte
cc3ed89e34 gpu: Draw proper shadows again
The fix in commit 5e7f227d broke shadows while trying to make them
faster.
So use a better way to make them faster.

With the normalized blur radius, we can now conclude that all the values
too far from p.y will cause the gauss() call to return close to 0, so we
can skip any y value that is too far from p.y.

And that allows us to put an upper limit on the loop iterations.

Tests included

Fixes #6888
2024-07-30 01:50:56 +02:00
Benjamin Otte
87e8265a2d Merge branch 'wip/otte/colomplications' into 'main'
wayland: Do not use compositor-provided image descriptions

See merge request GNOME/gtk!7522
2024-07-29 17:56:41 +00:00
Matthias Clasen
9fd6d431e3 Merge branch 'fix-ephy-crash' into 'main'
subsurface: Avoid a crash

Closes #6891

See merge request GNOME/gtk!7521
2024-07-29 17:39:05 +00:00
Benjamin Otte
5059ae1d7b gpu: Simplify box-shadow shader
Instead of doing complicated math, normalize the values to a sigma
of 1.0, and then use that.
This should also be beneficial for shader performance, because 1.0 is a
constant and constant-elimination can kick in on the inlined functions.
2024-07-29 19:14:10 +02:00
Benjamin Otte
50bb42f0f3 gl: Don't crash on box shadows with negative scales
Some places didn't fabs() the scale values properly, leading to
assertions when offscreens with negative sizes were created.
2024-07-29 19:14:10 +02:00
Benjamin Otte
d71a7c901d wayland: Do not use compositor-provided image descriptions
When the compositor sends us an image description, we currently happily
reuse it.

However, those image descriptions may contain optional properties that
we do not handle - example: reference white level. So if we were to
reuse that image description, we would set a wrong reference white
level.

To avoid issues like that, never use compositor-provided image
descriptions.

However, query those image descriptions and map them to the closest
GdkColorState, so that we can quickly look up *our* version of that
image description and use that one.
2024-07-29 18:45:41 +02:00
Matthias Clasen
65f727731c subsurface: Avoid a crash
When finalizing a subsurface, we need to make sure it is removed
from the sibling lists in its parent, or bad things will happen.

This should crashes seen in Epiphany nightly.

Fixes: #6891
2024-07-29 11:54:10 -04:00
Matthias Clasen
ff60b19e4b Merge branch 'matthiasc/for-main' into 'main'
image-tool: Add an --undecorated option

See merge request GNOME/gtk!7520
2024-07-29 15:52:42 +00:00
Matthias Clasen
b8f12c5d28 cicp: Improve the docs
Fix some formatting issues, and document GdkCicpRange.
2024-07-29 11:17:13 -04:00
Matthias Clasen
bfb779ac2f gsk: Add missing cicp transfer functions
This was overlooked in 50ea9450ea.
2024-07-29 10:35:32 -04:00
Matthias Clasen
84c28d2efb image-tool: Add an --undecorated option
This is useful if you want to debug things and don't want to end
up in the decoration rendering code paths.
2024-07-29 08:13:21 -04:00
Matthias Clasen
06372c5f2a Merge branch 'matthiasc/for-main' into 'main'
Fix indirect color state conversions

See merge request GNOME/gtk!7519
2024-07-29 11:11:28 +00:00
Matthias Clasen
3d75292c4d Fix indirect color state conversions
convert_func2 is a 'from' conversion function, ie it expects to
be passed the target color state. This was wrong both in
gdk_memory_convert and gdk_memory_convert_color_state.
2024-07-28 23:40:59 -04:00
Matthias Clasen
541ffbe4b5 Merge branch 'matthiasc/for-main' into 'main'
gst: Fix a wrong unref function

See merge request GNOME/gtk!7517
2024-07-28 23:35:16 +00:00
Matthias Clasen
17524f2794 gst: Fix a wrong unref function
Use gdk_color_state_unref on a color state.
2024-07-28 19:09:05 -04:00
Matthias Clasen
1040d7c7e4 Merge branch 'matthiasc/for-main' into 'main'
cicp: Fill in some more transfer functions

See merge request GNOME/gtk!7515
2024-07-28 20:51:40 +00:00
Matthias Clasen
1b53359cd3 Merge branch 'wip/smcv/ubsan' into 'main'
Avoid undefined behaviour in a few simple cases

See merge request GNOME/gtk!7508
2024-07-28 20:00:06 +00:00
Matthias Clasen
1987738d16 Merge branch 'wip/smcv/c11' into 'main'
README: Officially require C11, matching GLib 2.81.x

See merge request GNOME/gtk!7516
2024-07-28 19:58:51 +00:00
Benjamin Otte
b8890ca27d Merge branch 'wip/smcv/warnings' into 'main'
Fix compiler warnings on 32-bit

See merge request GNOME/gtk!7507
2024-07-28 18:40:46 +00:00
Benjamin Otte
2e7916cf4f Merge branch 'wip/smcv/align-gsk-ops' into 'main'
gskpathop: Align graphene_point_t to match gskpathop assumptions where required

Closes #6395

See merge request GNOME/gtk!7510
2024-07-28 17:54:35 +00:00
Simon McVittie
24cf5b6df8 README: Officially require C11, matching GLib 2.81.x
Previously GTK required a C99 compiler, but as discussed on
GNOME/gtk!7510 there's at least one anonymous union in public API
(in `GskPathPoint`), and that's a C11 feature.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:47:47 +01:00
Simon McVittie
214f5a6f98 gskpathop: Introduce a type to represent an aligned graphene_point_t
When we allocate a graphene_point_t on the stack, there's no guarantee
that it will be aligned at an 8-byte boundary, which is an assumption
made by gsk_pathop_encode() (which wants to use the lowest 3 bits to
encode the operation). In the places where it matters, force the
points on the stack and embedded in structs to be nicely aligned.

By using a distinct type for this (a union with a suitable size and
alignment), we ensure that the compiler will warn or error whenever we
can't prove that a particular point is, in fact, suitably aligned.
We can go from a `GskAlignedPoint *` to a `graphene_point_t *`
(which is always valid, because the `GskAlignedPoint` is aligned)
via &aligned_points[0].pt, but we cannot go back the other way
(which is not always valid, because the `graphene_point_t` is not
necessarily aligned nicely) without a cast.

In practice, it seems that a graphene_point_t on x86_64 *is* usually
placed at an 8-byte boundary, but this is not the case on 32-bit
architectures or on s390x.

In many cases we can avoid needing an explicit reference to the more
complicated type by making use of a transparent union. There's already
at least one transparent union in GSK's public API, so it's presumably
portable enough to match GTK's requirements.

Increasing the alignment of GskAlignedPoint also requires adjusting how
a GskStandardContour is allocated and initialized. This data structure
allocates extra memory to hold an array of GskAlignedPoint outside the
bounds of the struct itself, and that array now needs to be aligned
suitably. Previously the array started with at next byte after the
flexible array of gskpathop, but the alignment of a gskpathop is only
4 bytes on 32-bit architectures, so depending on the number of gskpathop
in the trailing flexible array, that pointer might be an unsuitable
location to allocate a GskAlignedPoint.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6395
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:31:41 +01:00
Matthias Clasen
50ea9450ea cicp: Fill in some more transfer functions
Handle gamma 2.2 and gamma 2.8.
2024-07-28 11:56:43 -04:00
Matthias Clasen
d2028c7323 Cosmetics 2024-07-28 11:33:39 -04:00
Benjamin Otte
76c1ea0449 Merge branch 'wip/smcv/gsize-is-guintptr' into 'main'
gdk: Codify the requirement that gsize is pointer-sized

See merge request GNOME/gtk!7514
2024-07-28 14:12:59 +00:00
Simon McVittie
a97f378d64 gdk: Codify the requirement that gsize is pointer-sized
This is widely assumed, but is not guaranteed by Standard C, and is
known to be false on CHERI architectures (which have 64-bit sizes and
128-bit tagged pointers). Add a static assertion to ensure that GTK
will not build on platforms where this assumption does not hold.

As discussed on GNOME/gtk!7510, if GTK switches from gsize to uintptr_t
as its representation of the underlying bits in a pointer, GTK maintainers
would prefer that to be done project-wide so that it's done consistently,
after which this static assertion could be removed.

At the time of writing, GLib makes the same assumption (GNOME/glib#2842),
but GLib contributors are gradually removing it (mostly by replacing gsize
with uintptr_t where a pointer-sized quantity is needed). Finishing
that work in GLib would be a prerequisite for being able to make GTK
work on the affected platforms.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 14:31:31 +01:00
Matthias Clasen
ffe82b7641 Merge branch 'wip/smcv/ubsan-half-float' into 'main'
gsk, testsuite: Avoid undefined behaviour converting float <-> fp16

See merge request GNOME/gtk!7509
2024-07-28 02:59:59 +00:00
Matthias Clasen
785709d51c Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7512
2024-07-28 02:55:57 +00:00
Matthias Clasen
8406c34166 Cosmetics 2024-07-27 22:11:39 -04:00
Matthias Clasen
2ee1f3e8cf Merge branch 'matthiasc/for-main' into 'main'
image-tool: Allow specifying cicp tuples

See merge request GNOME/gtk!7511
2024-07-27 23:45:21 +00:00
Matthias Clasen
1373a7a6f0 Change the matrix implementation
Go from float[3][3] to float[9]. That is easier to manage in
static initialization.
2024-07-27 19:20:14 -04:00
Matthias Clasen
a5aac30843 jpeg: Load grayscale as-is
We can handle grayscale textures just fine nowadays, so no need to
convert them to RGB.
2024-07-27 19:20:14 -04:00
Matthias Clasen
3149493679 jpeg: Set downloader color state explictly
This avoids surprises.
2024-07-27 19:02:59 -04:00
Matthias Clasen
a60cda3daa image-tool: Allow specifying cicp tuples
Accept --cicp=1/13/6/0 and similar to specify color states.
2024-07-27 18:42:39 -04:00
Simon McVittie
660c6c8d6f gsk, testsuite: Avoid undefined behaviour in half_to_float_one()
Similar to the previous commit, to avoid undefined behaviour we need
to avoid evaluating out-of-bounds shifts, even if their result is going
to ignored by being multiplied by 0 later.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
ad679187d3 gsk, testsuite: Avoid undefined behaviour in float_to_half_one()
If, for example, e == 0, it is undefined behaviour to compute an
expression involving an out-of-range shift by (125 - e), even if the
result is in fact irrelevant because it's going to be multiplied by 0.

This was already fixed for the memorytexture test in
commit 5d1b839 "testsuite: Fix another ubsan warning", so use the
implementation from that test everywhere. It's in the header as an
inline function to keep the linking of the relevant tests simple:
its only caller in production code is fp16.c, so there will be no
duplication outside the test suite.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
b769295682 gtkcssnodedeclaration: Avoid signed left shift by 31 bits
Left-shifting a signed 32-bit integer by 31 bits (such that the value
overflows into the sign bit) is undefined behaviour. Use an unsigned
integer instead.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
6649af5ec6 Avoid calling memcpy with n == 0
Some callers of these functions ask to copy 0 items from a NULL source,
which would be valid if they were copied in a loop (because NULL would
never be dereferenced), but is declared to be undefined behaviour for
Standard C memcpy. Guard the call to memcpy so that we only call it
if we have more than 0 items, and therefore should have a non-NULL
source pointer.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
ca7094296c gtktimsort: Avoid undefined behaviour on 32-bit
Shifting a 32-bit type by 32 bits is formally undefined behaviour,
even if it happens in code that is unreachable at runtime. Use a
compile-time check against GLib's GLIB_SIZEOF_SIZE_T, instead of hoping
a runtime check will be optimized away.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
15a09c79f9 Fix debug format strings for non-LP64 platforms
Unfortunately the format string for a size_t, `%zu`, is not portable
to all Windows compilers, and the appropriate format string for the
fundamental type that implements size_t varies between platforms
(typically `%u` on 32-bit platforms, `%lu` on 64-bit Linux or
`%llu` on 64-bit Windows).

In gtk-demo, cast the number of search results to long, to avoid
breaking up a translatable string.

Elsewhere, use GLib's abstraction for this.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 18:14:31 +01:00
Simon McVittie
e2a7dc5427 vulkan: Fix compiler warnings on 32-bit
Vulkan handles are pointers on 64-bit, but 64-bit integers on 32-bit.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 15:14:57 +01:00
Benjamin Otte
d301d16aee Merge branch 'wip/otte/for-main' into 'main'
wayland: Redo the image description code

See merge request GNOME/gtk!7505
2024-07-27 06:09:15 +00:00
Benjamin Otte
ec489e673c wayland: Add preferred formats to the hash tables
So we don't look them up all the time.
2024-07-27 07:26:51 +02:00
Benjamin Otte
a904da12b7 wayland: Don't query preferred colorstate if we don't care
If there's no change callback connected, exit early, because all this
lot of work would be for invoking that callback.
2024-07-27 07:26:51 +02:00
Benjamin Otte
91865d172b wayland: Track color information identities
So we don't need to query them all the time.

Or so I thought, because I get different ones for the same colorstate.
Thx Mutter.
2024-07-27 07:26:51 +02:00
Benjamin Otte
adedb89779 wayland: Actually sync the colorstate with the compositor 2024-07-27 07:26:51 +02:00