Compare commits

...

116 Commits

Author SHA1 Message Date
Matthias Clasen 3f8076a085 texture: Fix an oversight
construct-only properties also get set at construct time,
so we need to handle NULL here, until all our texture construction
methods pass a color state.
2024-06-24 07:39:36 -04:00
Matthias Clasen ca6fe07b27 gl: Do linear compositing 2024-06-22 13:19:57 -04:00
Matthias Clasen bdb6552408 gpu: Use stem darkening for linear composited glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear better, in particular at small sizes.

See https://freetype.org/freetype2/docs/hinting/text-rendering-general.html
2024-06-22 13:19:57 -04:00
Matthias Clasen 7626f8262d cairo: Use stem darkening for glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear better, in particular at small sizes.

See https://freetype.org/freetype2/docs/hinting/text-rendering-general.html
2024-06-22 13:19:57 -04:00
Matthias Clasen 05e470f2cd cairo: Convert the contents back to srgb
We let cairo operate in linear srgb (by giving it all colors and
texture input in linear srgb), and so we need to convert the
results back to srgb in the end.
2024-06-22 13:19:57 -04:00
Matthias Clasen c5883853d7 cairo: Convert textures to srgb-linear
Use the new gdk_memort_format_convert_color_state api to
convert textures to linear srgb before passing them to
cairo.
2024-06-22 13:19:57 -04:00
Matthias Clasen 2250761474 cairo: Convert colors to srgb-linear 2024-06-22 13:19:57 -04:00
Matthias Clasen d35df199b0 gdk: Add a fast-path
Special case u8 RGBA8p, which is the common case.
2024-06-22 13:19:57 -04:00
Matthias Clasen 87f9c26414 gdk: Add gdk_memory_format_convert_color_state
This allows in-place color state conversions.
2024-06-22 13:19:57 -04:00
Matthias Clasen d2cc2b6ea8 Temporarily disable gsk compare test variant
Too much failure.
2024-06-22 13:19:57 -04:00
Matthias Clasen f73a34e71a glx: Create srgb drawables if possible
Make our visual selection code prefer fbconfigs that are
'srgb framebuffer capable', and mark the surface as 'is srgb'
in this case.

This arranges things so that GSK knows not to use an offscreen
for converting contents back to srgb in the end.
2024-06-22 13:19:57 -04:00
Matthias Clasen b5f5e6e34b gl: Enable GL_FRAMEBUFFER_SRGB
It seems that we need this for GL_SRGB to work in GLX.
2024-06-22 13:19:57 -04:00
Matthias Clasen 7f71443d6b gdk: Use the vulkan srgb image format
We want to do compositing in a linear colorspace, and this
will take care of the 'convert back to srgb in the end' step.
2024-06-22 13:19:57 -04:00
Matthias Clasen bb130960e2 gdk: Create our egl surface with srgb colorspace
We want to do our compositing in a linear colorspace, and the
EXT_KHR_gl_colorspace extension helps for that. We don't hard-
require it, since it isn't super-common in the wild (37%).

If we have the extension, create our egl surface with the
srgb colorspace, and report that face in gdk_surface_gl_is_srgb().
2024-06-22 13:19:57 -04:00
Matthias Clasen 0ebc7660a2 gpu: Add debug spew 2024-06-22 13:19:57 -04:00
Matthias Clasen fe885d9f41 gpu: Make compositing happen in linear space
For now, we always deliver our framebuffer in srgb, and we always
want to composite in srgb-linear. If GL/Vulkan have provided us
with a back buffer that does this conversion on its own, we just
use it. The is expected to work at least for cases where we use
an u8 frame buffer.

Otherwise, we pass the target and compositing color states down
to where we call into the node processor to process nodes, create
an offscreen for rendering to, and then do manual color conversion
afterwards to put the result into the frame buffer.
2024-06-22 13:19:57 -04:00
Matthias Clasen 3076cd9a47 gpu: Convert textures to the right color state
Add function to convert an image from one color state to another,
and call it whenever we upload a texture.
2024-06-22 13:19:57 -04:00
Matthias Clasen b710e72e1e gpu: Return color state when uploading textures
We want to allow for the possibility that we can automatically
convert from srgb to srgb-linear by picking the right image
format, so we need the upload operation to return the proper
color state for the image that it created.

For now, we do nothing with the returned information.
2024-06-22 13:19:57 -04:00
Matthias Clasen c6bb894507 gpu: Pass color state to upload ops
This is so we can make decisions about the kind of image to create
based on the kind of colorstate we are going to upload.
2024-06-22 13:19:57 -04:00
Matthias Clasen a6351ea8be gpu: track color state in the texture cache
Keep the color state information around for cached images.

We keep up to two different images per texture - that is enough to
keep the original uploaded image and the one that has been converted
to the compositing colorstate.
2024-06-22 13:19:57 -04:00
Matthias Clasen 68e132d2c0 gpu: Pass linear colors to clear ops too
This was forgotten when colors were converted.
2024-06-22 13:19:57 -04:00
Matthias Clasen dd79dd0a52 gpu: Pass colors in srgb-linear
GdkRGBA is defined to be in srgb. Since we want to do our
compositing in srgb-linear, convert the coors as we send
them to the shader.
2024-06-22 13:19:57 -04:00
Matthias Clasen f7ff943d08 gpu: Pass compositing color states around
Make the node processor and the pattern writer track the current
compositing color state. Color state nodes change it. We pass
the surface color state down via the frame apis.
2024-06-22 13:19:57 -04:00
Matthias Clasen 6f37b64e4c gpu: Add a color convert shader
This shader converts between two color states, by using the
same functions that we use on the cpu. The conversion to perform
is passed as an integer encoding the pair of color states.

For now, the only possible color states are srgb and srgb-linear.
2024-06-22 13:19:57 -04:00
Matthias Clasen 7f7b104438 gpu: Mark images that convert srgb
This is a special property that gpu images can have, that they
automatically convert between the linear srgb that the shaders
see, and the nonlinear srgb that the image is stored in.
2024-06-22 13:19:57 -04:00
Matthias Clasen c76a22224b gdk: Add gdk_surface_get_gl_is_srgb()
This is a way to query whether the framebuffer we use is using GL_SRGB
or equivalent. Currently, it just returns FALSE.
2024-06-22 13:19:57 -04:00
Matthias Clasen 531ca56a20 gdk: Add gdk_texture_get_color_state
This does not do anything yet, just return srgb.
2024-06-22 13:19:57 -04:00
Matthias Clasen 5eaba3b123 gdk: Add GdkColorState
This is mostly an empty shell for now. We only have static instances
for srgb and srgb-linear, which we will use as markers during our
node processing.

In the future, this object may grow more instances, as well as the
ability to create them from and save them to icc profiles or cicp
data. And a color conversion api.
2024-06-22 13:19:57 -04:00
Benjamin Otte d697cce5b0 gdk: Allow querying GL SRGB formats
Nobody is using this yet.
2024-06-22 13:19:57 -04:00
Benjamin Otte ccc646dda7 gdk: Allow querying Vulkan SRGB formats
Nobody is using this yet, this is just infrastructure.
2024-06-22 13:19:57 -04:00
Matthias Clasen f5b7e131d6 Merge branch 'ngl-render-texture-dmabuf' into 'main'
ngl: Export dmabuf textures from render_texture

See merge request GNOME/gtk!7375
2024-06-22 17:19:24 +00:00
Matthias Clasen 51012c1802 ngl: Export dmabuf textures from render_texture
We want dmabufs because we can import them into Vulkan, amongst
other things.
2024-06-22 08:02:31 -04:00
Matthias Clasen b5c1e77d4c Merge branch 'matthiasc/for-main' into 'main'
testsuite: Fix up memorytexture printing

See merge request GNOME/gtk!7374
2024-06-21 23:42:45 +00:00
Matthias Clasen 85149445e0 testsuite: Fix up memorytexture printing
This was bungled in 96cb38dd05.
2024-06-21 19:14:31 -04:00
Matthias Clasen 61d0043f9c Merge branch 'fontconfig-grrr' into 'main'
Try to avoid aliasing with system fonts

See merge request GNOME/gtk!7368
2024-06-21 23:02:00 +00:00
Matthias Clasen 5c97089e59 Update expected results
Since we've given up on embedding subsetted system fonts, we need
to regenerate our reference files once more.
2024-06-21 18:45:43 -04:00
Matthias Clasen 6f5c610858 gsk: Give up automatic font subsetting
Despite my best effort, it seems impossible to make ci and local
builds agree on what font subsetter and fonts to use, so make this
opt-in for now: If you want to produce a node file with embedded
fonts, set GSK_SUBSET_FONTS=1.
2024-06-21 18:45:32 -04:00
Matthias Clasen a05dd4d194 Isolate our nodeparser tests better
Add a custom fontconfig setup and ship Cantarell as part of it.
This should hopefully make it so that the tests always see the
same default font, as long as you have FONTCONFIG_FILE set up
correctly.

Update all affected tests.
2024-06-21 18:17:11 -04:00
Matthias Clasen b1a840bec0 Try to avoid aliasing with system fonts
The rendernode parser creates its own fontmap for the fonts that
we deserialize from blobs. But we were using the system fontconfig
configuration for it, leading to system fonts still being found.
This is bad, and causes test failures in ci. Try with an empty
fontconfig configuration instead.
2024-06-21 18:17:11 -04:00
Matthias Clasen 31fabecddd Merge branch 'print-pixesl' into 'main'
wip: print pixels when memorytexture tests fail

See merge request GNOME/gtk!7373
2024-06-21 20:33:21 +00:00
Matthias Clasen 96cb38dd05 wip: print pixels when memorytexture tests fail
This helps with debugging.
2024-06-21 15:48:30 -04:00
Matthias Clasen b672dabee8 Merge branch 'wip/otte/for-main' into 'main'
node-editor: Make this app non-unique

See merge request GNOME/gtk!7372
2024-06-21 19:47:37 +00:00
Benjamin Otte 5fbdec2a29 vulkan: Slight refactoring for future changes
No functional changes.
2024-06-21 19:53:46 +02:00
Benjamin Otte f22ae99b98 gdk: Improve memorytexture test output
On failures, don't immediately abort, just g_test_fail().
This allows running the test with -k to get full output.

Also print something useful as the error message, namely the bytes that
are different.
2024-06-21 19:53:46 +02:00
Benjamin Otte 3be7ef17ff node-editor: Make this app non-unique
There's no benefit in having multiple windows share the process.

But there's a huge disadvantage because running the app a 2nd time with
different environment variables will open a window in the first process
instead and discard the variables.

And my use of GSK_RENDERER hates that.
2024-06-21 19:53:46 +02:00
Милош Поповић 146422fabd Update Serbian translation 2024-06-20 17:41:29 +00:00
Matthias Clasen a274a5ff4b Merge branch 'matthiasc/for-main' into 'main'
Simply some internal api

See merge request GNOME/gtk!7369
2024-06-19 06:40:25 +00:00
Matthias Clasen d1d4d80a1d Simply some internal api
The only caller of gdk_memory_texture_from_texture doesn't use
the second argument.
2024-06-19 02:06:14 -04:00
Matthias Clasen 167d32811d Merge branch 'matthiasc/for-main' into 'main'
Fix a crash in rendernode serialization

See merge request GNOME/gtk!7367
2024-06-18 03:02:53 +00:00
Matthias Clasen 6ec4a2a4a5 Exclude some more gradient compare tests
These are prone to rounding errors.
2024-06-17 22:28:33 -04:00
Matthias Clasen a11abf57e1 testsuite: Regenerate a bunch of .ref.node files
We serialize fonts now, so these show up in the node references.
2024-06-17 22:14:34 -04:00
Matthias Clasen a63a201812 Fix a crash in rendernode serialization
This snuck in with a6ffd6b3b2.
2024-06-17 22:09:30 -04:00
Matthias Clasen f09caced9b Drop debug spew 2024-06-17 21:44:33 -04:00
Emmanuele Bassi 01cd2fe4bb Merge branch 'wip/alice/about-dialog-fix' into 'main'
aboutdialog: Fix build on windows

See merge request GNOME/gtk!7365
2024-06-17 13:25:58 +00:00
Alice Mikhaylenko 45b93644b7 aboutdialog: Fix build on windows 2024-06-17 15:38:47 +04:00
Matthias Clasen 76a80d8f45 Merge branch 'docs-drawing-overview' into 'main'
docs: gtk_widget_queue_draw() is a single function, not a set anymore

See merge request GNOME/gtk!7362
2024-06-16 18:16:42 +00:00
Matthias Clasen 153b8399f7 Merge branch 'matthiasc/for-main' into 'main'
css: Move the color space enums to a better place

See merge request GNOME/gtk!7363
2024-06-16 18:14:01 +00:00
Matthias Clasen da41271dd5 css: Parse interpolation for conic gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

This commit fixes preexisting brokenness in conic-gradient parsing
and printing as well, and includes the relevant test changes.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:36 -04:00
Matthias Clasen 5610af1b77 css: Parse interpolation for radial gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:27 -04:00
Matthias Clasen 8da70fec91 css: Parse interpolation for linear gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:21:56 -04:00
Matthias Clasen f9cd30a859 css: Better error reporting
I seem to mix up the order of 'longer hue' occasionally, so lets
throw a helpful error message if we see 'hue' first.
2024-06-16 13:04:58 -04:00
Matthias Clasen 763d620a23 css: Parse all supported color spaces
The code parsing interpolation methods hadn't learned about
or latest color space additions. While we're at it, improve
the error reporting a bit.

Tests included.
2024-06-16 13:04:52 -04:00
Matthias Clasen 500a3a6dee css: Add a helper function for parsing
This will be helpful in gradient parsing code, where the color
interpolation is optional.
2024-06-16 13:04:44 -04:00
Matthias Clasen 57073e1057 css: Move the color space enums to a better place
These will be used in the gradient code too, so put them into
a more better place.
2024-06-16 13:04:13 -04:00
Daniel Rusek 6bbfd2f62a Update Czech translation 2024-06-16 13:32:33 +00:00
Gabor Karsay 6c69a96cd7 docs: link some methods in drawing model overview 2024-06-16 10:30:44 +00:00
Gabor Karsay fa247d5a84 docs: gtk_widget_queue_draw() is a single function, not a set anymore 2024-06-16 10:02:32 +00:00
Matthias Clasen 0320c4ac14 Merge branch 'matthiasc/for-main' into 'main'
gpu: Print some more details

See merge request GNOME/gtk!7360
2024-06-15 21:59:14 +00:00
Matthias Clasen 36993ac707 gpu: Print some more details
Print the variations of mask and blendmode operations.
Just because we can.
2024-06-15 14:00:46 -04:00
Matthias Clasen 2f93eb4a28 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7358
2024-06-14 23:18:55 +00:00
Matthias Clasen 5a2982ac31 testsuite: Fix one nodeparser error 2024-06-14 14:11:54 -04:00
Matthias Clasen 441b704afd testsuite: Stop relying on xpms
gdk-pixbuf isn't loading those anymore, by default.
2024-06-14 14:11:22 -04:00
Matthias Clasen abf6ebd7fe label: Only put alpha in attributes when needed
It does not do much harm, but it broke some of our tests.
2024-06-14 14:04:23 -04:00
Matthias Clasen 34fb08af6e Fix a copy-paste error
This was obviously meant to compare two different colors.
2024-06-14 12:30:06 -04:00
Matthias Clasen 0b9dfdd41f Merge branch 'wip/alice/color-fix' into 'main'
More color clamping and redraw fixes

See merge request GNOME/gtk!7357
2024-06-14 11:07:49 +00:00
Alice Mikhaylenko 701e0812e4 treeview: Clamp tree line and grid line colors 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko 4918a46172 textview: Redraw selection on style changes 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko ef5e3fae64 aboutdialog: Update link colors on css changes 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko 9fcf55571e textlayout: Clamp colors before passing them to Pango 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko 260898ecf6 text: Redraw when selection style changes 2024-06-14 01:41:22 +04:00
Alice Mikhaylenko 66c9132abe label: Update selection on css changes too 2024-06-14 01:41:22 +04:00
Alice Mikhaylenko c5abdfb72b label: Fix critical when updating styles
Noticed when testing with libadwaita styles instead of GTK styles.
2024-06-13 23:36:38 +04:00
Matthias Clasen 4fe37847ba Merge branch 'wip/alice/color-fix' into 'main'
Fix GtkLabel link color

Closes #6781

See merge request GNOME/gtk!7355
2024-06-13 13:28:58 +00:00
Alice Mikhaylenko c99a0b0518 label: Track link style changes
If we're gonna have system accents, would be nice to update links reliably
and not wait for other changes like changing color of the label itself.
2024-06-13 16:28:06 +04:00
Alice Mikhaylenko 31f3edec5c label: Clamp out-of-gamut link color
Support alpha too while we're here.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6781
2024-06-13 16:28:05 +04:00
Emmanuele Bassi dee372c08e Merge branch 'ebassi/docs-for-master' into 'main'
docs: Fix link to DragIcon.get_for_drag()

See merge request GNOME/gtk!7347
2024-06-13 11:27:28 +00:00
Matthias Clasen 8c0a4e5a6e Merge branch 'matthiasc/for-main' into 'main'
Silence a compiler warning

See merge request GNOME/gtk!7354
2024-06-12 03:24:29 +00:00
Matthias Clasen 7195514fb5 Silence a compiler warning 2024-06-11 17:47:48 -04:00
Matthias Clasen 420bd5bc16 Merge branch 'more-css-color-spaces' into 'main'
css: Add more color spaces

See merge request GNOME/gtk!7352
2024-06-11 21:05:06 +00:00
Matthias Clasen f024ee1adf Add more tests for css colors 2024-06-11 16:41:22 -04:00
Matthias Clasen 18c2c71cd5 css: Add support for rec2100-pq colors
This is our first HDR color space. Yay!!

The conversion between rec2020-linear and rec2100-linear
assumes that SDR 1,1,1 has a luminance of 203 cd/m².
2024-06-11 16:41:22 -04:00
Matthias Clasen 2d1bfc84b9 Expose more colorutils
We may want to have a rec2020-linear space available on the gsk
level, so expose the conversion functions for it.
2024-06-11 16:41:22 -04:00
Matthias Clasen 8edfa759fb css: Add support for rec2020 colors
Another extremely wide gamut color space.
2024-06-11 16:41:22 -04:00
Matthias Clasen 2d1e978599 css: Add support for xyz colors
This is somewhat central, and we have all the pieces to support
it, so we might as well add the css syntax for it.
2024-06-11 16:41:22 -04:00
Matthias Clasen d71fc41152 css: Add support for display-p3 colors
A wide-gamut colorspace.
2024-06-11 16:41:22 -04:00
Matthias Clasen d141cb7b72 Fix an oversight
This snuck in as part of 098d67f8befdb00d75.
2024-06-11 16:41:22 -04:00
Matthias Clasen 7010067884 Merge branch 'vulkan-high-depth' into 'main'
gpu: Print more info for renderpasses

See merge request GNOME/gtk!7351
2024-06-09 21:10:25 +00:00
Matthias Clasen 0ec29c4176 gsk: Pass the memory format for back buffer
We can now get this information from the Vulkan context,
so use it to accurately represent the back buffer.

Related: #6767
2024-06-09 15:59:56 -04:00
Matthias Clasen 42c6e0249f vulkan: Fix updating swap chains
gdk_vulkan_context_check_swapchain uses priv->current_format,
so we must update it first, and undo that if check_swapchain
falls. This fixes handling of high-depth back buffers in gsk.
2024-06-09 15:59:56 -04:00
Matthias Clasen 54eb85f814 vulkan: Add a getter for the memory format
We need this to accurately set up the gpu image for the
backbuffer in gsk.
2024-06-09 15:59:56 -04:00
Matthias Clasen 18b3b4feed gpu: Print more info for images
Show the memory format.

This helps debugging our depth selection.
2024-06-09 15:59:32 -04:00
Matthias Clasen 0045ac839b Give memory formats a name
This is useful in debugging.

The names I chose are shortened a bit from the enum values. We
use just a single depth, * for premultiplied, and f for float.
2024-06-09 15:59:27 -04:00
Matthias Clasen a9da807de3 Merge branch 'cmurtag/fix_harfbuzz_subset_wrap' into 'main'
Fix Harfbuzz subset dependency not found in wrap

See merge request GNOME/gtk!7349
2024-06-08 10:26:12 +00:00
cameron 366639b7e4 Fix Harfbuzz subset dependency not found in wrap
Add harfbuzz subset to the harfbuzz wrap file so Meson can find the
dependency.
2024-06-08 13:54:21 +10:00
Emmanuele Bassi 7d2e2171be docs: Fix link to DragIcon.get_for_drag()
It has been marked as a constructor in commit 13013053f7.
2024-06-07 13:33:32 +02:00
Matthias Clasen e3ceda15ac Merge branch 'gsktransform-improve-docs' into 'main'
gsktransform: Document consuming functions

See merge request GNOME/gtk!7342
2024-06-06 10:53:17 +00:00
Matthias Clasen 7291a21a85 Merge branch 'wip/alice/css' into 'main'
CSS fixes and more tests

See merge request GNOME/gtk!7345
2024-06-05 20:54:12 +00:00
Matthias Clasen 888afe3e46 Merge branch 'wip/alice/opacity' into 'main'
css: Allow percents in opacity

See merge request GNOME/gtk!7346
2024-06-05 20:53:55 +00:00
Alice Mikhaylenko 171bfde133 csscolorvalue: Fix percentage ranges for relative colors
Add tests as well, now that they can be computed at parse time.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko 82d1fdb714 csscolorvalue: Resolve relative colors at parse time when possible 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko 82b19daa7e csscolorvalue: Don't serialize relative colors as rgb()
Spec says it should be color(srgb).
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko dc1ff3c2e3 csscolorvalue: Fix oklab() percentage range 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko 6602ac5eae testsuite: Fix css tests
There are a bunch of new deprecations, and some tests weren't in
meson.build.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko 5dab5bf0e9 css: Allow percents in opacity
Add another missing feature from web css. It's nice to be able to use the
same variables in color-mix() and here.
2024-06-06 00:22:19 +04:00
Matthijs Velsink 721be8fe9f gsktransform: Document consuming functions
Since GskTransform is immutable, a lot of the documented "methods" are
more like "functions", in the sense that they don't keep the instance
alive but rather consume it.

This is annotated with `(transfer full)`, but since these functions are
listed as methods, their first argument is not shown.

Instead, let's add a line to the docs of each consuming function that
clarifies this behavior.
2024-06-05 15:59:49 +02:00
Matthias Clasen 58fe590eae Merge branch 'matthiasc/for-main' into 'main'
css: Plug a memory leak

See merge request GNOME/gtk!7341
2024-06-05 12:18:50 +00:00
149 changed files with 6596 additions and 2394 deletions
+1 -1
View File
@@ -299,7 +299,7 @@ node_editor_application_new (void)
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.NodeEditor",
"flags", G_APPLICATION_HANDLES_OPEN,
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE,
NULL);
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
+5 -6
View File
@@ -99,16 +99,15 @@ reaches the requested phase. However, in practice most things
happen at higher levels:
- If you are doing an animation, you can use
gtk_widget_add_tick_callback() which will cause a regular
[method@Gtk.Widget.add_tick_callback] which will cause a regular
beating of the clock with a callback in the Update phase
until you stop the tick.
- If some state changes that causes the size of your widget to
change you call gtk_widget_queue_resize() which will request
change you call [method@Gtk.Widget.queue_resize] which will request
a Layout phase and mark your widget as needing relayout.
- If some state changes so you need to redraw some area of
your widget you use the normal gtk_widget_queue_draw()
set of functions. These will request a Paint phase and
mark the region as needing redraw.
- If some state changes so you need to redraw your widget you
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
your widget.
There are also a lot of implicit triggers of these from the
CSS layer (which does animations, resizes and repaints as needed).
+1
View File
@@ -30,6 +30,7 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.h>
+183
View File
@@ -0,0 +1,183 @@
/* gdkcolorstate.c
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h>
/**
* GdkColorState:
*
* A `GdkColorState` object provides the information to interpret
* colors and pixels in a variety of ways.
*
* They are also known as
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
*
* Crucially, GTK knows how to convert colors from one color
* state to another.
*
* `GdkColorState objects are immutable and therefore threadsafe.
*
* Since 4.16
*/
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
gdk_color_state_ref, gdk_color_state_unref);
/* {{{ Public API */
/**
* gdk_color_state_ref:
* @self: a `GdkColorState`
*
* Increase the reference count of @self.
*
* Returns: the object that was passed in
*
* Since: 4.16
*/
GdkColorState *
(gdk_color_state_ref) (GdkColorState *self)
{
return _gdk_color_state_ref (self);
}
/**
* gdk_color_state_unref:
* @self:a `GdkColorState`
*
* Decrease the reference count of @self.
*
* Unless @self is static, it will be freed
* when the reference count reaches zero.
*
* Since: 4.16
*/
void
(gdk_color_state_unref) (GdkColorState *self)
{
_gdk_color_state_unref (self);
}
/**
* gdk_color_state_get_srgb:
*
* Returns the color state object representing the sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb (void)
{
return GDK_COLOR_STATE_SRGB;
}
/**
* gdk_color_state_get_srgb_linear:
*
* Returns the color state object representing the linearized sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
return GDK_COLOR_STATE_SRGB_LINEAR;
}
/**
* gdk_color_state_equal:
* @self: a `GdkColorState`
* @other: another `GdkColorStatee`
*
* Compares two `GdkColorStates` for equality.
*
* Note that this function is not guaranteed to be perfect and two objects
* describing the same color state may compare not equal. However, different
* color states will never compare equal.
*
* Returns: %TRUE if the two color states compare equal
*
* Since: 4.16
*/
gboolean
(gdk_color_state_equal) (GdkColorState *self,
GdkColorState *other)
{
return _gdk_color_state_equal (self, other);
}
/* }}} */
/* {{{ Default implementation */
const char *
gdk_color_state_get_name_from_id (GdkColorStateId id)
{
const char *names[] = {
"srgb", "srgb-linear",
};
return names[id];
}
GdkColorState gdk_default_color_states[] = {
{ NULL, 0 },
{ NULL, 0 },
};
/* }}} */
/* {{{ Private API */
const char *
gdk_color_state_get_name (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
{
switch (GDK_DEFAULT_COLOR_STATE_ID (self))
{
case GDK_COLOR_STATE_ID_SRGB: return "srgb";
case GDK_COLOR_STATE_ID_SRGB_LINEAR: return "srgb-linear";
default: g_assert_not_reached ();
}
}
return self->klass->get_name (self);
}
void
gdk_color_state_print (GdkColorState *self,
GString *string)
{
g_string_append (string, gdk_color_state_get_name (self));
}
GdkMemoryDepth
gdk_color_state_get_min_depth (GdkColorState *self)
{
if (self == GDK_COLOR_STATE_SRGB || self == GDK_COLOR_STATE_SRGB_LINEAR)
return GDK_MEMORY_U8;
return GDK_MEMORY_FLOAT16;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
+50
View File
@@ -0,0 +1,50 @@
/* gdkcolorstate.h
*
* Copyright 2024 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
GDK_AVAILABLE_IN_4_16
GType gdk_color_state_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_ref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
void gdk_color_state_unref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb_linear (void);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
G_END_DECLS
+84
View File
@@ -0,0 +1,84 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkmemoryformatprivate.h"
typedef enum
{
GDK_COLOR_STATE_ID_SRGB,
GDK_COLOR_STATE_ID_SRGB_LINEAR,
} GdkColorStateId;
typedef struct _GdkColorStateClass GdkColorStateClass;
struct _GdkColorState
{
GdkColorStateClass *klass;
int ref_count;
};
struct _GdkColorStateClass
{
void (* free) (GdkColorState *self);
gboolean (* equal) (GdkColorState *self,
GdkColorState *other);
const char * (* get_name) (GdkColorState *self);
};
extern GdkColorState gdk_default_color_states[];
#define GDK_COLOR_STATE_SRGB (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
#define GDK_COLOR_STATE_SRGB_LINEAR (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
#define GDK_IS_DEFAULT_COLOR_STATE(c) (GDK_COLOR_STATE_SRGB <= (c) && (c) <= GDK_COLOR_STATE_SRGB_LINEAR)
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (c - gdk_default_color_states))
const char * gdk_color_state_get_name (GdkColorState *color_state);
const char * gdk_color_state_get_name_from_id (GdkColorStateId id);
void gdk_color_state_print (GdkColorState *color_state,
GString *string);
GdkMemoryDepth gdk_color_state_get_min_depth (GdkColorState *color_state);
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
static inline GdkColorState *
_gdk_color_state_ref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return self;
self->ref_count++;
return self;
}
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
static inline void
_gdk_color_state_unref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return;
self->ref_count--;
if (self->ref_count == 0)
self->klass->free (self);
}
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
static inline gboolean
_gdk_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
if (self == other)
return TRUE;
if (GDK_IS_DEFAULT_COLOR_STATE (self) || GDK_IS_DEFAULT_COLOR_STATE (other))
return FALSE;
if (self->klass != other->klass)
return FALSE;
return self->klass->equal (self, other);
}
+2
View File
@@ -1874,6 +1874,8 @@ gdk_display_init_egl (GdkDisplay *self,
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
self->have_egl_dma_buf_export =
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
self->have_egl_gl_colorspace =
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
if (self->have_egl_no_config_context)
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
+1
View File
@@ -130,6 +130,7 @@ struct _GdkDisplay
guint have_egl_pixel_format_float : 1;
guint have_egl_dma_buf_import : 1;
guint have_egl_dma_buf_export : 1;
guint have_egl_gl_colorspace : 1;
GdkDmabufFormats *dmabuf_formats;
GdkDmabufDownloader *dmabuf_downloaders[4];
+2
View File
@@ -1758,6 +1758,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->features = supported_features & ~disabled_features;
glEnable (GL_FRAMEBUFFER_SRGB);
gdk_gl_context_init_memory_flags (context);
if ((priv->features & GDK_GL_FEATURE_DEBUG) && gl_debug)
+7 -7
View File
@@ -151,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLint q_internal_format;
GLint q_internal_format, q_internal_srgb_format;
GLenum q_format, q_type;
GLint q_swizzle[4];
@@ -164,6 +164,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&q_internal_format,
&q_internal_srgb_format,
&q_format,
&q_type,
q_swizzle);
@@ -187,7 +188,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLint gl_internal_format;
GLint gl_internal_format, gl_internal_srgb_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
@@ -199,7 +200,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
{
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride &&
download->format == format)
@@ -262,7 +263,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
}
@@ -274,7 +275,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
@@ -471,8 +472,7 @@ gdk_gl_texture_release (GdkGLTexture *self)
g_return_if_fail (self->saved == NULL);
texture = GDK_TEXTURE (self);
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture)));
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
drop_gl_resources (self);
}
+327
View File
@@ -23,6 +23,8 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkcolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
#include "gsk/gl/fp16private.h"
@@ -327,6 +329,7 @@ ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
struct _GdkMemoryFormatDescription
{
const char *name;
GdkMemoryAlpha alpha;
GdkMemoryFormat premultiplied;
GdkMemoryFormat straight;
@@ -337,7 +340,9 @@ struct _GdkMemoryFormatDescription
struct {
GLint internal_gl_format;
GLint internal_gles_format;
GLint internal_srgb_format;
GLenum format;
GLenum srgb_format;
GLenum type;
GLint swizzle[4];
/* -1 if none exists, ie the format is already RGBA
@@ -347,6 +352,7 @@ struct _GdkMemoryFormatDescription
} gl;
#ifdef GDK_RENDERING_VULKAN
VkFormat vk_format;
VkFormat vk_srgb_format;
#endif
#ifdef HAVE_DMABUF
guint32 dmabuf_fourcc;
@@ -366,6 +372,7 @@ struct _GdkMemoryFormatDescription
static const GdkMemoryFormatDescription memory_formats[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
.name = "*BGRA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -378,6 +385,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -386,6 +394,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -394,6 +403,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
.name = "*ARGB8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -406,6 +416,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -414,6 +425,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -422,6 +434,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_premultiplied_from_float,
},
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
.name = "*RGBA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -434,6 +447,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -441,6 +455,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -449,6 +464,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = {
.name = "*ABGR8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -461,6 +477,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -469,6 +486,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -477,6 +495,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_premultiplied_from_float,
},
[GDK_MEMORY_B8G8R8A8] = {
.name = "BGRA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -489,6 +508,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -497,6 +517,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -505,6 +526,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_from_float,
},
[GDK_MEMORY_A8R8G8B8] = {
.name = "ARGB8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -517,6 +539,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -525,6 +548,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -533,6 +557,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8A8] = {
.name = "RGBA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -545,6 +570,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -552,6 +578,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -560,6 +587,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_from_float,
},
[GDK_MEMORY_A8B8G8R8] = {
.name = "ABGR8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -572,6 +600,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -580,6 +609,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -588,6 +618,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_from_float,
},
[GDK_MEMORY_B8G8R8X8] = {
.name = "BGRX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8X8,
.straight = GDK_MEMORY_B8G8R8X8,
@@ -601,6 +632,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -609,6 +641,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XRGB8888,
@@ -617,6 +650,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8x8_from_float,
},
[GDK_MEMORY_X8R8G8B8] = {
.name = "XRGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8R8G8B8,
.straight = GDK_MEMORY_X8R8G8B8,
@@ -630,6 +664,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -638,6 +673,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRX8888,
@@ -646,6 +682,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8X8] = {
.name = "RGBX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8X8,
.straight = GDK_MEMORY_R8G8B8X8,
@@ -659,6 +696,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -666,6 +704,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XBGR8888,
@@ -674,6 +713,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8x8_from_float,
},
[GDK_MEMORY_X8B8G8R8] = {
.name = "XBGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8B8G8R8,
.straight = GDK_MEMORY_X8B8G8R8,
@@ -687,6 +727,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -695,6 +736,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBX8888,
@@ -703,6 +745,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8b8g8r8_from_float,
},
[GDK_MEMORY_R8G8B8] = {
.name = "RGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8,
.straight = GDK_MEMORY_R8G8B8,
@@ -716,6 +759,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_RGB,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -723,6 +767,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGR888,
@@ -731,6 +776,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8_from_float,
},
[GDK_MEMORY_B8G8R8] = {
.name = "BGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8,
.straight = GDK_MEMORY_B8G8R8,
@@ -744,6 +790,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_BGR,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -752,6 +799,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGB888,
@@ -760,6 +808,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8_from_float,
},
[GDK_MEMORY_R16G16B16] = {
.name = "RGB16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16,
.straight = GDK_MEMORY_R16G16B16,
@@ -776,6 +825,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16,
.internal_gles_format = GL_RGB16,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -783,6 +833,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -791,6 +842,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_from_float,
},
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
.name = "*RGBA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -806,6 +858,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -813,6 +866,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -821,6 +875,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16A16] = {
.name = "RGBA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -836,6 +891,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -843,6 +899,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -851,6 +908,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16_FLOAT,
.straight = GDK_MEMORY_R16G16B16_FLOAT,
@@ -866,6 +924,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16F,
.internal_gles_format = GL_RGB16F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -873,6 +932,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -881,6 +941,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -895,6 +956,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -902,6 +964,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -910,6 +973,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -924,6 +988,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -931,6 +996,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -939,6 +1005,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R32G32B32_FLOAT] = {
.name = "RGB32f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R32G32B32_FLOAT,
.straight = GDK_MEMORY_R32G32B32_FLOAT,
@@ -954,6 +1021,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB32F,
.internal_gles_format = GL_RGB32F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -961,6 +1029,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -969,6 +1038,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -983,6 +1053,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -990,6 +1061,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -998,6 +1070,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT] = {
.name = "RGBA32f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1012,6 +1085,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1019,6 +1093,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1027,6 +1102,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
.name = "*GA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1040,6 +1116,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1047,6 +1124,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1055,6 +1133,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_premultiplied_from_float,
},
[GDK_MEMORY_G8A8] = {
.name = "GA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1068,6 +1147,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1075,6 +1155,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1083,6 +1164,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_from_float,
},
[GDK_MEMORY_G8] = {
.name = "G8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G8,
.straight = GDK_MEMORY_G8,
@@ -1096,6 +1178,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1103,6 +1186,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R8,
@@ -1111,6 +1195,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8_from_float,
},
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
.name = "*GA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1127,6 +1212,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1134,6 +1220,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1142,6 +1229,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_premultiplied_from_float,
},
[GDK_MEMORY_G16A16] = {
.name = "GA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1158,6 +1246,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1165,6 +1254,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1173,6 +1263,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_from_float,
},
[GDK_MEMORY_G16] = {
.name = "G16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G16,
.straight = GDK_MEMORY_G16,
@@ -1189,6 +1280,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1196,6 +1288,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R16,
@@ -1204,6 +1297,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16_from_float,
},
[GDK_MEMORY_A8] = {
.name = "A8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8,
.straight = GDK_MEMORY_A8,
@@ -1217,6 +1311,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1224,6 +1319,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1232,6 +1328,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8_from_float,
},
[GDK_MEMORY_A16] = {
.name = "A16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16,
.straight = GDK_MEMORY_A16,
@@ -1248,6 +1345,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1255,6 +1353,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1263,6 +1362,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_from_float,
},
[GDK_MEMORY_A16_FLOAT] = {
.name = "A16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16_FLOAT,
.straight = GDK_MEMORY_A16_FLOAT,
@@ -1278,6 +1378,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16F,
.internal_gles_format = GL_R16F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1285,6 +1386,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1293,6 +1395,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_float_from_float,
},
[GDK_MEMORY_A32_FLOAT] = {
.name = "A32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A32_FLOAT,
.straight = GDK_MEMORY_A32_FLOAT,
@@ -1308,6 +1411,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R32F,
.internal_gles_format = GL_R32F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1315,6 +1419,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1509,6 +1614,7 @@ void
gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1517,6 +1623,7 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[format].gl.internal_gles_format;
else
*out_internal_format = memory_formats[format].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[format].gl.internal_srgb_format;
*out_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
@@ -1528,6 +1635,8 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
* @gles: TRUE for GLES, FALSE for GL
* @out_actual_format: The actual RGBA format
* @out_internal_format: the GL internal format
* @out_internal_srgb_format: the GL internal format to use for automatic
* sRGB<=>linear conversion
* @out_format: the GL format
* @out_type: the GL type
* @out_swizzle: The swizzle to use
@@ -1546,6 +1655,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1560,6 +1670,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[actual].gl.internal_gles_format;
else
*out_internal_format = memory_formats[actual].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[actual].gl.internal_srgb_format;
*out_format = memory_formats[actual].gl.format;
*out_type = memory_formats[actual].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.rgba_swizzle, sizeof(GLint) * 4);
@@ -1613,6 +1724,14 @@ gdk_memory_format_vk_format (GdkMemoryFormat format,
return memory_formats[format].vk_format;
}
/* Gets the matching SRGB version of a VkFormat
* Returns VK_FORMAT_UNDEFINED if none exists */
VkFormat
gdk_memory_format_vk_srgb_format (GdkMemoryFormat format)
{
return memory_formats[format].vk_srgb_format;
}
/* Vulkan version of gdk_memory_format_gl_rgba_format()
* Returns VK_FORMAT_UNDEFINED on failure */
VkFormat
@@ -1661,6 +1780,12 @@ gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format)
#endif
}
const char *
gdk_memory_format_get_name (GdkMemoryFormat format)
{
return memory_formats[format].name;
}
static void
premultiply (float *rgba,
gsize n)
@@ -1708,6 +1833,10 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
/* We don't allow overlap here. If you want to do in-place color state conversions,
* use gdk_memory_convert_color_state.
*/
g_assert (dest_data + height * dest_stride < src_data || src_data + height * src_stride < dest_data);
if (src_format == dest_format)
{
@@ -1793,3 +1922,201 @@ gdk_memory_convert (guchar *dest_data,
g_free (tmp);
}
static const guchar srgb_lookup[] = {
0, 12, 21, 28, 33, 38, 42, 46, 49, 52, 55, 58, 61, 63, 66, 68,
70, 73, 75, 77, 79, 81, 82, 84, 86, 88, 89, 91, 93, 94, 96, 97,
99, 100, 102, 103, 104, 106, 107, 109, 110, 111, 112, 114, 115, 116, 117, 118,
120, 121, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136,
137, 138, 139, 140, 141, 142, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
151, 152, 153, 154, 155, 156, 157, 157, 158, 159, 160, 161, 161, 162, 163, 164,
165, 165, 166, 167, 168, 168, 169, 170, 171, 171, 172, 173, 174, 174, 175, 176,
176, 177, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187,
187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 194, 195, 196, 196, 197,
197, 198, 199, 199, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206,
207, 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215,
216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
224, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232,
233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 237, 238, 238, 239, 239, 240,
240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 247, 247,
248, 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255
};
static const guchar srgb_inverse_lookup[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7,
7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19,
20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29,
29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40,
41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54,
55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70,
71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88,
89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109,
110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132,
134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159,
160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188,
190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220,
222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255
};
static void
convert_srgb_to_srgb_linear (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_inverse_lookup[r];
g = srgb_inverse_lookup[g];
b = srgb_inverse_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_linear_to_srgb (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_lookup[r];
g = srgb_lookup[g];
b = srgb_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_to_srgb_linear_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_to_srgb_linear (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_to_srgb_linear (data, width);
data += stride;
}
}
}
static void
convert_srgb_linear_to_srgb_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_linear_to_srgb (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_linear_to_srgb (data, width);
data += stride;
}
}
}
typedef void (* StepFunc) (float s0, float s1, float s2,
float *d0, float *d1, float *d2);
void
gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height)
{
if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
{
convert_srgb_to_srgb_linear_in_place (data, stride, width, height);
}
else if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
{
convert_srgb_linear_to_srgb_in_place (data, stride, width, height);
}
else
{
/* General case, treat it just like gdk_memory_convert */
const GdkMemoryFormatDescription *desc = &memory_formats[format];
StepFunc func;
float *tmp;
if (src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
func = gtk_rgb_to_linear_srgb;
else if (src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
func = gtk_linear_srgb_to_rgb;
else
return;
tmp = g_new (float, width * 4);
for (gsize y = 0; y < height; y++)
{
desc->to_float (tmp, data, width);
if (desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED)
unpremultiply (tmp, width);
for (gsize x = 0; x < 4 * width; x += 4)
func (tmp[x], tmp[x+1], tmp[x+2], &tmp[x], &tmp[x+1], &tmp[x+2]);
if (desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
desc->from_float (data, tmp, width);
data += stride;
}
g_free (tmp);
}
}
+11 -1
View File
@@ -57,6 +57,7 @@ GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth
void gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
@@ -64,18 +65,20 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
#ifdef GDK_RENDERING_VULKAN
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
VkComponentMapping *out_swizzle);
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
GdkMemoryFormat *out_rgba_format,
VkComponentMapping *out_swizzle);
#endif
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
const char * gdk_memory_format_get_name (GdkMemoryFormat format);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
@@ -85,6 +88,13 @@ void gdk_memory_convert (guchar
GdkMemoryFormat src_format,
gsize width,
gsize height);
void gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height);
G_END_DECLS
+5 -11
View File
@@ -202,8 +202,7 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
}
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
gdk_memory_texture_from_texture (GdkTexture *texture)
{
GdkTexture *result;
GBytes *bytes;
@@ -213,21 +212,16 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
if (GDK_IS_MEMORY_TEXTURE (texture))
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
if (gdk_texture_get_format (texture) == format)
return g_object_ref (memtex);
}
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, format, data, stride);
gdk_texture_do_download (texture, texture->format, data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
format,
texture->format,
bytes,
stride);
g_bytes_unref (bytes);
+1 -2
View File
@@ -28,8 +28,7 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format);
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x,
int y,
+24 -3
View File
@@ -1148,9 +1148,11 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
g_return_if_fail (priv->egl_native_window != NULL);
if (gdk_display_get_egl_config_high_depth (display) == gdk_display_get_egl_config (display))
high_depth = FALSE;
if (priv->egl_surface_high_depth != high_depth &&
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
priv->egl_surface != NULL)
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
@@ -1159,16 +1161,35 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
if (priv->egl_surface == NULL)
{
EGLint attribs[4];
int i;
i = 0;
if (!high_depth && display->have_egl_gl_colorspace)
{
attribs[i++] = EGL_GL_COLORSPACE_KHR;
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
}
g_assert (i < G_N_ELEMENTS (attribs));
attribs[i++] = EGL_NONE;
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
high_depth ? gdk_display_get_egl_config_high_depth (display)
: gdk_display_get_egl_config (display),
(EGLNativeWindowType) priv->egl_native_window,
NULL);
attribs);
priv->egl_surface_high_depth = high_depth;
self->is_srgb = !high_depth && display->have_egl_gl_colorspace;
}
#endif
}
gboolean
gdk_surface_get_gl_is_srgb (GdkSurface *self)
{
return self->is_srgb;
}
GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error)
+3
View File
@@ -70,6 +70,7 @@ struct _GdkSurface
guint shortcuts_inhibited : 1;
guint request_motion : 1;
guint has_pointer : 1;
guint is_srgb : 1;
guint request_motion_id;
@@ -302,6 +303,8 @@ void gdk_surface_ensure_egl_surface (GdkSurface
gboolean hdr);
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
gboolean gdk_surface_get_gl_is_srgb (GdkSurface *self);
void gdk_surface_set_widget (GdkSurface *self,
gpointer widget);
gpointer gdk_surface_get_widget (GdkSurface *self);
+50
View File
@@ -44,6 +44,7 @@
#include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h"
#include "gdksnapshot.h"
#include "gdkcolorstateprivate.h"
#include <graphene.h>
#include "loaders/gdkpngprivate.h"
@@ -69,6 +70,7 @@ enum {
PROP_0,
PROP_WIDTH,
PROP_HEIGHT,
PROP_COLOR_STATE,
N_PROPS
};
@@ -282,6 +284,15 @@ gdk_texture_set_property (GObject *gobject,
self->height = g_value_get_int (value);
break;
case PROP_COLOR_STATE:
if (self->color_state)
gdk_color_state_unref (self->color_state);
if (g_value_get_boxed (value))
self->color_state = gdk_color_state_ref (g_value_get_boxed (value));
else
self->color_state = GDK_COLOR_STATE_SRGB;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -306,6 +317,10 @@ gdk_texture_get_property (GObject *gobject,
g_value_set_int (value, self->height);
break;
case PROP_COLOR_STATE:
g_value_set_boxed (value, self->color_state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -344,6 +359,8 @@ gdk_texture_dispose (GObject *object)
gdk_texture_clear_render_data (self);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
}
@@ -388,12 +405,28 @@ gdk_texture_class_init (GdkTextureClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkTexture:color-state: (attributes org.gtk.Property.get=gdk_texture_get_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_boxed ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gdk_texture_init (GdkTexture *self)
{
self->color_state = GDK_COLOR_STATE_SRGB;
}
/**
@@ -727,6 +760,23 @@ gdk_texture_get_height (GdkTexture *texture)
return texture->height;
}
/**
* gdk_texture_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @texture: a `GdkTexture`
*
* Returns the color state associsated with @texture.
*
* Returns: (transfer none): the color state of the `GdkTexture`
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_get_color_state (GdkTexture *texture)
{
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
return texture->color_state;
}
void
gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
+3
View File
@@ -83,6 +83,9 @@ int gdk_texture_get_height (GdkTexture
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_texture_get_color_state (GdkTexture *self);
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
guchar *data,
+2
View File
@@ -26,6 +26,8 @@ struct _GdkTexture
int width;
int height;
GdkColorState *color_state;
gpointer render_key;
gpointer render_data;
GDestroyNotify render_notify;
+1
View File
@@ -74,6 +74,7 @@ typedef cairo_rectangle_int_t GdkRectangle;
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
typedef struct _GdkColorState GdkColorState;
typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
+20 -3
View File
@@ -30,6 +30,7 @@
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkprofilerprivate.h"
#include "gdkmemorytexture.h"
#include <glib/gi18n-lib.h>
#include <math.h>
@@ -647,15 +648,18 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
{
if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
{
GdkMemoryDepth old_format = priv->current_format;
GError *error = NULL;
priv->current_format = depth;
if (!gdk_vulkan_context_check_swapchain (context, &error))
{
g_warning ("%s", error->message);
g_error_free (error);
priv->current_format = old_format;
return;
}
}
priv->current_format = depth;
}
for (i = 0; i < priv->n_images; i++)
{
@@ -880,7 +884,9 @@ gdk_vulkan_context_real_init (GInitable *initable,
switch ((int) formats[i].format)
{
case VK_FORMAT_B8G8R8A8_UNORM:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
case VK_FORMAT_B8G8R8A8_SRGB:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_B8G8R8A8_UNORM)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
@@ -889,7 +895,9 @@ gdk_vulkan_context_real_init (GInitable *initable,
break;
case VK_FORMAT_R8G8B8A8_UNORM:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
case VK_FORMAT_R8G8B8A8_SRGB:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_R8G8B8A8_UNORM)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
@@ -1294,6 +1302,15 @@ gdk_vulkan_context_get_image_format (GdkVulkanContext *context)
return priv->formats[priv->current_format].vk_format.format;
}
GdkMemoryFormat
gdk_vulkan_context_get_memory_format (GdkVulkanContext *context)
{
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), GDK_MEMORY_DEFAULT);
return priv->formats[priv->current_format].gdk_format;
}
/**
* gdk_vulkan_context_get_n_images:
* @context: a `GdkVulkanContext`
+1
View File
@@ -94,6 +94,7 @@ VkDevice gdk_vulkan_context_get_device (GdkVulk
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
GdkMemoryFormat gdk_vulkan_context_get_memory_format (GdkVulkanContext *context);
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
guint id);
+2
View File
@@ -6,6 +6,7 @@ gdk_public_sources = files([
'gdkcairo.c',
'gdkcairocontext.c',
'gdkclipboard.c',
'gdkcolorstate.c',
'gdkcontentdeserializer.c',
'gdkcontentformats.c',
'gdkcontentprovider.c',
@@ -75,6 +76,7 @@ gdk_public_headers = files([
'gdkcairo.h',
'gdkcairocontext.h',
'gdkclipboard.h',
'gdkcolorstate.h',
'gdkcontentdeserializer.h',
'gdkcontentformats.h',
'gdkcontentprovider.h',
+35
View File
@@ -24,6 +24,7 @@
#include "gdkprofilerprivate.h"
#include <glib/gi18n-lib.h>
#include "gdksurfaceprivate.h"
#include <cairo-xlib.h>
@@ -53,6 +54,9 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
GdkX11Surface *self = GDK_X11_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self));
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
Display *dpy = gdk_x11_display_get_xdisplay (display);
XVisualInfo *visinfo;
int value;
if (self->glx_drawable)
return self->glx_drawable;
@@ -62,6 +66,11 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
gdk_x11_surface_get_xid (surface),
NULL);
visinfo = glXGetVisualFromFBConfig (dpy, display_x11->glx_config);
glXGetConfig (dpy, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
surface->is_srgb = value != 0;
XFree (visinfo);
return self->glx_drawable;
}
@@ -758,6 +767,17 @@ visual_is_rgba (XVisualInfo *visinfo)
visinfo->visual->blue_mask == 0x0000ff;
}
static gboolean
visual_is_srgb (Display *display,
XVisualInfo *visinfo)
{
int value;
glXGetConfig (display, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
return value != 0;
}
#define MAX_GLX_ATTRS 30
static gboolean
@@ -777,6 +797,7 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
WITH_STENCIL_AND_DEPTH_BUFFER,
NO_ALPHA,
NO_ALPHA_VISUAL,
NO_SRGB,
PERFECT
} best_features;
int i = 0;
@@ -865,6 +886,20 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
continue;
}
if (!visual_is_srgb (dpy, visinfo))
{
if (best_features < NO_SRGB)
{
GDK_DISPLAY_DEBUG (display, OPENGL, "Best GLX config is %u for visual 0x%lX with no SRGB", i, visinfo->visualid);
best_features = NO_SRGB;
*out_visual = visinfo->visual;
*out_depth = visinfo->depth;
self->glx_config = configs[i];
}
XFree (visinfo);
continue;
}
GDK_DISPLAY_DEBUG (display, OPENGL, "GLX config %u for visual 0x%lX is the perfect choice", i, visinfo->visualid);
best_features = PERFECT;
*out_visual = visinfo->visual;
+7 -1
View File
@@ -1483,6 +1483,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
gboolean ensure_mipmap,
gboolean *out_can_mipmap,
GLint *gl_internalformat,
GLint *gl_internalsrgbformat,
GLenum *gl_format,
GLenum *gl_type,
GLint gl_swizzle[4])
@@ -1507,6 +1508,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (data_format,
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1519,6 +1521,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_gl_context_get_use_es (self->context),
&alt_format,
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle))
@@ -1534,6 +1537,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (alt_format,
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1552,6 +1556,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1670,7 +1675,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
int width, height;
GdkMemoryFormat data_format;
GLint gl_internalformat;
GLint gl_internalformat, gl_internalsrgbformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
@@ -1713,6 +1718,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
ensure_mipmap,
out_can_mipmap,
&gl_internalformat,
&gl_internalsrgbformat,
&gl_format,
&gl_type,
gl_swizzle);
+2 -3
View File
@@ -972,7 +972,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
if (texture_id == 0)
{
downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
downloaded_texture = gdk_memory_texture_from_texture (texture);
/* The download_texture() call may have switched the GL context. Make sure
* the right context is at work again.
@@ -1471,8 +1471,7 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
}
slices = g_new0 (GskGLTextureSlice, n_slices);
memtex = gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture));
memtex = gdk_memory_texture_from_texture (texture);
if (ensure_mipmap)
{
+23
View File
@@ -30,6 +30,13 @@
#include "gskdebugprivate.h"
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
#define MAX_GLYPH_SIZE 128
G_DEFINE_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
@@ -218,6 +225,16 @@ render_glyph (cairo_surface_t *surface,
cairo_t *cr;
PangoGlyphString glyph_string;
PangoGlyphInfo glyph_info;
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (key->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
g_assert (surface != NULL);
@@ -236,6 +253,12 @@ render_glyph (cairo_surface_t *surface,
cairo_destroy (cr);
cairo_surface_flush (surface);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (key->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
static void
+5
View File
@@ -102,3 +102,8 @@ GSK_GL_DEFINE_PROGRAM_NO_CLIP (external,
GSK_GL_DEFINE_PROGRAM_NO_CLIP (premultiply,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("premultiply.glsl")),
GSK_GL_NO_UNIFORMS)
GSK_GL_DEFINE_PROGRAM (colorconvert,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("colorconvert.glsl")),
GSK_GL_ADD_UNIFORM (1, TO_LINEAR, u_to_linear))
+15 -2
View File
@@ -34,6 +34,7 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <glib/gi18n-lib.h>
#include <gsk/gskdebugprivate.h>
#include <gsk/gskrendererprivate.h>
@@ -362,6 +363,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
GdkSurface *surface;
gboolean clear_framebuffer;
float scale;
GdkColorState *target_color_state;
g_assert (GSK_IS_GL_RENDERER (renderer));
g_assert (root != NULL);
@@ -384,6 +386,17 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gsk_render_node_get_preferred_depth (root),
update_area);
if (gdk_surface_get_gl_is_srgb (surface))
{
g_debug ("Relying on GL to do srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
}
else
{
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB;
}
gdk_gl_context_make_current (self->context);
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
@@ -392,7 +405,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, clear_framebuffer);
gsk_gl_render_job_render (job, root);
gsk_gl_render_job_render (job, root, target_color_state);
gsk_gl_driver_end_frame (self->driver);
gsk_gl_render_job_free (job);
@@ -476,7 +489,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
{
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
job = gsk_gl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id, TRUE);
gsk_gl_render_job_render_flipped (job, root);
gsk_gl_render_job_render_flipped (job, root, GDK_COLOR_STATE_SRGB);
texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE);
texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id, gdk_format);
gsk_gl_driver_end_frame (self->driver);
+85 -10
View File
@@ -33,6 +33,7 @@
#include <gdk/gdkdmabuftexture.h>
#include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <gsk/gsktransformprivate.h>
#include <gsk/gskroundedrectprivate.h>
#include <gsk/gskrectprivate.h>
@@ -972,11 +973,28 @@ gsk_gl_render_job_update_clip (GskGLRenderJob *job,
return TRUE;
}
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static inline void
rgba_to_half (const GdkRGBA *rgba,
guint16 h[4])
{
float_to_half4 ((const float *)rgba, h);
float v[4];
v[0] = srgb_inverse_transfer_function (rgba->red);
v[1] = srgb_inverse_transfer_function (rgba->green);
v[2] = srgb_inverse_transfer_function (rgba->blue);
v[3] = rgba->alpha;
float_to_half4 (v, h);
}
/* fill_vertex_data */
@@ -3677,8 +3695,11 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3704,7 +3725,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (slices != NULL);
g_assert (n_slices > 0);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
for (unsigned int i = 0; i < n_slices; i++)
{
@@ -3718,6 +3739,9 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
if (i > 0)
gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3832,8 +3856,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
u1 = (clip_rect.origin.x + clip_rect.size.width - bounds->origin.x) / bounds->size.width;
v1 = (clip_rect.origin.y + clip_rect.size.height - bounds->origin.y) / bounds->size.height;
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3859,7 +3886,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_slice_texture (job->driver, texture, need_mipmap, &slices, &n_slices);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
for (guint i = 0; i < n_slices; i++)
{
@@ -3877,6 +3904,9 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
if (i > 0)
gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3910,8 +3940,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
render_texture:
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -4464,7 +4497,8 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
void
gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root)
GskRenderNode *root,
GdkColorState *target_color_state)
{
graphene_matrix_t proj;
guint framebuffer_id;
@@ -4506,8 +4540,17 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
gsk_gl_render_job_set_alpha (job, 1.0f);
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
GskGLProgram *program;
if (target_color_state == GDK_COLOR_STATE_SRGB)
program = CHOOSE_PROGRAM (job, colorconvert);
else
program = CHOOSE_PROGRAM (job, blit);
if (gsk_gl_render_job_begin_draw (job, program))
{
if (target_color_state == GDK_COLOR_STATE_SRGB)
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -4528,7 +4571,8 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
void
gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root)
GskRenderNode *root,
GdkColorState *target_color_state)
{
G_GNUC_UNUSED gint64 start_time;
float scale;
@@ -4551,7 +4595,38 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
if (job->clear_framebuffer)
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
gsk_gl_render_job_visit_node (job, root);
if (target_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
{
gsk_gl_render_job_visit_node (job, root);
}
else
{
GskGLRenderOffscreen offscreen = {0};
offscreen.bounds = &root->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = TRUE;
offscreen.do_not_cache = TRUE;
gsk_gl_render_job_visit_node_with_offscreen (job, root, &offscreen);
g_assert (offscreen.texture_id);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
job->source_is_glyph_atlas = FALSE;
gsk_gl_render_job_draw_offscreen_rect (job, &root->bounds);
gsk_gl_render_job_end_draw (job);
}
}
gdk_gl_context_pop_debug_group (job->command_queue->context);
gdk_profiler_end_mark (start_time, "Build GL command queue", "");
+4 -2
View File
@@ -30,7 +30,9 @@ GskGLRenderJob *gsk_gl_render_job_new (GskGLDriver *dri
gboolean clear_framebuffer);
void gsk_gl_render_job_free (GskGLRenderJob *job);
void gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root);
GskRenderNode *root,
GdkColorState *color_state);
void gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root);
GskRenderNode *root,
GdkColorState *color_state);
+63
View File
@@ -0,0 +1,63 @@
// VERTEX_SHADER:
// colorconvert.glsl
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
// colorconvert.glsl
uniform int u_to_linear;
float
srgb_transfer_function (float v)
{
if (v >= 0.04045)
return pow (((v + 0.055)/(1.0 + 0.055)), 2.4);
else
return v / 12.92;
}
float
srgb_inverse_transfer_function (float v)
{
if (v > 0.0031308)
return 1.055 * pow (v, 1.0/2.4) - 0.055;
else
return 12.92 * v;
}
vec4
srgb_to_linear_srgb (vec4 color)
{
return vec4 (srgb_transfer_function (color.r),
srgb_transfer_function (color.g),
srgb_transfer_function (color.b),
color.a);
}
vec4
linear_srgb_to_srgb (vec4 color)
{
return vec4 (srgb_inverse_transfer_function (color.r),
srgb_inverse_transfer_function (color.g),
srgb_inverse_transfer_function (color.b),
color.a);
}
void main() {
vec4 color = GskTexture(u_source, vUv);
if (color.a != 0.0)
color.rgb /= color.a;
if (u_to_linear != 0)
color = srgb_to_linear_srgb (color);
else
color = linear_srgb_to_srgb (color);
gskSetOutputColor(gsk_scaled_premultiply(color, u_alpha));
}
+10
View File
@@ -10,6 +10,7 @@
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkprofilerprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h>
@@ -76,6 +77,7 @@ gsk_gl_device_create_offscreen_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE,
width,
height);
@@ -85,6 +87,7 @@ static GskGpuImage *
gsk_gl_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -92,6 +95,7 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
format,
color_state,
0,
width,
height);
@@ -107,6 +111,7 @@ gsk_gl_device_create_download_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE,
width,
height);
@@ -121,6 +126,7 @@ gsk_gl_device_create_atlas_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE,
width,
height);
@@ -635,6 +641,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format,
GLenum *out_gl_type,
GLint out_swizzle[4])
@@ -654,6 +661,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle);
@@ -665,6 +673,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_gl_context_get_use_es (context),
&alt_format,
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle) &&
@@ -688,6 +697,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (context),
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle);
+1
View File
@@ -26,6 +26,7 @@ void gsk_gl_device_find_gl_format (GskGLDe
GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format,
GLenum *out_gl_type,
GLint out_swizzle[4]);
+43 -7
View File
@@ -1,9 +1,10 @@
#include "config.h"
#include "config.h"
#include "gskglimageprivate.h"
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
struct _GskGLImage
{
@@ -73,11 +74,13 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height)
gsize height,
gboolean is_srgb)
{
GskGLImage *self;
GskGpuImageFlags flags;
GLint swizzle[4];
GLint gl_internal_format, gl_internal_srgb_format;
self = g_object_new (GSK_TYPE_GL_IMAGE, NULL);
@@ -87,11 +90,25 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
0,
&format,
&flags,
&self->gl_internal_format,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format,
&self->gl_type,
swizzle);
if (is_srgb)
{
if (gl_internal_srgb_format != -1)
self->gl_internal_format = gl_internal_srgb_format;
else /* FIXME: not really correct */
self->gl_internal_format = gl_internal_format;
flags |= GSK_GPU_IMAGE_SRGB;
}
else
{
self->gl_internal_format = gl_internal_format;
}
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, format, width, height);
/* texture_id == 0 means backbuffer */
@@ -109,6 +126,7 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GskGpuImage *
gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height)
@@ -116,6 +134,7 @@ gsk_gl_image_new (GskGLDevice *device,
GskGLImage *self;
GLint swizzle[4];
GskGpuImageFlags flags;
GLint gl_internal_format, gl_internal_srgb_format;
gsize max_size;
max_size = gsk_gpu_device_get_max_image_size (GSK_GPU_DEVICE (device));
@@ -129,11 +148,23 @@ gsk_gl_image_new (GskGLDevice *device,
required_flags,
&format,
&flags,
&self->gl_internal_format,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format,
&self->gl_type,
swizzle);
if (gl_internal_srgb_format != -1 &&
gdk_color_state_equal (color_state, GDK_COLOR_STATE_SRGB))
{
self->gl_internal_format = gl_internal_srgb_format;
flags |= GSK_GPU_IMAGE_SRGB;
}
else
{
self->gl_internal_format = gl_internal_format;
}
gsk_gpu_image_setup (GSK_GPU_IMAGE (self),
flags,
format,
@@ -177,6 +208,7 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
GdkMemoryFormat format, real_format;
GskGpuImageFlags flags;
GskGLImage *self;
GLint gl_internal_format, gl_internal_srgb_format;
GLint swizzle[4];
format = gdk_texture_get_format (owner);
@@ -188,10 +220,14 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
0,
&real_format,
&flags,
&self->gl_internal_format,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format,
&self->gl_type,
swizzle);
self->gl_internal_format = gl_internal_format;
if (format != real_format)
flags = GSK_GPU_IMAGE_NO_BLIT |
(gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0);
+3 -1
View File
@@ -14,9 +14,11 @@ GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDe
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height);
gsize height,
gboolean converts_srgb);
GskGpuImage * gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height);
+1
View File
@@ -23,6 +23,7 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
{
GskGpuBlendmodeInstance *instance = (GskGpuBlendmodeInstance *) instance_;
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id);
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
+1 -1
View File
@@ -21,7 +21,7 @@ color_equal (const float *color1,
const float *color2)
{
return gdk_rgba_equal (&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] },
&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] });
&(GdkRGBA) { color2[0], color2[1], color2[2], color2[3] });
}
static void
+5 -14
View File
@@ -14,7 +14,7 @@ struct _GskGpuClearOp
GskGpuOp op;
cairo_rectangle_int_t rect;
GdkRGBA color;
float color[4];
};
static void
@@ -29,23 +29,14 @@ gsk_gpu_clear_op_print (GskGpuOp *op,
guint indent)
{
GskGpuClearOp *self = (GskGpuClearOp *) op;
float rgba[4];
gsk_gpu_print_op (string, indent, "clear");
gsk_gpu_print_int_rect (string, &self->rect);
gsk_gpu_rgba_to_float (&self->color, rgba);
gsk_gpu_print_rgba (string, rgba);
gsk_gpu_print_rgba (string, self->color);
gsk_gpu_print_newline (string);
}
#ifdef GDK_RENDERING_VULKAN
static void
gsk_gpu_init_clear_value (VkClearValue *value,
const GdkRGBA *rgba)
{
gsk_gpu_rgba_to_float (rgba, value->color.float32);
}
static GskGpuOp *
gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuFrame *frame,
@@ -54,7 +45,7 @@ gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuClearOp *self = (GskGpuClearOp *) op;
VkClearValue clear_value;
gsk_gpu_init_clear_value (&clear_value, &self->color);
memcpy (clear_value.color.float32, self->color, sizeof (float) * 4);
vkCmdClearAttachments (state->vk_command_buffer,
1,
@@ -92,7 +83,7 @@ gsk_gpu_clear_op_gl_command (GskGpuOp *op,
else
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height);
glClearColor (self->color.red, self->color.green, self->color.blue, self->color.alpha);
glClearColor (self->color[0], self->color[1], self->color[2], self->color[3]);
glClear (GL_COLOR_BUFFER_BIT);
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]);
@@ -121,5 +112,5 @@ gsk_gpu_clear_op (GskGpuFrame *frame,
self = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
self->rect = *rect;
self->color = *color;
gsk_gpu_rgba_to_float (color, self->color);
}
+86
View File
@@ -0,0 +1,86 @@
#include "config.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskrectprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gpu/shaders/gskgpucolorconvertinstance.h"
typedef struct _GskGpuColorConvertOp GskGpuColorConvertOp;
struct _GskGpuColorConvertOp
{
GskGpuShaderOp op;
};
static guint
gsk_gpu_color_conversion (GdkColorState *from,
GdkColorState *to)
{
if (from == to)
return 0;
return GDK_DEFAULT_COLOR_STATE_ID (from) | (GDK_DEFAULT_COLOR_STATE_ID (to) << 16);
}
static void
gsk_gpu_color_convert_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
GskGpuColorconvertInstance *instance = (GskGpuColorconvertInstance *) instance_;
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_color_conversion (string, shader->variation);
}
static const GskGpuShaderOpClass GSK_GPU_COLOR_CONVERT_OP_CLASS = {
{
GSK_GPU_OP_SIZE (GskGpuColorConvertOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
gsk_gpu_shader_op_gl_command
},
"gskgpucolorconvert",
sizeof (GskGpuColorconvertInstance),
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colorconvert_info,
#endif
gsk_gpu_color_convert_op_print_instance,
gsk_gpu_colorconvert_setup_attrib_locations,
gsk_gpu_colorconvert_setup_vao
};
void
gsk_gpu_color_convert_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *from,
GdkColorState *to,
GskGpuDescriptors *desc,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect)
{
GskGpuColorconvertInstance *instance;
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_COLOR_CONVERT_OP_CLASS,
gsk_gpu_color_conversion (from, to),
clip,
desc,
&instance);
gsk_gpu_rect_to_float (rect, offset, instance->rect);
gsk_gpu_rect_to_float (tex_rect, offset, instance->tex_rect);
instance->tex_id = descriptor;
}
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "gskgpushaderopprivate.h"
#include <graphene.h>
G_BEGIN_DECLS
void gsk_gpu_color_convert_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *from,
GdkColorState *to,
GskGpuDescriptors *desc,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect);
G_END_DECLS
+63 -20
View File
@@ -12,6 +12,7 @@
#include "gsk/gskdebugprivate.h"
#include "gsk/gskprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define MAX_SLICES_PER_ATLAS 64
@@ -252,6 +253,9 @@ struct _GskGpuCachedTexture
GdkTexture *texture;
GskGpuImage *image;
GdkColorState *color_state;
GskGpuImage *image2;
GdkColorState *color_state2;
};
static void
@@ -263,6 +267,9 @@ gsk_gpu_cached_texture_free (GskGpuDevice *device,
gpointer key, value;
g_clear_object (&self->image);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
g_clear_object (&self->image2);
g_clear_pointer (&self->color_state2, gdk_color_state_unref);
if (g_hash_table_steal_extended (priv->texture_cache, self->texture, &key, &value))
{
@@ -325,9 +332,10 @@ gsk_gpu_cached_texture_destroy_cb (gpointer data)
}
static GskGpuCachedTexture *
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image)
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image,
GdkColorState *color_state)
{
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device);
GskGpuCachedTexture *self;
@@ -340,6 +348,9 @@ gsk_gpu_cached_texture_new (GskGpuDevice *device,
self = gsk_gpu_cached_new (device, &GSK_GPU_CACHED_TEXTURE_CLASS, NULL);
self->texture = texture;
self->image = g_object_ref (image);
self->color_state = gdk_color_state_ref (color_state);
self->image2 = NULL;
self->color_state2 = NULL;
((GskGpuCached *)self)->pixels = gsk_gpu_image_get_width (image) * gsk_gpu_image_get_height (image);
self->dead_pixels_counter = &priv->dead_texture_pixels;
self->use_count = 2;
@@ -696,13 +707,14 @@ gsk_gpu_device_create_offscreen_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
gsize width,
gsize height)
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, width, height);
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, color_state, width, height);
}
void
@@ -850,34 +862,65 @@ gsk_gpu_device_add_atlas_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp)
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp)
{
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self);
GskGpuCachedTexture *cache;
GskGpuImage *image;
cache = gdk_texture_get_render_data (texture, self);
if (cache == NULL)
cache = g_hash_table_lookup (priv->texture_cache, texture);
if (!cache || !cache->image || gsk_gpu_cached_texture_is_invalid (cache))
if (!cache || gsk_gpu_cached_texture_is_invalid (cache))
return NULL;
if (gdk_color_state_equal (color_state, cache->color_state))
image = cache->image;
else if (cache->color_state2 && gdk_color_state_equal (color_state, cache->color_state2))
image = cache->image2;
else
return NULL;
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
return g_object_ref (cache->image);
return g_object_ref (image);
}
void
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image)
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image,
GdkColorState *color_state)
{
GskGpuCachedTexture *cache;
cache = gsk_gpu_cached_texture_new (self, texture, image);
cache = gdk_texture_get_render_data (texture, self);
if (cache)
{
if (gdk_color_state_equal (color_state, gdk_texture_get_color_state (texture)))
{
g_clear_pointer (&cache->color_state, gdk_color_state_unref);
g_clear_object (&cache->image);
cache->color_state = gdk_color_state_ref (color_state);
cache->image = g_object_ref (image);
}
else
{
g_clear_pointer (&cache->color_state2, gdk_color_state_unref);
g_clear_object (&cache->image2);
cache->color_state2 = gdk_color_state_ref (color_state);
cache->image2 = g_object_ref (image);
}
}
else
{
cache = gsk_gpu_cached_texture_new (self, texture, image, color_state);
}
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
}
@@ -950,7 +993,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
}
else
{
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height),
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, GDK_COLOR_STATE_SRGB, rect.size.width, rect.size.height),
rect.origin.x = 0;
rect.origin.y = 0;
padding = 0;
+5 -1
View File
@@ -35,6 +35,7 @@ struct _GskGpuDeviceClass
GskGpuImage * (* create_upload_image) (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
GskGpuImage * (* create_download_image) (GskGpuDevice *self,
@@ -64,6 +65,7 @@ GskGpuImage * gsk_gpu_device_create_offscreen_image (GskGpuD
GskGpuImage * gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
GskGpuImage * gsk_gpu_device_create_download_image (GskGpuDevice *self,
@@ -73,11 +75,13 @@ GskGpuImage * gsk_gpu_device_create_download_image (GskGpuD
void gsk_gpu_device_make_current (GskGpuDevice *self);
GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp);
void gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image);
GskGpuImage *image,
GdkColorState *color_state);
typedef enum
{
+52 -2
View File
@@ -12,6 +12,7 @@
#include "gskvulkanimageprivate.h"
#endif
#include "gdk/gdkdmabuftexturebuilderprivate.h"
#include "gdk/gdkdmabuftextureprivate.h"
#include "gdk/gdkglcontextprivate.h"
@@ -145,7 +146,7 @@ gsk_gpu_download_op_vk_command (GskGpuOp *op,
GskVulkanDevice *device = GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame));
VkDevice vk_device = gsk_vulkan_device_get_vk_device (device);
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image);
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image, gdk_texture_get_color_state (self->texture));
if (gsk_vulkan_device_has_feature (device, GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT))
{
@@ -262,6 +263,23 @@ gsk_gl_texture_data_free (gpointer user_data)
g_free (data);
}
#ifdef HAVE_DMABUF
typedef struct
{
GdkDmabuf dmabuf;
} Texture;
static void
release_dmabuf_texture (gpointer data)
{
Texture *texture = data;
for (unsigned int i = 0; i < texture->dmabuf.n_planes; i++)
g_close (texture->dmabuf.planes[i].fd, NULL);
g_free (texture);
}
#endif
static GskGpuOp *
gsk_gpu_download_op_gl_command (GskGpuOp *op,
GskGpuFrame *frame,
@@ -271,12 +289,44 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
GdkGLTextureBuilder *builder;
GskGLTextureData *data;
GdkGLContext *context;
guint texture_id;
context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame));
texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
#ifdef HAVE_DMABUF
if (self->allow_dmabuf)
{
Texture *texture;
texture = g_new0 (Texture, 1);
if (gdk_gl_context_export_dmabuf (context, texture_id, &texture->dmabuf))
{
GdkDmabufTextureBuilder *db;
db = gdk_dmabuf_texture_builder_new ();
gdk_dmabuf_texture_builder_set_display (db, gdk_gl_context_get_display (context));
gdk_dmabuf_texture_builder_set_dmabuf (db, &texture->dmabuf);
gdk_dmabuf_texture_builder_set_premultiplied (db, gdk_memory_format_get_premultiplied (gsk_gpu_image_get_format (self->image)));
gdk_dmabuf_texture_builder_set_width (db, gsk_gpu_image_get_width (self->image));
gdk_dmabuf_texture_builder_set_height (db, gsk_gpu_image_get_height (self->image));
self->texture = gdk_dmabuf_texture_builder_build (db, release_dmabuf_texture, texture, NULL);
g_object_unref (db);
if (self->texture)
return op->next;
}
g_free (texture);
}
#endif
data = g_new (GskGLTextureData, 1);
data->context = g_object_ref (context);
data->texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
data->texture_id = texture_id;
if (gdk_gl_context_has_feature (context, GDK_GL_FEATURE_SYNC))
data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+24 -8
View File
@@ -17,6 +17,7 @@
#include "gdk/gdkdmabufdownloaderprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024
@@ -402,17 +403,26 @@ gsk_gpu_frame_get_last_op (GskGpuFrame *self)
}
GskGpuImage *
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture)
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture,
GdkColorState **out_color_state)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
GdkColorState *color_state;
image = GSK_GPU_FRAME_GET_CLASS (self)->upload_texture (self, with_mipmap, texture);
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
else
color_state = gdk_texture_get_color_state (texture);
if (image)
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image);
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image, color_state);
*out_color_state = color_state;
return image;
}
@@ -561,6 +571,7 @@ copy_texture (gpointer user_data,
static void
gsk_gpu_frame_record_rect (GskGpuFrame *self,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -572,6 +583,7 @@ gsk_gpu_frame_record_rect (GskGpuFrame *self,
gsk_gpu_node_processor_process (self,
target,
target_color_state,
clip,
node,
viewport);
@@ -585,6 +597,7 @@ static void
gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -603,13 +616,14 @@ gsk_gpu_frame_record (GskGpuFrame *self,
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_frame_record_rect (self, target, &rect, node, viewport);
gsk_gpu_frame_record_rect (self, target, target_color_state, &rect, node, viewport);
}
}
else
{
gsk_gpu_frame_record_rect (self,
target,
target_color_state,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
@@ -656,6 +670,7 @@ void
gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -663,7 +678,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
{
gsk_gpu_frame_cleanup (self);
gsk_gpu_frame_record (self, timestamp, target, region, node, viewport, texture);
gsk_gpu_frame_record (self, timestamp, target, target_color_state, region, node, viewport, texture);
gsk_gpu_frame_submit (self);
}
@@ -702,10 +717,11 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
GdkColorState *color_state;
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, timestamp);
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, GDK_COLOR_STATE_SRGB, timestamp);
if (image == NULL)
image = gsk_gpu_frame_upload_texture (self, FALSE, texture);
image = gsk_gpu_frame_upload_texture (self, FALSE, texture, &color_state);
if (image == NULL)
{
g_critical ("Could not upload texture");
+3 -1
View File
@@ -58,7 +58,8 @@ gpointer gsk_gpu_frame_alloc_op (GskGpuF
gsize size);
GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture);
GdkTexture *texture,
GdkColorState **out_color_state);
GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self);
gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self,
gsize size);
@@ -75,6 +76,7 @@ void gsk_gpu_frame_wait (GskGpuF
void gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
+1 -1
View File
@@ -114,7 +114,7 @@ gsk_gpu_image_toggle_ref_texture (GskGpuImage *self,
g_object_add_toggle_ref (G_OBJECT (self), gsk_gpu_image_texture_toggle_ref_cb, texture);
g_object_unref (self);
}
GdkMemoryFormat
gsk_gpu_image_get_format (GskGpuImage *self)
{
+2
View File
@@ -5,6 +5,7 @@
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskrectprivate.h"
#include "gskenumtypes.h"
#include "gpu/shaders/gskgpumaskinstance.h"
@@ -22,6 +23,7 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
{
GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_;
gsk_gpu_print_enum (string, GSK_TYPE_MASK_MODE, shader->variation);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
+201 -24
View File
@@ -10,6 +10,7 @@
#include "gskgpubluropprivate.h"
#include "gskgpuclearopprivate.h"
#include "gskgpuclipprivate.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpucolorizeopprivate.h"
#include "gskgpucolormatrixopprivate.h"
#include "gskgpucoloropprivate.h"
@@ -44,6 +45,7 @@
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdksubsurfaceprivate.h"
#include "gdk/gdkcolorstateprivate.h"
/* the epsilon we allow pixels to be off due to rounding errors.
* Chosen rather randomly.
@@ -120,6 +122,7 @@ struct _GskGpuNodeProcessor
float opacity;
GskGpuGlobals pending_globals;
GdkColorState *color_state;
};
#define GDK_ARRAY_NAME pattern_buffer
@@ -141,6 +144,7 @@ struct _GskGpuPatternWriter
guint stack;
PatternBuffer buffer;
GdkColorState *color_state;
};
static void gsk_gpu_node_processor_add_node (GskGpuNodeProcessor *self,
@@ -153,6 +157,7 @@ gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
{
g_clear_pointer (&self->modelview, gsk_transform_unref);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static void
@@ -160,6 +165,7 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GskGpuDescriptors *desc,
GskGpuImage *target,
GdkColorState *color_state,
const cairo_rectangle_int_t *clip,
const graphene_rect_t *viewport)
{
@@ -202,6 +208,8 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
-viewport->origin.y);
self->opacity = 1.0;
self->pending_globals = GSK_GPU_GLOBAL_MATRIX | GSK_GPU_GLOBAL_SCALE | GSK_GPU_GLOBAL_CLIP | GSK_GPU_GLOBAL_SCISSOR | GSK_GPU_GLOBAL_BLEND;
self->color_state = gdk_color_state_ref (color_state);
}
static void
@@ -338,6 +346,7 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GdkMemoryDepth depth,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport)
{
GskGpuImage *image;
@@ -359,6 +368,7 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
frame,
NULL,
image,
color_state,
&area,
viewport);
@@ -381,9 +391,97 @@ gsk_gpu_node_processor_finish_draw (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_finish (self);
}
static GskGpuImage *
gsk_gpu_color_convert (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *from,
GdkColorState *to)
{
GskGpuNodeProcessor other;
int width, height;
GdkMemoryDepth depth;
GskGpuImage *copy;
guint32 descriptor;
graphene_rect_t rect;
if (gdk_color_state_equal (from, to))
return image;
width = gsk_gpu_image_get_width (image);
height = gsk_gpu_image_get_height (image);
depth = gdk_memory_format_get_depth (gsk_gpu_image_get_format (image));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (from));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (to));
rect = GRAPHENE_RECT_INIT (0, 0, width, height);
copy = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
FALSE,
depth,
width, height);
gsk_gpu_node_processor_init (&other,
frame,
NULL,
copy,
to,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
gsk_gpu_render_pass_begin_op (other.frame,
copy,
&(cairo_rectangle_int_t) { 0, 0, width, height },
GSK_RENDER_PASS_OFFSCREEN);
descriptor = gsk_gpu_node_processor_add_image (&other, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
from,
to,
other.desc,
descriptor,
&rect,
&other.offset,
&rect);
gsk_gpu_render_pass_end_op (other.frame,
copy,
GSK_RENDER_PASS_OFFSCREEN);
gsk_gpu_node_processor_finish (&other);
g_object_unref (image);
return copy;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static GskGpuImage * gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds);
void
gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -394,10 +492,46 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame,
frame,
NULL,
target,
GDK_COLOR_STATE_SRGB_LINEAR,
clip,
viewport);
gsk_gpu_node_processor_add_node (&self, node);
if (gdk_color_state_equal (target_color_state, GDK_COLOR_STATE_SRGB_LINEAR))
{
gsk_gpu_node_processor_add_node (&self, node);
}
else
{
GskGpuImage *image;
graphene_rect_t clip_bounds;
graphene_rect_t bounds;
guint32 descriptor;
gsk_gpu_node_processor_sync_globals (&self, 0);
gsk_gpu_node_processor_get_clip_bounds (&self, &clip_bounds);
image = gsk_gpu_get_node_as_image (frame,
&clip_bounds,
&self.scale,
GDK_COLOR_STATE_SRGB_LINEAR,
node,
&bounds);
descriptor = gsk_gpu_node_processor_add_image (&self, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
GDK_COLOR_STATE_SRGB_LINEAR,
target_color_state,
self.desc,
descriptor,
&bounds,
&self.offset,
&bounds);
g_object_unref (image);
}
gsk_gpu_node_processor_finish (&self);
}
@@ -406,6 +540,7 @@ static void
gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_point_t *offset,
const graphene_rect_t *bounds)
{
@@ -419,6 +554,8 @@ gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
self->scale = *scale;
self->stack = 0;
self->color_state = gdk_color_state_ref (color_state);
pattern_buffer_init (&self->buffer);
}
@@ -546,6 +683,7 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
pattern_buffer_clear (&self->buffer);
g_assert (self->stack == 0);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static gboolean
@@ -664,20 +802,6 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
&& int_rect->height == rect->size.height * scale_y;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static gboolean G_GNUC_WARN_UNUSED_RESULT
gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self,
GskRenderNode *node,
@@ -742,6 +866,7 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self,
static GskGpuImage *
gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport,
GskRenderNode *node)
{
@@ -752,6 +877,7 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
frame,
gsk_render_node_get_preferred_depth (node),
scale,
color_state,
viewport);
if (image == NULL)
return NULL;
@@ -768,6 +894,7 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
* @frame: frame to render in
* @clip_bounds: region of node that must be included in image
* @scale: scale factor to use for the image
* @color_state: the color state to composite in
* @node: the node to render
* @out_bounds: the actual bounds of the result
*
@@ -789,10 +916,12 @@ static GskGpuImage *
gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds)
{
GskGpuImage *result;
GdkColorState *image_color_state;
switch ((guint) gsk_render_node_get_node_type (node))
{
@@ -801,9 +930,19 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GdkTexture *texture = gsk_texture_node_get_texture (node);
GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
result = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
result = gsk_gpu_device_lookup_texture_image (device, texture, color_state, timestamp);
if (result == NULL)
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
{
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture, &image_color_state);
if (result &&
!gdk_color_state_equal (image_color_state, color_state))
{
result = gsk_gpu_color_convert (frame, result, image_color_state, color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, result, color_state);
}
}
if (result)
{
@@ -821,6 +960,8 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
gsk_render_node_ref (node),
(GDestroyNotify) gsk_render_node_unref);
result = gsk_gpu_color_convert (frame, result, GDK_COLOR_STATE_SRGB, color_state);
g_object_ref (result);
*out_bounds = *clip_bounds;
@@ -833,6 +974,7 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GSK_DEBUG (FALLBACK, "Offscreening node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
result = gsk_gpu_node_processor_create_offscreen (frame,
scale,
color_state,
clip_bounds,
node);
@@ -843,6 +985,7 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
static GskGpuImage *
gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
GskGpuImageFlags disallowed_flags)
{
@@ -895,6 +1038,7 @@ gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
frame,
NULL,
copy,
color_state,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
@@ -968,6 +1112,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
image = gsk_gpu_get_node_as_image (self->frame,
&clip,
&self->scale,
self->color_state,
node,
out_bounds);
if (image == NULL)
@@ -975,6 +1120,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
ensure = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
required_flags,
disallowed_flags);
@@ -985,7 +1131,8 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
gsk_gpu_device_cache_texture_image (gsk_gpu_frame_get_device (self->frame),
gsk_texture_node_get_texture (node),
gsk_gpu_frame_get_timestamp (self->frame),
ensure);
ensure,
self->color_state);
}
return ensure;
@@ -1026,6 +1173,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
self->frame,
source_depth,
&self->scale,
self->color_state,
&intermediate_rect);
gsk_gpu_node_processor_sync_globals (&other, 0);
@@ -1205,6 +1353,7 @@ gsk_gpu_node_processor_try_node_as_pattern (GskGpuNodeProcessor *self,
gsk_gpu_pattern_writer_init (&writer,
self->frame,
&self->scale,
self->color_state,
&self->offset,
&clipped);
@@ -1454,6 +1603,7 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&clip_bounds);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_rounded_color_op (other.frame,
@@ -1927,15 +2077,16 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
GskGpuImage *image;
GdkTexture *texture;
gint64 timestamp;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -1945,6 +2096,12 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -1955,6 +2112,7 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_MIPMAP_DEFAULT);
@@ -2001,17 +2159,24 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
guint32 descriptor;
GskGpuImage *image;
GskGpuSampler sampler;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
if (image == NULL)
return FALSE;
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -2020,6 +2185,7 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
{
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT;
@@ -2058,6 +2224,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gint64 timestamp;
guint32 descriptor;
gboolean need_mipmap, need_offscreen;
GdkColorState *image_color_state;
need_offscreen = self->modelview != NULL ||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ());
@@ -2081,6 +2248,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
clip_bounds.size.height = ceilf (clip_bounds.size.height);
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
graphene_vec2_one (),
self->color_state,
&clip_bounds,
node);
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT);
@@ -2101,10 +2269,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
need_mipmap = scaling_filter == GSK_SCALING_FILTER_TRILINEAR;
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture);
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture, &image_color_state);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -2114,10 +2282,16 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
@@ -2282,6 +2456,7 @@ gsk_gpu_node_processor_add_gradient_node (GskGpuNodeProcessor *self,
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&bounds);
other.blend = GSK_GPU_BLEND_ADD;
@@ -3331,6 +3506,7 @@ gsk_gpu_node_processor_repeat_tile (GskGpuNodeProcessor *self,
GSK_DEBUG (FALLBACK, "Offscreening node '%s' for tiling", g_type_name_from_instance ((GTypeInstance *) child));
image = gsk_gpu_node_processor_create_offscreen (self->frame,
&self->scale,
self->color_state,
&clipped_child_bounds,
child);
@@ -4123,6 +4299,7 @@ gsk_gpu_node_processor_create_node_pattern (GskGpuPatternWriter *self,
image = gsk_gpu_get_node_as_image (self->frame,
&bounds,
&self->scale,
self->color_state,
node,
&bounds);
if (image == NULL)
+1
View File
@@ -7,6 +7,7 @@ G_BEGIN_DECLS
void gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport);
+13 -2
View File
@@ -2,6 +2,8 @@
#include "gskgpuprintprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gskgpudescriptorsprivate.h"
#include "gskgpuimageprivate.h"
@@ -140,9 +142,10 @@ void
gsk_gpu_print_image (GString *string,
GskGpuImage *image)
{
g_string_append_printf (string, "%zux%zu ",
g_string_append_printf (string, "%zux%zu %s ",
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image));
gsk_gpu_image_get_height (image),
gdk_memory_format_get_name (gsk_gpu_image_get_format (image)));
}
void
@@ -154,3 +157,11 @@ gsk_gpu_print_image_descriptor (GString *string,
gsk_gpu_print_image (string, gsk_gpu_descriptors_get_image (desc, id));
}
void
gsk_gpu_print_color_conversion (GString *string,
guint conversion)
{
g_string_append_printf (string, "%s->%s ",
gdk_color_state_get_name_from_id (conversion & 0xffff),
gdk_color_state_get_name_from_id (conversion >> 16));
}
+2
View File
@@ -35,3 +35,5 @@ void gsk_gpu_print_image (GString
void gsk_gpu_print_image_descriptor (GString *string,
GskGpuDescriptors *desc,
guint32 descriptor);
void gsk_gpu_print_color_conversion (GString *string,
guint conversion);
+20 -3
View File
@@ -18,6 +18,7 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkdrawcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <graphene.h>
@@ -298,6 +299,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
GDK_COLOR_STATE_SRGB,
NULL,
root,
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
@@ -360,6 +362,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
GDK_COLOR_STATE_SRGB,
NULL,
root,
&rounded_viewport,
@@ -387,6 +390,8 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
GskGpuImage *backbuffer;
cairo_region_t *render_region;
double scale;
GdkMemoryDepth depth;
GdkColorState *target_color_state;
if (cairo_region_is_empty (region))
{
@@ -394,9 +399,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
return;
}
gdk_draw_context_begin_frame_full (priv->context,
gsk_render_node_get_preferred_depth (root),
region);
depth = gsk_render_node_get_preferred_depth (root);
gdk_draw_context_begin_frame_full (priv->context, depth, region);
gsk_gpu_device_maybe_gc (priv->device);
@@ -408,9 +413,21 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
render_region = get_render_region (self);
scale = gsk_gpu_renderer_get_scale (self);
if (gsk_gpu_image_get_flags (backbuffer) & GSK_GPU_IMAGE_SRGB)
{
g_debug ("Relying on GL/Vulkan to do srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
}
else
{
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB;
}
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
backbuffer,
target_color_state,
render_region,
root,
&GRAPHENE_RECT_INIT (
+15 -3
View File
@@ -4,6 +4,8 @@
#include "gskgputypesprivate.h"
#include <math.h>
G_BEGIN_DECLS
struct _GskGpuShaderOp
@@ -63,13 +65,23 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO
GskGpuFrame *frame,
GskGLCommandState *state);
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static inline void
gsk_gpu_rgba_to_float (const GdkRGBA *rgba,
float values[4])
{
values[0] = rgba->red;
values[1] = rgba->green;
values[2] = rgba->blue;
values[0] = srgb_inverse_transfer_function (rgba->red);
values[1] = srgb_inverse_transfer_function (rgba->green);
values[2] = srgb_inverse_transfer_function (rgba->blue);
values[3] = rgba->alpha;
}
+1
View File
@@ -29,6 +29,7 @@ typedef enum {
GSK_GPU_IMAGE_MIPMAP = (1 << 5),
GSK_GPU_IMAGE_FILTERABLE = (1 << 6),
GSK_GPU_IMAGE_RENDERABLE = (1 << 7),
GSK_GPU_IMAGE_SRGB = (1 << 8),
} GskGpuImageFlags;
typedef enum {
+27
View File
@@ -14,6 +14,15 @@
#include "gdk/gdkglcontextprivate.h"
#include "gsk/gskdebugprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
static GskGpuOp *
gsk_gpu_upload_op_gl_command_with_area (GskGpuOp *op,
@@ -304,6 +313,7 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
with_mipmap,
gdk_texture_get_format (texture),
gdk_texture_get_color_state (texture),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
if (image == NULL)
@@ -470,6 +480,7 @@ gsk_gpu_upload_cairo_op (GskGpuFrame *frame,
self->image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
FALSE,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
ceil (graphene_vec2_get_x (scale) * viewport->size.width),
ceil (graphene_vec2_get_y (scale) * viewport->size.height));
self->viewport = *viewport;
@@ -537,6 +548,16 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
cairo_surface_t *surface;
cairo_t *cr;
PangoRectangle ink_rect = { 0, };
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
@@ -578,6 +599,12 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
#ifdef GDK_RENDERING_VULKAN
+2 -1
View File
@@ -117,7 +117,8 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
GDK_GL_CONTEXT (context),
GDK_MEMORY_DEFAULT /* FIXME */,
ceil (gdk_surface_get_width (surface) * scale),
ceil (gdk_surface_get_height (surface) * scale));
ceil (gdk_surface_get_height (surface) * scale),
gdk_surface_get_gl_is_srgb (surface));
}
return self->backbuffer;
+2
View File
@@ -391,6 +391,7 @@ static GskGpuImage *
gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -399,6 +400,7 @@ gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
return gsk_vulkan_image_new_for_upload (self,
with_mipmap,
format,
color_state,
width,
height);
}
+25 -8
View File
@@ -11,6 +11,7 @@
#include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkmemoryformatprivate.h"
#include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <fcntl.h>
#include <string.h>
@@ -202,6 +203,9 @@ gsk_vulkan_device_check_format (GskVulkanDevice *device,
#define CHECK_FLAGS (GSK_GPU_IMAGE_NO_BLIT | GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE)
GskGpuImageFlags flags;
if (vk_format == VK_FORMAT_UNDEFINED)
return FALSE;
if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT &&
!gsk_component_mapping_is_framebuffer_compatible (vk_components))
return FALSE;
@@ -240,6 +244,7 @@ gsk_vulkan_device_check_format (GskVulkanDevice *device,
static GskVulkanImage *
gsk_vulkan_image_new (GskVulkanDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height,
@@ -261,15 +266,13 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
/* First, try the actual format */
vk_format = gdk_memory_format_vk_format (format, &vk_components);
if (vk_format == VK_FORMAT_UNDEFINED ||
!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
/* Second, try the potential RGBA format */
vk_format = gdk_memory_format_vk_rgba_format (format, NULL, &vk_components);
if (vk_format == VK_FORMAT_UNDEFINED ||
!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
@@ -281,8 +284,7 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
for (i = 0; fallbacks[i] != -1; i++)
{
vk_format = gdk_memory_format_vk_format (fallbacks[i], &vk_components);
if (vk_format != VK_FORMAT_UNDEFINED &&
gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
@@ -305,6 +307,13 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
(required_flags & GSK_GPU_IMAGE_CAN_MIPMAP))
flags |= GSK_GPU_IMAGE_CAN_MIPMAP;
if (gdk_memory_format_vk_srgb_format (format) != VK_FORMAT_UNDEFINED &&
gdk_color_state_equal (color_state, GDK_COLOR_STATE_SRGB))
{
vk_format = gdk_memory_format_vk_srgb_format (format);
flags |= GSK_GPU_IMAGE_SRGB;
}
vk_device = gsk_vulkan_device_get_vk_device (device);
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
@@ -366,6 +375,7 @@ GskGpuImage *
gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -373,6 +383,7 @@ gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
format,
color_state,
with_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE) : 0,
width,
height,
@@ -433,10 +444,12 @@ GskGpuImage *
gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image,
VkFormat format,
GdkMemoryFormat memory_format,
gsize width,
gsize height)
{
GskVulkanImage *self;
GskGpuImageFlags flags = 0;
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
@@ -449,9 +462,11 @@ gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
self->vk_image_layout = VK_IMAGE_LAYOUT_UNDEFINED;
self->vk_access = 0;
/* FIXME: The memory format and flags here are very suboptimal */
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), 0, GDK_MEMORY_DEFAULT, width, height);
if (format == gdk_memory_format_vk_srgb_format (memory_format))
flags |= GSK_GPU_IMAGE_SRGB;
/* FIXME: The flags here are very suboptimal */
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, memory_format, width, height);
gsk_vulkan_image_create_view (self,
format,
&(VkComponentMapping) {
@@ -474,6 +489,7 @@ gsk_vulkan_image_new_for_atlas (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE,
width,
height,
@@ -498,6 +514,7 @@ gsk_vulkan_image_new_for_offscreen (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
preferred_format,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE |
(with_mipmap ? GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_FILTERABLE : 0),
width,
+2
View File
@@ -14,6 +14,7 @@ G_DECLARE_FINAL_TYPE (GskVulkanImage, gsk_vulkan_image, GSK, VULKAN_IMAGE, GskGp
GskGpuImage * gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image,
VkFormat format,
GdkMemoryFormat memory_format,
gsize width,
gsize height);
@@ -28,6 +29,7 @@ GskGpuImage * gsk_vulkan_image_new_for_offscreen (GskVulk
GskGpuImage * gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
#ifdef HAVE_DMABUF
+1
View File
@@ -75,6 +75,7 @@ gsk_vulkan_renderer_update_images_cb (GdkVulkanContext *context,
self->targets[i] = gsk_vulkan_image_new_for_swapchain (device,
gdk_vulkan_context_get_image (context, i),
gdk_vulkan_context_get_image_format (context),
gdk_vulkan_context_get_memory_format (context),
width, height);
}
}
+1 -1
View File
@@ -19,4 +19,4 @@ luminance (vec3 color)
return dot (vec3 (0.2126, 0.7152, 0.0722), color);
}
#endif /* _COLOR_ */
#endif
+116
View File
@@ -0,0 +1,116 @@
#include "common.glsl"
PASS(0) vec2 _pos;
PASS_FLAT(1) Rect _rect;
PASS(2) vec2 _tex_coord;
PASS_FLAT(3) uint _tex_id;
#ifdef GSK_VERTEX_SHADER
IN(0) vec4 in_rect;
IN(1) vec4 in_tex_rect;
IN(2) uint in_tex_id;
void
run (out vec2 pos)
{
Rect r = rect_from_gsk (in_rect);
pos = rect_get_position (r);
_pos = pos;
_rect = r;
_tex_coord = rect_get_coord (rect_from_gsk (in_tex_rect), pos);
_tex_id = in_tex_id;
}
#endif
#ifdef GSK_FRAGMENT_SHADER
float
srgb_transfer_function (float v)
{
if (v >= 0.04045)
return pow (((v + 0.055)/(1.0 + 0.055)), 2.4);
else
return v / 12.92;
}
float
srgb_inverse_transfer_function (float v)
{
if (v > 0.0031308)
return 1.055 * pow (v, 1.0/2.4) - 0.055;
else
return 12.92 * v;
}
vec4
srgb_to_linear_srgb (vec4 color)
{
return vec4 (srgb_transfer_function (color.r),
srgb_transfer_function (color.g),
srgb_transfer_function (color.b),
color.a);
}
vec4
linear_srgb_to_srgb (vec4 color)
{
return vec4 (srgb_inverse_transfer_function (color.r),
srgb_inverse_transfer_function (color.g),
srgb_inverse_transfer_function (color.b),
color.a);
}
#define RGB 0u
#define LINRGB 1u
#define pair(u,v) ((u)|((v) << 16))
#define first(p) ((p) & 0xffffu)
#define second(p) ((p) >> 16)
bool
do_conversion (in vec4 color, in uint f, out vec4 result)
{
switch (f)
{
case pair (RGB, LINRGB): result = srgb_to_linear_srgb (color); break;
case pair (LINRGB, RGB): result = linear_srgb_to_srgb (color); break;
default: return false;
}
return true;
}
vec4
color_convert (in vec4 color, in uint f)
{
vec4 result;
if (f == 0u)
return color;
do_conversion (color, f, result);
return result;
}
void
run (out vec4 color,
out vec2 position)
{
vec4 pixel = gsk_texture (_tex_id, _tex_coord);
pixel = color_unpremultiply (pixel);
pixel = color_convert (pixel, GSK_VARIATION);
color = color_premultiply (pixel) * rect_coverage (_rect, _pos);
position = _pos;
}
#endif
+1
View File
@@ -18,6 +18,7 @@ gsk_private_gpu_shaders = files([
'gskgpuborder.glsl',
'gskgpuboxshadow.glsl',
'gskgpucolor.glsl',
'gskgpucolorconvert.glsl',
'gskgpucolorize.glsl',
'gskgpucolormatrix.glsl',
'gskgpuconicgradient.glsl',
+33 -6
View File
@@ -26,6 +26,7 @@
#include "gskrendererprivate.h"
#include "gskrendernodeprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkcolorstateprivate.h"
typedef struct {
GQuark cpu_time;
@@ -90,6 +91,19 @@ gsk_cairo_renderer_do_render (GskRenderer *renderer,
gsk_profiler_push_samples (profiler);
}
static void
surface_linear_srgb_to_srgb (cairo_surface_t *s)
{
gdk_memory_convert_color_state (cairo_image_surface_get_data (s),
cairo_image_surface_get_stride (s),
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GDK_COLOR_STATE_SRGB,
cairo_image_surface_get_width (s),
cairo_image_surface_get_height (s));
cairo_surface_mark_dirty (s);
}
static GdkTexture *
gsk_cairo_renderer_render_texture (GskRenderer *renderer,
GskRenderNode *root,
@@ -144,6 +158,7 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer,
cairo_destroy (cr);
surface_linear_srgb_to_srgb (surface);
texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
@@ -156,18 +171,17 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
const cairo_region_t *region)
{
GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer);
cairo_t *cr;
cairo_t *cr, *cr2;
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_surface_t *s;
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context),
region);
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context), region);
cr = gdk_cairo_context_cairo_create (self->cairo_context);
g_return_if_fail (cr != NULL);
if (GSK_RENDERER_DEBUG_CHECK (renderer, GEOMETRY))
{
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_save (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_rectangle (cr,
@@ -178,8 +192,21 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
cairo_restore (cr);
}
gsk_cairo_renderer_do_render (renderer, cr, root);
s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_surface_get_width (surface),
gdk_surface_get_height (surface));
cr2 = cairo_create (s);
gdk_cairo_region (cr2, gdk_draw_context_get_frame_region (GDK_DRAW_CONTEXT (self->cairo_context)));
cairo_clip (cr2);
gsk_cairo_renderer_do_render (renderer, cr2, root);
surface_linear_srgb_to_srgb (s);
cairo_set_source_surface (cr, s, 0, 0);
cairo_paint (cr);
cairo_destroy (cr2);
cairo_surface_destroy (s);
cairo_destroy (cr);
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context));
+91 -27
View File
@@ -40,6 +40,7 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <cairo.h>
#ifdef CAIRO_HAS_SVG_SURFACE
@@ -47,6 +48,13 @@
#endif
#include <hb-ot.h>
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
/* for oversized image fallback - we use a smaller size than Cairo actually
* allows to avoid rounding errors in Cairo */
#define MAX_CAIRO_IMAGE_WIDTH 16384
@@ -139,6 +147,39 @@ region_union_region_affine (cairo_region_t *region,
}
}
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static void
gsk_cairo_set_source_rgba (cairo_t *cr,
const GdkRGBA *rgba)
{
cairo_set_source_rgba (cr,
srgb_inverse_transfer_function (rgba->red),
srgb_inverse_transfer_function (rgba->green),
srgb_inverse_transfer_function (rgba->blue),
rgba->alpha);
}
static void
surface_srgb_to_linear_srgb (cairo_surface_t *s)
{
gdk_memory_convert_color_state (cairo_image_surface_get_data (s),
cairo_image_surface_get_stride (s),
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
GDK_COLOR_STATE_SRGB_LINEAR,
cairo_image_surface_get_width (s),
cairo_image_surface_get_height (s));
cairo_surface_mark_dirty (s);
}
/* {{{ GSK_COLOR_NODE */
/**
@@ -159,7 +200,7 @@ gsk_color_node_draw (GskRenderNode *node,
{
GskColorNode *self = (GskColorNode *) node;
gdk_cairo_set_source_rgba (cr, &self->color);
gsk_cairo_set_source_rgba (cr, &self->color);
gsk_cairo_rectangle (cr, &node->bounds);
cairo_fill (cr);
@@ -294,25 +335,25 @@ gsk_linear_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern,
0.0,
self->stops[0].color.red,
self->stops[0].color.green,
self->stops[0].color.blue,
srgb_inverse_transfer_function (self->stops[0].color.red),
srgb_inverse_transfer_function (self->stops[0].color.green),
srgb_inverse_transfer_function (self->stops[0].color.blue),
self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++)
{
cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset,
self->stops[i].color.red,
self->stops[i].color.green,
self->stops[i].color.blue,
srgb_inverse_transfer_function (self->stops[i].color.red),
srgb_inverse_transfer_function (self->stops[i].color.green),
srgb_inverse_transfer_function (self->stops[i].color.blue),
self->stops[i].color.alpha);
}
if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern,
1.0,
self->stops[self->n_stops-1].color.red,
self->stops[self->n_stops-1].color.green,
self->stops[self->n_stops-1].color.blue,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.blue),
self->stops[self->n_stops-1].color.alpha);
cairo_set_source (cr, pattern);
@@ -624,25 +665,25 @@ gsk_radial_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern,
0.0,
self->stops[0].color.red,
self->stops[0].color.green,
self->stops[0].color.blue,
srgb_inverse_transfer_function (self->stops[0].color.red),
srgb_inverse_transfer_function (self->stops[0].color.green),
srgb_inverse_transfer_function (self->stops[0].color.blue),
self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++)
{
cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset,
self->stops[i].color.red,
self->stops[i].color.green,
self->stops[i].color.blue,
srgb_inverse_transfer_function (self->stops[i].color.red),
srgb_inverse_transfer_function (self->stops[i].color.green),
srgb_inverse_transfer_function (self->stops[i].color.blue),
self->stops[i].color.alpha);
}
if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern,
1.0,
self->stops[self->n_stops-1].color.red,
self->stops[self->n_stops-1].color.green,
self->stops[self->n_stops-1].color.blue,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.blue),
self->stops[self->n_stops-1].color.alpha);
gsk_cairo_rectangle (cr, &node->bounds);
@@ -1011,7 +1052,12 @@ _cairo_mesh_pattern_set_corner_rgba (cairo_pattern_t *pattern,
guint corner_num,
const GdkRGBA *rgba)
{
cairo_mesh_pattern_set_corner_color_rgba (pattern, corner_num, rgba->red, rgba->green, rgba->blue, rgba->alpha);
cairo_mesh_pattern_set_corner_color_rgba (pattern,
corner_num,
srgb_inverse_transfer_function (rgba->red),
srgb_inverse_transfer_function (rgba->green),
srgb_inverse_transfer_function (rgba->blue),
rgba->alpha);
}
static void
@@ -1409,7 +1455,7 @@ gsk_border_node_draw (GskRenderNode *node,
gdk_rgba_equal (&self->border_color[0], &self->border_color[2]) &&
gdk_rgba_equal (&self->border_color[0], &self->border_color[3]))
{
gdk_cairo_set_source_rgba (cr, &self->border_color[0]);
gsk_cairo_set_source_rgba (cr, &self->border_color[0]);
}
else
{
@@ -1771,6 +1817,7 @@ gsk_texture_node_draw (GskRenderNode *node,
}
surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -1947,6 +1994,7 @@ gsk_texture_scale_node_draw (GskRenderNode *node,
cr2 = cairo_create (surface2);
surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -2149,7 +2197,7 @@ draw_shadow (cairo_t *cr,
if (has_empty_clip (cr))
return;
gdk_cairo_set_source_rgba (cr, color);
gsk_cairo_set_source_rgba (cr, color);
shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
@@ -2322,7 +2370,7 @@ draw_shadow_corner (cairo_t *cr,
g_hash_table_insert (corner_mask_cache, g_memdup2 (&key, sizeof (key)), mask);
}
gdk_cairo_set_source_rgba (cr, color);
gsk_cairo_set_source_rgba (cr, color);
pattern = cairo_pattern_create_for_surface (mask);
cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, sx, sy);
@@ -4693,7 +4741,7 @@ gsk_fill_node_draw (GskRenderNode *node,
if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds))
{
gdk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
gsk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
cairo_fill (cr);
}
else
@@ -4886,7 +4934,7 @@ gsk_stroke_node_draw (GskRenderNode *node,
if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds))
{
gdk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
gsk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
}
else
{
@@ -5111,7 +5159,7 @@ gsk_shadow_node_draw (GskRenderNode *node,
gsk_render_node_draw (self->child, cr);
pattern = cairo_pop_group (cr);
cairo_reset_clip (cr);
gdk_cairo_set_source_rgba (cr, &shadow->color);
gsk_cairo_set_source_rgba (cr, &shadow->color);
cairo_mask (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_restore (cr);
@@ -5728,6 +5776,16 @@ gsk_text_node_draw (GskRenderNode *node,
{
GskTextNode *self = (GskTextNode *) node;
PangoGlyphString glyphs;
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
glyphs.num_glyphs = self->num_glyphs;
glyphs.glyphs = self->glyphs;
@@ -5735,11 +5793,17 @@ gsk_text_node_draw (GskRenderNode *node,
cairo_save (cr);
gdk_cairo_set_source_rgba (cr, &self->color);
gsk_cairo_set_source_rgba (cr, &self->color);
cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
cairo_restore (cr);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
static void
+9 -33
View File
@@ -1005,7 +1005,7 @@ ensure_fontmap (Context *context)
context->fontmap = pango_cairo_font_map_new ();
config = FcInitLoadConfig ();
config = FcConfigCreate ();
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config);
FcConfigDestroy (config);
@@ -2990,8 +2990,13 @@ printer_init_collect_font_info (Printer *printer,
info->face = hb_face_reference (hb_font_get_face (pango_font_get_hb_font (font)));
if (!g_object_get_data (G_OBJECT (pango_font_get_font_map (font)), "font-files"))
{
info->input = hb_subset_input_create_or_fail ();
hb_subset_input_set_flags (info->input, HB_SUBSET_FLAGS_RETAIN_GIDS);
if (g_strcmp0 (g_getenv ("GSK_SUBSET_FONTS"), "1") == 0)
{
info->input = hb_subset_input_create_or_fail ();
hb_subset_input_set_flags (info->input, HB_SUBSET_FLAGS_RETAIN_GIDS);
}
else
info->serialized = TRUE; /* Don't subset (or serialize) system fonts */
}
g_hash_table_insert (printer->fonts, info->face, info);
@@ -3022,11 +3027,11 @@ printer_init_duplicates_for_node (Printer *printer,
switch (gsk_render_node_get_node_type (node))
{
case GSK_CAIRO_NODE:
case GSK_TEXT_NODE:
printer_init_collect_font_info (printer, node);
break;
case GSK_CAIRO_NODE:
case GSK_COLOR_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
@@ -3622,33 +3627,6 @@ append_texture_param (Printer *p,
g_bytes_unref (bytes);
}
static void
print_font (PangoFont *font)
{
PangoFontDescription *desc;
char *s;
hb_face_t *face;
hb_blob_t *blob;
const char *data;
unsigned int length;
char *csum;
desc = pango_font_describe_with_absolute_size (font);
s = pango_font_description_to_string (desc);
face = hb_font_get_face (pango_font_get_hb_font (font));
blob = hb_face_reference_blob (face);
data = hb_blob_get_data (blob, &length);
csum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (const guchar *)data, length);
g_print ("%s, face %p, sha %s\n", s, face, csum);
g_free (csum);
hb_blob_destroy (blob);
g_free (s);
}
static void
gsk_text_node_serialize_font (GskRenderNode *node,
Printer *p)
@@ -3669,8 +3647,6 @@ gsk_text_node_serialize_font (GskRenderNode *node,
g_free (s);
pango_font_description_free (desc);
g_print ("serializing ");
print_font (font);
info = g_hash_table_lookup (p->fonts, hb_font_get_face (pango_font_get_hb_font (font)));
if (info->serialized)
return;
+33
View File
@@ -489,6 +489,9 @@ gsk_transform_matrix_with_category (GskTransform *next,
*
* Multiplies @next with the given @matrix.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: The new transform
**/
GskTransform *
@@ -643,6 +646,9 @@ static const GskTransformClass GSK_TRANSLATE_TRANSFORM_CLASS =
*
* Translates @next in 2-dimensional space by @point.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -663,6 +669,9 @@ gsk_transform_translate (GskTransform *next,
*
* Translates @next by @point.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -880,6 +889,9 @@ normalize_angle (float angle)
* Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis.
* The rotation happens around the origin point of (0, 0).
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1008,6 +1020,9 @@ static const GskTransformClass GSK_ROTATE3D_TRANSFORM_CLASS =
*
* For a rotation in 2D space, use [method@Gsk.Transform.rotate]
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1184,6 +1199,9 @@ static const GskTransformClass GSK_SKEW_TRANSFORM_CLASS =
*
* Applies a skew transform.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*
* Since: 4.6
@@ -1356,6 +1374,9 @@ static const GskTransformClass GSK_SCALE_TRANSFORM_CLASS =
*
* Use [method@Gsk.Transform.scale_3d] to scale in all 3 dimensions.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -1375,6 +1396,9 @@ gsk_transform_scale (GskTransform *next,
*
* Scales @next by the given factors.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -1510,6 +1534,9 @@ static const GskTransformClass GSK_PERSPECTIVE_TRANSFORM_CLASS =
* those with negative Z values towards the origin. Points
* on the z=0 plane are unchanged.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: The new transform
*/
GskTransform *
@@ -1919,6 +1946,9 @@ gsk_transform_to_translate (GskTransform *self,
*
* Applies all the operations from @other to @next.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1955,6 +1985,9 @@ gsk_transform_transform (GskTransform *next,
* between those cases, you should check @self is not %NULL
* before calling this function.
*
* This function consumes @self. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The inverted transform
*/
GskTransform *
+2
View File
@@ -4,6 +4,7 @@ gsk_private_gl_shaders = [
'gl/resources/preamble.vs.glsl',
'gl/resources/border.glsl',
'gl/resources/blit.glsl',
'gl/resources/colorconvert.glsl',
'gl/resources/coloring.glsl',
'gl/resources/color.glsl',
'gl/resources/linear_gradient.glsl',
@@ -105,6 +106,7 @@ gsk_private_sources = files([
'gpu/gskgpushaderop.c',
'gpu/gskgpuscissorop.c',
'gpu/gskgpustraightalphaop.c',
'gpu/gskgpucolorconvertop.c',
'gpu/gskgputextureop.c',
'gpu/gskgpuuberop.c',
'gpu/gskgpuuploadop.c',
+16 -16
View File
@@ -4197,20 +4197,20 @@ gtk_tree_view_snapshot_grid_line (GtkTreeView *tree_view,
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */
data[0] = round (grid_line_color->blue * 255);
data[1] = round (grid_line_color->green * 255);
data[2] = round (grid_line_color->red * 255);
data[3] = round (grid_line_color->alpha * 255);
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255);
priv->horizontal_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface);
data[0] = round (grid_line_color->blue * 255);
data[1] = round (grid_line_color->green * 255);
data[2] = round (grid_line_color->red * 255);
data[3] = round (grid_line_color->alpha * 255);
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255);
priv->vertical_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
@@ -4272,20 +4272,20 @@ gtk_tree_view_snapshot_tree_line (GtkTreeView *tree_view,
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */
data[0] = round (tree_line_color->blue * 255);
data[1] = round (tree_line_color->green * 255);
data[2] = round (tree_line_color->red * 255);
data[3] = round (tree_line_color->alpha * 255);
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255);
priv->horizontal_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface);
data[0] = round (tree_line_color->blue * 255);
data[1] = round (tree_line_color->green * 255);
data[2] = round (tree_line_color->red * 255);
data[3] = round (tree_line_color->alpha * 255);
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255);
priv->vertical_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
+62 -1
View File
@@ -201,6 +201,10 @@ struct _GtkAboutDialog
guint hovering_over_link : 1;
guint wrap_license : 1;
guint in_child_changed : 1;
GSList *link_tags;
guint update_links_cb_id;
};
struct _GtkAboutDialogClass
@@ -706,6 +710,52 @@ update_credits_button_visibility (GtkAboutDialog *about)
update_stack_switcher_visibility (about);
}
static void
update_links_cb (GtkAboutDialog *about)
{
GtkCssStyle *style;
GdkRGBA link_color, visited_link_color;
GSList *l;
style = gtk_css_node_get_style (about->link_node);
link_color = *gtk_css_color_value_get_rgba (style->core->color);
style = gtk_css_node_get_style (about->visited_link_node);
visited_link_color = *gtk_css_color_value_get_rgba (style->core->color);
for (l = about->link_tags; l != NULL; l = l->next)
{
GtkTextTag *tag = l->data;
GdkRGBA color;
const char *uri = g_object_get_data (G_OBJECT (tag), "uri");
if (uri && g_ptr_array_find_with_equal_func (about->visited_links, uri, (GCompareFunc)strcmp, NULL))
color = visited_link_color;
else
color = link_color;
g_object_set (G_OBJECT (tag), "foreground-rgba", &color, NULL);
}
about->update_links_cb_id = 0;
}
static void
link_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkAboutDialog *about)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
{
/* If we access the node right here, we'll end up with infinite recursion */
if (about->link_tags && !about->update_links_cb_id)
{
about->update_links_cb_id =
g_idle_add_once ((GSourceOnceFunc) update_links_cb, about);
}
}
}
static void
gtk_about_dialog_init (GtkAboutDialog *about)
{
@@ -748,12 +798,16 @@ gtk_about_dialog_init (GtkAboutDialog *about)
gtk_css_node_set_name (about->link_node, g_quark_from_static_string ("link"));
gtk_css_node_set_parent (about->link_node, node);
gtk_css_node_set_state (about->link_node, state | GTK_STATE_FLAG_LINK);
g_signal_connect (about->link_node, "style-changed",
G_CALLBACK (link_style_changed_cb), about);
g_object_unref (about->link_node);
about->visited_link_node = gtk_css_node_new ();
gtk_css_node_set_name (about->visited_link_node, g_quark_from_static_string ("link"));
gtk_css_node_set_parent (about->visited_link_node, node);
gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_VISITED);
gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_LINK);
g_signal_connect (about->visited_link_node, "style-changed",
G_CALLBACK (link_style_changed_cb), about);
g_object_unref (about->visited_link_node);
}
@@ -788,6 +842,10 @@ gtk_about_dialog_finalize (GObject *object)
g_slist_free_full (about->credit_sections, destroy_credit_section);
g_ptr_array_unref (about->visited_links);
g_slist_free (about->link_tags);
g_clear_handle_id (&about->update_links_cb_id, g_source_remove);
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
}
@@ -1910,6 +1968,9 @@ text_buffer_new (GtkAboutDialog *about,
"foreground-rgba", &color,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
about->link_tags = g_slist_prepend (about->link_tags, tag);
if (strcmp (link_type, "email") == 0)
{
char *escaped;
+206
View File
@@ -423,3 +423,209 @@ gtk_linear_srgb_to_rgb (float linear_red, float linear_green, float linear_bl
*green = apply_gamma (linear_green);
*blue = apply_gamma (linear_blue);
}
void
gtk_linear_srgb_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (506752.0 / 1228815.0) * r + (87881.0 / 245763.0) * g + (12673.0 / 70218.0) * b;
*y = (87098.0 / 409605.0) * r + (175762.0 / 245763.0) * g + (12673.0 / 175545.0) * b;
*z = ( 7918.0 / 409605.0) * r + (87881.0 / 737289.0) * g + (1001167.0 / 1053270.0) * b;
}
void
gtk_xyz_to_linear_srgb (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (12831.0 / 3959.0) * x - (329.0 / 214.0) * y - (1974.0 / 3959.0) * z;
*g = - (851781.0 / 878810.0) * x + (1648619.0 / 878810.0) * y + (36519.0 / 878810.0) * z;
*b = (705.0 / 12673.0) * x - (2585.0 / 12673.0) * y + (705.0 / 667.0) * z;
}
static void
gtk_lin_p3_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (608311.0 / 1250200.0) * r + (189793.0 / 714400.0) * g + (198249.0 / 1000160.0) * b;
*y = (35783.0 / 156275.0) * r + (247089.0 / 357200.0) * g + (198249.0 / 2500400.0) * b;
*z = ( 0 / 1) * r + (32229.0 / 714400.0) * g + (5220557.0 / 5000800.0) * b;
}
static void
gtk_xyz_to_lin_p3 (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (446124.0 / 178915.0) * x - (333277.0 / 357830.0) * y - (72051.0 / 178915.0) * z;
*g = - (14852.0 / 17905.0) * x + (63121.0 / 35810.0) * y + (423.0 / 17905.0) * z;
*b = (11844.0 / 330415.0) * x - (50337.0 / 660830.0) * y + (316169.0 / 330415.0) * z;
}
void gtk_rgb_to_p3 (float red, float green, float blue,
float *pr, float *pg, float *pb)
{
float r, g, b;
float x, y, z;
gtk_rgb_to_linear_srgb (red, green, blue, &r, &g, &b);
gtk_linear_srgb_to_xyz (r, g, b, &x, &y, &z);
gtk_xyz_to_lin_p3 (x, y, z, &r, &g, &b);
gtk_linear_srgb_to_rgb (r, g, b, pr, pg, pb);
}
void
gtk_p3_to_rgb (float pr, float pg, float pb,
float *red, float *green, float *blue)
{
float r, g, b;
float x, y, z;
gtk_rgb_to_linear_srgb (pr, pg, pb, &r, &g, &b);
gtk_lin_p3_to_xyz (r, g, b, &x, &y, &z);
gtk_xyz_to_linear_srgb (x, y, z, &r, &g, &b);
gtk_linear_srgb_to_rgb (r, g, b, red, green, blue);
}
static inline float
linearize_one (float val)
{
float alpha = 1.09929682680944 ;
float beta = 0.018053968510807;
int sign = val < 0 ? -1 : 1;
float abs = fabs (val);
if (abs < beta * 4.5 )
return val / 4.5;
else
return sign * powf ((abs + alpha - 1) / alpha, 1.0 / 0.45);
}
void
gtk_rec2020_to_rec2020_linear (float r, float g , float b,
float *rr, float *gg, float *bb)
{
*rr = linearize_one (r);
*gg = linearize_one (g);
*bb = linearize_one (b);
}
void
gtk_rec2020_linear_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (63426534.0 / 99577255.0) * r + (20160776.0 / 139408157.0) * g + (47086771.0 / 278816314.0) * b;
*y = (26158966.0 / 99577255.0) * r + (472592308.0 / 697040785.0) * g + (8267143.0 / 139408157.0) * b;
*z = ( 0 / 1) * r + (19567812.0 / 697040785.0) * g + (295819943.0 / 278816314.0) * b;
}
void
gtk_rec2020_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
gtk_rec2020_to_rec2020_linear (r, g, b, &r, &g, &b);
gtk_rec2020_linear_to_xyz (r, g, b, x, y, z);
}
static inline float
delinearize_one (float val)
{
float alpha = 1.09929682680944;
float beta = 0.018053968510807;
int sign = val < 0 ? -1 : 1;
float abs = fabsf (val);
if (abs > beta)
return sign * (alpha * powf (abs, 0.45) - (alpha - 1));
else
return 4.5 * val;
}
void
gtk_rec2020_linear_to_rec2020 (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = delinearize_one (r);
*gg = delinearize_one (g);
*bb = delinearize_one (b);
}
void
gtk_xyz_to_rec2020_linear (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (30757411.0 / 17917100.0) * x - (6372589.0 / 17917100.0) * y - (4539589.0 / 17917100.0) * z;
*g = - (19765991.0 / 29648200.0) * x + (47925759.0 / 29648200.0) * y + (467509.0 / 29648200.0) *z;
*b = (792561.0 / 44930125.0) * x - (1921689.0 / 44930125.0) * y + (42328811.0 / 44930125.0) * z;
}
void
gtk_xyz_to_rec2020 (float x, float y, float z,
float *r, float *g, float *b)
{
gtk_xyz_to_rec2020_linear (x, y, z, r, g, b);
gtk_rec2020_linear_to_rec2020 (*r, *g, *b, r, g, b);
}
/* maps [0, 1] to [0, 70] */
static inline float
pq_to_linear (float v)
{
float ninv = (1 << 14) / 2610.0;
float minv = (1 << 5) / 2523.0;
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
return x * 10000 / 203.0;
}
/* maps [0, 70] to [0, 1] */
void
gtk_rec2100_pq_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = pq_to_linear (r);
*gg = pq_to_linear (g);
*bb = pq_to_linear (b);
}
static inline float
linear_to_pq (float v)
{
float x = v * 203.0 / 10000.0;
float n = 2610.0 / (1 << 14);
float m = 2523.0 / (1 << 5);
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
}
void
gtk_rec2100_linear_to_rec2100_pq (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = linear_to_pq (r);
*gg = linear_to_pq (g);
*bb = linear_to_pq (b);
}
void
gtk_rec2100_linear_to_rec2020_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = r;
*gg = g;
*bb = b;
}
void
gtk_rec2020_linear_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = r;
*gg = g;
*bb = b;
}
+34
View File
@@ -51,5 +51,39 @@ void gtk_rgb_to_linear_srgb (float red, float green, float blue
void gtk_linear_srgb_to_rgb (float linear_red, float linear_green, float linear_blue,
float *red, float *green, float *blue);
void gtk_rgb_to_p3 (float red, float green, float blue,
float *pr, float *pg, float *pb);
void gtk_p3_to_rgb (float pr, float pg, float pb,
float *red, float *green, float *blue);
void gtk_xyz_to_linear_srgb (float x, float y, float z,
float *r, float *g, float *b);
void gtk_linear_srgb_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_rec2020_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_xyz_to_rec2020 (float x, float y, float z,
float *r, float *g, float *b);
void gtk_rec2020_to_rec2020_linear (float r, float g , float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_rec2020 (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_xyz_to_rec2020_linear (float x, float y, float z,
float *r, float *g, float *b);
void gtk_rec2100_pq_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2100_linear_to_rec2100_pq (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2100_linear_to_rec2020_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
G_END_DECLS
+269 -8
View File
@@ -35,6 +35,10 @@ gtk_css_color_init (GtkCssColor *color,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -136,6 +140,22 @@ gtk_css_color_print (const GtkCssColor *color,
g_string_append (string, "oklch(");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "color(display-p3 ");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "color(xyz ");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "color(rec2020 ");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "color(rec2100-pq ");
break;
default:
g_assert_not_reached ();
}
@@ -181,6 +201,9 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
{
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
switch (coord)
{
case 0: return "r";
@@ -188,6 +211,14 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
case 2: return "b";
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_XYZ:
switch (coord)
{
case 0: return "x";
case 1: return "y";
case 2: return "z";
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_HSL:
switch (coord)
{
@@ -225,6 +256,64 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
}
}
void
gtk_css_color_space_get_coord_range (GtkCssColorSpace color_space,
gboolean legacy_rgb_scale,
guint coord,
float *lower,
float *upper)
{
if (coord == 3)
{
*lower = 0;
*upper = 1;
return;
}
switch (color_space)
{
case GTK_CSS_COLOR_SPACE_SRGB:
*lower = 0;
*upper = legacy_rgb_scale ? 255 : 1;
return;
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
*lower = 0;
*upper = 1;
return;
case GTK_CSS_COLOR_SPACE_HSL:
case GTK_CSS_COLOR_SPACE_HWB:
switch (coord)
{
case 0: *lower = *upper = NAN; return;
case 1:
case 2: *lower = 0; *upper = 100; return;
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_OKLAB:
switch (coord)
{
case 0: *lower = 0; *upper = 1; return;
case 1:
case 2: *lower = -0.4; *upper = 0.4; return;
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_OKLCH:
switch (coord)
{
case 0: *lower = 0; *upper = 1; return;
case 1: *lower = 0; *upper = 0.4; return;
case 2: *lower = *upper = NAN; return;
default: g_assert_not_reached ();
}
default:
g_assert_not_reached ();
}
}
static gboolean
color_space_is_polar (GtkCssColorSpace color_space)
{
@@ -233,11 +322,17 @@ color_space_is_polar (GtkCssColorSpace color_space)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
return FALSE;
case GTK_CSS_COLOR_SPACE_HSL:
case GTK_CSS_COLOR_SPACE_HWB:
case GTK_CSS_COLOR_SPACE_OKLCH:
return TRUE;
default:
g_assert_not_reached ();
}
@@ -257,6 +352,10 @@ convert_to_rectangular (GtkCssColor *output)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -298,7 +397,11 @@ convert_to_linear (GtkCssColor *output)
g_assert (output->color_space == GTK_CSS_COLOR_SPACE_SRGB ||
output->color_space == GTK_CSS_COLOR_SPACE_SRGB_LINEAR ||
output->color_space == GTK_CSS_COLOR_SPACE_OKLAB);
output->color_space == GTK_CSS_COLOR_SPACE_OKLAB ||
output->color_space == GTK_CSS_COLOR_SPACE_DISPLAY_P3 ||
output->color_space == GTK_CSS_COLOR_SPACE_XYZ ||
output->color_space == GTK_CSS_COLOR_SPACE_REC2020 ||
output->color_space == GTK_CSS_COLOR_SPACE_REC2100_PQ);
if (output->color_space == GTK_CSS_COLOR_SPACE_SRGB)
{
@@ -309,6 +412,52 @@ convert_to_linear (GtkCssColor *output)
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_DISPLAY_P3)
{
gtk_p3_to_rgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rgb_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_XYZ)
{
gtk_xyz_to_linear_srgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_REC2020)
{
gtk_rec2020_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_REC2100_PQ)
{
gtk_rec2100_pq_to_rec2100_linear (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rec2100_linear_to_rec2020_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2020_linear_to_xyz (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
}
static void
@@ -333,6 +482,52 @@ convert_from_linear (GtkCssColor *output,
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB, v);
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
gtk_linear_srgb_to_rgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rgb_to_p3 (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_DISPLAY_P3, v);
break;
case GTK_CSS_COLOR_SPACE_XYZ:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_XYZ, v);
break;
case GTK_CSS_COLOR_SPACE_REC2020:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_rec2020 (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_REC2020, v);
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_rec2020_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2020_linear_to_rec2100_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2100_linear_to_rec2100_pq (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_REC2100_PQ, v);
break;
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_OKLCH:
@@ -354,6 +549,10 @@ convert_from_rectangular (GtkCssColor *output,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_assert (output->color_space == dest);
break;
@@ -520,6 +719,10 @@ apply_hue_interpolation (GtkCssColor *from,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -552,6 +755,10 @@ normalize_hue (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -589,6 +796,10 @@ premultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
premultiply_component (color, 0);
premultiply_component (color, 1);
premultiply_component (color, 2);
@@ -631,6 +842,10 @@ unpremultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
unpremultiply_component (color, 0);
unpremultiply_component (color, 1);
unpremultiply_component (color, 2);
@@ -667,7 +882,10 @@ collect_analogous_missing (const GtkCssColor *color,
{ -1, -1, -1, -1, -1, 0, -1, -1, 3 }, /* hwb */
{ -1, -1, -1, 0, -1, -1, 1, 2, 3 }, /* oklab */
{ -1, -1, -1, 0, 1, 2, -1, -1, 3 }, /* oklch */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* display-p3 */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* xyz */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* rec2020 */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* rec2100-pq */
};
int *src = analogous[color->color_space];
@@ -776,6 +994,11 @@ parse_hue_interpolation (GtkCssParser *parser,
gtk_css_parser_consume_token (parser);
*interp = GTK_CSS_HUE_INTERPOLATION_DECREASING;
}
else if (gtk_css_token_is_ident (token, "hue"))
{
gtk_css_parser_error_syntax (parser, "'hue' goes after the interpolation method");
return FALSE;
}
else
{
*interp = GTK_CSS_HUE_INTERPOLATION_SHORTER;
@@ -791,6 +1014,12 @@ parse_hue_interpolation (GtkCssParser *parser,
return TRUE;
}
gboolean
gtk_css_color_interpolation_method_can_parse (GtkCssParser *parser)
{
return gtk_css_token_is_ident (gtk_css_parser_get_token (parser), "in");
}
gboolean
gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
GtkCssColorSpace *in,
@@ -826,19 +1055,39 @@ gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_HWB;
}
else if (gtk_css_token_is_ident (token, "oklch"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_OKLCH;
}
else if (gtk_css_token_is_ident (token, "oklab"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_OKLAB;
}
else if (gtk_css_token_is_ident (token, "oklch"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_OKLCH;
}
else if (gtk_css_token_is_ident (token, "display-p3"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_DISPLAY_P3;
}
else if (gtk_css_token_is_ident (token, "xyz"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_XYZ;
}
else if (gtk_css_token_is_ident (token, "rec2020"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_REC2020;
}
else if (gtk_css_token_is_ident (token, "rec2100-pq"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_REC2100_PQ;
}
else
{
gtk_css_parser_error_syntax (parser, "Invalid color space");
gtk_css_parser_error_syntax (parser, "Invalid color space: %s", gtk_css_token_to_string (token));
return FALSE;
}
@@ -876,6 +1125,18 @@ gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
case GTK_CSS_COLOR_SPACE_OKLAB:
g_string_append (string, "oklab");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "display-p3");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "xyz");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "rec2020");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "rec2100-pq");
break;
default:
g_assert_not_reached ();
}
+9 -16
View File
@@ -21,17 +21,10 @@
#include <math.h>
#include "gtk/css/gtkcssparserprivate.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
typedef enum {
GTK_CSS_COLOR_SPACE_SRGB,
GTK_CSS_COLOR_SPACE_SRGB_LINEAR,
GTK_CSS_COLOR_SPACE_HSL,
GTK_CSS_COLOR_SPACE_HWB,
GTK_CSS_COLOR_SPACE_OKLAB,
GTK_CSS_COLOR_SPACE_OKLCH,
} GtkCssColorSpace;
typedef struct
{
@@ -96,14 +89,6 @@ void gtk_css_color_convert (const GtkCssColor *input,
GtkCssColorSpace dest,
GtkCssColor *output);
typedef enum
{
GTK_CSS_HUE_INTERPOLATION_SHORTER,
GTK_CSS_HUE_INTERPOLATION_LONGER,
GTK_CSS_HUE_INTERPOLATION_INCREASING,
GTK_CSS_HUE_INTERPOLATION_DECREASING,
} GtkCssHueInterpolation;
void gtk_css_color_interpolate (const GtkCssColor *from,
const GtkCssColor *to,
float progress,
@@ -114,6 +99,14 @@ void gtk_css_color_interpolate (const GtkCssColor *from,
const char * gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
guint coord);
void gtk_css_color_space_get_coord_range (GtkCssColorSpace color_space,
gboolean legacy_rgb_scale,
guint coord,
float *lower,
float *upper);
gboolean gtk_css_color_interpolation_method_can_parse (GtkCssParser *parser);
gboolean gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
GtkCssColorSpace *in,
GtkCssHueInterpolation *interp);
+131 -26
View File
@@ -357,6 +357,30 @@ gtk_css_value_color_print (const GtkCssValue *value,
g_string_append (string, " srgb-linear");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " display-p3");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " xyz");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " rec2020");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " rec2100-pq");
break;
case GTK_CSS_COLOR_SPACE_HSL:
g_string_append (string, "hsl(from ");
gtk_css_value_print (value->relative.origin, string);
@@ -593,6 +617,49 @@ apply_color_mix (GtkCssColorSpace in,
missing);
}
static GtkCssValue *
resolve_relative (GtkCssValue *values[4],
GtkCssColorSpace color_space,
gboolean legacy_rgb_scale)
{
float v[4];
gboolean m[4];
for (guint i = 0; i < 4; i++)
{
if (values[i])
{
float lower, upper;
gtk_css_color_space_get_coord_range (color_space, legacy_rgb_scale,
i, &lower, &upper);
m[i] = FALSE;
v[i] = gtk_css_number_value_get_canonical (values[i], upper - lower);
if (gtk_css_number_value_has_percent (values[i]))
v[i] += lower;
}
else
{
m[i] = TRUE;
v[i] = 0;
}
}
if (color_space == GTK_CSS_COLOR_SPACE_SRGB &&
legacy_rgb_scale)
{
v[0] /= 255.;
v[1] /= 255.;
v[2] /= 255.;
}
v[3] = CLAMP (v[3], 0, 1); /* clamp alpha */
return gtk_css_color_value_new_color (color_space, FALSE, v, m);
}
static GtkCssValue *
gtk_css_color_value_do_resolve (GtkCssValue *color,
guint property_id,
@@ -613,39 +680,23 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
case COLOR_TYPE_RELATIVE:
{
float v[4];
gboolean m[4];
GtkCssValue *vals[4];
for (guint i = 0; i < 4; i++)
{
if (color->relative.values[i])
{
GtkCssValue *val;
m[i] = FALSE;
val = gtk_css_value_compute (color->relative.values[i], property_id, context);
v[i] = gtk_css_number_value_get_canonical (val, 1);
gtk_css_value_unref (val);
}
vals[i] = gtk_css_value_compute (color->relative.values[i], property_id, context);
else
{
m[i] = TRUE;
v[i] = 0;
}
vals[i] = NULL;
}
if (color->relative.color_space == GTK_CSS_COLOR_SPACE_SRGB &&
color->relative.legacy_srgb)
value = resolve_relative (vals, color->relative.color_space, color->relative.legacy_srgb);
for (guint i = 0; i < 4; i++)
{
v[0] /= 255.;
v[1] /= 255.;
v[2] /= 255.;
if (vals[i])
gtk_css_value_unref (vals[i]);
}
v[3] = CLAMP (v[3], 0, 1); /* clamp alpha */
value = gtk_css_color_value_new_color (color->relative.color_space, FALSE, v, m);
}
break;
@@ -852,6 +903,25 @@ gtk_css_color_value_new_relative (GtkCssValue *origin,
GtkCssValue *values[4])
{
GtkCssValue *value;
gboolean computed = TRUE;
if (!gtk_css_value_is_computed (origin))
computed = FALSE;
if (!computed)
{
for (guint i = 0; i < 4; i++)
{
if (values[i] && !gtk_css_value_is_computed (values[i]))
{
computed = FALSE;
break;
}
}
}
if (computed)
return resolve_relative (values, color_space, legacy_srgb);
value = gtk_css_value_alloc (&GTK_CSS_VALUE_COLOR,
sizeof (GtkCssValue) + sizeof (GtkCssValue *) * 3);
@@ -1432,7 +1502,11 @@ parse_ok_ab_value (GtkCssParser *parser,
if (data->values[idx] == NULL)
return FALSE;
data->v[idx] = gtk_css_number_value_get_canonical (data->values[idx], 0.4);
data->v[idx] = gtk_css_number_value_get_canonical (data->values[idx], 0.8);
/* gtk_css_number_value_get_canonical() doesn't let us specify what 0% is */
if (gtk_css_number_value_has_percent (data->values[idx]))
data->v[idx] -= 0.4;
}
return TRUE;
@@ -1577,6 +1651,8 @@ parse_color_color_channel (GtkCssParser *parser,
ParseData *data,
guint arg)
{
const GtkCssToken *token;
switch (arg)
{
case 0:
@@ -1592,7 +1668,35 @@ parse_color_color_channel (GtkCssParser *parser,
return 1;
}
gtk_css_parser_error_syntax (parser, "Invalid color space in color()");
if (gtk_css_parser_try_ident (parser, "display-p3"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_DISPLAY_P3;
return 1;
}
if (gtk_css_parser_try_ident (parser, "xyz"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_XYZ;
return 1;
}
if (gtk_css_parser_try_ident (parser, "rec2020"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_REC2020;
return 1;
}
if (gtk_css_parser_try_ident (parser, "rec2100-pq"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_REC2100_PQ;
return 1;
}
token = gtk_css_parser_get_token (parser);
gtk_css_parser_error_syntax (parser,
"Invalid color space in color(): %s",
gtk_css_token_to_string (token));
return 0;
case 1:
@@ -1639,6 +1743,7 @@ parse_color_function (GtkCssParser *self,
{
data->ctx.color = gtk_css_color_value_parse (self);
data->syntax = COLOR_SYNTAX_MODERN;
data->serialize_as_rgb = FALSE;
}
arg = 0;
+71 -30
View File
@@ -81,7 +81,10 @@ gtk_css_image_conic_snapshot (GtkCssImage *image,
last = i;
}
gtk_snapshot_append_conic_gradient (
if (self->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
gtk_snapshot_append_conic_gradient (
snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (_gtk_css_position_value_get_x (self->center, width),
@@ -172,37 +175,57 @@ gtk_css_image_conic_parse_first_arg (GtkCssImageConic *self,
GtkCssParser *parser,
GArray *stop_array)
{
gboolean nothing_parsed = TRUE;
gboolean has_rotation = FALSE;
gboolean has_center = FALSE;
gboolean has_colorspace = FALSE;
int retval = 1;
if (gtk_css_parser_try_ident (parser, "from"))
do
{
self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (self->rotation == NULL)
return 0;
nothing_parsed = FALSE;
}
else
{
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser))
{
if (!gtk_css_color_interpolation_method_parse (parser, &self->color_space, &self->hue_interp))
return 0;
has_colorspace = TRUE;
}
else if (!has_rotation && gtk_css_parser_try_ident (parser, "from"))
{
self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (self->rotation == NULL)
return 0;
has_rotation = TRUE;
}
else if (!has_center && gtk_css_parser_try_ident (parser, "at"))
{
self->center = _gtk_css_position_value_parse (parser);
if (self->center == NULL)
return 0;
has_center = TRUE;
}
else if (gtk_css_token_is (gtk_css_parser_get_token (parser), GTK_CSS_TOKEN_COMMA))
{
retval = 1;
break;
}
else
{
if (gtk_css_image_conic_parse_color_stop (self, parser, stop_array))
{
retval = 2;
break;
}
}
}
while (!(has_colorspace && has_rotation && has_center));
if (gtk_css_parser_try_ident (parser, "at"))
{
self->center = _gtk_css_position_value_parse (parser);
if (self->center == NULL)
return 0;
nothing_parsed = FALSE;
}
else
{
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
}
if (!has_rotation)
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
if (!nothing_parsed)
return 1;
if (!has_center)
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
return 1 + gtk_css_image_conic_parse_color_stop (self, parser, stop_array);
return retval;
}
typedef struct
@@ -265,7 +288,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
gboolean written = FALSE;
guint i;
g_string_append (string, "self-gradient(");
g_string_append (string, "conic-gradient(");
if (self->center)
{
@@ -274,7 +297,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
if (!gtk_css_value_equal (self->center, compare))
{
g_string_append (string, "from ");
g_string_append (string, "at ");
gtk_css_value_print (self->center, string);
written = TRUE;
}
@@ -286,8 +309,19 @@ gtk_css_image_conic_print (GtkCssImage *image,
{
if (written)
g_string_append_c (string, ' ');
g_string_append (string, "at ");
g_string_append (string, "from ");
gtk_css_value_print (self->rotation, string);
written = TRUE;
}
if (self->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
if (written)
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (self->color_space,
self->hue_interp,
string);
written = TRUE;
}
if (written)
@@ -325,6 +359,8 @@ gtk_css_image_conic_compute (GtkCssImage *image,
copy->center = gtk_css_value_compute (self->center, property_id, context);
copy->rotation = gtk_css_value_compute (self->rotation, property_id, context);
copy->color_space = self->color_space;
copy->hue_interp = self->hue_interp;
copy->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
@@ -380,6 +416,9 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
if (result->rotation == NULL)
goto fail;
result->color_space = start->color_space;
result->hue_interp = start->hue_interp;
result->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * start->n_stops);
result->n_stops = 0;
for (i = 0; i < start->n_stops; i++)
@@ -435,7 +474,9 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
guint i;
if (!gtk_css_value_equal (conic1->center, conic2->center) ||
!gtk_css_value_equal (conic1->rotation, conic2->rotation))
!gtk_css_value_equal (conic1->rotation, conic2->rotation) ||
conic1->color_space != conic2->color_space ||
conic1->hue_interp != conic2->hue_interp)
return FALSE;
for (i = 0; i < conic1->n_stops; i++)
+3
View File
@@ -47,6 +47,9 @@ struct _GtkCssImageConic
GtkCssValue *center;
GtkCssValue *rotation;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageConicColorStop *color_stops;
};
+116 -63
View File
@@ -244,6 +244,9 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
last = i;
}
if (linear->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
if (linear->repeating)
{
gtk_snapshot_append_repeating_linear_gradient (
@@ -304,75 +307,102 @@ gtk_css_image_linear_parse_first_arg (GtkCssImageLinear *linear,
GArray *stop_array)
{
guint i;
gboolean has_colorspace = FALSE;
gboolean has_side_or_angle = FALSE;
guint retval = 1;
if (gtk_css_parser_try_ident (parser, "to"))
do
{
for (i = 0; i < 2; i++)
if (!has_colorspace &&gtk_css_color_interpolation_method_can_parse (parser))
{
if (gtk_css_parser_try_ident (parser, "left"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_LEFT);
}
else if (gtk_css_parser_try_ident (parser, "right"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_RIGHT);
}
else if (gtk_css_parser_try_ident (parser, "top"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_TOP);
}
else if (gtk_css_parser_try_ident (parser, "bottom"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_BOTTOM);
}
else
break;
if (!gtk_css_color_interpolation_method_parse (parser, &linear->color_space, &linear->hue_interp))
return 0;
has_colorspace = TRUE;
}
if (linear->side == 0)
else if (!has_side_or_angle && gtk_css_parser_try_ident (parser, "to"))
{
gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to");
gtk_css_parser_consume_token (parser);
for (i = 0; i < 2; i++)
{
if (gtk_css_parser_try_ident (parser, "left"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_LEFT);
}
else if (gtk_css_parser_try_ident (parser, "right"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_RIGHT);
}
else if (gtk_css_parser_try_ident (parser, "top"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_TOP);
}
else if (gtk_css_parser_try_ident (parser, "bottom"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_BOTTOM);
}
else
break;
}
if (linear->side == 0)
{
gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to");
return 0;
}
has_side_or_angle = TRUE;
}
else if (!has_side_or_angle && gtk_css_number_value_can_parse (parser))
{
linear->angle = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (linear->angle == NULL)
return 0;
has_side_or_angle = TRUE;
}
else if (gtk_css_token_is (gtk_css_parser_get_token (parser), GTK_CSS_TOKEN_COMMA))
{
retval = 1;
break;
}
else
{
if (gtk_css_image_linear_parse_color_stop (linear, parser, stop_array))
{
retval = 2;
break;
}
return 0;
}
return 1;
}
else if (gtk_css_number_value_can_parse (parser))
{
linear->angle = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (linear->angle == NULL)
return 0;
while (!(has_colorspace && has_side_or_angle));
return 1;
}
else
{
linear->side = 1 << GTK_CSS_BOTTOM;
if (!gtk_css_image_linear_parse_color_stop (linear, parser, stop_array))
return 0;
if (linear->angle == NULL && linear->side == 0)
linear->side = (1 << GTK_CSS_BOTTOM);
return 2;
}
return retval;
}
typedef struct
@@ -437,6 +467,7 @@ gtk_css_image_linear_print (GtkCssImage *image,
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
guint i;
gboolean has_printed = FALSE;
if (linear->repeating)
g_string_append (string, "repeating-linear-gradient(");
@@ -459,15 +490,29 @@ gtk_css_image_linear_print (GtkCssImage *image,
else if (linear->side & (1 << GTK_CSS_RIGHT))
g_string_append (string, " right");
g_string_append (string, ", ");
has_printed = TRUE;
}
}
else
{
gtk_css_value_print (linear->angle, string);
g_string_append (string, ", ");
has_printed = TRUE;
}
if (linear->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
if (has_printed)
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (linear->color_space,
linear->hue_interp,
string);
has_printed = TRUE;
}
if (has_printed)
g_string_append (string, ", ");
for (i = 0; i < linear->n_stops; i++)
{
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
@@ -499,6 +544,8 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
copy->side = linear->side;
copy->color_space = linear->color_space;
copy->hue_interp = linear->hue_interp;
if (linear->angle)
copy->angle = gtk_css_value_compute (linear->angle, property_id, context);
@@ -545,11 +592,15 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
end = GTK_CSS_IMAGE_LINEAR (end_image);
if ((start->repeating != end->repeating)
|| (start->n_stops != end->n_stops))
|| (start->n_stops != end->n_stops)
|| (start->color_space != end->color_space)
|| (start->hue_interp != end->hue_interp))
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress);
result = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
result->repeating = start->repeating;
result->color_space = start->color_space;
result->hue_interp = start->hue_interp;
if (start->side != end->side)
goto fail;
@@ -618,7 +669,9 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
if (linear1->repeating != linear2->repeating ||
linear1->side != linear2->side ||
(linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) ||
linear1->n_stops != linear2->n_stops)
linear1->n_stops != linear2->n_stops ||
linear1->color_space != linear2->color_space ||
linear1->hue_interp != linear2->hue_interp)
return FALSE;
for (i = 0; i < linear1->n_stops; i++)
+3
View File
@@ -48,6 +48,9 @@ struct _GtkCssImageLinear
guint repeating :1;
GtkCssValue *angle;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageLinearColorStop *color_stops;
};
+27 -3
View File
@@ -194,6 +194,9 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
last = i;
}
if (radial->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
if (radial->repeating)
gtk_snapshot_append_repeating_radial_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
@@ -255,6 +258,7 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
{
gboolean has_shape = FALSE;
gboolean has_size = FALSE;
gboolean has_colorspace = FALSE;
gboolean found_one = FALSE;
guint i;
static struct {
@@ -270,7 +274,13 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
found_one = FALSE;
do {
if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser))
{
if (!gtk_css_color_interpolation_method_parse (parser, &radial->color_space, &radial->hue_interp))
return 0;
has_colorspace = TRUE;
}
else if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
{
radial->circle = TRUE;
found_one = has_shape = TRUE;
@@ -467,6 +477,14 @@ gtk_css_image_radial_print (GtkCssImage *image,
g_string_append (string, " at ");
gtk_css_value_print (radial->position, string);
if (radial->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (radial->color_space,
radial->hue_interp,
string);
}
g_string_append (string, ", ");
for (i = 0; i < radial->n_stops; i++)
@@ -501,6 +519,8 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->repeating = radial->repeating;
copy->circle = radial->circle;
copy->size = radial->size;
copy->color_space = radial->color_space;
copy->hue_interp = radial->hue_interp;
copy->position = gtk_css_value_compute (radial->position, property_id, context);
@@ -554,7 +574,9 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
if (start->repeating != end->repeating ||
start->n_stops != end->n_stops ||
start->size != end->size ||
start->circle != end->circle)
start->circle != end->circle ||
start->color_space != end->color_space ||
start->hue_interp != end->hue_interp)
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_radial_parent_class)->transition (start_image, end_image, property_id, progress);
result = g_object_new (GTK_TYPE_CSS_IMAGE_RADIAL, NULL);
@@ -645,7 +667,9 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
(radial1->sizes[0] && radial2->sizes[0] && !gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
((radial1->sizes[1] == NULL) != (radial2->sizes[1] == NULL)) ||
(radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
radial1->n_stops != radial2->n_stops)
radial1->n_stops != radial2->n_stops ||
radial1->color_space != radial2->color_space ||
radial1->hue_interp != radial2->hue_interp)
return FALSE;
for (i = 0; i < radial1->n_stops; i++)
+5
View File
@@ -54,8 +54,13 @@ struct _GtkCssImageRadial
GtkCssValue *position;
GtkCssValue *sizes[2];
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageRadialColorStop *color_stops;
GtkCssRadialSize size;
guint circle : 1;
guint repeating :1;
+3 -2
View File
@@ -240,9 +240,10 @@ parse_css_direction (GtkCssStyleProperty *property,
static GtkCssValue *
opacity_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
GtkCssParser *parser)
{
return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER
| GTK_CSS_PARSE_PERCENT);
}
static GtkCssValue *
+22 -1
View File
@@ -573,5 +573,26 @@ gtk_css_hash_id (GQuark id)
return id * 11;
}
G_END_DECLS
typedef enum {
GTK_CSS_COLOR_SPACE_SRGB,
GTK_CSS_COLOR_SPACE_SRGB_LINEAR,
GTK_CSS_COLOR_SPACE_HSL,
GTK_CSS_COLOR_SPACE_HWB,
GTK_CSS_COLOR_SPACE_OKLAB,
GTK_CSS_COLOR_SPACE_OKLCH,
GTK_CSS_COLOR_SPACE_DISPLAY_P3,
GTK_CSS_COLOR_SPACE_XYZ,
GTK_CSS_COLOR_SPACE_REC2020,
GTK_CSS_COLOR_SPACE_REC2100_PQ,
} GtkCssColorSpace;
typedef enum
{
GTK_CSS_HUE_INTERPOLATION_SHORTER,
GTK_CSS_HUE_INTERPOLATION_LONGER,
GTK_CSS_HUE_INTERPOLATION_INCREASING,
GTK_CSS_HUE_INTERPOLATION_DECREASING,
} GtkCssHueInterpolation;
G_END_DECLS
+1 -1
View File
@@ -47,7 +47,7 @@
* and is destroyed when the drag ends.
*
* To set up a drag icon and associate it with an ongoing drag operation,
* use [func@Gtk.DragIcon.get_for_drag] to get the icon for a drag. You can
* use [ctor@Gtk.DragIcon.get_for_drag] to get the icon for a drag. You can
* then use it like any other widget and use [method@Gtk.DragIcon.set_child]
* to set whatever widget should be used for the drag icon.
*
+41 -3
View File
@@ -840,13 +840,24 @@ gtk_label_update_layout_attributes (GtkLabel *self,
}
link_color = gtk_css_color_value_get_rgba (style->core->color);
attr = pango_attr_foreground_new (link_color->red * 65535,
link_color->green * 65535,
link_color->blue * 65535);
attr = pango_attr_foreground_new (CLAMP (link_color->red * 65535. + 0.5, 0, 65535),
CLAMP (link_color->green * 65535. + 0.5, 0, 65535),
CLAMP (link_color->blue * 65535. + 0.5, 0, 65535));
attr->start_index = link->start;
attr->end_index = link->end;
pango_attr_list_insert (attrs, attr);
if (link_color->alpha < 0.999)
{
attr = pango_attr_foreground_alpha_new (CLAMP (link_color->alpha * 65535. + 0.5, 0, 65535));
attr->start_index = link->start;
attr->end_index = link->end;
pango_attr_list_insert (attrs, attr);
}
pango_attr_list_unref (link_attrs);
}
}
@@ -3423,6 +3434,29 @@ finish_text (UriParserData *pdata)
}
}
static void
link_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkLabel *self)
{
if (gtk_css_style_change_affects (change,
GTK_CSS_AFFECTS_CONTENT |
GTK_CSS_AFFECTS_TEXT_ATTRS))
{
gtk_label_ensure_layout (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkLabel *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
start_element_handler (GMarkupParseContext *context,
const char *element_name,
@@ -3511,6 +3545,7 @@ start_element_handler (GMarkupParseContext *context,
gtk_css_node_set_parent (link.cssnode, widget_node);
if (class)
gtk_css_node_add_class (link.cssnode, g_quark_from_string (class));
g_signal_connect (link.cssnode, "style-changed", G_CALLBACK (link_style_changed_cb), self);
state = gtk_css_node_get_state (widget_node);
if (visited)
@@ -5129,6 +5164,8 @@ gtk_label_select_region_index (GtkLabel *self,
gtk_css_node_set_name (self->select_info->selection_node, g_quark_from_static_string ("selection"));
gtk_css_node_set_parent (self->select_info->selection_node, widget_node);
gtk_css_node_set_state (self->select_info->selection_node, gtk_css_node_get_state (widget_node));
g_signal_connect (self->select_info->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), self);
g_object_unref (self->select_info->selection_node);
}
}
@@ -6277,3 +6314,4 @@ gtk_label_accessible_text_init (GtkAccessibleTextInterface *iface)
/* }}} */
/* vim:set foldmethod=marker expandtab: */
+11
View File
@@ -3858,6 +3858,15 @@ get_better_cursor_x (GtkText *self,
return (direction == priv->resolved_dir) ? strong_pos.x / PANGO_SCALE : weak_pos.x / PANGO_SCALE;
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkText *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
gtk_text_move_cursor (GtkText *self,
GtkMovementStep step,
@@ -4510,6 +4519,8 @@ gtk_text_set_positions (GtkText *self,
gtk_css_node_set_name (priv->selection_node, g_quark_from_static_string ("selection"));
gtk_css_node_set_parent (priv->selection_node, widget_node);
gtk_css_node_set_state (priv->selection_node, gtk_css_node_get_state (widget_node));
g_signal_connect (priv->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), self);
g_object_unref (priv->selection_node);
}
}
+22 -5
View File
@@ -1407,6 +1407,16 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
overline_equal (appearance1, appearance2);
}
static inline GdkRGBA *
clamp_rgba (GdkRGBA *rgba)
{
rgba->red = CLAMP (rgba->red, 0, 1);
rgba->green = CLAMP (rgba->green, 0, 1);
rgba->blue = CLAMP (rgba->blue, 0, 1);
rgba->alpha = CLAMP (rgba->alpha, 0, 1);
return rgba;
}
/*
* gtk_text_attr_appearance_new:
* @desc:
@@ -1439,19 +1449,19 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
result->appearance = *appearance;
if (appearance->fg_rgba)
result->appearance.fg_rgba = gdk_rgba_copy (appearance->fg_rgba);
result->appearance.fg_rgba = clamp_rgba (gdk_rgba_copy (appearance->fg_rgba));
if (appearance->bg_rgba)
result->appearance.bg_rgba = gdk_rgba_copy (appearance->bg_rgba);
result->appearance.bg_rgba = clamp_rgba (gdk_rgba_copy (appearance->bg_rgba));
if (appearance->underline_rgba)
result->appearance.underline_rgba = gdk_rgba_copy (appearance->underline_rgba);
result->appearance.underline_rgba = clamp_rgba (gdk_rgba_copy (appearance->underline_rgba));
if (appearance->overline_rgba)
result->appearance.overline_rgba = gdk_rgba_copy (appearance->overline_rgba);
result->appearance.overline_rgba = clamp_rgba (gdk_rgba_copy (appearance->overline_rgba));
if (appearance->strikethrough_rgba)
result->appearance.strikethrough_rgba = gdk_rgba_copy (appearance->strikethrough_rgba);
result->appearance.strikethrough_rgba = clamp_rgba (gdk_rgba_copy (appearance->strikethrough_rgba));
return (PangoAttribute *)result;
}
@@ -4090,6 +4100,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
GtkWidget *widget,
GtkSnapshot *snapshot,
const GdkRectangle *clip,
gboolean selection_style_changed,
float cursor_alpha)
{
GtkTextLayoutPrivate *priv;
@@ -4227,6 +4238,12 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
{
if (line_display->has_block_cursor && gtk_widget_has_focus (widget))
g_clear_pointer (&line_display->node, gsk_render_node_unref);
if (selection_style_changed &&
(selection_start_index != -1 || selection_end_index != -1))
{
g_clear_pointer (&line_display->node, gsk_render_node_unref);
}
}
if (line_display->node == NULL &&
+1
View File
@@ -376,6 +376,7 @@ void gtk_text_layout_snapshot (GtkTextLayout *layout,
GtkWidget *widget,
GtkSnapshot *snapshot,
const GdkRectangle *clip,
gboolean selection_style_changed,
float cursor_alpha);
void gtk_text_layout_set_mru_size (GtkTextLayout *layout,
+1 -1
View File
@@ -286,7 +286,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
gtk_css_style_snapshot_background (&boxes, snapshot);
}
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, 1.0);
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, FALSE, 1.0);
g_object_unref (layout);
g_object_unref (new_buffer);
+20
View File
@@ -303,6 +303,8 @@ struct _GtkTextViewPrivate
guint vscroll_policy : 1;
guint cursor_handle_dragged : 1;
guint selection_handle_dragged : 1;
guint selection_style_changed : 1;
};
struct _GtkTextPendingScroll
@@ -840,6 +842,19 @@ gtk_text_view_notify (GObject *object,
G_OBJECT_CLASS (gtk_text_view_parent_class)->notify (object, pspec);
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkTextView *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
{
GtkTextViewPrivate *priv = self->priv;
priv->selection_style_changed = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
gtk_text_view_class_init (GtkTextViewClass *klass)
{
@@ -2041,6 +2056,8 @@ gtk_text_view_init (GtkTextView *text_view)
gtk_css_node_set_state (priv->selection_node,
gtk_css_node_get_state (priv->text_window->css_node) & ~GTK_STATE_FLAG_DROP_ACTIVE);
gtk_css_node_set_visible (priv->selection_node, FALSE);
g_signal_connect (priv->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), text_view);
g_object_unref (priv->selection_node);
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.can-redo", FALSE);
@@ -5922,9 +5939,12 @@ gtk_text_view_paint (GtkWidget *widget,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget)
},
priv->selection_style_changed,
priv->cursor_alpha);
gtk_snapshot_restore (snapshot);
priv->selection_style_changed = FALSE;
}
static void
+1 -1
View File
@@ -11857,7 +11857,7 @@ gtk_widget_create_render_node (GtkWidget *widget,
style = gtk_css_node_get_style (priv->cssnode);
css_opacity = gtk_css_number_value_get (style->other->opacity, 100);
css_opacity = gtk_css_number_value_get (style->other->opacity, 1);
opacity = CLAMP (css_opacity, 0.0, 1.0) * priv->user_alpha / 255.0;
if (opacity <= 0.0)
+307 -285
View File
File diff suppressed because it is too large Load Diff
+2482 -1658
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -7,3 +7,5 @@ depth = 1
[provide]
harfbuzz = libharfbuzz_dep
harfbuzz-subset = libharfbuzz_subset_dep
+2 -1
View File
@@ -189,7 +189,8 @@ allocate_memfd (gsize size)
if (fd == -1)
g_error ("memfd allocation failed");
ftruncate (fd, size);
if (ftruncate (fd, size) != 0)
g_error ("ftruncate failed");
return fd;
}
+9 -2
View File
@@ -27,7 +27,7 @@
#include "gtk/gtkcssstylepropertyprivate.h"
#include "gtk/gtkcssstaticstyleprivate.h"
#define EPSILON 0.001
#define EPSILON 0.005
static gboolean
color_is_near (const GtkCssColor *color1,
@@ -116,8 +116,15 @@ static ColorConversionTest conversion_tests[] = {
{ "oklch(0.66016 0.15546 134.231)", GTK_CSS_COLOR_SPACE_SRGB, "rgb(40.73% 65.12% 22.35%)" },
{ "oklch(72.322% 0.12403 247.996)", GTK_CSS_COLOR_SPACE_SRGB, "rgb(38.29% 67.27% 93.85%)" },
{ "oklch(42.1% 48.25% 328.4)", GTK_CSS_COLOR_SPACE_SRGB, "color(srgb 0.501808 0.00257216 0.501403)" },
/* more random tests */
/* some self-conversions */
{ "oklch(0.392 0.4 none)", GTK_CSS_COLOR_SPACE_OKLCH, "oklch(0.392 0.4 0)" },
{ "color(display-p3 1 1 1)", GTK_CSS_COLOR_SPACE_DISPLAY_P3, "color(display-p3 1 1 1)" },
{ "color(rec2020 1 1 1)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 1 1 1)" },
{ "color(rec2100-pq 0.58 0.58 0.58)", GTK_CSS_COLOR_SPACE_REC2100_PQ, "color(rec2100-pq 0.58 0.58 0.58)" },
/* more random tests */
{ "color(rec2100-pq 0.58 0.58 0.58)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 1 1 1)" },
{ "color(xyz 0.5 0.7 99%)", GTK_CSS_COLOR_SPACE_DISPLAY_P3, "color(display-p3 0.48 0.93 0.96)" },
{ "hsl(250 100 20)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 0.042 0.008 0.3226)" },
};
static void
@@ -1,3 +1,4 @@
at-invalid-12.css:1:21-25: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:25-29: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:31-36: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:38-44: error: GTK_CSS_PARSER_ERROR_SYNTAX
@@ -1,2 +1,3 @@
at-invalid-13.css:1:21-25: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-13.css:1:25-30: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-13.css:1:32-35: error: GTK_CSS_PARSER_ERROR_SYNTAX
@@ -1 +1,2 @@
at-invalid-14.css:1:21-25: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-14.css:1:25-28: error: GTK_CSS_PARSER_ERROR_SYNTAX

Some files were not shown because too many files have changed in this diff Show More