Commit Graph

81390 Commits

Author SHA1 Message Date
Jonas Ådahl
8089222fc3 gsk/gpu/downloadop: Include glib-unix.h
It's needed by g_close().
2024-08-06 23:41:46 +02:00
Benjamin Otte
0667bd39fb Merge branch 'wip/otte/for-main' into 'main'
gpu: Consult target colorstate for depth

See merge request GNOME/gtk!7567
2024-08-06 21:07:44 +00:00
Benjamin Otte
a4854dfa9e memoryformat: Use "(p)" as premultiplied indicator in names
This matches what the gpu renderer does when printing
colorstates.

It also avoids it printing "S*RGBA8" for the format and instead prints
"SRGBA8(p)" now.
2024-08-06 22:15:17 +02:00
Benjamin Otte
6c54d0a7e2 gpu: Consult target colorstate for depth
When creating images for use with different colorstates, ensure that
they have the depth of that colorstate. Otherwise we might lose accuracy
due to quantization.

Fixes mipmaps in rec2100 being rendered as RGBA8.
2024-08-06 22:15:17 +02:00
Matthias Clasen
341860eb4d Merge branch 'small-fixes' into 'main'
colorstate: Drop xyz for now

See merge request GNOME/gtk!7565
2024-08-06 20:06:38 +00:00
Matthias Clasen
876445f080 inspector: Show color states of textures 2024-08-06 15:38:31 -04:00
Matthias Clasen
03ef6a7719 colorstate: Drop xyz for now
Converting to and from xyz turns out to be more difficult than
expected, depending on what whitepoint you choose, And different
specs choose different whitepoints, so we can't directly map
css xyz to cicp xyz anyway.
2024-08-06 15:38:31 -04:00
Benjamin Otte
fde8c6df79 Merge branch 'wip/otte/for-main' into 'main'
rendrenodeparser: Use simpler function

See merge request GNOME/gtk!7564
2024-08-06 16:18:13 +00:00
Benjamin Otte
6c06e1855e roaring: Fix a compiler warning
This is a simple fix, I did not investigate if NULL is actually possible
here.

In function ‘bitset_container_empty’,
    inlined from ‘bitset_container_const_nonzero_cardinality’ at ../gtk/roaring/roaring.h:1942:13,
    inlined from ‘container_nonzero_cardinality’ at ../gtk/roaring/roaring.h:4055:20,
    inlined from ‘roaring_bitmap_lazy_xor’ at ../gtk/roaring/roaring.c:9727:17:
../gtk/roaring/roaring.h:1928:13: error: potential null pointer dereference [-Werror=null-dereference]
 1928 |   if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
      |       ~~~~~~^~~~~~~~~~~~~
2024-08-06 17:53:41 +02:00
Benjamin Otte
c60ae0b575 textview: Fix compiler warning
../gtk/gtktextview.c: In function ‘gtk_text_view_add_default_attributes’:
../gtk/gtktextview.c:10681:8: error: potential null pointer dereference [-Werror=null-dereference]
2024-08-06 17:50:57 +02:00
Benjamin Otte
e58f9ea1b4 rendrenodeparser: Use simpler function
We don't need to peek tokens.
2024-08-06 17:50:43 +02:00
Matthias Clasen
2960bb7cb2 Add a compare test for colorstates in borders 2024-08-06 07:35:00 -04:00
Matthias Clasen
161c0f0963 inspector: Show more detail for border nodes
Show the color state, and create textures with the full color
information.
2024-08-06 07:35:00 -04:00
Matthias Clasen
3002591d08 gtk: Use new border snapshot api
Preserve color states from css as much as possible.
2024-08-06 07:35:00 -04:00
Matthias Clasen
1b2b9726f8 gtk: Add gtk_snapshot_append_border2
This is a private snapshot function that uses the new constructor
to create a border node with the given GdkColors.
2024-08-06 07:35:00 -04:00
Matthias Clasen
a3691d311b nodeparser: Support color states in border nodes
Test included.
2024-08-06 07:35:00 -04:00
Matthias Clasen
89d449352f testsuite: Replay border nodes properly
Use the new apis for this.
2024-08-06 07:35:00 -04:00
Matthias Clasen
e220e6dae7 gsk: Use private border node api
Use the GdkColors returned by this function instead of assuming
the colors of a border node are always sRGB.
2024-08-06 07:35:00 -04:00
Matthias Clasen
bd3d1f7715 gsk: Add private border node api
Add a constructor that takes GdkColors, and a getter for those.

To support the existing api, we convert the colors to GdkRGBA
as needed.
2024-08-06 07:35:00 -04:00
Matthias Clasen
f3ffa99f6a gsk: Change the border op api
Pass the ccs, opacity and GdkColors to the op to let it make
decisions about color conversion. Also, reorder the offset to
follow the same order as the color ops.

Update the callers.
2024-08-06 07:35:00 -04:00
Matthias Clasen
3d55d733dc Merge branch 'fix-premul-for-colorize' into 'main'
Colors are always unpremultiplied

See merge request GNOME/gtk!7563
2024-08-06 11:33:38 +00:00
Matthias Clasen
582dba54b1 Try to fix win32 build of compare-render 2024-08-06 07:10:04 -04:00
Matthias Clasen
0775432ed9 Add a compare test for premultiplied colors
This test checks a that a specific combination of mask with alpha
inside opacity works as expected. We were treating the mask color
as premultiplied here, although it isn't.
2024-08-06 00:59:23 -04:00
Matthias Clasen
d9e15ff6e9 Colors are always unpremultiplied
We can't use gsk_gpu_node_processor_color_states_self() for ops which
apply alt to colors that don't come from textures, since those are
always unpremultiplied.

This fixes the + and - in disabled spin buttons appearing completely
white.
2024-08-06 00:59:23 -04:00
Matthias Clasen
c04edfc76e Merge branch 'matthiasc/for-main' into 'main'
rewrite color parsing in the node parser

See merge request GNOME/gtk!7560
2024-08-06 04:54:04 +00:00
Matthias Clasen
71d6392572 nodeparser: Rewrite the color parsing
Use gtk_css_parser_consume_function, for better error handling.
We are now getting the expected error for

  color(srgb 1 2 3 4 5 6)

Test included.
2024-08-06 00:23:07 -04:00
Matthias Clasen
dbd16cd9da Rename GDK_COLOR_INIT_SRGB
Rename the macro to GDK_COLOR_SRGB, and make it usable as
a compound literal as well.

Update all users.
2024-08-06 00:06:41 -04:00
Matthias Clasen
950d266894 Merge branch 'wip/chergert/fix-6133-commit-funcs' into 'main'
textbuffer: Add GtkTextBufferCommitNotify

Closes #6133

See merge request GNOME/gtk!7524
2024-08-06 01:41:23 +00:00
Matthias Clasen
884974eeaa Merge branch 'matthiasc/for-main' into 'main'
gsk: Improve handling of fill and stroke nodes

See merge request GNOME/gtk!7559
2024-08-05 21:01:54 +00:00
Christian Hergert
e836166664 textbuffer: Add GtkTextBufferCommitNotify
Add a new function callback called GtkTetBufferCommitNotify to be notified
of changes to a GtkTextBuffer without being involved in a signal chain.

This is necessary for some situations because signal handlers may modify
the parameters as they proceed down to default handler. As such, the signal
is unsuitable for applications heavily utilizing plug-ins such as Builder
due to non-deterministic signal connection ordering.

This technique has been used in Builder for the better part of a decade
and now would also vastly help in situations like libspelling where you
also want to know about changes to the buffer right before they are
committed to the b-tree.

Fixes: #6133
2024-08-05 13:28:59 -07:00
Matthias Clasen
c1a99bf901 tests: Link compare-render statically
This is a temporary change, only needed until we make the new
snapshot and rendernode apis public.
2024-08-05 16:09:42 -04:00
Matthias Clasen
f9c9a03404 gsk: Improve handling of fill and stroke nodes
Use GdkColor here. We still convert to sRGB as the last step, though.
2024-08-05 15:59:28 -04:00
Matthias Clasen
3a337824e6 Merge branch 'css-color-hookup-1' into 'main'
Add GdkColor, make non-srgb css colors work for color nodes

See merge request GNOME/gtk!7546
2024-08-05 16:11:39 +00:00
Matthias Clasen
7dab23e38a gl: Handle color nodes with color states
Since we don't have proper color management here, just convert
any color we meet to sRGB and hope for the best.
2024-08-05 11:11:15 -04:00
Matthias Clasen
78935ec83c Make node-format.md part of the docs
This makes useful information more easily available, and it also
serves to validate the markdown.
2024-08-05 11:11:15 -04:00
Matthias Clasen
b8989b7ff6 Add a compare test for color states
This checks that the red values in all 4 default color states
come out identical to a plain old red png.
2024-08-05 11:11:15 -04:00
Matthias Clasen
96cd47d0a0 inspector: Show more color node details
Show the color state, and create textures with the full color
information.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d6a6cfe6c5 gtk: Fix gtk_snapshot_collect_repeat
This creates a new color node that is meant to be identical to
an existing one, so we need to use gsk_color_node_new2 to preserve
the color state information.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
501356116d gtk: Preserve css background color spaces
When rendering css backgrounds, use the new gtk_css_color_get_color
and gtk_snapshot_append_color2 apis to preserve color spaces as
far as possible.
2024-08-05 11:11:15 -04:00
Matthias Clasen
e11e5525db gtk: Add gtk_snapshot_append_color2
This is a private snapshot function that uses the new color
node constructor to create a color node with a given color state.
2024-08-05 11:11:15 -04:00
Matthias Clasen
16431da3f2 nodeparser: Add support for cicp color states
Allow defining cicp color states with an @-rule:

    @cicp "jpeg" {
      primaries: 1;
      transfer: 13;
      matrix: 6;
      range: full;
    }

And allow using them in color() like this:

    color("jpeg" 50% 0.5 1 / 75%)

Note that custom color states use a string, unlike default color
states which use an ident.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
842949fcf3 nodeparser: Support color states
And allow using color states for colors with a syntax similar
to modern css color syntax.

color(srgb 50% 0.5 1 / 75%)

Both floating point numbers and percentages can be used.

Currently, this is only supported for color nodes.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
3d3e935c91 offload: Use gsk_color_node_get_color2
We want the blackest black.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d5ae94ca5d testsuite: Update replay nodes
We can't currently recreate color nodes with public api, so cheat
and reuse the node we got.
2024-08-05 11:11:15 -04:00
Matthias Clasen
87e9c940a4 gsk: Use the private color node api
Use the color state returned by this function instead of assuming
the color of a color node is always sRGB.

Node colors are converted to the css on the cpu. That is necessary
since we don't know if they are in one of the default color states,
and our shaders can't deal with non-default color states.
2024-08-05 11:11:14 -04:00
Matthias Clasen
6a02fa4be8 gsk: Add private color node api
Add a constructor that takes a color state, a getter for it, and
also a getter for the color coordinates that avoids GdkRGBA.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9f548efd32 gsk: Change color op apis
Make color-related ops take the ccs and a GdkColor, and make
decisions about color conversion on the cpu vs the gpu.

This makes the node processor code simpler, and lets use convert
the color directly into the op instance without extra copying.

We also pass opacity to the op, so it can be applied when we
write the color into the instance.

Lastly, rorder the offset to come right after the opacity argument.

Treat the color and rounded color ops the same way.

Update all callers.

With this, the prepare_color apis in gskgpunodeprocessor.c are
no longer used and have been dropped.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9eebe8e547 gsk: Change the clear op api
A clear op is just a fancy memcpy. Make it the callers responsibility
to convert the color to the right color state before passing it
to the clear op.
2024-08-05 11:11:14 -04:00
Matthias Clasen
f9612533c2 css: Add gtk_css_color_to_color
This api lets one obtain a color state and color values from
a GtkCssColor. We don't want to force everything though sRGB,
but we can't quite avoid conversion here, since we don't have
a 100% match between the css color spaces and color states.

css color cleanup
2024-08-05 11:11:14 -04:00
Matthias Clasen
c9c0d444a2 cairo: Add gdk_cairo_set_source_color
This lets us set a GdkColor as a cairo source.
2024-08-05 11:11:14 -04:00