Commit Graph

81274 Commits

Author SHA1 Message Date
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
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
Matthias Clasen
13a8704f51 Add GdkColor
For now, this is all private api.

Parts of it will be opened up in 4.18.
2024-08-05 11:11:14 -04:00
Arjan Molenaar
f20714262c Merge branch 'macos-fix-window-transparency' into 'main'
macos: fix window transparency

Closes #6838

See merge request GNOME/gtk!7544
2024-08-05 12:20:32 +00:00
Matthias Clasen
11ffeeb55c Merge branch 'wip/otte/for-alice' into 'main'
Fix warning on startup

See merge request GNOME/gtk!7547
2024-08-05 12:18:00 +00:00
Matthias Clasen
ffc89e40a0 colorstate: Add a color conversion function
Add a function for converting a single color from one
color state to another. This is a generalization of the
already existing function to convert a GdkRGBA to another
color state.
2024-08-04 14:21:15 -04:00
Matthias Clasen
1c92f2d963 Merge branch 'matthiasc/for-main' into 'main'
Disable blur-performance build

See merge request GNOME/gtk!7549
2024-08-04 02:52:53 +00:00
Matthias Clasen
12e0ec0b48 Add gtk_css_parser_has_percentage 2024-08-03 22:31:32 -04:00
Matthias Clasen
5574bf59f6 Disable blur-performance build
This is an old test that isn't very relevant anymore, and it has
some linking problems because it includes private headers that
have inlined functions.
2024-08-03 22:31:21 -04:00
Matthias Clasen
7ee27cc0ad Merge branch 'matthiasc/for-main' into 'main'
gpu: Rename function

See merge request GNOME/gtk!7548
2024-08-04 01:23:41 +00:00
Benjamin Otte
040974c8a2 iconhelper: Size no longer depends on scale
This is a leftover from GTK3 when iconhelper sizes depended on the
texture size.

Now we only need to queue a redraw with the new icon.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 03:11:56 +02:00
Benjamin Otte
126d689086 gpu: Rename function
We want to reuse gsk_gpu_color_to_float() for use with GdkColor and this
function will be replaced. But until that's fully done, we need 2
different names.

So rename this one to something else
2024-08-03 20:59:40 -04:00
Benjamin Otte
8e676c7360 windowcontrols: No need to listen to scale factor changes
This is a GTK3 leftover where the icons were manually drawn and sized.
Now that they're managed by actual widgets that enforce a correct size
that is independent of scale factor, this is no longer necessary.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 01:23:07 +02:00
Arjan Molenaar
84847e46fa macos: fix window transparency
Revert window decoration changes from
a6ce506714.
2024-08-02 17:30:48 +02:00
Matthias Clasen
3fca84f974 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7543
2024-08-02 13:45:40 +00:00
Matthias Clasen
2be48a8f86 Pass ccs to the cairo blur code
This is needed to set the color properly.
2024-08-02 09:13:41 -04:00
Matthias Clasen
389d246af8 Fix up the blur-performance test
Add a hack to work aroundt he fact that the blur performance test
includes private headers which inline accesses to non-exported
variables.
2024-08-02 09:12:37 -04:00