Compare commits

...

398 Commits

Author SHA1 Message Date
Matthias Clasen
aa91c59bd7 Rewrite compare-render test
Rewrite this to use TAP and do a single invocation for a whole
directory of files.

This uncovers that the GL renderer is mishandling transforms with
offscreens. There is also some randomness in the failures with the
GL renderer that I have yet to track down.
2023-12-21 08:27:12 -05:00
Matthias Clasen
3ee4dba206 testsuite: Run nodeparser tests as one binary
Instead of relaunching the offload test binary for each file,
just run it once and let it iterate over the directory where
all the node files are.
2023-12-21 08:27:01 -05:00
Matthias Clasen
55c2965dc7 testsuite: Run offload tests as one binary
Instead of relaunching the offload test binary for each file,
just run it once and let it iterate over the directory where
all the node files are.
2023-12-21 08:27:01 -05:00
Matthias Clasen
312c0f0b3b Merge branch 'fix-crossing-events' into 'main'
main: Fix crossing event setup

Closes #6279

See merge request GNOME/gtk!6684
2023-12-20 21:50:33 +00:00
Matthias Clasen
adc9cc568e main: Check crossing invariants on both legs
We were calling check_crossing_invariants for the ascending
part, but not for the descending part. Fix that.
2023-12-20 15:26:05 -05:00
Matthias Clasen
3e59b0b582 Fix a typo
This unfortunate typo made it so we never actually checked
the crossing invariants.
2023-12-20 15:26:05 -05:00
Matthias Clasen
6a5ee99c23 main: Fix crossing event setup
We were not determining the new descendent correctly. And since
our invariants check was ineffective, nobody noticed until now.

Fixes: #6279
2023-12-20 15:25:50 -05:00
Matthias Clasen
8fda63c85e Merge branch 'pragma-once-header-cleanup' into 'main'
media: Convert headers to #pragma once

See merge request GNOME/gtk!6682
2023-12-20 18:38:42 +00:00
Matthias Clasen
cfa9dc6162 testsuite: Use #pragma once consistently 2023-12-20 10:55:14 -05:00
Matthias Clasen
9f068866e2 examples: Use #pragma once consistently
It is our current coding style.
2023-12-20 10:29:45 -05:00
Matthias Clasen
0d03e570b0 tests: Use #pragma once consistently
Its the current coding style.
2023-12-20 10:25:41 -05:00
Matthias Clasen
0dcf31292d icon-browser: Use #pragma once consistently
That is the current coding style.
2023-12-20 10:24:05 -05:00
Matthias Clasen
4ab18b6657 gtk4-demo: Use #pragma once consistently
This is our current coding style.
2023-12-20 09:55:11 -05:00
Matthias Clasen
957d96102a gtk: Use #pragma once consistently
One header snuck in missing it.
2023-12-20 09:52:04 -05:00
Matthias Clasen
d21a691f44 node-editor: Convert headers to #pragma once
That is our current coding style.
2023-12-20 09:51:19 -05:00
Matthias Clasen
ae5ea8e495 printing: Convert headers to #pragma once
That is our current coding style.
2023-12-20 09:44:29 -05:00
Matthias Clasen
bbabb1973c media: Convert headers to #pragma once
This is our current coding style.
2023-12-20 09:43:54 -05:00
Benjamin Otte
d2a85abf79 Merge branch 'wip/otte/dmabuf-refactoring' into 'main'
dmabuf refactoring

See merge request GNOME/gtk!6678
2023-12-20 10:25:29 +00:00
Benjamin Otte
74620ffc46 dmabufdownloader: Add a close() function
We need to unrealize renderers before unreffing them. This vfunc takes
care of that.
2023-12-20 10:59:25 +01:00
Benjamin Otte
ce04dfad41 renderer: Move function into only caller
The convert_texture() path only works for the GL renderer, the new
renderers potentially use dmabuf textures as result of render_texture(),
so they need to be smarter here.
2023-12-20 10:59:25 +01:00
Benjamin Otte
568eed9477 dmabuf: Turn the downloader into an interface
This way, we can move the actual downloader code into GSK - by just
implementing the interface in the GskGLRenderer.
2023-12-20 10:59:25 +01:00
Benjamin Otte
26561ab2e7 dmabuf: Refactor downloader vfuncs
This is in preparation for future commits. It also makes the API
clearer.
2023-12-20 01:51:46 +01:00
Benjamin Otte
26060b1be2 dmabuf: move DmabufTexture typedef
Preparation work.
2023-12-20 01:51:46 +01:00
Benjamin Otte
210c71b856 egl: Split out a function
This makes no sense by itself, but we want to create the EGLImage at
DmabufTexture construction so that we can actually reject dmabufs that
we can't create EGLImages for.

This will make it possible to bail when the stride limitation for AMD
GPUs hits.
2023-12-20 01:51:46 +01:00
Benjamin Otte
7206060450 dmabuf: Move thread marshalling into DmabufTexture
All downloaders are going to need this, it would make no sense if they
all need to duplicate that code.
2023-12-20 01:51:46 +01:00
Matthias Clasen
31cd2b19cd Merge branch 'macos-pre-10.13' into 'main'
gdk/macos: fix builds on macOS before 10.13

Closes #5738

See merge request GNOME/gtk!5813
2023-12-19 01:20:18 +00:00
Matthias Clasen
857de33937 Merge branch 'michaelweghorn/a11y_add_article_and_comment_roles' into 'main'
a11y: Add article and comment roles

See merge request GNOME/gtk!6646
2023-12-19 01:19:17 +00:00
Matthias Clasen
3d9d4031d6 Merge branch '0bsd-license' into 'main'
Add Zero-Clause BSD license

See merge request GNOME/gtk!6643
2023-12-19 01:12:38 +00:00
Benjamin Otte
738b48c660 dmabufegl: Remove unsued argument from function 2023-12-18 23:34:47 +01:00
Emmanuele Bassi
cce5f691e2 Merge branch 'ebassi/issue-6273' into 'main'
Fix typo in GtkAspectFrame.yalign accessor

Closes #6273

See merge request GNOME/gtk!6676
2023-12-18 19:24:05 +00:00
Emmanuele Bassi
ad4f2de86c Fix typo in GtkAspectFrame.yalign accessor
Copy-paste error.

Fixes: #6273
2023-12-18 19:03:53 +00:00
Matthias Clasen
9166e90bd4 Merge branch 'gles-glyph-upload' into 'main'
gsk: Fix icon and glyph upload with GLES

Closes #6216

See merge request GNOME/gtk!6674
2023-12-18 12:34:58 +00:00
Matthias Clasen
6ad15fe6d0 gsk: Fix icon and glyph upload with GLES
We can't avoid a copy here, unfortunately.

Fixes: #6216
2023-12-17 21:53:10 -05:00
Benjamin Otte
66b992c3c0 dmabuf: Change the way downloaders work
Instead of having an add_formats() function, make the get_downloader()
function add the formats.

This allows putting the actual downloader in a different place from the
initialization code.
2023-12-16 21:36:21 +01:00
Benjamin Otte
b19f71dd24 dmabuf: Add Vulkan formats to the large table
This is done without testing, just doing my best to map all the DRM
formats to VkFormats.

Once people start using them, they'll figure it out when it's wrong.
(Somebody needs to write a testsuite.)
2023-12-16 19:16:50 +01:00
Benjamin Otte
cccec91b66 memoryformat: Put dmabuf fourccs into the big format table
I'm concentrating the data about memory formats, and this part was
missing.
2023-12-16 17:01:42 +01:00
Matthias Clasen
cd6e8d9e5b Merge branch 'straight-alpha-dmabuf' into 'main'
memoryformat: Expand docs

See merge request GNOME/gtk!6669
2023-12-16 13:05:13 +00:00
Benjamin Otte
00566261b2 dmabuf: Explode the DmabufFormatInfo array
it's growing more and mroe, and it gets too wide and unreadable
otherwise.
2023-12-16 09:21:20 +01:00
Benjamin Otte
888b9ee352 dmabuf: Don't use a downloader for builtin downloads
When we use the builtin downloads via mmap(), it's a special case where
we don't need to initialize subsystems and query them for support. We
know what we can and can't do.

Also, we want to use these formats with the lowest priority but pick the
downloader first for supported formats, and queueing it in the
downloaders list doesn't reflect that. So don't do it.
2023-12-16 09:21:19 +01:00
Benjamin Otte
f0eceb4aa3 dmabuf: Remove out argument
The format is the same everywhere, so instead of letting every
implementation do the same thing, do it in a central place instead.
2023-12-16 09:20:36 +01:00
Benjamin Otte
ff082a7758 memoryformat: Add Vulkan format information
This is not used yet, but I want to add it, so that it exists.

That way, when we add new formats, people don't forget to add the Vulkan
formats.
2023-12-16 09:20:36 +01:00
Benjamin Otte
f357623170 memoryformat: Fix broken swizzle values
I can't copy/paste.
2023-12-16 09:20:29 +01:00
Matthias Clasen
bd3afd1006 testdmabuf: Add a --unpremultiplied option
This lets us test handling of straight-alpha dmabufs.
2023-12-15 07:40:27 -05:00
Matthias Clasen
79009d4158 gsk: Handle straight-alpha dmabufs
This omission was noticed by Benjamin Otte. Add a premultiply
uniform to the external shader, and add a separate premultiply
shader for the non-external case.
2023-12-15 07:40:27 -05:00
Benjamin Otte
b782f80311 Merge branch 'testsuite_fix_display_x11_on_win32' into 'main'
testsuite: don't run x11-specific tests if disabled

See merge request GNOME/gtk!6657
2023-12-14 01:57:13 +00:00
Matthias Clasen
c48a3152f0 memoryformat: Expand docs
This captures some irc exchanges about the intended use of
the new memory format apis.
2023-12-13 12:44:20 -05:00
Emmanuele Bassi
d2d2fb4b50 Merge branch 'michaelweghorn/a11y_atspi_map_row_col_index_text' into 'main'
a11y atspi: Map GTK_ACCESSIBLE_RELATION_{COL,ROW}_INDEX_TEXT to AT-SPI

See merge request GNOME/gtk!6563
2023-12-13 14:48:10 +00:00
Benjamin Otte
81adf6be22 dmabuf: Add gdk_dmabuf_fourcc_is_yuv()
In the future, we want to be using GdkColorState instead, but for now,
let's use this.

Also remove a duplicate entry in the list of formats.
2023-12-13 05:54:06 +01:00
Benjamin Otte
ff9c9e05c3 Merge branch 'testsuite_fix_icontheme_win32_v2' into 'main'
testsuite: fix icontheme test failure on win32 [v2]

See merge request GNOME/gtk!6664
2023-12-12 23:54:43 +00:00
g.willems
e3f39bf0c3 testsuite: only run x11-specific tests if x11 enabled
Some testcases rely on X11 support, which is not always available,
typically on win32.
Skip them if the x11 backend is disabled.
2023-12-12 21:29:03 +01:00
g.willems
d692243727 testsuite: fix icontheme test failure on win32
g_str_has_suffix() fails due to different path separators.
Compare URIs instead.
2023-12-12 21:25:16 +01:00
Benjamin Otte
6ad9db0bf0 Merge branch 'texture-diff-against-distant-ancestors' into 'main'
texture: Enable texture diff against arbitrarily distant ancestors

See merge request GNOME/gtk!6644
2023-12-12 01:46:05 +00:00
Benjamin Otte
486157f6bf Merge branch 'wip/otte/for-main' into 'main'
testsuite: Add a test for opacity + color-matrix nodes

See merge request GNOME/gtk!6659
2023-12-12 01:05:00 +00:00
Benjamin Otte
5ca4ab3aaa dmabuf: Add gdk_dmabuf_import/export_sync_fd()
Vulkan needs this.

This code is following the code that compositors with Wayland support -
like wlroots - are doing.

The code was introduced to Linux in
https://lore.kernel.org/dri-devel/20220506180216.2095060-1-jason@jlekstrand.net/
2023-12-12 01:49:41 +01:00
Benjamin Otte
a37b3fb691 dmabuf: Add gdk_dmabuf_ioctl()
The function is a copy of libdrm's drmIoctl() and handles EINTR and
EAGAIN error.s

Use it for the sync ioctls in the dmabuf mmaping calls.
2023-12-12 01:49:41 +01:00
Benjamin Otte
c414889cfa testsuite: Make memorytexture test work with GLES < 3.1
Previously, the code was skipping various tests and not skipping others
that it should.

Fix both of these cases.
2023-12-12 01:49:41 +01:00
Benjamin Otte
4dfc07ef57 memoryformat: Fix variable types
Use the same types that GL uses.
2023-12-12 01:49:41 +01:00
Benjamin Otte
cf4b0a27f8 glcontext: Only swizzle when we can
Don't use the recently added swizzle optimization if we're using a GL
version that is too old to support swizzling (GLES 2).
2023-12-12 01:49:41 +01:00
Benjamin Otte
393ee574b6 gl: Print debug for CPU conversions of textures
When the GL renderer cannot upload a given format, print a FALLBACK
debug message with the failed format and the alternative that was
picked, for example:

Unsupported format b8g8r8a8, converting on CPU to b8g8r8a8-premultiplied

Makes it easier to figure out what's happening, especially when using
old GLES versions that don't support all formats.
2023-12-12 01:49:41 +01:00
Benjamin Otte
e3c85be53f memoryformat: Add gdk_memory_format_get_fallbacks()
Track fallback formats to use in the memoryformat directly instead of
using in the GL uploading code.

First of all, this allows sharing the code and ensuring all our
renderers use the same fallback mechanism.

But also, this allows tracking fallbacks per-format which is useful
because the fallback formats aren't really a tree. We want to make
FLOAT16 fall back to FLOAT32 when not available, but we also want
FLOAT32 fall back to FLOAT16.
By tracking the fallbacks per-format, we can achieve that.
2023-12-12 01:49:40 +01:00
Benjamin Otte
0f5fda2277 memoryformat: Introduce new (private) API
Add gdk_memory_format_get_premultiplied() and
gdk_memory_format_get_straight() which return the matching
premultiplied/straight format.

Use this to pick the premultiplied format when uploading GL textures.

And remove the duplication in the dmabuf code, where we can now use
these functions instead of tracking both the premultiplied and straight
alpha versions.
2023-12-12 01:49:40 +01:00
Benjamin Otte
0889037959 gltexture: Use the right format to download
When the format is set correctly, which it should be, we should just use
it.

So do that.
2023-12-12 01:49:40 +01:00
Benjamin Otte
ee56ad792c memoryformat: Fix 2 broken formats
They are straight alpha, and the GL renderer isn't using them yet, so
existing code is not affected.
2023-12-12 01:49:40 +01:00
Benjamin Otte
5688b7b4bb gl: Add a new alternative format
Add an "RGBA" format that just maps to the swizzled version of the
default format.

This way, BGR gets mapped to RGB + swizzling first before trying to map
it to the default format for the depth.

The benefit here is that this format has the same memory width, so
uploading/downloading code can treat it equivalent to the original
format and there's no conversion neccessary later.
2023-12-12 01:49:40 +01:00
Luca Bacci
df1802f756 Merge branch 'gdkwin32_support_debug_default-settings' into 'main'
gdk/win32: support default-settings debug flag

See merge request GNOME/gtk!6658
2023-12-11 23:15:38 +00:00
Benjamin Otte
84de90756d memoryformat: Make the big array more readable
Prefix the struct members with their name, similar to how our Vulkan
code looks.
2023-12-11 22:11:28 +01:00
Benjamin Otte
cb5a8a76da Merge branch '6261-gtkstringlist-lacks-item-type-and-n-items' into 'main'
stringlist: Introduce :item-type and :n-items

Closes #6261

See merge request GNOME/gtk!6662
2023-12-11 18:18:49 +00:00
António Fernandes
26c35c00e1 stringlist: Introduce :item-type and :n-items
While not required by the GListModel interface, they are a useful
convention which is already implemented by other GListModel public
implementation in GTK, particularly for use in expressions and
bindings.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/6261
2023-12-11 17:36:52 +00:00
Emmanuele Bassi
5d4879aae7 Merge branch 'wip/typo' into 'main'
gtk-demo: Fix typo

See merge request GNOME/gtk!6661
2023-12-11 13:58:27 +00:00
Carlos Garnacho
39b08b82ca gtk-demo: Fix typo
Close the quotes in alert dialog message.
2023-12-11 14:22:30 +01:00
Benjamin Otte
2b6e7147d6 build: Sort alphabetically 2023-12-11 07:33:26 +01:00
Benjamin Otte
3a1349e8ef gl: Make gdk_memory_format_gl_format() no longer check support
Now that we have gdk_gl_context_get_memory_flags() and code can use that
function, make the code do that.

Remove support checks from gdk_memory_format_gl_format().

This is an initial naive port that doesn't try to make use of the finer-grained
flags yet.
2023-12-11 07:33:26 +01:00
Benjamin Otte
5485d806c5 glcontext: Add gdk_gl_context_get_memory_flags()
Checks which features of a given memory format are supported by
the current GL implementation.

We check:
 * usable: Can be used as a texture with NEAREST filter
 * renderable: Can be used as a render target
 * filterable: Can be used with GL_LINEAR

In normal GL, all formats are all of these things, but GLES is a lot
more picky.

So far nobody uses this.
2023-12-11 07:33:26 +01:00
Benjamin Otte
6e7c499408 testsuite: Don't create nodes with negative size
If width or height are too small, only create one mask node.

The previous math would create the 2nd node with negative width/height.
2023-12-11 07:33:26 +01:00
Benjamin Otte
c341da32aa gsk: Set correct blur radius for cairo shadows 2023-12-11 07:33:26 +01:00
Benjamin Otte
d39ec8c09e gsk: Quality of life improvements for Cairo rendering
1. Check for an empty clip region before push/pop_group() calls

2. Remove save/restore() pairs as the vfunc invocation does so already.
2023-12-11 07:33:26 +01:00
Benjamin Otte
e3299e38df cairo: Handle clipped blur content
This is the result of experimenting with corner cases when blurring.

The result is a test that tests when the child of a blur node is
clipped out but the blurred child is not, the blurred parts are still
visible.

This immediately broke the cairo renderer, so the fix is included.
2023-12-11 07:33:24 +01:00
Benjamin Otte
8fd02f6fa2 subsurface: Do not punch holes for subsurfaces that are above
If a subsurface is not below, it is visible no matter what the opaque
region is.

Also, we don't need to care about transparency in the subsurface if we
ignore it anyway. So this is a win-win.
2023-12-11 07:32:06 +01:00
Benjamin Otte
9bc0ad9a13 gdk: Handle subsurface opaque region with transparency
We accept transparent subsurfaces for passthrough now, when they are
above the surface.
But we did not unset the opaque region to empty when the texture is
transprent.
2023-12-11 07:32:06 +01:00
Benjamin Otte
19171c7a89 testsuite: Add a test for opacity + color-matrix nodes
These are 2x2 combinations that:
1. Use a texture child node vs a color child node
   This should force an offscreen vs straight up use a texture.
2. Switch opacity and color-matrix
   Either put the color matrix into the opacity node or put the opacity
   into the color matrix.

This is worth testing because renderers often combine opacity into the
color matrix to avoid offscreens.

And they do that because applications often create faded out symbolic
images, which end up as a combination of these nodes.
2023-12-09 19:32:39 +01:00
Benjamin Otte
abf942efe5 dmabuf: Don't leak the display 2023-12-09 19:32:39 +01:00
g.willems
dfe7afdb04 gdk/win32: support default-settings debug flag 2023-12-09 17:59:24 +01:00
Ben Mather
1629b072fe texture: Enable texture diff against arbitrarily distant ancestors 2023-12-08 11:29:56 +00:00
Matthias Clasen
0b0a5a52af Merge branch 'docs_clarify_gtk_drop_down_get_selected_item' into 'main'
docs: Clarify how to obtain strings from GtkDropDown

See merge request GNOME/gtk!6647
2023-12-08 10:20:12 +00:00
Matthias Clasen
75d259eedf Merge branch 'fix-label-docs' into 'main'
Docs: Fix unfenced HTML tag in GtkLabel docs

See merge request GNOME/gtk!6650
2023-12-08 10:17:59 +00:00
FeRD (Frank Dana)
6fec018cbd Docs: Fix unfenced HTML tag in GtkLabel docs 2023-12-08 02:29:10 -05:00
Matthias Clasen
6d9c950b82 Merge branch 'ebassi/inhibit-reason-fallback' into 'main'
Add fallback string for empty inhibit reason

See merge request GNOME/gtk!6648
2023-12-08 04:06:11 +00:00
Emmanuele Bassi
0933ea63c5 Add fallback string for empty inhibit reason
The public gtk_application_inhibit() API allows a NULL reason argument,
and we have a fallback in place when going through the session manager
proxy; when using the inhibit D-Bus API directly, though, we're just
passing a potentially NULL value to g_variant_new_string(), which will
rightfully complain.
2023-12-07 11:55:20 +00:00
Logan Rathbone
8cb594696e docs: Clarify how to obtain strings from GtkDropDown 2023-12-07 00:03:04 -05:00
Michael Weghorn
ab7592ee4f a11y: Add article and comment roles
Add new accessible roles
GTK_ACCESSIBLE_ROLE_ARTICLE and
GTK_ACCESSIBLE_ROLE_COMMENT.

ARIA has corresponding roles as well [1] [2],
with the article role being the superclass role
of the comment role.

Acccording to the ARIA spec, the article role
has the document role as superclass role and
the name can be set by the author.

For the comment role, the name can be set by the
author or come from the content.

The ARIA spec for the comment contains this sentence [2]:

> If the author has not explicitly declared aria-level, aria-posinset, or
> aria-setsize for a comment element, user agents MUST automatically
> compute the missing values and expose them to assistive technologies.

However, these properties are not listed as "Required States and
Properties" in the following table for that role. Potentially
the above requirement only applies for the first of the two
possible described cases of how the relationship between comments
and the commented content can be set, so don't hard-require
these attributes in the a11y overlay's
`check_widget_accessibility_errors` either.

[1] https://w3c.github.io/aria/#article
[2] https://w3c.github.io/aria/#comment
2023-12-06 15:36:50 +01:00
Matthias Clasen
9d7389aea7 Merge branch 'emoji-15.1' into 'main'
emoji: Update data to CLDR v44

See merge request GNOME/gtk!6642
2023-12-06 11:26:05 +00:00
Nazar Mokrynskyi
994644ffe7 Add Zero-Clause BSD license 2023-12-04 07:05:43 +02:00
Jeremy Bícha
76a1f1714d emoji: Update data to CLDR v44
Based on emojibase v15.3.0

Contains the changes in Unicode 15.1

https://unicode.org/versions/Unicode15.1.0/
https://cldr.unicode.org/index/downloads/cldr-44
https://github.com/milesj/emojibase/blob/emojibase-data%4015.3.0/packages/data/CHANGELOG.md
2023-12-03 16:32:42 -05:00
Yaron Shahrabani
9af08e17e0 Update Hebrew translation 2023-12-03 13:32:37 +00:00
Boyuan Yang
276afbca92 Update Chinese (China) translation 2023-12-03 01:40:50 +00:00
Yaron Shahrabani
0342d23dbe Update Hebrew translation
(cherry picked from commit cde309d9fa)
2023-12-02 22:12:14 +00:00
Matthias Clasen
1c10837b21 Merge branch 'matthiasc/for-main' into 'main'
Revert "Merge branch 'rgba-new-from-string' into 'main'"

See merge request GNOME/gtk!6640
2023-12-02 05:43:12 +00:00
Matthias Clasen
7cc5d5c7a5 Revert "Merge branch 'rgba-new-from-string' into 'main'"
This reverts commit 77f40d7508, reversing
changes made to b969f4649d.

It turns out we did not have agreement on this after all.
2023-12-02 10:55:35 +05:45
Matthias Clasen
6a59326dbf Merge branch 'emoji-15' into 'main'
emoji: Update data to CLDR v43

See merge request GNOME/gtk!6639
2023-12-02 02:12:17 +00:00
Yaron Shahrabani
1968f331d9 Update Hebrew translation 2023-12-01 21:02:25 +00:00
Jeremy Bícha
bf35836350 emoji: Update data to CLDR v43
Based on emojibase v15.2.0

Contains the changes in Unicode 15.0

https://unicode.org/versions/Unicode15.0.0/
https://cldr.unicode.org/index/downloads/cldr-43
https://github.com/milesj/emojibase/blob/emojibase-data%4015.2.0/packages/data/CHANGELOG.md
2023-12-01 15:57:02 -05:00
Daniel Rusek
036629a491 Update Czech translation 2023-11-30 18:26:58 +00:00
Arjan Molenaar
8cabf59cf3 Merge branch 'macos-secure-restore' into 'main'
macos: Add method that denotes secure restorable state

See merge request GNOME/gtk!6632
2023-11-30 15:17:04 +00:00
Arjan Molenaar
6a4b238641 macos: Add method that denotes secure restorable state
Fix process injection vulnerability on macOS.
2023-11-29 12:30:30 +01:00
Matthias Clasen
d4d0239ae7 Merge branch 'macos-fix-function-signature' into 'main'
Fix function signature warning on macOS

See merge request GNOME/gtk!6628
2023-11-29 00:53:31 +00:00
Matthias Clasen
a30f32db8d Merge branch '6236_fix_modify_textbuffer_in_irreversible' into 'main'
gtktexthistory: allow setting the modified flag in irreversible action

Closes #6236

See merge request GNOME/gtk!6626
2023-11-28 23:51:51 +00:00
Arjan Molenaar
6948a74d72 Fix function signature warning
No arguments -> void
2023-11-28 21:24:10 +01:00
Matthias Clasen
14ec255812 Merge branch 'gles-texture-slice-fixes' into 'main'
gsk: Be more careful about texture slice formats

See merge request GNOME/gtk!6627
2023-11-28 20:07:44 +00:00
Matthias Clasen
00ebd51d06 gsk: Be more careful about texture slice formats
We need to make sure that all our textures have the same memory
format, or we'll run into trouble in the upload code, at least
on GLES, which isn't as forgiving about format mismatches.

Related: #6238
2023-11-28 14:16:21 -05:00
g.willems
7de528b487 gtktexthistory: allow set modified in irreversible action
Allow setting the modified flag, but skip propagating the history state update
as it will be done by gtk_text_history_end_irreversible_action().

Fixes #6236
Closes #6236
2023-11-28 19:57:11 +01:00
Matthias Clasen
77f40d7508 Merge branch 'rgba-new-from-string' into 'main'
Add convenience function gdk_rgba_new_from_string()

See merge request GNOME/gtk!6599
2023-11-28 17:56:21 +00:00
Danial Behzadi
b969f4649d Update Persian translation 2023-11-28 08:47:40 +00:00
FeRD (Frank Dana)
f4f25e584c Fix docs function reference 2023-11-27 21:16:44 -05:00
FeRD (Frank Dana)
b049a3501a Additional review fixes 2023-11-27 19:44:24 -05:00
Emmanuele Bassi
0114fad8a5 Style/doc fixes from review 2023-11-28 00:42:19 +00:00
Matthias Clasen
afafac6878 Merge branch 'matthiasc/for-main' into 'main'
Use O_CLOEXEC instead of FD_CLOEXEC

See merge request GNOME/gtk!6624
2023-11-27 23:10:35 +00:00
Matthias Clasen
108eb43b01 gsk: Add some more proiler marks
These should help us determine if time is spent converting or
uploading textures.
2023-11-27 17:50:28 -05:00
Matthias Clasen
6961c1fe4a Use O_CLOEXEC instead of FD_CLOEXEC
GLib is complaining vocally about this.
2023-11-27 17:50:18 -05:00
Matthias Clasen
606d150e0b Merge branch 'matthiasc/for-main' into 'main'
wayland: Be more careful when loading cursors

See merge request GNOME/gtk!6622
2023-11-27 21:01:16 +00:00
Matthias Clasen
96f7bb99a7 css: Fix opacity handling
We were using the invert value for opacity.
2023-11-27 15:30:37 -05:00
Matthias Clasen
b937c17985 wayland: Be more careful when loading cursors
Make sure we don't access the cursor_images array out of bounds.

Related: #6234
2023-11-27 13:58:38 -05:00
Emmanuele Bassi
79cb370f81 Merge branch 'gtk_font_dialog_choose_font_and_features_finish_fix' into 'main'
GtkFontDialog: fix annotation for choose_font_and_features_finish

See merge request GNOME/gtk!6621
2023-11-27 17:53:38 +00:00
Val Och
154b73723f GtkFontDialog: fix annotation for choose_font_and_features_finish
Parameters in question have callee-allocated semantics.
2023-11-27 19:48:48 +03:00
Artur S0
c0efed4e4a Update Russian translation 2023-11-27 16:16:29 +00:00
Matthias Clasen
4402676aa2 Merge branch 'update-ci-images' into 'main'
ci: Update the fedora image for F39

See merge request GNOME/gtk!6620
2023-11-27 15:25:57 +00:00
Matthias Clasen
9bf4a45d47 Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!6619
2023-11-27 14:59:30 +00:00
Matthias Clasen
85ce343816 ci: Update the fedora image for F39
This will hopefully help with getting the gpu renderer tests
to work.
2023-11-27 09:51:14 -05:00
FeRD (Frank Dana)
114d0621aa Fix coding style issues 2023-11-26 16:19:06 -05:00
Matthias Clasen
d595aff52d coding style: Mention the available stack size 2023-11-26 09:07:38 -05:00
Matthias Clasen
d72fd951e1 Quiet a compiler warning 2023-11-26 08:47:51 -05:00
Matthias Clasen
78706e3fbe Merge branch 'clarify_template_builder_docs' into 'main'
docs: Clarify how to refer to instances created by <template>

See merge request GNOME/gtk!6605
2023-11-25 18:03:08 +00:00
Matthias Clasen
98b796a371 Merge branch 'ci-run-less-tests' into 'main'
ci: Pick up reports for all test setups

See merge request GNOME/gtk!6616
2023-11-25 18:01:50 +00:00
Matthias Clasen
c99f62aef1 Merge branch 'wip/dnd-fixes' into 'main'
DnD fixes

See merge request GNOME/gtk!6608
2023-11-25 17:59:39 +00:00
Matthias Clasen
8754247a90 Merge branch 'wip/otte/dmabuf' into 'main'
dmabuf: A bunch of cleanups

See merge request GNOME/gtk!6610
2023-11-25 17:58:11 +00:00
Matthias Clasen
fd12707162 Merge branch 'doc-fixes' into 'main'
Docs: Misc Fixes

See merge request GNOME/gtk!6615
2023-11-25 17:55:47 +00:00
Matthias Clasen
34bca0ff56 Merge branch 'gtk4-portal-close' into 'main'
[gtk4] Fix file chooser and open uri portal close.

See merge request GNOME/gtk!6613
2023-11-25 17:19:31 +00:00
Matthias Clasen
c668519d07 ci: Handle deprecation warnings in report scripts 2023-11-25 11:21:48 -05:00
Matthias Clasen
454e6eadc6 ci: Rebalance test runs
Move x11 to the debug build, and make it a full run.
2023-11-25 11:03:15 -05:00
Matthias Clasen
e248a01fbd ci: Run less tests
Our test setups are mostly about varying the rendering environment
(different backends, or renderers, etc). Therefore, we don't need
to duplicate the runs of the css or node parser or path tests.
Just run the gdk and gsk-gl tests under all setups.
2023-11-25 10:37:39 -05:00
Matthias Clasen
e2bd7defa4 ci: Tweak the run-tests script
The main change here is to pass the suites to run as an explicit
argument. This is in preparation for running less tests.
2023-11-25 10:37:39 -05:00
Matthias Clasen
855fa6d523 ci: Produce a junit report for asan too 2023-11-25 10:37:39 -05:00
Matthias Clasen
7c620ac2b7 ci: Pick up reports for all test setups
We added a wayland_gl test setup recently, and all the setups
have to be listed manually in .gitlab-ci.yml.
2023-11-25 09:21:16 -05:00
Maximiliano Sandoval R.
d96f2f54e9 stylecontext: Properly anotate Deprecated 2023-11-25 15:02:06 +01:00
Maximiliano Sandoval R.
71c2ee3530 gskenums: Add Since to missing enum values
Use same Since annotation as elsewhere
2023-11-25 15:01:53 +01:00
Maximiliano Sandoval R.
5e415ee916 gskenums: Don't break the docstring 2023-11-25 15:00:40 +01:00
Maximiliano Sandoval R.
e163021b8f debug: Document missing enum 2023-11-25 15:00:14 +01:00
Benjamin Otte
1bf88f1d81 Merge branch 'wip/otte/for-main' into 'main'
Revert commits that disabled the testsuite

See merge request GNOME/gtk!6614
2023-11-25 12:31:21 +00:00
Benjamin Otte
72d2b8e546 Revert "ci: Tweak the run-tests script"
This reverts commit 9aadc2b860.
2023-11-25 13:09:50 +01:00
Benjamin Otte
37f7f3d60c Revert "wip: ci: rework the test runs"
This reverts commit c679ba9ebf.
2023-11-25 13:09:50 +01:00
Benjamin Otte
8d1443994b Revert "ci: Run less tests"
This reverts commit 5a8a839921.
2023-11-25 13:09:49 +01:00
FeRD (Frank Dana)
39db73dff1 Add gdk_rgba_new_from_string()
Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
2023-11-24 22:19:39 -05:00
Emilio Cobos Álvarez
68cf5f2cf3 [gtk4] gtkopenuriportal: Fix portal close signal.
Same fix. The other instance of this pattern in gtkapplication-dbus.c
does it right.
2023-11-25 03:49:58 +01:00
Emilio Cobos Álvarez
77c4097c86 [gtk4] GtkFileChooserNative: Fix portal close.
This makes closing a portal file chooser work.

Fixes the GTK4 bits of #6225.
2023-11-25 03:47:28 +01:00
Benjamin Otte
d7bc4c719b dmabuf: Remove unused headers 2023-11-25 01:44:34 +01:00
Benjamin Otte
725857e15b dmabuf: Add a fallback list of fourccs
That way, we can work with older libdrm versions.

The list was generated via a bit of sed and grep from the current
dmabuf-fourcc.h, which is why I put it into its own file and included
all the formats, no matter how old they are.
2023-11-25 01:44:34 +01:00
Benjamin Otte
50ee872978 dmabuf: Add gdk_dmabuf_get_fourcc()
Returns the fourcc for a given GdkMemoryFormat.

Not sure if this is the best name, but I didn't know a better one.
2023-11-25 01:44:34 +01:00
Benjamin Otte
b6c82c6b54 dmabuf: Add all formats
Add the matching GdkMemoryFormat for all dmabuf formats.

This way, we don't fall back to RGBA8 for 10- and 16-bit formats that we
don't support natively when EGL or Vulkan use them.

Also includes corrections for a few mixups.
2023-11-25 01:44:34 +01:00
Benjamin Otte
1bf94b045c dmabuf: Refactor function
1. Don't require passing in a GdkDisplay

2. return TRUE/FALSE if a format was found, so calling code can
   decide how to handle failure itself
2023-11-25 01:44:34 +01:00
Matthias Clasen
13bfe188b5 Merge branch 'matthiasc/for-main' into 'main'
frameclock: Inline a few things

See merge request GNOME/gtk!6607
2023-11-25 00:04:57 +00:00
Matthias Clasen
f21175b3d0 frameclock: Inline a few things
There is no need to call type-checking getters in a loop.
2023-11-24 17:53:34 -05:00
Carlos Garnacho
d78475372f gtk: Obey GTK grabs on DnD events
Make DnD events get directed to the right places (and most
importantly, not to the wrong places) when happening over
modal parts of the UI.

Fixes DnD started from popovers being able to drop on their
modal toplevel.
2023-11-24 23:37:20 +01:00
Carlos Garnacho
988b9de210 gdk/wayland: Pass surface-relative coordinates in DnD events
Make this event behave like the other regular events, and emit
coordinates based on native surfaces. Fixes DnD over popovers
finding the correct coordinates.
2023-11-24 23:35:45 +01:00
Carlos Garnacho
0c19ef6c2c gdk/wayland: Improve recent serial lookup
This function takes an event, so the place(s) that do
not have one readily available can only pass NULL, so
the serial lookup will only work for the pointer.

Pass a device (plus optional sequence) to this function,
as these places do at least have the corresponding
GdkDevice at hand.

Fixes serial lookups for DnD, for other devices than
pointers (e.g. tablets, or touch).
2023-11-24 23:30:36 +01:00
Matthias Clasen
2bfd4a88d6 Fix some more static analysis warnings 2023-11-24 16:36:46 -05:00
Matthias Clasen
de3eeb4970 Merge branch 'docs_clarify_nested_lookup_tags' into 'main'
docs: Clarify that <lookup> tags can be nested.

See merge request GNOME/gtk!6606
2023-11-24 21:22:47 +00:00
Logan Rathbone
5c2e2977e0 docs: Clarify that <lookup> tags can be nested. 2023-11-24 15:52:32 -05:00
Logan Rathbone
24f3ec0949 docs: Clarify how to refer to instances created by <template> 2023-11-24 14:44:12 -05:00
Matthias Clasen
bcab0e4254 Merge branch 'none-bitfield' into 'main'
gdk-enums: Add GDK_NO_MODIFIER_MASK

See merge request GNOME/gtk!6602
2023-11-24 18:33:56 +00:00
Matthias Clasen
253955c017 Merge branch 'ebassi/docs-content-files' into 'main'
Add content_base_url to the docs project files

See merge request GNOME/gtk!6604
2023-11-24 18:19:06 +00:00
Maximiliano Sandoval R.
3a8834a437 gdk-enums: Add GDK_NO_MODIFIER_MASK 2023-11-24 18:04:56 +01:00
Emmanuele Bassi
48ea2ecac3 docs: Add content_base_url
Newer versions of gi-docgen support linking the rendered content files
to its source inside the repository, just like a symbol docblock.
2023-11-24 16:50:41 +00:00
Emmanuele Bassi
6d0b31128b docs: Update the user support information
The IRC channel is on Libera and there's a Matrix room.
2023-11-24 16:50:41 +00:00
Emmanuele Bassi
0b519bc353 docs: Clarify title of the Initialization content file 2023-11-24 16:50:41 +00:00
Emmanuele Bassi
bb756b35a2 docs: Remove duplicate titles 2023-11-24 16:50:41 +00:00
Emmanuele Bassi
7ba7ab1e3d docs: Fix links to the 2.x to 4 migration guide
The GTK3 migration guide is on docs.gtk.org, these days; and the
3.x to 4 migration guide is in the same location as this file.
2023-11-24 16:50:41 +00:00
Emmanuele Bassi
f73a7e29ca docs: Use consistent style for content metadata 2023-11-24 16:50:41 +00:00
Emmanuele Bassi
2eb6e3d4c5 docs: Clean up the key value content file
Use a more descriptive title, add links to the API, add code elements,
and align the text a bit better.
2023-11-24 16:50:41 +00:00
Matthias Clasen
b28cf76f11 Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!6603
2023-11-24 16:09:19 +00:00
Matthias Clasen
36314f28e2 gsk: Some more rect inlining 2023-11-24 10:35:57 -05:00
Matthias Clasen
b7a1b1d7ee Fix some static analysis warnings 2023-11-24 10:35:57 -05:00
Matthias Clasen
57e382b59c Merge branch 'sumibi-yakitori/fix-mouse-cursor-on-macos' into 'main'
macos: Change to send motion events to NSApp

Closes #6134

See merge request GNOME/gtk!6451
2023-11-24 13:06:53 +00:00
Matthias Clasen
a35a885902 Merge branch 'file-launcher-writable' into 'main'
file laucher: Add a writable property

Closes #4247

See merge request GNOME/gtk!6600
2023-11-23 00:13:19 +00:00
Matthias Clasen
5fa3a2a39f file laucher: Add a writable property
If GtkFileLauncher:writable is TRUE, we ask the openuri portal
to make the file writable for the handler that it launches.

Fixes: #4247
2023-11-22 17:43:10 -05:00
Matthias Clasen
7f53b3d3f4 openuri portal: Introduce flags 2023-11-22 17:30:37 -05:00
Matthias Clasen
9b25257cbf Merge branch 'matthiasc/for-main' into 'main'
Address various static analysis complaints

See merge request GNOME/gtk!6598
2023-11-22 11:49:57 +00:00
Matthias Clasen
a90a6c4517 Address various static analysis complaints
These were picked out of the scan_build logs in ci.
2023-11-22 00:07:47 -05:00
Matthias Clasen
e69f062c99 Merge branch 'testsuite-leaks' into 'main'
testsuite: Don't leak so much

See merge request GNOME/gtk!6597
2023-11-22 04:48:42 +00:00
Matthias Clasen
210c7f25ad testsuite: Leak even less
A memory leak spotted by asan.
2023-11-21 23:21:55 -05:00
Matthias Clasen
9695791f7b testsuite: Don't leak so much
My subsurface attach code was leaking all the nodes. Oops.
2023-11-21 23:21:55 -05:00
Matthias Clasen
ca0da0dd83 Merge branch 'matthiasc/for-main' into 'main'
ci: Run less tests

See merge request GNOME/gtk!6596
2023-11-22 03:41:15 +00:00
Matthias Clasen
5a8a839921 ci: Run less tests
Our test setups are mostly about varying the rendering environment
(different backends, or renderers, etc). Therefore, we don't need
to duplicate the runs of the css or node parser or path tests.
Just run the gdk and gsk-gl tests under all setups.
2023-11-21 22:20:47 -05:00
Matthias Clasen
eb84171cda Merge branch 'testsuite-improvements' into 'main'
ci: Tweak the run-tests script

See merge request GNOME/gtk!6587
2023-11-21 19:31:15 +00:00
Benjamin Otte
5608a8978e Merge branch 'picture-integral-size' into 'main'
picture: Keep paintable size integral

See merge request GNOME/gtk!6593
2023-11-21 19:30:53 +00:00
Matthias Clasen
efefdbd5c0 Merge branch 'no-fractional-offload' into 'main'
wayland: Don't offload with fractional scales

See merge request GNOME/gtk!6592
2023-11-21 19:28:03 +00:00
Matthias Clasen
6bea059424 Merge branch 'subsurface-api-tweaks' into 'main'
subsurface: Replace place_above/below

See merge request GNOME/gtk!6595
2023-11-21 18:52:07 +00:00
Matthias Clasen
c99c06f0da wayland: Careful offloading with fractional scales
Sadly, subsurface positioning is undefined in this case. We'll
trust the compositor to not mess up if the device coordinates
after applying the scale are integral, but otherwise, we'll
decline.
2023-11-21 13:47:10 -05:00
Matthias Clasen
bda8f5393d wayland: Allow attaching (some) non-opaque textures
Allow translucent textures when we are raising the subsurface.
2023-11-21 13:24:04 -05:00
Matthias Clasen
160fa969d4 subsurface: Replace place_above/below
Instead, do it all in attach(), which becomes more and more like
ConfigureWindow. This is good, because it will let us take the
above-ness into account when making decisions about attaching.
2023-11-21 13:24:04 -05:00
Benjamin Otte
edf33a6617 Merge branch 'wip/otte/for-main' into 'main'
subsurface: Don't marka failure as success

See merge request GNOME/gtk!6594
2023-11-21 17:01:54 +00:00
Benjamin Otte
86587a9328 subsurface: Don't marka failure as success
There was one branch in the success case that turned it into a failure,
yet we were still reporting a success (and discarding the buffer).

Don't do that.
2023-11-21 17:31:40 +01:00
Matthias Clasen
8691d471d0 picture: Keep paintable size integral
Without this, offloading is very hit-and-miss, since you need
to hit the few size combinations where you get an exact integral
size when preserving the aspect ratio.
2023-11-21 11:14:15 -05:00
Matthias Clasen
463b6dd1fd Merge branch 'egl-device-info' into 'main'
EGL: Print out the device info

See merge request GNOME/gtk!6590
2023-11-21 05:04:35 +00:00
Matthias Clasen
88e1f77f90 EGL: Print out the device info
This may become more relevant info, with dmabuf formats being
tied to specific devices.
2023-11-20 23:40:00 -05:00
Matthias Clasen
1ee488f445 Merge branch 'matthiasc/for-main' into 'main'
wayland: Move subsurface creation code

See merge request GNOME/gtk!6589
2023-11-21 00:04:02 +00:00
Matthias Clasen
eae0e15b9d wayland: Move subsurface creation code
This belongs with all the other subsurface handling.
2023-11-20 18:01:09 -05:00
Matthias Clasen
00d551bda8 Merge branch 'drop-legacy-gl' into 'main'
Drop the gl-legacy debug value

See merge request GNOME/gtk!6585
2023-11-20 13:31:27 +00:00
Matthias Clasen
2dcec44714 Drop the nograbs debug value
This was only used in the x11 backend, and I haven't seen it
actively recommended for debugging anything in ages.
2023-11-20 08:02:03 -05:00
Matthias Clasen
f04c819439 Drop the gl-legacy debug value
The consensus is that we can do without this.
2023-11-20 08:02:02 -05:00
Matthias Clasen
c679ba9ebf wip: ci: rework the test runs 2023-11-19 21:26:04 -05:00
Matthias Clasen
9aadc2b860 ci: Tweak the run-tests script
The main change here is to pass the suite to run as an explicit
argument. This is in preparation for running less tests.
2023-11-19 21:26:04 -05:00
Emmanuele Bassi
e4370cc95e Merge branch 'matthiasc/for-main' into 'main'
file dialog: Return an error if no file is selected

Closes #6139

See merge request GNOME/gtk!6586
2023-11-19 18:29:57 +00:00
Matthias Clasen
22ceb018fb file dialog: Return an error if no file is selected
This was brought as a problem for bindings in #6139.

Fixes: #6139
2023-11-19 12:46:56 -05:00
Matthias Clasen
833d307695 Merge branch 'default-to-gles' into 'main'
Use GLES by default

Closes #6170

See merge request GNOME/gtk!6520
2023-11-19 16:14:04 +00:00
Piotr Drąg
e8afb5e210 Update Polish translation 2023-11-19 15:34:46 +01:00
Matthias Clasen
b916c4dac1 ci: Reshuffle test setups
Add a wayland_gl setup that explicitly uses desktop GL, and rename
wayland_gles to wayland_gles2 (since that is what it does).

In ci, make the fedora-x86_64 runner run tests with wayland_gl
and wayland_gles2, and make the fedora-release runner run test
with wayland and x11.
2023-11-19 08:24:38 -05:00
Matthias Clasen
699c6d6159 Use GLES by default
With the advent of dmabuf support, using GLES has become more
attractive, since we can use its external texture support to
support more dmabuf formats.

You can go back to the previous preference order by setting

    GDK_DEBUG=gl-prefer-gl
2023-11-19 08:07:03 -05:00
Matthias Clasen
025b846fce Add a debug value to prefer desktop GL
This will be used in the next commit, when we change the default
preference to be GLES.
2023-11-19 08:07:02 -05:00
Matthias Clasen
fcdbab3f69 gl: Tweak debug values for GL api selection
Replace GDK_DEBUG=gl-gles with GDK_DEBUG=gl-disable-gl, and add
a GDK_DEBUG=gl-disable-gles to match.
2023-11-19 08:07:02 -05:00
Matthias Clasen
d7eac7a6ad Merge branch 'cssselector-alloc' into 'main'
css: Don't allocate needlessly while processing selectors

See merge request GNOME/gtk!6584
2023-11-19 12:46:57 +00:00
Matthias Clasen
52dbb3f372 css: Don't allocate needlessly while processing selectors
The recursive subdivide_info function works by soring the
selector infos it gets into 2 (or 3) buckets: exact matches,
matches, and remaining. Then it recurses on the matches and
remaining buckets. This can be done without allocating extra
arrays, by sorting the given array in the right way.

This needs some serious testing.

Fixes: #6583
2023-11-18 18:12:10 -05:00
Piotr Drąg
7dc38ca12f Update Polish translation 2023-11-18 17:15:18 +01:00
Matthias Clasen
e858924d03 Merge branch 'matthiasc/for-main' into 'main'
inspector: Update the logging tab

See merge request GNOME/gtk!6581
2023-11-18 15:26:33 +00:00
Matthias Clasen
852aab1576 inspector: Update the logging tab
There's two new values here, Dmabuf and Offload.
2023-11-18 09:54:43 -05:00
Matthias Clasen
5eb42815ed Merge branch 'subsurface-aboveness' into 'main'
offload: Keep was-raised for each subsurface

Closes #6214

See merge request GNOME/gtk!6580
2023-11-18 13:42:27 +00:00
Luca Bacci
0b853f62ed Merge branch '6203_gdk_win32_precalculate_keymap' into 'main'
GdkWin32: precalculate keymap at display opening

Closes #6203

See merge request GNOME/gtk!6566
2023-11-18 13:24:21 +00:00
Matthias Clasen
fb969f5431 offload: Raise all subsurfaces that can be
If two subsurfaces don't overlap and aren't otherwise obstructed,
we can just raise them  both.

Tests included.
2023-11-18 08:19:43 -05:00
Matthias Clasen
ef6ed31853 offload: Drop unused api 2023-11-18 08:19:43 -05:00
Matthias Clasen
c57245b73c diff: Take above-ness into account
We need to include the full area if a subsurface
above-ness changes, since we only punch holes if
it is above.

Fixes: #6214
2023-11-18 08:19:43 -05:00
Matthias Clasen
f9fd78b67e offload: Keep was-raised for each subsurface
We need this information for proper diffing.
2023-11-18 08:19:43 -05:00
Matthias Clasen
00a63a9fcf offload tests: Fix the simple test
This was expecting the wrong 'above'. Oops.
2023-11-18 08:19:43 -05:00
Matthias Clasen
b4ae2377b3 offload tests: Make --verbose work
When passing a directory via G_TEST_SRCDIR, still pay attention
to --verbose, and print out each file thats tests. This lets us
quickly pin down which test fails.
2023-11-18 08:19:43 -05:00
Matthias Clasen
392977d670 offload tests: fix output 2023-11-18 08:18:29 -05:00
Matthias Clasen
5a29e2704c Merge branch 'dmabuf-separate-alpha-formats' into 'main'
dmabuf: Add support for separate alpha formats

See merge request GNOME/gtk!6571
2023-11-18 07:41:44 +00:00
Matthias Clasen
ec6c52680e Merge branch 'michaelweghorn/a11y_align_paragraph_super_role_with_aria' into 'main'
a11y: Align paragraph's super role with ARIA

See merge request GNOME/gtk!6579
2023-11-17 12:02:53 +00:00
Sveinn í Felli
d850161b2f Update Icelandic translation
(cherry picked from commit e608a18043)
2023-11-17 10:36:10 +00:00
Michael Weghorn
1a3504469d a11y: Align paragraph's super role with ARIA
As the commit message in

    commit 9f078bd5c9
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon Sep 25 10:41:42 2023 +0200

        a11y: Add paragraph role

already says, the super role of the paragraph role
in ARIA is the section role [1]. But then, that commit
accidently set the structure role for the super role,
so fix that now.

[1] https://www.w3.org/TR/wai-aria-1.2/#paragraph
2023-11-17 07:46:55 +01:00
Matthias Clasen
be0546bb39 testdmabuf: Support a separate-alpha format
This helps with verifying the support for these formats
in gdkdmabuf.c.
2023-11-16 20:54:16 -05:00
Matthias Clasen
d4a569057f Cosmetics: Typo fix 2023-11-16 20:54:15 -05:00
Matthias Clasen
c5727df568 dmabuf: Add support for separate alpha formats
Support dmabuf formats with alpha in a separate plane.

Related: #6208
2023-11-16 20:53:52 -05:00
Benjamin Otte
7406cea257 Merge branch 'wip/otte/for-main' into 'main'
wayland: Don't create a new wl_buffer if the texture didn't change

See merge request GNOME/gtk!6577
2023-11-16 23:54:57 +00:00
Benjamin Otte
de3f55fc5f testdmabuf: Use Vulkan to create dmabufs
This is somewhat hacky, but good enough for testing.

And it's definitely better than needing to chmod files owned by root.
2023-11-17 00:22:27 +01:00
Benjamin Otte
010ff81b2f wayland: Don't create a new wl_buffer if the texture didn't change
Avoids flickering in Mutter - which is probably a mutter bug.

But it also reduces traffic, so it's a good thing anyway.
2023-11-17 00:22:27 +01:00
Matthias Clasen
c94ec8b658 Merge branch 'michaelweghorn/bump_version' into 'main'
Bump version in meson.build to 4.13.4

See merge request GNOME/gtk!6574
2023-11-16 19:04:59 +00:00
Michael Weghorn
9c1ae5374d Bump version in meson.build to 4.13.4
... as commit 3a88522a19 did
for the NEWS file after the 4.13.3 release
(tag "4.13.3", commit 358cd28d09).
2023-11-16 17:02:44 +01:00
Matthias Clasen
4a018de0a1 Merge branch 'michaelweghorn/a11y_add_blockquote_role' into 'main'
a11y: Add block quote role

See merge request GNOME/gtk!6539
2023-11-16 14:25:01 +00:00
Matthias Clasen
23e50bb21d Merge branch 'main' into 'main'
Fix warnings when compiling with -pedantic

See merge request GNOME/gtk!6570
2023-11-15 23:00:41 +00:00
madmurphy
a8e3e747df Fix warnings when compiling with -pedantic 2023-11-15 23:00:41 +00:00
Matthias Clasen
7fd90853f8 Merge branch 'matthiasc/for-main' into 'main'
video: Hide controls and cursor in fullscreen

Closes #6210

See merge request GNOME/gtk!6572
2023-11-15 20:46:38 +00:00
Matthias Clasen
01aa4989f8 Merge branch 'wip/wjt/gtkgraphicsoffload-docs-typo' into 'main'
gtkgraphicsoffload: fix documentation typo

See merge request GNOME/gtk!6573
2023-11-15 20:46:15 +00:00
Will Thompson
d4fee23ff6 gtkgraphicsoffload: fix documentation typo 2023-11-15 19:45:17 +00:00
Matthias Clasen
b878949f00 video: Hide controls and cursor in fullscreen
Be a bit more aggressive about hiding the controls, and also
hide the cursor if we are paying a video and are fullscreen.

Fixes: #6210
2023-11-15 14:24:39 -05:00
Matthias Clasen
3a88522a19 Post-release version bump 2023-11-15 10:07:50 -05:00
Matthias Clasen
358cd28d09 4.13.3 2023-11-15 09:44:44 -05:00
Matthias Clasen
6eb6b0cb50 Cosmetics: typo fix 2023-11-15 06:45:52 -05:00
Matthias Clasen
c81954120a Merge branch 'fix-giodesktopappinfo-check' into 'main'
Revert "Conditional check for gdesktopappinfo header"

See merge request GNOME/gtk!6568
2023-11-15 05:13:08 +00:00
Matthias Clasen
4bdc44f4af Revert "Conditional check for gdesktopappinfo header"
This reverts commit 13b94dab10.

As pointed out in #6557, this commit is broken and causes
gio/gdesktopappinfo.h to never be found.
2023-11-14 23:45:17 -05:00
Matthias Clasen
3ab7b2d7ce Merge branch 'va-fixes-reported-by-pvs' into 'main'
Fix issues spotted by PVS-Studio

See merge request GNOME/gtk!6558
2023-11-15 00:27:08 +00:00
Matthias Clasen
429056c214 Merge branch 'wip/otte/for-mclasen' into 'main'
gl: Don't punch hole if the subsurface is above

See merge request GNOME/gtk!6567
2023-11-15 00:26:45 +00:00
Benjamin Otte
acecf519bc offload: Reject non-integer rectangles
We shouldn't just fudge with coordinates if we want accurate rendering.
2023-11-14 21:55:10 +01:00
Benjamin Otte
b2fbdcda41 subsurface: Report better error messages when rejecting textures 2023-11-14 21:54:38 +01:00
Benjamin Otte
1b08fda93e renderer: Remove offload argument from render()
It turns out it's not needed, because all relevant information for
subsurfaces is already available by querying the subsurface itself.
2023-11-14 21:54:35 +01:00
Benjamin Otte
f6b6176ec0 gl: Handle subsurfaces without GskOffload 2023-11-14 21:51:07 +01:00
Luca Bacci
2803189afd Merge branch 'gdkwin32_modernize_clipboard' into 'main'
GdkWin32: switch to new clipboard API

Closes #442

See merge request GNOME/gtk!6560
2023-11-14 20:09:55 +00:00
g.willems
ad08c1444a win32: precalculate keymap at display opening
The default keymap and keymap layouts are calculated on request.
If done once a surface is setup and listening at win32 events,
we may then enter in a recursive loop.
To avoid this, precalculate the keymap as soon as displays are open.

Fixes #6203
Closes #6203
2023-11-14 20:26:05 +01:00
Benjamin Otte
ef77a6fa73 gl: Don't punch hole if the subsurface is above
Saves some work.
2023-11-14 20:22:24 +01:00
Matthias Clasen
667f02ecd8 Merge branch 'matthiasc/for-main' into 'main'
Updates

See merge request GNOME/gtk!6562
2023-11-14 17:49:04 +00:00
Benjamin Otte
160f632668 Merge branch 'wip/otte/for-main' into 'main'
renderer: Remove priv->root_node

See merge request GNOME/gtk!6565
2023-11-14 14:43:47 +00:00
Benjamin Otte
653bf46494 offload: Refactor texture finding
It's the same code, but with way more debose debug messages.
2023-11-14 15:04:38 +01:00
Benjamin Otte
46d4c70cd7 offload: Only print one debug message
... when failing to create the wl_buffer.
2023-11-14 15:04:38 +01:00
Benjamin Otte
4920ac4a57 offload: Move a debug message
If we fail to attach a buffer, we don't want to print this.
2023-11-14 15:04:38 +01:00
Benjamin Otte
5bdc9f71fd renderer: Remove priv->root_node
It's not used anywhere.
2023-11-14 15:04:38 +01:00
Benjamin Otte
c92761b184 Merge branch 'wip/otte/for-main' into 'main'
Add a debug node for CSS outlines

See merge request GNOME/gtk!6564
2023-11-14 13:39:38 +00:00
Benjamin Otte
9185f15cd9 renderer: Add a supports_offload flag
This flag must be set when creating the class or offloading
will be disabled for this renderer.

Set that flag for the GL renderer.

Fixes the Cairo and Vulkan renderer not showing Video.
2023-11-14 13:06:05 +01:00
Benjamin Otte
efec30babb renderer: Don't crash with offload disabled 2023-11-14 13:06:05 +01:00
Benjamin Otte
190e7da317 wayland: Don't g_warning() on expected error
Print a GDK_DEBUG() message instead.
2023-11-14 13:06:05 +01:00
Benjamin Otte
28d38cd730 Add a debug node for CSS outlines
All the other CSS render operations have one, so outlines should, too.

This was found by tracking down a random border node in a rendering.
2023-11-14 13:06:05 +01:00
Michael Weghorn
d7a72493ae a11y atspi: Map GTK_ACCESSIBLE_RELATION_{COL,ROW}_INDEX_TEXT to AT-SPI
Map GTK_ACCESSIBLE_RELATION_COL_INDEX_TEXT and
GTK_ACCESSIBLE_RELATION_ROW_INDEX_TEXT to the
corresponding AT-SPI object attributes
"colindextext" and "rowindextext", as it is specified
e.g. in the Core Accessibility Mappings 1.2 for the
corresponding attributes [1] [2].

Orca makes use of these object attributes in web browsers
and since recently also for LibreOffice [3] and is
planning to use that more globally.

[1] https://www.w3.org/TR/core-aam-1.2/#ariaColIndexText
[2] https://www.w3.org/TR/core-aam-1.2/#ariaRowIndexText
[3] 3c056cd7b5
2023-11-14 12:18:47 +01:00
Benjamin Otte
7299c9baa9 Merge branch 'andyholmes/get-default-size' into 'main'
gtk: fix NULL pointer dereference

See merge request GNOME/gtk!6559
2023-11-14 11:08:53 +00:00
Andrey Kutejko
540a83327f Fix issues spotted by PVS-Studio 2023-11-14 08:56:40 +01:00
Matthias Clasen
04d41eaa66 Updates 2023-11-13 23:53:24 -05:00
Matthias Clasen
524d681496 Merge branch 'dmabuf-passthrough' into 'main'
dmabuf passthrough

Closes #6132

See merge request GNOME/gtk!6533
2023-11-14 03:20:12 +00:00
Matthias Clasen
44d977844b testsuite: Add offload tests
These tests come in two variants.

The first takes .node and .offload file, parses the node file,
and compares the resulting subsurface attachments to expected results.

The second variant takes two .node/.offload file pairs and a .diff
file, parses the node files, compares the resulting subsurface
attachments, and then diffs the nodes, comparing the resulting
area to the region in the .diff file.
2023-11-13 18:41:53 -06:00
Matthias Clasen
6259800f5a Merge branch 'matthiasc/for-main' into 'main'
gsk: Robustness fix

See merge request GNOME/gtk!6561
2023-11-13 23:36:58 +00:00
Matthias Clasen
d3a5aa5304 testdmabuf: Use GtkGraphicsOffload 2023-11-13 22:27:51 +01:00
Matthias Clasen
d32ab7544d gtk-demo: Enable offload in the video player 2023-11-13 22:27:51 +01:00
Matthias Clasen
e2e7c931c5 gtk: Use GtkGraphicsOffload in GtkVideo
Video playback is one of the main use cases for graphics offload,
so it makes a lot of sense to do it in GtkVideo.
2023-11-13 22:27:51 +01:00
Matthias Clasen
e202348380 gtk: Add GtkGraphicsOffload
This is new widget that will attempt to pass through the content
of its child via a subsurface. This is mostly meant for internal
use, but the minimal api is available.
2023-11-13 22:27:51 +01:00
Matthias Clasen
ba5403da17 gtk: Add gtk_snapshot_push_subsurface
This is currently private api.
2023-11-13 22:17:36 +01:00
Matthias Clasen
904d44074f gsk gl: Handle subsurfaces during rendering
During rendering, restack offloaded subsurfaces below the main
surface, and clear the area so they peek through. After rendering,
raise the last subsurface if we haven't drawn over it.
2023-11-13 22:17:36 +01:00
Matthias Clasen
c636baf6f5 gsk gl: Make it possible to clear a rectangle
Add a blend mode to the draw command, so it can draw transparent
black. This will be used to erase the area on top of a subsurface
when we do passthrough.
2023-11-13 22:17:36 +01:00
Matthias Clasen
b7c2528ad1 gsk: Prepare subsurface offload
Use a GskOffloadInfo to update subsurfaces (and collect info about
them). Pass that info to both the diff and the render vfuncs.
2023-11-13 22:17:36 +01:00
Matthias Clasen
48740de71a gsk: Add a subsurface mode to node diffing
Add an extra argument to pass offload info to the diffing code.
This is then used for diffing subsurface nodes differently,
depending on their offloading status.
2023-11-13 22:17:35 +01:00
Matthias Clasen
34c16b0df2 gsk: Add code to offload to subsurfaces
This code walks the node tree, finds subsurface nodes, determines
if we can offload to the subsurface, and if yes, does so. This
isn't used yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
d0a675ab01 gsk: Add subsurface nodes
Also show them in the inspector recorder, with some information.
2023-11-13 22:17:35 +01:00
Matthias Clasen
0e0bf8ed47 gsk: Add a debug flag for graphics offload
Add GSK_DEBUG=offload-disable to disable graphics offload via
attaching of dmabufs to subsurfaces. This is not used anywhere yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
00d7d4b17b wayland: Implement empty_frame in draw contexts 2023-11-13 22:17:35 +01:00
Matthias Clasen
9eef566b54 gdk: Introduce empty frames in GdkDrawContext
We need a way to commit pending subsurface changes, even when no
drawing happened for the frame. empty_frame() is that way.
2023-11-13 22:17:35 +01:00
Matthias Clasen
272168c94b inspector: Add a subsurface overlay
We have to be careful to not draw over the subsurface area with
our highlighting, otherwise this would interfere with raising
unobstructed subsurfaces.
2023-11-13 22:17:35 +01:00
Matthias Clasen
ca054bfdc9 wayland: Request frame callbacks on subsurfaces
We need this for the case when the subsurface completely covers
up the main surface. Without it, we just stop updating.
2023-11-13 22:17:35 +01:00
Matthias Clasen
59dbfb0843 wayland: Implement subsurface api
This is not used anywhere yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
223e27e7dc gdk: Add private subsurface api
Add api to allow creating subsurfaces, attaching textures to them,
and changing the stacking order.

This is just the api, there is no implementation yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
efe1415429 gdk: Add a debug flag for subsurfaces
You can now use GDK_DEBUG=offload to get debug spew about
subsurfaces and graphics offload.
2023-11-13 22:17:35 +01:00
Matthias Clasen
489723916d wayland: Get format info for dmabufs
For now, all we do with it is dump the formats if you
set GDK_DEBUG=misc. In the future, this will be used
when attaching dmabufs to subsurfaces.
2023-11-13 22:17:35 +01:00
Matthias Clasen
e8894ad383 gsk: Robustness fix
I was seeing empty regions being passed as scissor.
2023-11-13 22:17:35 +01:00
Matthias Clasen
9423d6261a gtk: Use some more inline helpers 2023-11-13 22:17:35 +01:00
Matthias Clasen
b766f92026 gsk: Use some more inline helpers 2023-11-13 22:17:35 +01:00
Matthias Clasen
a37aacf4e4 Add another inline rect helper 2023-11-13 22:17:35 +01:00
Matthias Clasen
93959ef7df gsk: Robustness fix
I was seeing empty regions being passed as scissor.
2023-11-13 22:16:07 +01:00
Matthias Clasen
209a1a69cc gtk: Use some more inline helpers 2023-11-13 22:15:57 +01:00
Matthias Clasen
982f965ea8 gsk: Use some more inline helpers 2023-11-13 22:15:45 +01:00
Matthias Clasen
f7fc90daa0 Add another inline rect helper 2023-11-13 22:15:35 +01:00
g.willems
a58424588f win32: switch to new clipboard API
This is a backport of !1143 to gtk4.

SetClipboardViewer() API is obsolete is prone to clipboard chain breaks
from other applications.
Use recommended AddClipboardFormatListener() instead.

Fixes #442
2023-11-13 21:29:48 +01:00
Andy Holmes
f8c9b3394b gtk: fix NULL pointer dereference
`gtk_window_get_default_size()` claims width/height are optional-out
arguments, but defers to `gtk_window_get_remembered_size()` which
may dereference a NULL-pointer.

Since `gtk_window_get_remembered_size()` is only called by
`gtk_window_get_default_size()`, collapse it into the latter
and perform the NULL check there.
2023-11-13 12:05:31 -08:00
Benjamin Otte
ce4d8cc6d9 Merge branch 'wip/otte/tree-indent' into 'main'
theme: Halve indentation of trees

See merge request GNOME/gtk!6553
2023-11-13 16:16:38 +00:00
Matthias Clasen
c85766ac71 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Add a debug message for format fallback

See merge request GNOME/gtk!6556
2023-11-12 12:59:22 +00:00
Matthias Clasen
b24ae31716 dmabuf: Improve consistency of debug messages
Make sure all our dmabuf debug messages are display-scoped so the
inspector doesn't trigger them, use the same formatting throughout,
and improve consistency of wording here and there.
2023-11-12 13:02:58 +01:00
Matthias Clasen
7cf805c8b3 dmabuf: Add a debug message for format fallback
This may be helpful in pinpointing why a dmabuf format behaves
unexpectedly.
2023-11-12 11:24:37 +01:00
Matthias Clasen
1f62c693cd Merge branch 'nv12-opaque' into 'main'
dmabuf: NV12 is opaque

See merge request GNOME/gtk!6555
2023-11-11 23:47:59 +00:00
Matthias Clasen
6ae9cbfe0f dmabuf: NV12 is opaque
Getting this wrong matters, since we won't offload textures in
non-opaque formats. Found by Robert Mader. At the same time,
unify the two places we have for mapping from fourcc to memory
format.
2023-11-11 23:56:01 +01:00
Benjamin Otte
7803aad872 theme: Halve indentation of trees
Deep trees quickly add so much empty space on the left, so that it gets
really hard to read after an indentation level of ~10.

By halving, we still keep the visual clarity of indenting but we can now
handle twice as many indentation levels, ie ~20.

It is what sysprof has been using, and it also feels right in the
inspector.
2023-11-11 10:34:57 +01:00
Ekaterine Papava
cc2d3fa7d6 Update Georgian translation 2023-11-09 09:41:14 +00:00
Benjamin Otte
a9e4993184 Merge branch 'wip/otte/enable-debug' into 'main'
Remove G_ENABLE_DEBUG around debug checks

See merge request GNOME/gtk!6546
2023-11-07 15:12:11 +00:00
Benjamin Otte
33703bfe01 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Set same YUV colorspace as elsewhere

See merge request GNOME/gtk!6548
2023-11-07 05:11:10 +00:00
Benjamin Otte
7ba5cf5309 inspector: Add more info about GL
Print all the variables queryable via glGetString().

And remove them from the Windows backend.
2023-11-07 05:33:48 +01:00
Benjamin Otte
bb890f6004 inspector: Don't list unused EGL extension
We don't use that extension and I don't even know what it is about -
which is a good reason to get rid of showing it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
1c7a0e7a15 inspector: Use right name for Vulkan validation layer
The name got changed a while ago, so let's reflect that.
2023-11-07 05:12:57 +01:00
Benjamin Otte
cd7e1c1387 dmabuf: Modify gdk_gl_context_import_dmabuf()
Move a bunch of code - namely the target selection - into the function.

I want to use the same code in the NGL renderer, so no need to duplicate
it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
a2e1e727c5 testsuite: Make texture-scale-magnify tests have roundable numbers
Use a number that's 2^N * 255 to get floating point awesomeness combined
with uint8_t awesomeness.

Fixes rounding errors in samplers.
2023-11-07 05:12:57 +01:00
Benjamin Otte
61207f81c3 dmabuf: Set same YUV colorspace as elsewhere
We use ITU.601 full range everywhere, so ensure it's used here, too.
2023-11-07 05:12:57 +01:00
Benjamin Otte
f624586a75 testsuite: Don't skip test
The test now works without debugging as debug messages are always
available.
2023-11-05 11:16:23 +01:00
Benjamin Otte
1a93967e1f gdk: Remove debug modes in gdk_debug_parse_var()
Always support all variables.
2023-11-05 11:16:23 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Benjamin Otte
d55801c8ba debug: Turn gdk_debug_message() into a function
1. MSVC can't deal with the nonstandard ##__VA_ARGS__

2. It allows setting a breakpoint on it.
2023-11-05 10:21:54 +01:00
Matthias Clasen
b1809bfd88 Merge branch 'matthiasc/for-main' into 'main'
print dialog: Improve local fallback

See merge request GNOME/gtk!6547
2023-11-04 23:20:53 +00:00
Matthias Clasen
deb8a35ea0 print dialog: Improve local fallback
We need to set embed-page-setup for the paper size and orientation
combos to work.
2023-11-05 01:00:39 +02:00
Jordi Mas i Hernandez
c5ce24c82c Update Catalan translation 2023-11-04 18:28:38 +00:00
Artur S0
54815e4771 Update Russian translation 2023-11-04 02:09:09 +00:00
Matthias Clasen
5a99790a87 Merge branch 'examples-gtk-widget-show' into 'main'
docs: Replace deprecated gtk_widget_show with gtk_widget_set_visible

See merge request GNOME/gtk!6538
2023-11-03 15:29:39 +00:00
Matthias Clasen
8aa7174bfb Merge branch 'faster-fps-overlay' into 'main'
inspector: Speed up the fps overlay

See merge request GNOME/gtk!6544
2023-11-01 22:44:44 +00:00
Benjamin Otte
9df5e3cbd6 inspector: Replace "no glyph" with space glyph
This makes right-aligning the text work again.
2023-11-01 21:57:56 +01:00
Benjamin Otte
8b5194c016 inspector: Use the right font for the fps overlay
Initialize the font only when we have a widget that provides it. That
way we don't pick a terrible default font, but the widget's preferred
one.
2023-11-01 21:32:55 +01:00
Matthias Clasen
9a63172cf5 Some minor fpsoverlay improvements
Avoid some allocations.
2023-11-01 14:45:57 -04:00
Matthias Clasen
3ade9ae184 inspector: Speed up the fps overlay
Do less work!
2023-11-01 14:00:42 -04:00
Benjamin Otte
76349ff6e5 Merge branch 'wip/otte/for-main' into 'main'
testsuite: Add render test for texture placement

See merge request GNOME/gtk!6543
2023-11-01 14:36:07 +00:00
Benjamin Otte
dd530b45e2 gstmediafile: Handle premultiplied alpha
1. Check GStreamer caps for premultiplied alpha and select
   GdkMemoryFormat accordingly

2. Set a GdkMemoryFormat for GL textures

Fixes the video in widget-factory being treated as premultiplied when it
isn't.
2023-11-01 08:01:27 +01:00
Benjamin Otte
00ce51472c testsuite: Add render test for texture placement
Make sure that texture nodes sample from the texture properly.
2023-11-01 08:01:27 +01:00
Matthias Clasen
b6bcbeae23 Merge branch 'matthiasc/for-main' into 'main'
inspector: Show more EGL extensions

See merge request GNOME/gtk!6542
2023-10-31 23:12:54 +00:00
Robert Ancell
cf86cc1184 docs: Use gtk_window_present instead of gtk_widget_set_visible 2023-11-01 10:54:33 +13:00
Matthias Clasen
b503b60a49 inspector: Show more EGL extensions
We care about these now.
2023-10-31 17:53:25 -04:00
Matthias Clasen
5850055b68 Merge branch 'progressbar_overflow_fix' into 'main'
GtkProgressBar: Fix: progress can overflow trough

See merge request GNOME/gtk!6445
2023-10-31 11:22:32 +00:00
Matthias Clasen
b224e66a9f Merge branch 'scale_overflow_fix' into 'main'
GtkScale: Fix: highlight can overflow trough

Closes #5751

See merge request GNOME/gtk!6444
2023-10-31 11:22:02 +00:00
Michael Weghorn
bbb0150383 a11y: Add block quote role
Add a new GTK_ACCESSIBLE_ROLE_BLOCK_QUOTE role
for block quotes/block quotations.

ARIA has a corresponding "blockquote" role as well. [1]

The role is used e.g. in document editors
like LibreOffice or web browsers like Firefox.

According to the ARIA spec (§ 5.2.8.4, [2]), the
blockquote role is among those that can be named by
the author, and the superclass role is section. [1]

Related change for LibreOffice making use of the new
role: [3]

[1] https://www.w3.org/TR/wai-aria-1.2/#blockquote
[2] https://www.w3.org/TR/wai-aria-1.2/#namefromauthor
[3] https://gerrit.libreoffice.org/c/core/+/158685
2023-10-31 09:33:06 +01:00
Robert Ancell
8aef682079 docs: Replace deprecated gtk_widget_show with gtk_widget_set_visible 2023-10-31 13:27:26 +13:00
Benjamin Otte
fe4b7a5159 Merge branch 'wip/otte/for-main' into 'main'
rendernode-tool: Add --undecorated to show command

See merge request GNOME/gtk!6537
2023-10-31 00:23:18 +00:00
Benjamin Otte
7ba4ba05e1 gl: Fix padding in icon library
The previous code would not pad the left side with the left column of
pixels but with the top row.

Test attached.
2023-10-31 00:50:00 +01:00
Benjamin Otte
85e1088171 gsk: Fix texture-scale node Cairo drawing
The code was interpreting x/y coordinates wrong sometimes and causing
things to not be drawn at the correct offset.

Testcase included.
2023-10-31 00:36:27 +01:00
Benjamin Otte
c1ed034367 rendernode: Use an exisiting function instead of reimplementing it 2023-10-31 00:36:27 +01:00
Benjamin Otte
cc3e25b163 testsuite: Be more resistant against rounding errors
Make a test use numbers that are less likely to cause rounding
issues in GPUs (read: use powers of 2).
2023-10-31 00:36:27 +01:00
Benjamin Otte
bdb3e345c8 testsuite: Add test for scaling texture-scale node
Finally figured out a way to test that a texture-scale node using
NEAREST that is upscaled using a transform node doesn't use NEAREST but
LINEAR.
2023-10-31 00:36:27 +01:00
Benjamin Otte
a30e9dcfeb testsuite: Add a test for nearest vs linear scales 2023-10-31 00:36:27 +01:00
Benjamin Otte
76007c4d09 rendernode-tool: Add --undecorated to show command
This is to get exactly just the rendernode drawn when testing, and not
any extra drawing code.
2023-10-31 00:36:27 +01:00
Matthias Clasen
020ef51cb0 Merge branch 'matthiasc/for-main' into 'main'
Revert "glcontext: Better debug spew"

See merge request GNOME/gtk!6536
2023-10-29 19:04:26 +00:00
Matthias Clasen
1914adc344 dmabuf: Don't check for image storage
I was wrong about this extension, and it isn't even a GL extension
to begin with, so revert all this.
2023-10-29 14:45:20 -04:00
Matthias Clasen
6e236b9459 Revert "gl context: Check for more GL extensions"
This reverts commit b8b5835fc6.
2023-10-29 14:44:46 -04:00
Matthias Clasen
11715760f9 Revert "glcontext: Better debug spew"
This reverts commit 30e14f73fa.
2023-10-29 14:44:29 -04:00
Matthias Clasen
f19c08ffda Merge branch 'add-view-grid-symbolic-icon' into 'main'
icons: Add view-grid-symbolic

Closes #6184

See merge request GNOME/gtk!6534
2023-10-29 15:32:27 +00:00
Kleis Auke Wolthuizen
d0f76b6ab4 widget-factory: Remove insert-image icon
This icon is already present in the hicolor icon theme.
2023-10-28 20:25:53 +02:00
Kleis Auke Wolthuizen
4c7206343a widget-factory: Remove view-grid-symbolic icon
No longer needed as it's included in the hicolor icon theme now.
2023-10-28 20:25:53 +02:00
Kleis Auke Wolthuizen
dfae2cb3a5 icons: Add view-grid-symbolic
This showed up as missing icon in the file chooser when used with
the hicolor icon theme.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6184
2023-10-28 20:05:27 +02:00
Matthias Clasen
de74d38039 Merge branch 'improve-msvc-force-include' into 'main'
MSVC builds: Improve build process (was: MSVC builds: Always enable items from msvc_recommended_pragmas.h)

See merge request GNOME/gtk!6114
2023-10-27 22:11:06 +00:00
Matthias Clasen
fb20542fcc Merge branch 'fix_name_computation' into 'main'
a11y: When using rule 2.E for computing accessible name, use it only if appropriate

See merge request GNOME/gtk!6495
2023-10-27 17:32:14 +00:00
Lukáš Tyrychtr
a26e289d5c Adjust tests 2023-10-26 09:44:59 +02:00
Lukáš Tyrychtr
892d3b9530 a11y: When using rule 2.E for computing accessible name, use it only if appropriate
We were using it in all cases, so, we were using it to compute descriptions,
and also for non-embedded controls. That was overriding descriptions
set, for example, in Gnome settings, and was causing the value of spinboxes
to be read multiple times.
2023-10-26 09:40:30 +02:00
Chun-wei Fan
8477dcfeff builds: Require -Zc:preprocessor for Visual Studio debug builds
This flag is actually required for the debugging code to successfully build,
so check that it is really there for debug-enabled Visual Studio builds.
2023-10-26 10:40:17 +08:00
Chun-wei Fan
25835afd9c MSVC Builds: Don't enable -utf-8 explicitly
We already require a Meson release that enables -utf-8 by default, so we don't
really need to explicitly enable it here.
2023-10-26 10:40:17 +08:00
Matthias Clasen
06dda4e12b Merge branch 'memory-format-swizzle-check' into 'main'
gl: Check all swizzle values

See merge request GNOME/gtk!6524
2023-10-26 02:38:35 +00:00
Chun-wei Fan
26edfe6d18 build: Add msvc_recommended_pragmas.h
We really always want to force-include msvc_recommended_pragmas.h to check for
things at compile time so that we can avoid stuff like missing includes or
attempting to return a value in a function that is supposed to have a
void-return-type.

The current problem is that, as indicated in the Visual Studio CI job, that we
couldn't locate msvc_recommended_pragmas.h during the build if GLib is built
as a subproject, and/or when msvc_recommended_pragmas.h is not in the paths
indicated by %INCLUDE%, meaning that the aforementioned issues would not be
caught by CI, which will then break builds on Visual Studio for people when
msvc_recommended_pragmas.h is found during their builds.

It would also be nice to be quiet from the warnings that we can really
disregard anyways.

So, add a copy of msvc_recommended_pragmas.h from GLib and update the build
files to look for it in build-aux/msvc, so that it can always be used during
the build, especially by the CI.
2023-10-26 10:38:14 +08:00
Matthias Clasen
4a749aee6e Fix swizzle values for some memory formats
For opaque formats with 3 channels, we should use the default
GL_ALPHA, but for opaque formats with an ignored 4th channel,
we must use GL_ONE.
2023-10-25 21:39:52 -04:00
Matthias Clasen
99a8417142 Merge branch 'add-bn-hi-po-translated' into 'main'
translated bn.po and hi.po

See merge request GNOME/gtk!6530
2023-10-25 16:34:19 +00:00
Matthias Clasen
20e2075a10 Merge branch 'allow-implicit-modifiers' into 'main'
Allow implicit modifiers

See merge request GNOME/gtk!6529
2023-10-25 02:52:49 +00:00
Matthias Clasen
d8c649b57f Merge branch 'matthiasc/for-main' into 'main'
dmabuf: No mipmaps for dmabuf textures

See merge request GNOME/gtk!6531
2023-10-25 02:43:19 +00:00
Matthias Clasen
bb2b8bf2c3 dmabuf: Refine the handling of implicit modifiers
If all formats with a given fourcc are external, treat the
fourcc with implicit modifiers as external too, following a
sugestion by Benjamin Otte.
2023-10-24 22:33:45 -04:00
Matthias Clasen
eb048c91be dmabuf: Allow implicit modifiers
Remove all the roadblocks we've put up to keep implicit modifiers
out. Our importing code already handles them as a signal that says
'No modifiers, please!'. Now we just hope for the best and pass
things along.

This is necessary since some drivers won't produce any explicit
modifiers.
2023-10-24 22:33:45 -04:00
Matthias Clasen
358779dfb2 dmabuf: No mipmaps for dmabuf textures
Calling glGenerateMipmap on imported dmabufs does not work, so
don't do it.
2023-10-24 22:03:31 -04:00
Matthias Clasen
8f90ddb906 dmabuf: Cache egl formats
Only call eglQueryDmaBufModifiersEXT once, and reuse the results.
2023-10-24 21:53:09 -04:00
Matthias Clasen
ed54aa8acf Merge branch 'matthiasc/for-main' into 'main'
Fix annotations

See merge request GNOME/gtk!6522
2023-10-24 15:04:16 +00:00
Matthias Clasen
a90ffb117f docs: Some additions
Add a link to the kernel docs about dmabufs.
2023-10-24 10:50:46 -04:00
Matthias Clasen
29681717ed Fix annotations
It is always org.gtk.Property, even if we are in gdk.
2023-10-24 07:16:42 -04:00
sudip
e0cd2b756f translated bn.po and hi.po
Resolves:https://gitlab.gnome.org/GNOME/gtk/-/issues/6164
2023-10-24 16:20:24 +05:30
Matthias Clasen
2c85060b5f Merge branch 'msvc-for-main' into 'main'
Few small fixes for Visual Studio builds

See merge request GNOME/gtk!6521
2023-10-24 10:44:22 +00:00
Chun-wei Fan
864c5b4608 testsuite: Disable dmabuftexture test on Windows
It's not meaningful there.
2023-10-24 14:08:16 +08:00
Chun-wei Fan
1ab501649e gsk/gskcurve.c: Avoid returning value in void-retype function
This is considered a compiler error with later GLib releases with Visual Studio
builds, so avoid that.
2023-10-24 13:18:26 +08:00
Matthias Clasen
677e78bdce gl: Check all swizzle values
There is no reason not check the alpha swizzle for being different
from its default value. I am thinking about implementing RGBx
upload with a swizzle of rgb1, and that would break here.
2023-10-23 07:55:39 -04:00
sumibi-yakitori
37a5ad3a53 Fix coding style 2023-10-04 03:30:32 +09:00
sumibi-yakitori
00e4dab1ef macos: change to send motion events to NSApp
This fix addresses a problem where the mouse cursor cannot be changed after it becomes a resize indicator, even in non-CSD windows
2023-10-03 08:14:27 +09:00
Mazhar Hussain
8367411785 GtkProgressBar: Fix: progress can overflow trough
For visual explanation, visit https://gitlab.gnome.org/GNOME/gtk/-/issues/5751
The linked issue tracker is for GtkScale but GtkProgressBar has the exact same problem as well
2023-09-30 14:11:47 +05:00
Mazhar Hussain
17e37dc42a GtkScale: Fix: highlight can overflow trough
For visual explanation, visit https://gitlab.gnome.org/GNOME/gtk/-/issues/5751
2023-09-30 13:39:00 +05:00
Peter Williams
90183b3588 gdk/macos: fix builds on macOS before 10.13
Nothing profound here, just need to get some of the workarounds
into the right places.
2023-04-10 14:21:49 -04:00
401 changed files with 27764 additions and 16162 deletions

View File

@@ -26,7 +26,7 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v48"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v49"
workflow:
rules:
@@ -66,7 +66,8 @@ style-check-diff:
junit:
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gles.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gl.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gles2.xml"
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
@@ -103,8 +104,9 @@ fedora-x86_64:
${FEATURE_FLAGS}
_build
- meson compile -C _build
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build wayland_gles
- .gitlab-ci/run-tests.sh _build x11 gtk
# only repeat test runs that are likely affected by test setups
- .gitlab-ci/run-tests.sh _build wayland_gl gtk:gdk,gtk:gsk-gl
release-build:
extends: .build-fedora-default
@@ -129,7 +131,9 @@ release-build:
- meson install -C _build
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
- .gitlab-ci/run-tests.sh _build x11
- .gitlab-ci/run-tests.sh _build wayland gtk
# only repeat test runs that are likely affected by test setups
- .gitlab-ci/run-tests.sh _build wayland_gles2 gtk:gdk,gtk:gsk-gl
fedora-clang:
extends: .build-fedora-default
@@ -423,11 +427,12 @@ asan-build:
-Df16c=disabled
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build wayland_gles
- .gitlab-ci/run-tests.sh _build x11
- .gitlab-ci/run-tests.sh _build wayland gtk
artifacts:
when: always
reports:
junit:
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"

Binary file not shown.

View File

@@ -1,4 +1,4 @@
FROM fedora:38
FROM fedora:39
RUN dnf -y install \
adwaita-icon-theme \

View File

@@ -324,7 +324,7 @@ for line in args.infile:
units.append(unit)
report = {}
report['date'] = datetime.datetime.utcnow()
report['date'] = datetime.datetime.now(datetime.UTC)
report['locale_date'] = report['date'].strftime("%c")
report['project_name'] = args.project_name
report['backend'] = args.backend

View File

@@ -44,7 +44,7 @@ outfile = args.output
testsuites = ET.Element('testsuites')
testsuites.set('id', '{}/{}'.format(args.job_id, args.branch))
testsuites.set('package', args.project_name)
testsuites.set('timestamp', datetime.datetime.utcnow().isoformat(timespec='minutes'))
testsuites.set('timestamp', datetime.datetime.now(datetime.UTC).isoformat(timespec='minutes'))
suites = {}
for line in args.infile:

View File

@@ -1,27 +1,29 @@
#!/bin/bash
set +x
set -x
set +e
srcdir=$( pwd )
builddir=$1
backend=$2
setup=$2
suite=$3
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
export G_SLICE=always-malloc
case "${backend}" in
x11)
case "${setup}" in
x11*)
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
meson test -C ${builddir} \
--quiet \
--timeout-multiplier "${multiplier}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
--setup=${setup} \
--suite=${suite//,/ --suite=} \
--no-suite=failing \
--no-suite=${setup}_failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=gsk-compare-broadway
@@ -42,19 +44,19 @@ case "${backend}" in
--quiet \
--timeout-multiplier "${multiplier}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
--setup=${setup} \
--suite=${suite//,/ --suite=} \
--no-suite=failing \
--no-suite=${setup}_failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=${backend}_failing \
--no-suite=gsk-compare-broadway
exit_code=$?
kill ${compositor}
;;
broadway)
broadway*)
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
${builddir}/gdk/broadway/gtk4-broadwayd :5 &
@@ -65,9 +67,10 @@ case "${backend}" in
--quiet \
--timeout-multiplier "${multiplier}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
--setup=${setup} \
--suite=${suite//,/ --suite=} \
--no-suite=failing \
--no-suite=${setup}_failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=gsk-compare-opengl
@@ -76,7 +79,7 @@ case "${backend}" in
;;
*)
echo "Failed to add ${backend} to .gitlab-ci/run-tests.sh"
echo "Failed to add ${setup} to .gitlab-ci/run-tests.sh"
exit 1
;;
@@ -86,17 +89,17 @@ cd ${builddir}
$srcdir/.gitlab-ci/meson-junit-report.py \
--project-name=gtk \
--backend="${backend}" \
--backend="${setup}" \
--job-id="${CI_JOB_NAME}" \
--output="report-${backend}.xml" \
"meson-logs/testlog-${backend}.json"
--output="report-${setup}.xml" \
"meson-logs/testlog-${setup}.json"
$srcdir/.gitlab-ci/meson-html-report.py \
--project-name=gtk \
--backend="${backend}" \
--backend="${setup}" \
--job-id="${CI_JOB_NAME}" \
--reftest-output-dir="testsuite/reftests/output/${backend}" \
--output="report-${backend}.html" \
"meson-logs/testlog-${backend}.json"
--reftest-output-dir="testsuite/reftests/output/${setup}" \
--output="report-${setup}.html" \
"meson-logs/testlog-${setup}.json"
exit $exit_code

38
NEWS
View File

@@ -1,6 +1,42 @@
Overview of Changes in 4.13.3, xx-xx-xxxx
Overview of Changes in 4.13.4, xx-xx-xxxx
=========================================
Overview of Changes in 4.13.3, 15-11-2023
=========================================
* GtkGraphicsOffload: A new widget to support passthrough
of dmabuf textures with subsurfaces on Wayland
* GtkListView:
- reduce tree indentation
* GtkInspector:
- Show more GL information
- Add a subsurface overlay
- Improve the fps overlay
* GDK
- Allow implicit modifiers for dmabufs
- Support more dmabuf formats: NV16, NV61, NV24, NV42
and 3-plane YUV formats
* GSK
- Fix padding of icons in the GL atlas
- Fix handling of texture-scale nodes in cairo
- Treat texture-scale nodes more faithfully in GL
* Accessibility:
- Tweak the accessible name computation for corner cases
* The GTK/GDK/GSK_DEBUG environment variables now
work in productions as well as in debug builds
* Translation updates
Catalan
French
Russian
Overview of Changes in 4.13.2, 22-10-2023
=========================================

View File

@@ -0,0 +1,41 @@
#ifndef _MSC_VER
#pragma error "This header is for Microsoft VC or clang-cl only."
#endif /* _MSC_VER */
/* Make MSVC more pedantic, this is a recommended pragma list
* from _Win32_Programming_ by Rector and Newcomer.
*/
#ifndef __clang__
#pragma warning(error:4002) /* too many actual parameters for macro */
#pragma warning(error:4003) /* not enough actual parameters for macro */
#pragma warning(1:4010) /* single-line comment contains line-continuation character */
#pragma warning(error:4013) /* 'function' undefined; assuming extern returning int */
#pragma warning(1:4016) /* no function return type; using int as default */
#pragma warning(error:4020) /* too many actual parameters */
#pragma warning(error:4021) /* too few actual parameters */
#pragma warning(error:4027) /* function declared without formal parameter list */
#pragma warning(error:4029) /* declared formal parameter list different from definition */
#pragma warning(error:4033) /* 'function' must return a value */
#pragma warning(error:4035) /* 'function' : no return value */
#pragma warning(error:4045) /* array bounds overflow */
#pragma warning(error:4047) /* different levels of indirection */
#pragma warning(error:4049) /* terminating line number emission */
#pragma warning(error:4053) /* An expression of type void was used as an operand */
#pragma warning(error:4071) /* no function prototype given */
#pragma warning(disable:4101) /* unreferenced local variable */
#pragma warning(error:4150)
/* G_NORETURN */
#pragma warning(error:4646) /* function declared with __declspec(noreturn) has non-void return type */
#pragma warning(error:4715) /* 'function': not all control paths return a value */
#pragma warning(error:4098) /* 'void' function returning a value */
#pragma warning(disable:4244) /* No possible loss of data warnings */
#pragma warning(disable:4305) /* No truncation from int to char warnings */
#pragma warning(error:4819) /* The file contains a character that cannot be represented in the current code page */
#endif /* __clang__ */
/* work around Microsoft's premature attempt to deprecate the C-Library */
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS

View File

@@ -35,7 +35,7 @@ show_action_dialog (GSimpleAction *action)
{
GtkAlertDialog *dialog;
dialog = gtk_alert_dialog_new ("You activated action: \"%s\n",
dialog = gtk_alert_dialog_new ("You activated action: \"%s\"",
g_action_get_name (G_ACTION (action)));
gtk_alert_dialog_show (dialog, NULL);
g_object_unref (dialog);

View File

@@ -18,8 +18,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BLUR_OVERLAY_H__
#define __BLUR_OVERLAY_H__
#pragma once
#include <gtk/gtk.h>
@@ -60,5 +59,3 @@ void blur_overlay_set_child (BlurOverlay *overlay,
GtkWidget *widget);
G_END_DECLS
#endif /* __BLUR_OVERLAY_H__ */

View File

@@ -75,7 +75,9 @@ query_tooltip (GtkWidget *widget,
gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
precision = 1;
s = NULL;
do {
g_free (s);
s = g_strdup_printf ("%.*f", precision, self->scale);
l = strlen (s) - 1;
while (s[l] == '0')

View File

@@ -18,8 +18,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DEMO_TAGGED_ENTRY_H__
#define __DEMO_TAGGED_ENTRY_H__
#pragma once
#include <gtk/gtk.h>
@@ -57,5 +56,3 @@ void demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *
gboolean has_close_button);
G_END_DECLS
#endif /* __DEMO_TAGGED_ENTRY_H__ */

View File

@@ -15,8 +15,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FONT_PLANE_H__
#define __GTK_FONT_PLANE_H__
#pragma once
#include <gtk/gtk.h>
@@ -60,5 +59,3 @@ GtkWidget * gtk_font_plane_new (GtkAdjustment *width_adj,
GtkAdjustment *weight_adj);
G_END_DECLS
#endif /* __GTK_FONT_PLANE_H__ */

View File

@@ -17,8 +17,7 @@
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __GSK_SHADER_PAINTABLE_H__
#define __GSK_SHADER_PAINTABLE_H__
#pragma once
#include <gdk/gdk.h>
#include <gsk/gsk.h>
@@ -42,5 +41,3 @@ void gsk_shader_paintable_update_time (GskShaderPaintable *self
int time_idx,
gint64 frame_time);
G_END_DECLS
#endif /* __GSK_SHADER_PAINTABLE_H__ */

View File

@@ -15,8 +15,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FISHBOWL_H__
#define __GTK_FISHBOWL_H__
#pragma once
#include <gtk/gtk.h>
@@ -65,5 +64,3 @@ void gtk_fishbowl_set_creation_func (GtkFishbowl *fishbowl,
GtkFishCreationFunc creation_func);
G_END_DECLS
#endif /* __GTK_FISHBOWL_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef __GTK_GEARS_H__
#define __GTK_GEARS_H__
#pragma once
#include <gtk/gtk.h>
@@ -44,5 +43,3 @@ void gtk_gears_set_fps_label (GtkGears *gears,
G_END_DECLS
#endif /* __GTK_GEARS_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef __GTK_SHADER_BIN_H__
#define __GTK_SHADER_BIN_H__
#pragma once
#include <gtk/gtk.h>
@@ -19,5 +18,3 @@ void gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
G_END_DECLS
#endif /* __GTK_SHADER_BIN_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef __GTK_SHADER_STACK_H__
#define __GTK_SHADER_STACK_H__
#pragma once
#include <gtk/gtk.h>
@@ -19,5 +18,3 @@ void gtk_shader_stack_set_active (GtkShaderStack *self,
int index);
G_END_DECLS
#endif /* __GTK_SHADER_STACK_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef __GTK_SHADERTOY_H__
#define __GTK_SHADERTOY_H__
#pragma once
#include <gtk/gtk.h>
@@ -30,5 +29,3 @@ void gtk_shadertoy_set_image_shader (GtkShadertoy *shadertoy,
const char *shader);
G_END_DECLS
#endif /* __GTK_SHADERTOY_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef LANGUAGE_NAMES_H
#define LANGUAGE_NAMES_H
#pragma once
#include <pango/pango.h>
@@ -9,5 +8,3 @@ const char * get_language_name (PangoLanguage *language);
const char * get_language_name_for_tag (guint32 tag);
G_END_DECLS
#endif

View File

@@ -1,5 +1,4 @@
#ifndef __PAINTABLE_H__
#define __PAINTABLE_H__
#pragma once
#include <gtk/gtk.h>
@@ -13,5 +12,3 @@ void gtk_nuclear_snapshot (GtkSnapshot *snapshot,
GdkPaintable * gtk_nuclear_icon_new (double rotation);
GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background);
GtkMediaStream *gtk_nuclear_media_stream_new (void);
#endif /* __PAINTABLE_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef __PUZZLE_PIECE_H__
#define __PUZZLE_PIECE_H__
#pragma once
#include <gtk/gtk.h>
@@ -19,5 +18,3 @@ GdkPaintable * gtk_puzzle_piece_new (GdkPaintable *puzzle,
GdkPaintable * gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self);
guint gtk_puzzle_piece_get_x (GtkPuzzlePiece *self);
guint gtk_puzzle_piece_get_y (GtkPuzzlePiece *self);
#endif /* __PUZZLE_PIECE_H__ */

View File

@@ -1,5 +1,4 @@
#ifndef SCRIPT_NAMES_H
#define SCRIPT_NAMES_H
#pragma once
#include <glib.h>
@@ -9,5 +8,3 @@ const char * get_script_name (GUnicodeScript script);
const char * get_script_name_for_tag (guint32 tag);
G_END_DECLS
#endif

View File

@@ -139,6 +139,7 @@ do_video_player (GtkWidget *do_widget)
video = gtk_video_new ();
gtk_video_set_autoplay (GTK_VIDEO (video), TRUE);
gtk_video_set_graphics_offload (GTK_VIDEO (video), GTK_GRAPHICS_OFFLOAD_ENABLED);
gtk_window_set_child (GTK_WINDOW (window), video);
title = gtk_header_bar_new ();

View File

@@ -1,5 +1,4 @@
#ifndef __ICON_BROWSER_APP_H
#define __ICON_BROWSER_APP_H
#pragma once
#include <gtk/gtk.h>
@@ -14,6 +13,3 @@ typedef struct _IconBrowserAppClass IconBrowserAppClass;
GType icon_browser_app_get_type (void);
IconBrowserApp *icon_browser_app_new (void);
#endif /* __ICON_BROWSER_APP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __ICON_BROWSER_WIN_H
#define __ICON_BROWSER_WIN_H
#pragma once
#include <gtk/gtk.h>
#include "iconbrowserapp.h"
@@ -15,6 +14,3 @@ typedef struct _IconBrowserWindowClass IconBrowserWindowClass;
GType icon_browser_window_get_type (void);
IconBrowserWindow *icon_browser_window_new (IconBrowserApp *app);
#endif /* __ICON_BROWSER_WIN_H */

View File

@@ -17,8 +17,7 @@
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_RENDERER_PAINTABLE_H__
#define __GTK_RENDERER_PAINTABLE_H__
#pragma once
#include <gsk/gsk.h>
@@ -39,5 +38,3 @@ void gtk_renderer_paintable_set_paintable (GtkRendererPaintable
GdkPaintable * gtk_renderer_paintable_get_paintable (GtkRendererPaintable *self) G_GNUC_PURE;
G_END_DECLS
#endif /* __GTK_RENDERER_PAINTABLE_H__ */

View File

@@ -17,8 +17,7 @@
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __NODE_EDITOR_APPLICATION_H__
#define __NODE_EDITOR_APPLICATION_H__
#pragma once
#include <gtk/gtk.h>
@@ -33,6 +32,3 @@ typedef struct _NodeEditorApplicationClass NodeEditorApplicationClass;
GType node_editor_application_get_type (void);
NodeEditorApplication *node_editor_application_new (void);
#endif /* __NODE_EDITOR_APPLICATION_H__ */

View File

@@ -17,8 +17,7 @@
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __NODE_EDITOR_WINDOW_H__
#define __NODE_EDITOR_WINDOW_H__
#pragma once
#include <gtk/gtk.h>
@@ -38,5 +37,3 @@ NodeEditorWindow * node_editor_window_new (NodeEditorApplication
gboolean node_editor_window_load (NodeEditorWindow *self,
GFile *file);
#endif /* __NODE_EDITOR_WINDOW_H__ */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M3.384 3h3.231c.213 0 .385.224.385.502v2.996C7 6.776 6.828 7 6.615 7h-3.23C3.17 7 3 6.776 3 6.498V3.502C3 3.224 3.17 3 3.384 3zm6 0h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C9.17 7 9 6.776 9 6.498V3.502C9 3.224 9.17 3 9.384 3zm-6 6h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C3.17 13 3 12.776 3 12.498V9.502C3 9.224 3.17 9 3.384 9zm6 0h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C9.17 13 9 12.776 9 12.498V9.502C9 9.224 9.17 9 9.384 9z" style="marker:none" overflow="visible" color="#000" fill="#474747"/></svg>

Before

Width:  |  Height:  |  Size: 654 B

View File

@@ -25,14 +25,12 @@
<file>icons/16x16/actions/format-justify-fill-symbolic.symbolic.png</file>
<file>icons/16x16/actions/format-justify-left-symbolic.symbolic.png</file>
<file>icons/16x16/actions/format-justify-right-symbolic.symbolic.png</file>
<file>icons/16x16/actions/insert-image.png</file>
<file>icons/16x16/actions/insert-link-symbolic.symbolic.png</file>
<file>icons/16x16/actions/send-to-symbolic.symbolic.png</file>
<file>icons/16x16/actions/star-new-symbolic.symbolic.png</file>
<file>icons/16x16/actions/view-continuous-symbolic.symbolic.png</file>
<file>icons/16x16/actions/view-dual-symbolic.symbolic.png</file>
<file>icons/16x16/actions/view-fullscreen-symbolic.symbolic.png</file>
<file>icons/16x16/actions/view-grid-symbolic.symbolic.png</file>
<file>icons/16x16/actions/view-paged-symbolic.symbolic.png</file>
<file>icons/16x16/actions/zoom-in-symbolic.symbolic.png</file>
<file>icons/16x16/actions/zoom-in.png</file>
@@ -88,7 +86,6 @@
<file>icons/scalable/actions/view-dual-symbolic.svg</file>
<file>icons/scalable/actions/view-paged-symbolic.svg</file>
<file>icons/scalable/actions/view-fullscreen-symbolic.svg</file>
<file>icons/scalable/actions/view-grid-symbolic.svg</file>
<file>icons/scalable/actions/zoom-in-symbolic.svg</file>
<file>icons/scalable/actions/zoom-original-symbolic.svg</file>
<file>icons/scalable/actions/zoom-out-symbolic.svg</file>

View File

@@ -685,6 +685,8 @@ stack-allocated using `g_newa()` or `g_alloca()`. But limit the amount
of stack memory that you consume this way, in particular in recursive
functions.
On Windows, the default stack size we have to work with is 1M.
### Macros
Try to avoid private macros unless strictly necessary. Remember to #undef

View File

@@ -1,6 +1,4 @@
----
Title: Cairo interaction
----
## Functions to support using cairo

View File

@@ -107,4 +107,5 @@ content_images = [
"images/popup-flip.png",
"images/popup-slide.png",
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gdk/"
urlmap_file = "urlmap.js"

View File

@@ -1,4 +1,4 @@
Title: Key Values
Title: Keyboard Codes, Groups, And Modifiers
## Functions for manipulating keyboard codes
@@ -8,19 +8,19 @@ The complete list of key values can be found in the [`gdk/gdkkeysyms.h`](https:/
file.
Key values are regularly updated from the upstream X.org X11 implementation,
so new values are added regularly. They will be prefixed with GDK_KEY_ rather
than XF86XK_ or XK_ (for older symbols).
so new values are added regularly. They will be prefixed with `GDK_KEY_` rather
than `XF86XK_` or `XK_` (for older symbols).
Key values can be converted into a string representation using
gdk_keyval_name(). The reverse function, converting a string to a key value,
is provided by gdk_keyval_from_name().
[`func@Gdk.keyval_name`]. The reverse function, converting a string to a key
value, is provided by [`func@Gdk.keyval_from_name`].
The case of key values can be determined using gdk_keyval_is_upper() and
gdk_keyval_is_lower(). Key values can be converted to upper or lower case
using gdk_keyval_to_upper() and gdk_keyval_to_lower().
The case of key values can be determined using [`func@Gdk.keyval_is_upper`]
and [`func@Gdk.keyval_is_lower`]. Key values can be converted to upper or lower
case using [`func@Gdk.keyval_to_upper`] and [`func@Gdk.keyval_to_lower`].
When it makes sense, key values can be converted to and from
Unicode characters with gdk_keyval_to_unicode() and gdk_unicode_to_keyval().
When it makes sense, key values can be converted to and from Unicode characters
with [`func@Gdk.keyval_to_unicode`] and [`func@Gdk.unicode_to_keyval`].
## Key groups
@@ -36,23 +36,23 @@ You can think of a [struct@Gdk.KeymapKey] as a representation of a symbol
printed on a physical keyboard key. That is, it contains three pieces of
information:
1. first, it contains the hardware keycode; this is an identifying number
for a physical key
1. second, it contains the “level” of the key. The level indicates which
symbol on the key will be used, in a vertical direction. So on a standard
US keyboard, the key with the number “1“ on it also has the exclamation
point (”!”) character on it. The level indicates whether to use the “1”
or the “!” symbol. The letter keys are considered to have a lowercase
letter at level 0, and an uppercase letter at level 1, though normally
only the uppercase letter is printed on the key
1. third, the [struct@Gdk.KeymapKey] contains a group; groups are not used on
standard US keyboards, but are used in many other countries. On a
keyboard with groups, there can be 3 or 4 symbols printed on a single
key. The group indicates movement in a horizontal direction. Usually
groups are used for two different languages. In group 0, a key might
have two English characters, and in group 1 it might have two Hebrew
characters. The Hebrew characters will be printed on the key next to
the English characters.
1. first, it contains the hardware keycode; this is an identifying number
for a physical key
1. second, it contains the “level” of the key. The level indicates which
symbol on the key will be used, in a vertical direction. So on a standard
US keyboard, the key with the number “1“ on it also has the exclamation
point (”!”) character on it. The level indicates whether to use the “1”
or the “!” symbol. The letter keys are considered to have a lowercase
letter at level 0, and an uppercase letter at level 1, though normally
only the uppercase letter is printed on the key
1. third, the [struct@Gdk.KeymapKey] contains a group; groups are not used on
standard US keyboards, but are used in many other countries. On a
keyboard with groups, there can be 3 or 4 symbols printed on a single
key. The group indicates movement in a horizontal direction. Usually
groups are used for two different languages. In group 0, a key might
have two English characters, and in group 1 it might have two Hebrew
characters. The Hebrew characters will be printed on the key next to
the English characters.
When GDK creates a key event in order to deliver a key press or release,
it first converts the current keyboard state into an effective group and
@@ -72,7 +72,7 @@ in the key event and can be obtained via [class@Gdk.KeyEvent] getters.
### Consumed modifiers
The `consumed_modifiers` in a key event are modifiers that should be masked
out from @state when comparing this key press to a hot key. For instance,
out from `@state` when comparing this key press to a hot key. For instance,
on a US keyboard, the `plus` symbol is shifted, so when comparing a key
press to a `<Control>plus` accelerator `<Shift>` should be masked out.
@@ -91,9 +91,8 @@ if (keyval == GDK_PLUS &&
```
An older interpretation of `consumed_modifiers` was that it contained
all modifiers that might affect the translation of the key;
this allowed accelerators to be stored with irrelevant consumed
modifiers, by doing:
all modifiers that might affect the translation of the key; this allowed
accelerators to be stored with irrelevant consumed modifiers, by doing:
```c
// XXX Dont do this XXX
@@ -102,12 +101,11 @@ if (keyval == accel_keyval &&
// Accelerator was pressed
```
However, this did not work if multi-modifier combinations were
used in the keymap, since, for instance, `<Control>` would be
masked out even if only `<Control><Alt>` was used in
the keymap. To support this usage as well as well as possible, all single
modifier combinations that could affect the key for any combination
of modifiers will be returned in `consumed_modifiers`; multi-modifier
combinations are returned only when actually found in `state`. When
you store accelerators, you should always store them with consumed
However, this did not work if multi-modifier combinations were used in the
keymap, since, for instance, `<Control>` would be masked out even if only
`<Control><Alt>` was used in the keymap. To support this usage as well as
well as possible, all single modifier combinations that could affect the key
for any combination of modifiers will be returned in `consumed_modifiers`;
multi-modifier combinations are returned only when actually found in `state`.
When you store accelerators, you should always store them with consumed
modifiers removed. Store `<Control>plus`, not `<Control><Shift>plus`.

View File

@@ -1,4 +1,4 @@
Title: Pango Interaction
Title: Pango Interaction
Pango is the text layout system used by GDK and GTK. The functions
and types in this section are used to obtain clip regions for

View File

@@ -62,4 +62,5 @@ content_images = [
"images/stroke-miter.png",
"images/stroke-round.png",
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gsk/"
urlmap_file = "urlmap.js"

View File

@@ -1,8 +1,6 @@
Title: Compiling the GTK Libraries
Title: Building GTK
Slug: gtk-building
## Building GTK
Before we get into the details of how to compile GTK, we should
mention that in many cases, binary packages of GTK prebuilt for
your operating system will be available, either from your

View File

@@ -1,8 +1,6 @@
Title: Coordinate systems
Title: Coordinate systems in GTK
Slug: gtk-coordinates
## Coordinate systems in GTK
All coordinate systems in GTK have the origin at the top left, with the X axis
pointing right, and the Y axis pointing down. This matches the convention used
in X11, Wayland and cairo, but differs from OpenGL and PostScript, where the origin

View File

@@ -41,7 +41,7 @@ activate (GtkApplication* app,
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
gtk_widget_show (window);
gtk_window_present (GTK_WINDOW (window));
}
int
@@ -183,7 +183,7 @@ activate (GtkApplication *app,
gtk_box_append (GTK_BOX (box), button);
gtk_widget_show (window);
gtk_window_present (GTK_WINDOW (window));
}
int
@@ -331,8 +331,7 @@ activate (GtkApplication *app,
*/
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);
gtk_widget_show (window);
gtk_window_present (GTK_WINDOW (window));
}
int
@@ -554,7 +553,7 @@ activate (GtkApplication *app,
g_signal_connect (press, "pressed", G_CALLBACK (pressed), drawing_area);
gtk_widget_show (window);
gtk_window_present (GTK_WINDOW (window));
}
int
@@ -631,7 +630,7 @@ activate (GtkApplication *app,
button = gtk_builder_get_object (builder, "quit");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
gtk_widget_show (GTK_WIDGET (window));
gtk_widget_set_visible (GTK_WIDGET (window), TRUE);
/* We do not need the builder any more */
g_object_unref (builder);

View File

@@ -35,6 +35,11 @@ Showing
The ``show`` command displays the rendernode.
``--undecorated``
Removes window decorations. This is meant for rendering of exactly the rendernode
without any titlebar.
Rendering
^^^^^^^^^

View File

@@ -245,4 +245,5 @@ content_images = [
"images/box-model-light.png",
"images/box-model-dark.png",
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/"
urlmap_file = "urlmap.js"

View File

@@ -1,8 +1,6 @@
----
Title: Initialization
----
Title: Initializing GTK
# Library initialization and main loop
## Library initialization and main loop
Before using GTK, you need to initialize it using [func@Gtk.init]; this
connects to the windowing system, sets up the locale and performs other
@@ -49,7 +47,7 @@ main (int argc, char **argv)
// ...
// Show the application window
gtk_widget_show (window);
gtk_window_present (GTK_WINDOW (window));
// Enter the main event loop, and wait for user interaction
while (!done)
@@ -66,5 +64,5 @@ as spinning the main loop.
### See also
- the GLib manual, especially `GMainLoop`
- signal-related functions, such as `g_signal_connect()` in GObject
- the GLib manual, especially `GMainLoop`
- signal-related functions, such as `g_signal_connect()` in GObject

View File

@@ -2,5 +2,6 @@ Title: Migrating from GTK 2.x to GTK 4
Slug: gtk-migrating-2-to-4
If your application is still using GTK 2, you should first convert it to GTK 3,
by following the [migration guide](https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html)
in the GTK 3 documentation, and then follow [these instructions](#gtk-migrating-3-to-4).
by following the [migration guide](https://docs.gtk.org/gtk3/migrating-2to3.html)
in the GTK 3 documentation, and then follow [the GTK 3 to 4 migration
guide](migrating-3to4.html).

View File

@@ -31,10 +31,11 @@ for GTK, available on GitLab.
If you want to discuss your approach before or after working on it,
good ways to contact the GTK developers, apart from GitLab issues,
are
are:
- the #gtk IRC channel on irc.gnome.org
- the gtk tag on the [GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
- the `#gtk:gnome.org` Matrix room
- the `#gtk` IRC channel on `irc.libera.chat`
You should not send patches by email, as they will inevitably get lost,
or forgotten. Always open a merge request.

View File

@@ -206,10 +206,10 @@ are only available when GTK has been configured with `-Ddebug=true`.
`dmabuf`
: Information about dmabuf handling (Linux-only)
A number of options affect behavior instead of logging:
`offload`
: Information about subsurfaces and graphics offload (Wayland-only)
`nograbs`
: Turn off all pointer and keyboard grabs
A number of options affect behavior instead of logging:
`portals`
: Force the use of [portals](https://docs.flatpak.org/en/latest/portals.html)
@@ -226,11 +226,14 @@ A number of options affect behavior instead of logging:
`gl-debug`
: Insert debugging information in OpenGL
`gl-legacy`
: Use a legacy OpenGL context
`gl-disable-gl`
: Don't allow the use of OpenGL GL API. This forces GLES to be used
`gl-gles`
: Use a GLES OpenGL context
`gl-disable-gles`
: Don't allow the use of OpenGL GLES API. This forces GL to be used
`gl-prefer-gl`
: Prefer OpenGL over OpenGL ES. This was the default behavior before GTK 4.14.
`gl-egl`
: Use an EGL context on X11 or Windows
@@ -306,6 +309,9 @@ A number of options affect behavior instead of logging:
`sync`
: Sync after each frame
`offload-disable`
: Disable graphics offload to subsurfaces
`vulkan-staging-image`
: Use a staging image for Vulkan texture upload

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -8,6 +7,3 @@
G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPPREFS_H
#define __EXAMPLEAPPPREFS_H
#pragma once
#include <gtk/gtk.h>
#include "exampleappwin.h"
@@ -10,6 +9,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
#endif /* __EXAMPLEAPPPREFS_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPPREFS_H
#define __EXAMPLEAPPPREFS_H
#pragma once
#include <gtk/gtk.h>
#include "exampleappwin.h"
@@ -10,6 +9,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
#endif /* __EXAMPLEAPPPREFS_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPPREFS_H
#define __EXAMPLEAPPPREFS_H
#pragma once
#include <gtk/gtk.h>
#include "exampleappwin.h"
@@ -10,6 +9,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
#endif /* __EXAMPLEAPPPREFS_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPP_H
#define __EXAMPLEAPP_H
#pragma once
#include <gtk/gtk.h>
@@ -9,6 +8,3 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
ExampleApp *example_app_new (void);
#endif /* __EXAMPLEAPP_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPPREFS_H
#define __EXAMPLEAPPPREFS_H
#pragma once
#include <gtk/gtk.h>
#include "exampleappwin.h"
@@ -10,6 +9,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
#endif /* __EXAMPLEAPPPREFS_H */

View File

@@ -1,5 +1,4 @@
#ifndef __EXAMPLEAPPWIN_H
#define __EXAMPLEAPPWIN_H
#pragma once
#include <gtk/gtk.h>
#include "exampleapp.h"
@@ -12,6 +11,3 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
ExampleAppWindow *example_app_window_new (ExampleApp *app);
void example_app_window_open (ExampleAppWindow *win,
GFile *file);
#endif /* __EXAMPLEAPPWIN_H */

View File

@@ -209,13 +209,11 @@ _gdk_broadway_roundtrip_notify (GdkSurface *surface,
timings->complete = TRUE;
#ifdef G_ENABLE_DEBUG
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
_gdk_frame_clock_debug_print_timings (clock, timings);
if (GDK_PROFILER_IS_RUNNING)
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
#endif
}
}

View File

@@ -369,14 +369,12 @@ portal_file_serializer (GdkContentSerializer *serializer)
GDK_DEBUG (DND, "file transfer portal: Adding %s", g_file_peek_path (file));
g_ptr_array_add (files, g_file_get_path (file));
}
#ifdef G_ENABLE_DEBUG
else if (GDK_DEBUG_CHECK (DND))
{
char *uri = g_file_get_uri (file);
gdk_debug_message ("file transfer portal: %s has no path, dropping\n", uri);
g_free (uri);
}
#endif
g_ptr_array_add (files, NULL);
}
@@ -426,14 +424,12 @@ portal_finish (GObject *object,
return;
}
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (DND))
{
char *s = g_strjoinv (", ", files);
gdk_debug_message ("file transfer portal: Receiving files: %s", s);
g_free (s);
}
#endif
value = gdk_content_deserializer_get_value (deserializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))

View File

@@ -118,24 +118,25 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "selection", GDK_DEBUG_SELECTION, "Information about selections" },
{ "clipboard", GDK_DEBUG_CLIPBOARD, "Information about clipboards" },
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
{ "nograbs", GDK_DEBUG_NOGRABS, "Disable pointer and keyboard grabs (X11)", TRUE },
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals", TRUE },
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals", TRUE },
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support", TRUE },
{ "gl-fractional", GDK_DEBUG_GL_FRACTIONAL, "Enable fractional scaling for OpenGL (experimental)", TRUE },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL", TRUE },
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context", TRUE },
{ "gl-gles", GDK_DEBUG_GL_GLES, "Only allow OpenGL GLES API", TRUE },
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows", TRUE },
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11", TRUE },
{ "gl-wgl", GDK_DEBUG_GL_WGL, "Use WGL on Windows", TRUE },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support", TRUE },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer", TRUE },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings", TRUE },
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible", TRUE },
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)", TRUE },
{ "dmabuf-disable", GDK_DEBUG_DMABUF_DISABLE, "Disable dmabuf support", TRUE },
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
{ "gl-fractional", GDK_DEBUG_GL_FRACTIONAL, "Enable fractional scaling for OpenGL (experimental)" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
{ "gl-disable-gl", GDK_DEBUG_GL_DISABLE_GL, "Only allow OpenGL GLES API" },
{ "gl-disable-gles", GDK_DEBUG_GL_DISABLE_GLES, "Don't allow OpenGL GLES API" },
{ "gl-prefer-gl", GDK_DEBUG_GL_PREFER_GL, "Prefer GL over GLES API" },
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows" },
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
{ "gl-wgl", GDK_DEBUG_GL_WGL, "Use WGL on Windows" },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible" },
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)" },
{ "dmabuf-disable", GDK_DEBUG_DMABUF_DISABLE, "Disable dmabuf support" },
};
@@ -196,13 +197,6 @@ gdk_parse_debug_var (const char *variable,
const char *q;
gboolean invert;
gboolean help;
gboolean debug_enabled;
#ifdef G_ENABLE_DEBUG
debug_enabled = TRUE;
#else
debug_enabled = FALSE;
#endif
string = g_getenv (variable);
if (string == NULL)
@@ -234,12 +228,6 @@ gdk_parse_debug_var (const char *variable,
if (strlen (keys[i].key) == q - p &&
g_ascii_strncasecmp (keys[i].key, p, q - p) == 0)
{
if (!debug_enabled && !keys[i].always_enabled)
{
fprintf (stderr, "\"%s\" is only available when building GTK with G_ENABLE_DEBUG. See %s=help\n",
val, variable);
break;
}
result |= keys[i].value;
break;
}
@@ -263,8 +251,7 @@ gdk_parse_debug_var (const char *variable,
fprintf (stderr, "Supported %s values:\n", variable);
for (i = 0; i < nkeys; i++) {
if (debug_enabled || keys[i].always_enabled)
fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
}
fprintf (stderr, " %s%*s%s\n", "all", max_width - 3, " ", "Enable all values. Other given values are subtracted");
fprintf (stderr, " %s%*s%s\n", "help", max_width - 4, " ", "Print this help");
@@ -277,8 +264,7 @@ gdk_parse_debug_var (const char *variable,
for (i = 0; i < nkeys; i++)
{
if (debug_enabled || keys[i].always_enabled)
all_flags |= keys[i].value;
all_flags |= keys[i].value;
}
result = all_flags & (~result);

View File

@@ -37,25 +37,27 @@ typedef enum {
GDK_DEBUG_SELECTION = 1 << 9,
GDK_DEBUG_CLIPBOARD = 1 << 10,
GDK_DEBUG_DMABUF = 1 << 11,
GDK_DEBUG_OFFLOAD = 1 << 12,
/* flags below are influencing behavior */
GDK_DEBUG_NOGRABS = 1 << 12,
GDK_DEBUG_PORTALS = 1 << 13,
GDK_DEBUG_NO_PORTALS = 1 << 14,
GDK_DEBUG_GL_DISABLE = 1 << 15,
GDK_DEBUG_GL_FRACTIONAL = 1 << 16,
GDK_DEBUG_GL_LEGACY = 1 << 17,
GDK_DEBUG_GL_GLES = 1 << 18,
GDK_DEBUG_GL_DEBUG = 1 << 19,
GDK_DEBUG_GL_EGL = 1 << 20,
GDK_DEBUG_GL_GLX = 1 << 21,
GDK_DEBUG_GL_WGL = 1 << 22,
GDK_DEBUG_VULKAN_DISABLE = 1 << 23,
GDK_DEBUG_VULKAN_VALIDATE = 1 << 24,
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 25,
GDK_DEBUG_HIGH_DEPTH = 1 << 26,
GDK_DEBUG_NO_VSYNC = 1 << 27,
GDK_DEBUG_DMABUF_DISABLE = 1 << 28,
GDK_DEBUG_PORTALS = 1 << 14,
GDK_DEBUG_NO_PORTALS = 1 << 15,
GDK_DEBUG_GL_DISABLE = 1 << 16,
GDK_DEBUG_GL_FRACTIONAL = 1 << 17,
GDK_DEBUG_GL_DISABLE_GL = 1 << 19,
GDK_DEBUG_GL_DISABLE_GLES = 1 << 20,
GDK_DEBUG_GL_PREFER_GL = 1 << 21,
GDK_DEBUG_GL_DEBUG = 1 << 22,
GDK_DEBUG_GL_EGL = 1 << 23,
GDK_DEBUG_GL_GLX = 1 << 24,
GDK_DEBUG_GL_WGL = 1 << 25,
GDK_DEBUG_VULKAN_DISABLE = 1 << 26,
GDK_DEBUG_VULKAN_VALIDATE = 1 << 27,
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 28,
GDK_DEBUG_HIGH_DEPTH = 1 << 29,
GDK_DEBUG_NO_VSYNC = 1 << 30,
GDK_DEBUG_DMABUF_DISABLE = 1 << 31,
} GdkDebugFlags;
extern guint _gdk_debug_flags;
@@ -64,13 +66,24 @@ GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
void gdk_display_set_debug_flags (GdkDisplay *display,
GdkDebugFlags flags);
#ifdef GLIB_USING_SYSTEM_PRINTF
#define gdk_debug_message(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
#else
#define gdk_debug_message(format, ...) g_fprintf (stderr, format "\n", ##__VA_ARGS__)
#endif
static inline void
gdk_debug_message (const char *format, ...) G_GNUC_PRINTF(1, 2);
static inline void
gdk_debug_message (const char *format, ...)
{
va_list args;
char *s;
#ifdef G_ENABLE_DEBUG
va_start (args, format);
s = g_strdup_vprintf (format, args);
va_end (args);
#ifdef GLIB_USING_SYSTEM_PRINTF
fprintf (stderr, "%s\n", s);
#else
g_fprintf (stderr, "%s\n", s);
#endif
g_free (s);
}
#define GDK_DISPLAY_DEBUG_CHECK(display,type) \
G_UNLIKELY (gdk_display_get_debug_flags (display) & GDK_DEBUG_##type)
@@ -81,13 +94,6 @@ void gdk_display_set_debug_flags (GdkDisplay *display,
gdk_debug_message (__VA_ARGS__); \
} G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GDK_DISPLAY_DEBUG_CHECK(display,type) 0
#define GDK_DISPLAY_DEBUG(display,type,...)
#endif /* G_ENABLE_DEBUG */
#define GDK_DEBUG_CHECK(type) GDK_DISPLAY_DEBUG_CHECK (NULL,type)
#define GDK_DEBUG(type,...) GDK_DISPLAY_DEBUG (NULL,type,__VA_ARGS__)
@@ -96,7 +102,6 @@ typedef struct
const char *key;
guint value;
const char *help;
gboolean always_enabled;
} GdkDebugKey;
guint gdk_parse_debug_var (const char *variable,

View File

@@ -31,6 +31,7 @@
#include "gdkclipboardprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkdmabufeglprivate.h"
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabufformatsprivate.h"
#include "gdkdmabuftextureprivate.h"
@@ -44,6 +45,11 @@
#ifdef HAVE_EGL
#include <epoxy/egl.h>
#endif
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <math.h>
#include <stdlib.h>
@@ -386,12 +392,22 @@ gdk_display_dispose (GObject *object)
{
GdkDisplay *display = GDK_DISPLAY (object);
GdkDisplayPrivate *priv = gdk_display_get_instance_private (display);
gsize i;
for (i = 0; i < G_N_ELEMENTS (display->dmabuf_downloaders); i++)
{
if (display->dmabuf_downloaders[i] == NULL)
continue;
gdk_dmabuf_downloader_close (display->dmabuf_downloaders[i]);
g_clear_object (&display->dmabuf_downloaders[i]);
}
_gdk_display_manager_remove_display (gdk_display_manager_get (), display);
g_queue_clear (&display->queued_events);
g_clear_object (&display->egl_gsk_renderer);
g_clear_pointer (&display->egl_dmabuf_formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&display->egl_external_formats, gdk_dmabuf_formats_unref);
g_clear_object (&priv->gl_context);
@@ -1427,7 +1443,6 @@ gdk_display_get_gl_context (GdkDisplay *self)
}
#ifdef HAVE_EGL
#ifdef G_ENABLE_DEBUG
static int
strvcmp (gconstpointer p1,
gconstpointer p2)
@@ -1484,7 +1499,6 @@ describe_egl_config (EGLDisplay egl_display,
return g_strdup_printf ("R%dG%dB%dA%d%s", red, green, blue, alpha, type == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT ? "" : " float");
}
#endif
gpointer
gdk_display_get_egl_config (GdkDisplay *self)
@@ -1688,6 +1702,23 @@ gdk_display_check_egl_extensions (EGLDisplay egl_display,
return TRUE;
}
static const char *
find_egl_device (EGLDisplay egl_display)
{
EGLAttrib value;
EGLDeviceEXT egl_device;
eglQueryDisplayAttribEXT (egl_display, EGL_DEVICE_EXT, &value);
egl_device = (EGLDeviceEXT)value;
#ifndef EGL_DRM_RENDER_NODE_FILE_EXT
#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377
#endif
return eglQueryDeviceStringEXT (egl_device, EGL_DRM_RENDER_NODE_FILE_EXT);
}
gboolean
gdk_display_init_egl (GdkDisplay *self,
int platform,
@@ -1785,15 +1816,22 @@ gdk_display_init_egl (GdkDisplay *self,
if (priv->egl_config_high_depth == NULL)
priv->egl_config_high_depth = priv->egl_config;
#ifdef G_ENABLE_DEBUG
if (GDK_DISPLAY_DEBUG_CHECK (self, OPENGL))
{
char *ext = describe_extensions (priv->egl_display);
char *std_cfg = describe_egl_config (priv->egl_display, priv->egl_config);
char *hd_cfg = describe_egl_config (priv->egl_display, priv->egl_config_high_depth);
const char *path;
struct stat buf = { .st_rdev = 0, };
path = find_egl_device (priv->egl_display);
if (path)
stat (path, &buf);
gdk_debug_message ("EGL API version %d.%d found\n"
" - Vendor: %s\n"
" - Version: %s\n"
" - Device: %s, %d %d\n"
" - Client APIs: %s\n"
" - Extensions:\n"
"\t%s\n"
@@ -1802,6 +1840,12 @@ gdk_display_init_egl (GdkDisplay *self,
major, minor,
eglQueryString (priv->egl_display, EGL_VENDOR),
eglQueryString (priv->egl_display, EGL_VERSION),
path ? path : "unknown",
#ifdef HAVE_SYS_SYSMACROS_H
major (buf.st_rdev), minor (buf.st_rdev),
#else
0, 0,
#endif
eglQueryString (priv->egl_display, EGL_CLIENT_APIS),
ext, std_cfg,
priv->egl_config_high_depth == priv->egl_config ? "none" : hd_cfg);
@@ -1809,7 +1853,6 @@ gdk_display_init_egl (GdkDisplay *self,
g_free (std_cfg);
g_free (ext);
}
#endif
gdk_profiler_end_mark (start_time, "init EGL", NULL);
@@ -1848,13 +1891,12 @@ gdk_display_get_egl_display (GdkDisplay *self)
#ifdef HAVE_DMABUF
static void
gdk_display_add_dmabuf_downloader (GdkDisplay *display,
const GdkDmabufDownloader *downloader,
GdkDmabufFormatsBuilder *builder)
gdk_display_add_dmabuf_downloader (GdkDisplay *display,
GdkDmabufDownloader *downloader)
{
gsize i;
if (!downloader->add_formats (downloader, display, builder))
if (downloader == NULL)
return;
/* dmabuf_downloaders is NULL-terminated */
@@ -1864,7 +1906,7 @@ gdk_display_add_dmabuf_downloader (GdkDisplay *display,
break;
}
g_assert (i < G_N_ELEMENTS (display->dmabuf_downloaders));
g_assert (i < G_N_ELEMENTS (display->dmabuf_downloaders) - 1);
display->dmabuf_downloaders[i] = downloader;
}
@@ -1888,16 +1930,16 @@ gdk_display_init_dmabuf (GdkDisplay *self)
builder = gdk_dmabuf_formats_builder_new ();
#ifdef HAVE_DMABUF
if (!GDK_DEBUG_CHECK (DMABUF_DISABLE))
if (!GDK_DISPLAY_DEBUG_CHECK (self, DMABUF_DISABLE))
{
gdk_display_prepare_gl (self, NULL);
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_direct_downloader (), builder);
#ifdef HAVE_EGL
if (gdk_display_prepare_gl (self, NULL))
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (), builder);
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (self, builder));
#endif
gdk_dmabuf_formats_builder_add_formats (builder,
gdk_dmabuf_get_mmap_formats ());
}
#endif
@@ -1920,6 +1962,8 @@ gdk_display_init_dmabuf (GdkDisplay *self)
* The formats returned by this function can be used for negotiating
* buffer formats with producers such as v4l, pipewire or GStreamer.
*
* To learn more about dma-bufs, see [class@Gdk.DmabufTextureBuilder].
*
* Returns: (transfer none): a `GdkDmabufFormats` object
*
* Since: 4.14

View File

@@ -26,6 +26,7 @@
#include "gdkkeysprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkdmabufdownloaderprivate.h"
#ifdef GDK_RENDERING_VULKAN
#include <vulkan/vulkan.h>
@@ -118,10 +119,10 @@ struct _GdkDisplay
guint have_egl_dma_buf_export : 1;
GdkDmabufFormats *dmabuf_formats;
const GdkDmabufDownloader *dmabuf_downloaders[4];
GdkDmabufDownloader *dmabuf_downloaders[4];
/* Cached data the EGL dmabuf downloader */
gpointer egl_gsk_renderer;
GdkDmabufFormats *egl_dmabuf_formats;
GdkDmabufFormats *egl_external_formats;
};

File diff suppressed because it is too large Load Diff

48
gdk/gdkdmabufdownloader.c Normal file
View File

@@ -0,0 +1,48 @@
#include "config.h"
#include "gdkdmabufdownloaderprivate.h"
G_DEFINE_INTERFACE (GdkDmabufDownloader, gdk_dmabuf_downloader, G_TYPE_OBJECT)
static void
gdk_dmabuf_downloader_default_init (GdkDmabufDownloaderInterface *iface)
{
}
void
gdk_dmabuf_downloader_close (GdkDmabufDownloader *self)
{
GdkDmabufDownloaderInterface *iface;
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
iface->close (self);
}
gboolean
gdk_dmabuf_downloader_supports (GdkDmabufDownloader *self,
GdkDmabufTexture *texture,
GError **error)
{
GdkDmabufDownloaderInterface *iface;
g_return_val_if_fail (GDK_IS_DMABUF_DOWNLOADER (self), FALSE);
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
return iface->supports (self, texture, error);
}
void
gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
guchar *data,
gsize stride)
{
GdkDmabufDownloaderInterface *iface;
g_return_if_fail (GDK_IS_DMABUF_DOWNLOADER (self));
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
iface->download (self, texture, format, data, stride);
}

View File

@@ -0,0 +1,39 @@
#pragma once
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_DMABUF_DOWNLOADER (gdk_dmabuf_downloader_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (GdkDmabufDownloader, gdk_dmabuf_downloader, GDK, DMABUF_DOWNLOADER, GObject)
struct _GdkDmabufDownloaderInterface
{
GTypeInterface g_iface;
void (* close) (GdkDmabufDownloader *downloader);
gboolean (* supports) (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GError **error);
void (* download) (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
guchar *data,
gsize stride);
};
void gdk_dmabuf_downloader_close (GdkDmabufDownloader *downloader);
gboolean gdk_dmabuf_downloader_supports (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GError **error);
void gdk_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
guchar *data,
gsize stride);
G_END_DECLS

View File

@@ -19,10 +19,11 @@
#include "config.h"
#if defined(HAVE_DMABUF) && defined (HAVE_EGL)
#include "gdkdmabufprivate.h"
#include "gdkdmabufeglprivate.h"
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdebugprivate.h"
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkdisplayprivate.h"
@@ -30,237 +31,106 @@
#include "gdktexturedownloader.h"
#include <graphene.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/dma-buf.h>
#include <drm_fourcc.h>
#include <epoxy/egl.h>
/* A dmabuf downloader implementation that downloads buffers via
* gsk_renderer_render_texture + GL texture download.
*/
static gboolean
gdk_dmabuf_egl_downloader_add_formats (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
GdkDmabufFormatsBuilder *builder)
gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
GdkDmabufFormatsBuilder *formats,
GdkDmabufFormatsBuilder *external)
{
GdkGLContext *context = gdk_display_get_gl_context (display);
EGLDisplay egl_display = gdk_display_get_egl_display (display);
GdkDmabufFormatsBuilder *external;
gboolean retval = FALSE;
g_assert (display->egl_external_formats == NULL);
external = gdk_dmabuf_formats_builder_new ();
gdk_gl_context_make_current (context);
if (egl_display != EGL_NO_DISPLAY &&
display->have_egl_dma_buf_import &&
gdk_gl_context_has_image_storage (context))
{
int num_fourccs;
int *fourccs;
guint64 *modifiers;
unsigned int *external_only;
int n_mods;
eglQueryDmaBufFormatsEXT (egl_display, 0, NULL, &num_fourccs);
fourccs = g_new (int, num_fourccs);
eglQueryDmaBufFormatsEXT (egl_display, num_fourccs, fourccs, &num_fourccs);
n_mods = 80;
modifiers = g_new (guint64, n_mods);
external_only = g_new (unsigned int, n_mods);
for (int i = 0; i < num_fourccs; i++)
{
int num_modifiers;
eglQueryDmaBufModifiersEXT (egl_display,
fourccs[i],
0,
NULL,
NULL,
&num_modifiers);
if (num_modifiers > n_mods)
{
n_mods = num_modifiers;
modifiers = g_renew (guint64, modifiers, n_mods);
external_only = g_renew (unsigned int, external_only, n_mods);
}
eglQueryDmaBufModifiersEXT (egl_display,
fourccs[i],
num_modifiers,
modifiers,
external_only,
&num_modifiers);
for (int j = 0; j < num_modifiers; j++)
{
/* All linear formats we support are already added my the mmap downloader.
* We don't add external formats, unless we can use them (via GLES)
*/
if (modifiers[j] != DRM_FORMAT_MOD_LINEAR &&
(!external_only[j] || gdk_gl_context_get_use_es (context)))
{
GDK_DEBUG (DMABUF, "%s%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
external_only[j] ? "external " : "",
downloader->name,
(char *) &fourccs[i],
modifiers[j]);
gdk_dmabuf_formats_builder_add_format (builder, fourccs[i], modifiers[j]);
}
if (external_only[j])
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
}
}
g_free (modifiers);
g_free (external_only);
g_free (fourccs);
retval = TRUE;
}
display->egl_external_formats = gdk_dmabuf_formats_builder_free_to_formats (external);
return retval;
}
static GdkMemoryFormat
get_memory_format (guint32 fourcc,
gboolean premultiplied)
{
switch (fourcc)
{
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_XRGB8888_A8:
case DRM_FORMAT_XBGR8888_A8:
return premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED : GDK_MEMORY_A8R8G8B8;
case DRM_FORMAT_RGBA8888:
case DRM_FORMAT_RGBX8888_A8:
return premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED : GDK_MEMORY_R8G8B8A8;
case DRM_FORMAT_BGRA8888:
return premultiplied ? GDK_MEMORY_B8G8R8A8_PREMULTIPLIED : GDK_MEMORY_B8G8R8A8;
case DRM_FORMAT_RGB888:
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_RGBX8888:
case DRM_FORMAT_BGRX8888:
return GDK_MEMORY_R8G8B8;
case DRM_FORMAT_BGR888:
return GDK_MEMORY_B8G8R8;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010:
case DRM_FORMAT_RGBX1010102:
case DRM_FORMAT_BGRX1010102:
case DRM_FORMAT_XRGB16161616:
case DRM_FORMAT_XBGR16161616:
return GDK_MEMORY_R16G16B16;
case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGBA1010102:
case DRM_FORMAT_BGRA1010102:
case DRM_FORMAT_ARGB16161616:
case DRM_FORMAT_ABGR16161616:
return premultiplied ? GDK_MEMORY_R16G16B16A16_PREMULTIPLIED : GDK_MEMORY_R16G16B16A16;
case DRM_FORMAT_ARGB16161616F:
case DRM_FORMAT_ABGR16161616F:
return premultiplied ? GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED : GDK_MEMORY_R16G16B16A16_FLOAT;
case DRM_FORMAT_XRGB16161616F:
case DRM_FORMAT_XBGR16161616F:
return GDK_MEMORY_R16G16B16_FLOAT;
case DRM_FORMAT_YUYV:
case DRM_FORMAT_YVYU:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_VYUY:
case DRM_FORMAT_XYUV8888:
#ifdef DRM_FORMAT_XVUY8888
case DRM_FORMAT_XVUY8888:
#endif
case DRM_FORMAT_VUY888:
return GDK_MEMORY_R8G8B8;
/* Add more formats here */
default:
return premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED : GDK_MEMORY_A8R8G8B8;
}
}
static gboolean
gdk_dmabuf_egl_downloader_supports (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
const GdkDmabuf *dmabuf,
gboolean premultiplied,
GdkMemoryFormat *out_format,
GError **error)
{
EGLDisplay egl_display;
GdkGLContext *context;
int num_modifiers;
int num_fourccs;
int *fourccs;
guint64 *modifiers;
unsigned int *external_only;
int n_mods;
egl_display = gdk_display_get_egl_display (display);
if (egl_display == EGL_NO_DISPLAY)
{
g_set_error_literal (error,
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT,
"EGL not available");
return FALSE;
}
context = gdk_display_get_gl_context (display);
if (egl_display == EGL_NO_DISPLAY ||
!display->have_egl_dma_buf_import)
return FALSE;
gdk_gl_context_make_current (context);
eglQueryDmaBufModifiersEXT (egl_display,
dmabuf->fourcc,
0,
NULL,
NULL,
&num_modifiers);
eglQueryDmaBufFormatsEXT (egl_display, 0, NULL, &num_fourccs);
fourccs = g_new (int, num_fourccs);
eglQueryDmaBufFormatsEXT (egl_display, num_fourccs, fourccs, &num_fourccs);
modifiers = g_newa (uint64_t, num_modifiers);
external_only = g_newa (unsigned int, num_modifiers);
n_mods = 80;
modifiers = g_new (guint64, n_mods);
external_only = g_new (unsigned int, n_mods);
eglQueryDmaBufModifiersEXT (egl_display,
dmabuf->fourcc,
num_modifiers,
modifiers,
external_only,
&num_modifiers);
for (int i = 0; i < num_modifiers; i++)
for (int i = 0; i < num_fourccs; i++)
{
if (modifiers[i] == dmabuf->modifier)
int num_modifiers;
gboolean all_external;
eglQueryDmaBufModifiersEXT (egl_display,
fourccs[i],
0,
NULL,
NULL,
&num_modifiers);
if (num_modifiers > n_mods)
{
*out_format = get_memory_format (dmabuf->fourcc, premultiplied);
return TRUE;
n_mods = num_modifiers;
modifiers = g_renew (guint64, modifiers, n_mods);
external_only = g_renew (unsigned int, external_only, n_mods);
}
eglQueryDmaBufModifiersEXT (egl_display,
fourccs[i],
num_modifiers,
modifiers,
external_only,
&num_modifiers);
all_external = TRUE;
for (int j = 0; j < num_modifiers; j++)
{
/* All linear formats we support are already added my the mmap downloader.
* We don't add external formats, unless we can use them (via GLES)
*/
if (modifiers[j] != DRM_FORMAT_MOD_LINEAR &&
(!external_only[j] || gdk_gl_context_get_use_es (context)))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"%s EGL dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
external_only[j] ? "external " : "",
(char *) &fourccs[i],
modifiers[j]);
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], modifiers[j]);
}
if (external_only[j])
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
else
all_external = FALSE;
}
/* Accept implicit modifiers as long as we accept the format at all.
* This is a bit of a crapshot, but unfortunately needed for a bunch
* of drivers.
*
* As an extra wrinkle, treat the implicit modifier as 'external only'
* if all formats with the same fourcc are 'external only'.
*/
if (!all_external || gdk_gl_context_get_use_es (context))
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], DRM_FORMAT_MOD_INVALID);
if (all_external)
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], DRM_FORMAT_MOD_INVALID);
}
g_set_error (error,
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT,
"Unsupported dmabuf format: %.4s:%#" G_GINT64_MODIFIER "x",
(char *) &dmabuf->fourcc, dmabuf->modifier);
g_free (modifiers);
g_free (external_only);
g_free (fourccs);
return FALSE;
return TRUE;
}
/* Hack. We don't include gsk/gsk.h here to avoid a build order problem
@@ -268,146 +138,138 @@ gdk_dmabuf_egl_downloader_supports (const GdkDmabufDownloader *downloader,
* a bit to access the gsk api we need.
*/
typedef gpointer GskRenderer;
typedef struct _GskRenderer GskRenderer;
extern GskRenderer * gsk_gl_renderer_new (void);
extern gboolean gsk_renderer_realize (GskRenderer *renderer,
GdkSurface *surface,
GError **error);
extern GdkTexture * gsk_renderer_convert_texture (GskRenderer *renderer,
GdkTexture *texture);
typedef void (* InvokeFunc) (gpointer data);
typedef struct _InvokeData
GdkDmabufDownloader *
gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
GdkDmabufFormatsBuilder *builder)
{
volatile int spinlock;
InvokeFunc func;
gpointer data;
} InvokeData;
GdkDmabufFormatsBuilder *formats;
GdkDmabufFormatsBuilder *external;
gboolean retval = FALSE;
GError *error = NULL;
GskRenderer *renderer;
static gboolean
gdk_dmabuf_egl_downloader_invoke_callback (gpointer data)
{
InvokeData *invoke = data;
GdkGLContext *previous;
g_assert (display->egl_dmabuf_formats == NULL);
g_assert (display->egl_external_formats == NULL);
previous = gdk_gl_context_get_current ();
if (!gdk_display_prepare_gl (display, NULL))
return NULL;
invoke->func (invoke->data);
formats = gdk_dmabuf_formats_builder_new ();
external = gdk_dmabuf_formats_builder_new ();
if (previous)
gdk_gl_context_make_current (previous);
else
gdk_gl_context_clear_current ();
retval = gdk_dmabuf_egl_downloader_collect_formats (display, formats, external);
g_atomic_int_set (&invoke->spinlock, 1);
display->egl_dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (formats);
display->egl_external_formats = gdk_dmabuf_formats_builder_free_to_formats (external);
return FALSE;
}
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_dmabuf_formats);
/* Run func in the main thread, taking care not to disturb
* the current GL context of the caller.
*/
static void
gdk_dmabuf_egl_downloader_run (InvokeFunc func,
gpointer data)
{
InvokeData invoke = { 0, func, data };
if (!retval)
return NULL;
g_main_context_invoke (NULL, gdk_dmabuf_egl_downloader_invoke_callback, &invoke);
renderer = gsk_gl_renderer_new ();
while (g_atomic_int_get (&invoke.spinlock) == 0) ;
}
typedef struct _Download Download;
struct _Download
{
GdkDmabufTexture *texture;
GdkMemoryFormat format;
guchar *data;
gsize stride;
};
static GskRenderer *
get_gsk_renderer (GdkDisplay *display)
{
if (!display->egl_gsk_renderer)
if (!gsk_renderer_realize (renderer, NULL, &error))
{
GskRenderer *renderer;
GError *error = NULL;
g_warning ("Failed to realize GL renderer: %s", error->message);
g_error_free (error);
g_object_unref (renderer);
renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (renderer, NULL, &error))
{
g_warning ("Failed to realize GL renderer: %s", error->message);
g_error_free (error);
g_object_unref (renderer);
return NULL;
}
display->egl_gsk_renderer = renderer;
return NULL;
}
return display->egl_gsk_renderer;
return GDK_DMABUF_DOWNLOADER (renderer);
}
static void
gdk_dmabuf_egl_downloader_do_download (gpointer data)
EGLImage
gdk_dmabuf_egl_create_image (GdkDisplay *display,
int width,
int height,
const GdkDmabuf *dmabuf,
int target)
{
Download *download = data;
GdkDisplay *display;
GskRenderer *renderer;
GdkTexture *native;
GdkTextureDownloader *downloader;
EGLDisplay egl_display = gdk_display_get_egl_display (display);
EGLint attribs[64];
int i;
EGLImage image;
display = gdk_dmabuf_texture_get_display (download->texture);
g_return_val_if_fail (width > 0, 0);
g_return_val_if_fail (height > 0, 0);
g_return_val_if_fail (1 <= dmabuf->n_planes && dmabuf->n_planes <= 4, 0);
g_return_val_if_fail (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES, 0);
renderer = get_gsk_renderer (display);
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_import)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import dmabufs into GL, missing EGL or EGL_EXT_image_dma_buf_import_modifiers");
return EGL_NO_IMAGE;
}
native = gsk_renderer_convert_texture (renderer, GDK_TEXTURE (download->texture));
GDK_DISPLAY_DEBUG (display, DMABUF,
"Importing dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %u) into GL",
(char *) &dmabuf->fourcc, dmabuf->modifier, dmabuf->n_planes);
downloader = gdk_texture_downloader_new (native);
gdk_texture_downloader_set_format (downloader, download->format);
gdk_texture_downloader_download_into (downloader, download->data, download->stride);
gdk_texture_downloader_free (downloader);
i = 0;
attribs[i++] = EGL_IMAGE_PRESERVED_KHR;
attribs[i++] = EGL_TRUE;
attribs[i++] = EGL_WIDTH;
attribs[i++] = width;
attribs[i++] = EGL_HEIGHT;
attribs[i++] = height;
attribs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[i++] = dmabuf->fourcc;
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[i++] = EGL_ITU_REC601_EXT;
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
g_object_unref (native);
}
#define ADD_PLANE(plane) \
{ \
if (dmabuf->modifier != DRM_FORMAT_MOD_INVALID) \
{ \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_MODIFIER_LO_EXT; \
attribs[i++] = dmabuf->modifier & 0xFFFFFFFF; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ## _MODIFIER_HI_EXT; \
attribs[i++] = dmabuf->modifier >> 32; \
} \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_FD_EXT; \
attribs[i++] = dmabuf->planes[plane].fd; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_PITCH_EXT; \
attribs[i++] = dmabuf->planes[plane].stride; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_OFFSET_EXT; \
attribs[i++] = dmabuf->planes[plane].offset; \
}
static void
gdk_dmabuf_egl_downloader_download (const GdkDmabufDownloader *downloader,
GdkTexture *texture,
GdkMemoryFormat format,
guchar *data,
gsize stride)
{
Download download;
ADD_PLANE (0);
GDK_DEBUG (DMABUF, "Using %s for downloading a dmabuf", downloader->name);
if (dmabuf->n_planes > 1) ADD_PLANE (1);
if (dmabuf->n_planes > 2) ADD_PLANE (2);
if (dmabuf->n_planes > 3) ADD_PLANE (3);
download.texture = GDK_DMABUF_TEXTURE (texture);
download.format = format;
download.data = data;
download.stride = stride;
attribs[i++] = EGL_NONE;
gdk_dmabuf_egl_downloader_run (gdk_dmabuf_egl_downloader_do_download, &download);
}
image = eglCreateImageKHR (egl_display,
EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
(EGLClientBuffer)NULL,
attribs);
const GdkDmabufDownloader *
gdk_dmabuf_get_egl_downloader (void)
{
static const GdkDmabufDownloader downloader = {
"egl",
gdk_dmabuf_egl_downloader_add_formats,
gdk_dmabuf_egl_downloader_supports,
gdk_dmabuf_egl_downloader_download,
};
if (image == EGL_NO_IMAGE)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating EGLImage for dmabuf failed: %#x",
eglGetError ());
return 0;
}
return &downloader;
return image;
}
#endif /* HAVE_DMABUF && HAVE_EGL */

18
gdk/gdkdmabufeglprivate.h Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
#if defined(HAVE_DMABUF) && defined (HAVE_EGL)
#include "gdkdmabufprivate.h"
#include "gdkdmabufdownloaderprivate.h"
#include <epoxy/egl.h>
GdkDmabufDownloader * gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
GdkDmabufFormatsBuilder *builder);
EGLImage gdk_dmabuf_egl_create_image (GdkDisplay *display,
int width,
int height,
const GdkDmabuf *dmabuf,
int target);
#endif /* HAVE_DMABUF && HAVE_EGL */

View File

@@ -37,6 +37,10 @@
* The list of supported formats is sorted by preference,
* with the best formats coming first.
*
* The list may contains (format, modfier) pairs where the modifier
* is `DMA_FORMAT_MOD_INVALID`, indicating that **_implicit modifiers_**
* may be used with this format.
*
* See [class@Gdk.DmabufTextureBuilder] for more information
* about DMA buffers.
*

View File

@@ -22,9 +22,6 @@
#include "gdkdmabufformatsprivate.h"
#ifdef HAVE_DMABUF
#include <drm_fourcc.h>
#endif
#define GDK_ARRAY_NAME gdk_dmabuf_formats_builder
#define GDK_ARRAY_TYPE_NAME GdkDmabufFormatsBuilder
@@ -121,12 +118,6 @@ gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint64 modifier)
{
#ifdef HAVE_DMABUF
g_return_if_fail (modifier != DRM_FORMAT_MOD_INVALID);
#else
g_return_if_reached ();
#endif
gdk_dmabuf_formats_builder_append (self, &(GdkDmabufFormat) { fourcc, modifier });
}

View File

@@ -0,0 +1,380 @@
#pragma once
#ifdef HAVE_DMABUF
#include <drm_fourcc.h>
#endif
#ifndef fourcc_code
#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
((__u32)(c) << 16) | ((__u32)(d) << 24))
#endif
#ifndef DRM_FORMAT_C1
#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ')
#endif
#ifndef DRM_FORMAT_C2
#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ')
#endif
#ifndef DRM_FORMAT_C4
#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ')
#endif
#ifndef DRM_FORMAT_C8
#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')
#endif
#ifndef DRM_FORMAT_D1
#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ')
#endif
#ifndef DRM_FORMAT_D2
#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ')
#endif
#ifndef DRM_FORMAT_D4
#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ')
#endif
#ifndef DRM_FORMAT_D8
#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ')
#endif
#ifndef DRM_FORMAT_R1
#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')
#endif
#ifndef DRM_FORMAT_R2
#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ')
#endif
#ifndef DRM_FORMAT_R4
#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ')
#endif
#ifndef DRM_FORMAT_R8
#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')
#endif
#ifndef DRM_FORMAT_R10
#define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ')
#endif
#ifndef DRM_FORMAT_R12
#define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ')
#endif
#ifndef DRM_FORMAT_R16
#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ')
#endif
#ifndef DRM_FORMAT_RG88
#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8')
#endif
#ifndef DRM_FORMAT_GR88
#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8')
#endif
#ifndef DRM_FORMAT_RG1616
#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2')
#endif
#ifndef DRM_FORMAT_GR1616
#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2')
#endif
#ifndef DRM_FORMAT_RGB332
#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8')
#endif
#ifndef DRM_FORMAT_BGR233
#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8')
#endif
#ifndef DRM_FORMAT_XRGB4444
#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2')
#endif
#ifndef DRM_FORMAT_XBGR4444
#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2')
#endif
#ifndef DRM_FORMAT_RGBX4444
#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2')
#endif
#ifndef DRM_FORMAT_BGRX4444
#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2')
#endif
#ifndef DRM_FORMAT_ARGB4444
#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2')
#endif
#ifndef DRM_FORMAT_ABGR4444
#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2')
#endif
#ifndef DRM_FORMAT_RGBA4444
#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2')
#endif
#ifndef DRM_FORMAT_BGRA4444
#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2')
#endif
#ifndef DRM_FORMAT_XRGB1555
#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5')
#endif
#ifndef DRM_FORMAT_XBGR1555
#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5')
#endif
#ifndef DRM_FORMAT_RGBX5551
#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5')
#endif
#ifndef DRM_FORMAT_BGRX5551
#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5')
#endif
#ifndef DRM_FORMAT_ARGB1555
#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5')
#endif
#ifndef DRM_FORMAT_ABGR1555
#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5')
#endif
#ifndef DRM_FORMAT_RGBA5551
#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5')
#endif
#ifndef DRM_FORMAT_BGRA5551
#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5')
#endif
#ifndef DRM_FORMAT_RGB565
#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6')
#endif
#ifndef DRM_FORMAT_BGR565
#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6')
#endif
#ifndef DRM_FORMAT_RGB888
#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4')
#endif
#ifndef DRM_FORMAT_BGR888
#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4')
#endif
#ifndef DRM_FORMAT_XRGB8888
#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4')
#endif
#ifndef DRM_FORMAT_XBGR8888
#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4')
#endif
#ifndef DRM_FORMAT_RGBX8888
#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4')
#endif
#ifndef DRM_FORMAT_BGRX8888
#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4')
#endif
#ifndef DRM_FORMAT_ARGB8888
#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4')
#endif
#ifndef DRM_FORMAT_ABGR8888
#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4')
#endif
#ifndef DRM_FORMAT_RGBA8888
#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4')
#endif
#ifndef DRM_FORMAT_BGRA8888
#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4')
#endif
#ifndef DRM_FORMAT_XRGB2101010
#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0')
#endif
#ifndef DRM_FORMAT_XBGR2101010
#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0')
#endif
#ifndef DRM_FORMAT_RGBX1010102
#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0')
#endif
#ifndef DRM_FORMAT_BGRX1010102
#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0')
#endif
#ifndef DRM_FORMAT_ARGB2101010
#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0')
#endif
#ifndef DRM_FORMAT_ABGR2101010
#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0')
#endif
#ifndef DRM_FORMAT_RGBA1010102
#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0')
#endif
#ifndef DRM_FORMAT_BGRA1010102
#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0')
#endif
#ifndef DRM_FORMAT_XRGB16161616
#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8')
#endif
#ifndef DRM_FORMAT_XBGR16161616
#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8')
#endif
#ifndef DRM_FORMAT_ARGB16161616
#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8')
#endif
#ifndef DRM_FORMAT_ABGR16161616
#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8')
#endif
#ifndef DRM_FORMAT_XRGB16161616F
#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H')
#endif
#ifndef DRM_FORMAT_XBGR16161616F
#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H')
#endif
#ifndef DRM_FORMAT_ARGB16161616F
#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H')
#endif
#ifndef DRM_FORMAT_ABGR16161616F
#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H')
#endif
#ifndef DRM_FORMAT_AXBXGXRX106106106106
#define DRM_FORMAT_AXBXGXRX106106106106 fourcc_code('A', 'B', '1', '0')
#endif
#ifndef DRM_FORMAT_YUYV
#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V')
#endif
#ifndef DRM_FORMAT_YVYU
#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U')
#endif
#ifndef DRM_FORMAT_UYVY
#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y')
#endif
#ifndef DRM_FORMAT_VYUY
#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y')
#endif
#ifndef DRM_FORMAT_AYUV
#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V')
#endif
#ifndef DRM_FORMAT_AVUY8888
#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y')
#endif
#ifndef DRM_FORMAT_XYUV8888
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V')
#endif
#ifndef DRM_FORMAT_XVUY8888
#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y')
#endif
#ifndef DRM_FORMAT_VUY888
#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4')
#endif
#ifndef DRM_FORMAT_VUY101010
#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0')
#endif
#ifndef DRM_FORMAT_Y210
#define DRM_FORMAT_Y210 fourcc_code('Y', '2', '1', '0')
#endif
#ifndef DRM_FORMAT_Y212
#define DRM_FORMAT_Y212 fourcc_code('Y', '2', '1', '2')
#endif
#ifndef DRM_FORMAT_Y216
#define DRM_FORMAT_Y216 fourcc_code('Y', '2', '1', '6')
#endif
#ifndef DRM_FORMAT_Y410
#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0')
#endif
#ifndef DRM_FORMAT_Y412
#define DRM_FORMAT_Y412 fourcc_code('Y', '4', '1', '2')
#endif
#ifndef DRM_FORMAT_Y416
#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6')
#endif
#ifndef DRM_FORMAT_XVYU2101010
#define DRM_FORMAT_XVYU2101010 fourcc_code('X', 'V', '3', '0')
#endif
#ifndef DRM_FORMAT_XVYU12_16161616
#define DRM_FORMAT_XVYU12_16161616 fourcc_code('X', 'V', '3', '6')
#endif
#ifndef DRM_FORMAT_XVYU16161616
#define DRM_FORMAT_XVYU16161616 fourcc_code('X', 'V', '4', '8')
#endif
#ifndef DRM_FORMAT_Y0L0
#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0')
#endif
#ifndef DRM_FORMAT_X0L0
#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0')
#endif
#ifndef DRM_FORMAT_Y0L2
#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2')
#endif
#ifndef DRM_FORMAT_X0L2
#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2')
#endif
#ifndef DRM_FORMAT_YUV420_8BIT
#define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8')
#endif
#ifndef DRM_FORMAT_YUV420_10BIT
#define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0')
#endif
#ifndef DRM_FORMAT_XRGB8888_A8
#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8')
#endif
#ifndef DRM_FORMAT_XBGR8888_A8
#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8')
#endif
#ifndef DRM_FORMAT_RGBX8888_A8
#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8')
#endif
#ifndef DRM_FORMAT_BGRX8888_A8
#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8')
#endif
#ifndef DRM_FORMAT_RGB888_A8
#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8')
#endif
#ifndef DRM_FORMAT_BGR888_A8
#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8')
#endif
#ifndef DRM_FORMAT_RGB565_A8
#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8')
#endif
#ifndef DRM_FORMAT_BGR565_A8
#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8')
#endif
#ifndef DRM_FORMAT_NV12
#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2')
#endif
#ifndef DRM_FORMAT_NV21
#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1')
#endif
#ifndef DRM_FORMAT_NV16
#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6')
#endif
#ifndef DRM_FORMAT_NV61
#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1')
#endif
#ifndef DRM_FORMAT_NV24
#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4')
#endif
#ifndef DRM_FORMAT_NV42
#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2')
#endif
#ifndef DRM_FORMAT_NV15
#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5')
#endif
#ifndef DRM_FORMAT_P210
#define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0')
#endif
#ifndef DRM_FORMAT_P010
#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0')
#endif
#ifndef DRM_FORMAT_P012
#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2')
#endif
#ifndef DRM_FORMAT_P016
#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6')
#endif
#ifndef DRM_FORMAT_P030
#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0')
#endif
#ifndef DRM_FORMAT_Q410
#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0')
#endif
#ifndef DRM_FORMAT_Q401
#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1')
#endif
#ifndef DRM_FORMAT_YUV410
#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9')
#endif
#ifndef DRM_FORMAT_YVU410
#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9')
#endif
#ifndef DRM_FORMAT_YUV411
#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1')
#endif
#ifndef DRM_FORMAT_YVU411
#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1')
#endif
#ifndef DRM_FORMAT_YUV420
#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2')
#endif
#ifndef DRM_FORMAT_YVU420
#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2')
#endif
#ifndef DRM_FORMAT_YUV422
#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6')
#endif
#ifndef DRM_FORMAT_YVU422
#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6')
#endif
#ifndef DRM_FORMAT_YUV444
#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4')
#endif
#ifndef DRM_FORMAT_YVU444
#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4')
#endif

View File

@@ -2,10 +2,13 @@
#include "gdkdmabufformatsbuilderprivate.h"
#ifdef GDK_RENDERING_VULKAN
#include <vulkan/vulkan.h>
#endif
#define GDK_DMABUF_MAX_PLANES 4
typedef struct _GdkDmabuf GdkDmabuf;
typedef struct _GdkDmabufDownloader GdkDmabufDownloader;
struct _GdkDmabuf
{
@@ -19,29 +22,23 @@ struct _GdkDmabuf
} planes[GDK_DMABUF_MAX_PLANES];
};
struct _GdkDmabufDownloader
{
const char *name;
gboolean (* add_formats) (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
GdkDmabufFormatsBuilder *builder);
gboolean (* supports) (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
const GdkDmabuf *dmabuf,
gboolean premultiplied,
GdkMemoryFormat *out_format,
GError **error);
void (* download) (const GdkDmabufDownloader *downloader,
GdkTexture *texture,
#ifdef HAVE_DMABUF
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
void gdk_dmabuf_download_mmap (GdkTexture *texture,
GdkMemoryFormat format,
guchar *data,
gsize stride);
};
#ifdef HAVE_DMABUF
const GdkDmabufDownloader * gdk_dmabuf_get_direct_downloader (void) G_GNUC_CONST;
const GdkDmabufDownloader * gdk_dmabuf_get_egl_downloader (void) G_GNUC_CONST;
int gdk_dmabuf_ioctl (int fd,
unsigned long request,
void *arg);
gboolean gdk_dmabuf_import_sync_file (int dmabuf_fd,
guint32 flags,
int sync_file_fd);
int gdk_dmabuf_export_sync_file (int dmabuf_fd,
guint32 flags);
gboolean gdk_dmabuf_sanitize (GdkDmabuf *dest,
gsize width,
@@ -51,4 +48,14 @@ gboolean gdk_dmabuf_sanitize (GdkDmabuf
gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf);
gboolean gdk_dmabuf_fourcc_is_yuv (guint32 fourcc,
gboolean *is_yuv);
gboolean gdk_dmabuf_get_memory_format (guint32 fourcc,
gboolean premultiplied,
GdkMemoryFormat *out_format);
#ifdef GDK_RENDERING_VULKAN
VkFormat gdk_dmabuf_get_vk_format (guint32 fourcc,
VkComponentMapping *out_components);
#endif
#endif

View File

@@ -21,21 +21,15 @@
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkdmabufdownloaderprivate.h"
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabufprivate.h"
#include "gdktextureprivate.h"
#include <gdk/gdkglcontext.h>
#include <gdk/gdkgltexturebuilder.h>
#include <gdk/gdktexturedownloader.h>
#ifdef HAVE_DMABUF
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/dma-buf.h>
#include <drm_fourcc.h>
#include <epoxy/egl.h>
#endif
/**
* GdkDmabufTexture:
*
@@ -52,7 +46,7 @@ struct _GdkDmabufTexture
GdkTexture parent_instance;
GdkDisplay *display;
const GdkDmabufDownloader *downloader;
GdkDmabufDownloader *downloader;
GdkDmabuf dmabuf;
@@ -69,11 +63,6 @@ G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
static void
gdk_dmabuf_texture_init (GdkDmabufTexture *self)
{
}
static void
gdk_dmabuf_texture_dispose (GObject *object)
{
@@ -82,9 +71,39 @@ gdk_dmabuf_texture_dispose (GObject *object)
if (self->destroy)
self->destroy (self->data);
g_clear_object (&self->downloader);
g_clear_object (&self->display);
G_OBJECT_CLASS (gdk_dmabuf_texture_parent_class)->dispose (object);
}
typedef struct _Download Download;
struct _Download
{
GdkDmabufTexture *texture;
GdkMemoryFormat format;
guchar *data;
gsize stride;
volatile int spinlock;
};
static gboolean
gdk_dmabuf_texture_invoke_callback (gpointer data)
{
Download *download = data;
gdk_dmabuf_downloader_download (download->texture->downloader,
download->texture,
download->format,
download->data,
download->stride);
g_atomic_int_set (&download->spinlock, 1);
return FALSE;
}
static void
gdk_dmabuf_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
@@ -92,12 +111,19 @@ gdk_dmabuf_texture_download (GdkTexture *texture,
gsize stride)
{
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (texture);
Download download = { self, format, data, stride, 0 };
self->downloader->download (self->downloader,
texture,
format,
data,
stride);
if (self->downloader == NULL)
{
#ifdef HAVE_DMABUF
gdk_dmabuf_download_mmap (texture, format, data, stride);
#endif
return;
}
g_main_context_invoke (NULL, gdk_dmabuf_texture_invoke_callback, &download);
while (g_atomic_int_get (&download.spinlock) == 0);
}
static void
@@ -111,6 +137,11 @@ gdk_dmabuf_texture_class_init (GdkDmabufTextureClass *klass)
gobject_class->dispose = gdk_dmabuf_texture_dispose;
}
static void
gdk_dmabuf_texture_init (GdkDmabufTexture *self)
{
}
GdkDisplay *
gdk_dmabuf_texture_get_display (GdkDmabufTexture *self)
{
@@ -134,14 +165,15 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
GdkTexture *update_texture;
GdkDisplay *display;
GdkDmabuf dmabuf;
GdkMemoryFormat format;
GError *local_error = NULL;
int width, height;
gboolean premultiplied;
gsize i;
display = gdk_dmabuf_texture_builder_get_display (builder);
width = gdk_dmabuf_texture_builder_get_width (builder);
height = gdk_dmabuf_texture_builder_get_height (builder);
premultiplied = gdk_dmabuf_texture_builder_get_premultiplied (builder);
if (!gdk_dmabuf_sanitize (&dmabuf,
width,
@@ -152,43 +184,57 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
gdk_display_init_dmabuf (display);
for (i = 0; display->dmabuf_downloaders[i] != NULL; i++)
{
if (local_error && g_error_matches (local_error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT))
g_clear_error (&local_error);
if (display->dmabuf_downloaders[i]->supports (display->dmabuf_downloaders[i],
display,
&dmabuf,
gdk_dmabuf_texture_builder_get_premultiplied (builder),
&format,
local_error ? NULL : &local_error))
break;
}
if (display->dmabuf_downloaders[i] == NULL)
{
g_propagate_error (error, local_error);
return NULL;
}
GDK_DEBUG (DMABUF,
"Dmabuf texture, format %.4s:%#lx, %s%u planes, memory format %u, downloader %s",
(char *) &dmabuf.fourcc, dmabuf.modifier,
gdk_dmabuf_texture_builder_get_premultiplied (builder) ? " premultiplied, " : "",
dmabuf.n_planes,
format,
display->dmabuf_downloaders[i]->name);
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
"width", width,
"height", height,
NULL);
GDK_TEXTURE (self)->format = format;
g_set_object (&self->display, display);
self->downloader = display->dmabuf_downloaders[i];
self->dmabuf = dmabuf;
if (!gdk_dmabuf_get_memory_format (dmabuf.fourcc, premultiplied, &(GDK_TEXTURE (self)->format)))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Falling back to generic RGBA for dmabuf format %.4s",
(char *) &dmabuf.fourcc);
GDK_TEXTURE (self)->format = premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED
: GDK_MEMORY_R8G8B8A8;
}
if (!gdk_dmabuf_formats_contains (gdk_dmabuf_get_mmap_formats (), dmabuf.fourcc, dmabuf.modifier))
{
for (i = 0; display->dmabuf_downloaders[i] != NULL; i++)
{
if (local_error && g_error_matches (local_error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT))
g_clear_error (&local_error);
if (gdk_dmabuf_downloader_supports (display->dmabuf_downloaders[i],
self,
local_error ? NULL : &local_error))
{
self->downloader = g_object_ref (display->dmabuf_downloaders[i]);
break;
}
}
if (self->downloader == NULL)
{
g_propagate_error (error, local_error);
g_object_unref (self);
return NULL;
}
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating dmabuf texture, format %.4s:%#" G_GINT64_MODIFIER "x, %s%u planes, memory format %u, downloader %s",
(char *) &dmabuf.fourcc, dmabuf.modifier,
gdk_dmabuf_texture_builder_get_premultiplied (builder) ? " premultiplied, " : "",
dmabuf.n_planes,
GDK_TEXTURE (self)->format,
self->downloader ? G_OBJECT_TYPE_NAME (self->downloader) : "none");
/* Set this only once we know that the texture will be created.
* Otherwise dispose() will run the callback */
self->destroy = destroy;
self->data = data;

View File

@@ -34,7 +34,6 @@ G_BEGIN_DECLS
#define GDK_DMABUF_ERROR (gdk_dmabuf_error_quark ())
typedef struct _GdkDmabufTexture GdkDmabufTexture;
typedef struct _GdkDmabufTextureClass GdkDmabufTextureClass;
GDK_AVAILABLE_IN_4_14

View File

@@ -27,11 +27,6 @@
#include "gdkdmabuftextureprivate.h"
#include <cairo-gobject.h>
#ifdef HAVE_DMABUF
#include <drm_fourcc.h>
#else
#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
#endif
struct _GdkDmabufTextureBuilder
@@ -85,12 +80,15 @@ struct _GdkDmabufTextureBuilderClass
* descriptor per plane.
*
* The format of the data (for graphics data, essentially its colorspace) is described
* by a 32-bit integer. These format identifiers are defined in the header file
* [drm_fourcc.h](https://github.com/torvalds/linux/blob/master/include/uapi/drm_fourcc.h)
* by a 32-bit integer. These format identifiers are defined in the header file `drm_fourcc.h`
* and commonly referred to as **_fourcc_** values, since they are identified by 4 ASCII
* characters. Additionally, each DMA buffer has a **_modifier_**, which is a 64-bit integer
* that describes driver-specific details of the memory layout, such as tiling or compression.
*
* For historical reasons, some producers of dma-bufs don't provide an explicit modifier, but
* instead return `DMA_FORMAT_MOD_INVALID` to indicate that their modifier is **_implicit_**.
* GTK tries to accomodate this situation by accepting `DMA_FORMAT_MOD_INVALID` as modifier.
*
* The operation of `GdkDmabufTextureBuilder` is quite simple: Create a texture builder,
* set all the necessary properties, and then call [method@Gdk.DmabufTextureBuilder.build]
* to create the new texture.
@@ -106,6 +104,12 @@ struct _GdkDmabufTextureBuilderClass
* `GdkDmabufTextureBuilder` can be used for quick one-shot construction of
* textures as well as kept around and reused to construct multiple textures.
*
* For further information, see
*
* * The Linux kernel [documentation](https://docs.kernel.org/driver-api/dma-buf.html)
*
* * The header file [drm_fourcc.h](https://gitlab.freedesktop.org/mesa/drm/-/blob/main/include/drm/drm_fourcc.h)
*
* Since: 4.14
*/
@@ -254,7 +258,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
gobject_class->set_property = gdk_dmabuf_texture_builder_set_property;
/**
* GdkDmabufTextureBuilder:display: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_display org.gdk.Property.set=gdk_dmabuf_texture_builder_set_display)
* GdkDmabufTextureBuilder:display: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_display org.gtk.Property.set=gdk_dmabuf_texture_builder_set_display)
*
* The display that this texture will be used on.
*
@@ -266,7 +270,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:width: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_width org.gdk.Property.set=gdk_dmabuf_texture_builder_set_width)
* GdkDmabufTextureBuilder:width: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_width org.gtk.Property.set=gdk_dmabuf_texture_builder_set_width)
*
* The width of the texture.
*
@@ -278,7 +282,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:height: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_height org.gdk.Property.set=gdk_dmabuf_texture_builder_set_height)
* GdkDmabufTextureBuilder:height: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_height org.gtk.Property.set=gdk_dmabuf_texture_builder_set_height)
*
* The height of the texture.
*
@@ -290,7 +294,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:fourcc: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_fourcc org.gdk.Property.set=gdk_dmabuf_texture_builder_set_fourcc)
* GdkDmabufTextureBuilder:fourcc: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_fourcc org.gtk.Property.set=gdk_dmabuf_texture_builder_set_fourcc)
*
* The format of the texture, as a fourcc value.
*
@@ -328,7 +332,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:n-planes: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_n_planes org.gdk.Property.set=gdk_dmabuf_texture_builder_set_n_planes)
* GdkDmabufTextureBuilder:n-planes: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_n_planes org.gtk.Property.set=gdk_dmabuf_texture_builder_set_n_planes)
*
* The number of planes of the texture.
*
@@ -343,7 +347,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:update-region: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_update_region org.gdk.Property.set=gdk_dmabuf_texture_builder_set_update_region)
* GdkDmabufTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_region org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_region)
*
* The update region for [property@Gdk.GLTextureBuilder:update-texture].
*
@@ -355,9 +359,9 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:update-texture: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_update_texture org.gdk.Property.set=gdk_dmabuf_texture_builder_set_update_texture)
* GdkDmabufTextureBuilder:update-texture: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_texture org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_texture)
*
* The texture [property@Gdk.GLTextureBuilder:update-region] is an update for.
* The texture [property@Gdk.DmabufTextureBuilder:update-region] is an update for.
*
* Since: 4.14
*/
@@ -439,7 +443,7 @@ gdk_dmabuf_texture_builder_set_display (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_width: (attributes org.gdk.Method.get_property=width)
* gdk_dmabuf_texture_builder_get_width: (attributes org.gtk.Method.get_property=width)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the width previously set via gdk_dmabuf_texture_builder_set_width() or
@@ -458,7 +462,7 @@ gdk_dmabuf_texture_builder_get_width (GdkDmabufTextureBuilder *self)
}
/**
* gdk_dmabuf_texture_builder_set_width: (attributes org.gdk.Method.set_property=width)
* gdk_dmabuf_texture_builder_set_width: (attributes org.gtk.Method.set_property=width)
* @self: a `GdkDmabufTextureBuilder`
* @width: The texture's width or 0 to unset
*
@@ -483,7 +487,7 @@ gdk_dmabuf_texture_builder_set_width (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_height: (attributes org.gdk.Method.get_property=height)
* gdk_dmabuf_texture_builder_get_height: (attributes org.gtk.Method.get_property=height)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the height previously set via gdk_dmabuf_texture_builder_set_height() or
@@ -502,7 +506,7 @@ gdk_dmabuf_texture_builder_get_height (GdkDmabufTextureBuilder *self)
}
/**
* gdk_dmabuf_texture_builder_set_height: (attributes org.gdk.Method.set_property=height)
* gdk_dmabuf_texture_builder_set_height: (attributes org.gtk.Method.set_property=height)
* @self: a `GdkDmabufTextureBuilder`
* @height: the texture's height or 0 to unset
*
@@ -527,7 +531,7 @@ gdk_dmabuf_texture_builder_set_height (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_fourcc: (attributes org.gdk.Method.get_property=fourcc)
* gdk_dmabuf_texture_builder_get_fourcc: (attributes org.gtk.Method.get_property=fourcc)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the format previously set via gdk_dmabuf_texture_builder_set_fourcc()
@@ -548,7 +552,7 @@ gdk_dmabuf_texture_builder_get_fourcc (GdkDmabufTextureBuilder *self)
}
/**
* gdk_dmabuf_texture_builder_set_fourcc: (attributes org.gdk.Method.set_property=fourcc)
* gdk_dmabuf_texture_builder_set_fourcc: (attributes org.gtk.Method.set_property=fourcc)
* @self: a `GdkDmabufTextureBuilder`
* @fourcc: the texture's format or 0 to unset
*
@@ -606,13 +610,6 @@ gdk_dmabuf_texture_builder_set_modifier (GdkDmabufTextureBuilder *self,
guint64 modifier)
{
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
if (modifier == DRM_FORMAT_MOD_INVALID)
{
g_critical ("GTK does not support the INVALID modifier. "
"If you use code that produces it, it should include "
"instructions how to transform it into a regular modifier.");
return;
}
if (self->dmabuf.modifier == modifier)
return;
@@ -623,7 +620,7 @@ gdk_dmabuf_texture_builder_set_modifier (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_n_planes: (attributes org.gdk.Method.get_property=n-planes)
* gdk_dmabuf_texture_builder_get_n_planes: (attributes org.gtk.Method.get_property=n-planes)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the number of planes.
@@ -685,7 +682,7 @@ gdk_dmabuf_texture_builder_set_premultiplied (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_set_n_planes: (attributes org.gdk.Method.set_property=n-planes)
* gdk_dmabuf_texture_builder_set_n_planes: (attributes org.gtk.Method.set_property=n-planes)
* @self: a `GdkDmabufTextureBuilder`
* @n_planes: the number of planes
*
@@ -846,7 +843,7 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gdk.Method.get_property=update_texture)
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the texture previously set via gdk_dmabuf_texture_builder_set_update_texture() or
@@ -865,7 +862,7 @@ gdk_dmabuf_texture_builder_get_update_texture (GdkDmabufTextureBuilder *self)
}
/**
* gdk_dmabuf_texture_builder_set_update_texture: (attributes org.gdk.Method.set_property=update_texture)
* gdk_dmabuf_texture_builder_set_update_texture: (attributes org.gtk.Method.set_property=update-texture)
* @self: a `GdkDmabufTextureBuilder`
* @texture: (nullable): the texture to update
*
@@ -888,7 +885,7 @@ gdk_dmabuf_texture_builder_set_update_texture (GdkDmabufTextureBuilder *self,
}
/**
* gdk_dmabuf_texture_builder_get_update_region: (attributes org.gdk.Method.get_property=update_region)
* gdk_dmabuf_texture_builder_get_update_region: (attributes org.gtk.Method.get_property=update-region)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the region previously set via gdk_dmabuf_texture_builder_set_update_region() or
@@ -907,7 +904,7 @@ gdk_dmabuf_texture_builder_get_update_region (GdkDmabufTextureBuilder *self)
}
/**
* gdk_dmabuf_texture_builder_set_update_region: (attributes org.gdk.Method.set_property=update_region)
* gdk_dmabuf_texture_builder_set_update_region: (attributes org.gtk.Method.set_property=update-region)
* @self: a `GdkDmabufTextureBuilder`
* @region: (nullable): the region to update
*
@@ -991,9 +988,10 @@ gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
for (i = 0; i < self->dmabuf.n_planes; i++)
g_return_val_if_fail (self->dmabuf.planes[i].fd != -1, NULL);
if (GDK_DEBUG_CHECK (DMABUF_DISABLE))
if (GDK_DISPLAY_DEBUG_CHECK (self->display, DMABUF_DISABLE))
{
g_set_error_literal (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
g_set_error_literal (error,
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
"dmabuf support disabled via GDK_DEBUG environment variable");
return NULL;
}

View File

@@ -68,6 +68,12 @@ gdk_draw_context_default_surface_resized (GdkDrawContext *context)
{
}
static void
gdk_draw_context_default_empty_frame (GdkDrawContext *context)
{
g_warning ("FIXME: Implement");
}
static void
gdk_draw_context_dispose (GObject *gobject)
{
@@ -161,6 +167,7 @@ gdk_draw_context_class_init (GdkDrawContextClass *klass)
gobject_class->dispose = gdk_draw_context_dispose;
klass->surface_resized = gdk_draw_context_default_surface_resized;
klass->empty_frame = gdk_draw_context_default_empty_frame;
/**
* GdkDrawContext:display: (attributes org.gtk.Property.get=gdk_draw_context_get_display)
@@ -470,3 +477,17 @@ gdk_draw_context_get_frame_region (GdkDrawContext *context)
return priv->frame_region;
}
void
gdk_draw_context_empty_frame (GdkDrawContext *context)
{
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
g_return_if_fail (GDK_IS_DRAW_CONTEXT (context));
g_return_if_fail (priv->surface != NULL);
if (GDK_SURFACE_DESTROYED (priv->surface))
return;
GDK_DRAW_CONTEXT_GET_CLASS (context)->empty_frame (context);
}

View File

@@ -45,6 +45,7 @@ void gdk_draw_context_begin_frame (GdkDrawContext
const cairo_region_t *region);
GDK_AVAILABLE_IN_ALL
void gdk_draw_context_end_frame (GdkDrawContext *context);
GDK_AVAILABLE_IN_ALL
gboolean gdk_draw_context_is_in_frame (GdkDrawContext *context);
GDK_AVAILABLE_IN_ALL

View File

@@ -46,6 +46,7 @@ struct _GdkDrawContextClass
cairo_region_t *update_area);
void (* end_frame) (GdkDrawContext *context,
cairo_region_t *painted);
void (* empty_frame) (GdkDrawContext *context);
void (* surface_resized) (GdkDrawContext *context);
};
@@ -54,5 +55,9 @@ void gdk_draw_context_surface_resized (GdkDrawContext
void gdk_draw_context_begin_frame_full (GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region);
void gdk_draw_context_empty_frame (GdkDrawContext *context);
G_END_DECLS

View File

@@ -114,6 +114,15 @@ typedef enum
*/
typedef enum
{
/**
* GDK_NO_MODIFIER_MASK:
*
* No modifier.
*
* Since: 4.14
*/
GDK_NO_MODIFIER_MASK GDK_AVAILABLE_ENUMERATOR_IN_4_14 = 0,
GDK_SHIFT_MASK = 1 << 0,
GDK_LOCK_MASK = 1 << 1,
GDK_CONTROL_MASK = 1 << 2,

View File

@@ -402,7 +402,6 @@ gdk_event_alloc (GdkEventType event_type,
GdkEvent *event = (GdkEvent *) g_type_create_instance (gdk_event_types[event_type]);
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (EVENTS))
{
char *str = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event_type);
@@ -410,7 +409,6 @@ gdk_event_alloc (GdkEventType event_type,
g_type_name (gdk_event_types[event_type]), str);
g_free (str);
}
#endif
event->event_type = event_type;
event->surface = surface != NULL ? g_object_ref (surface) : NULL;

View File

@@ -346,19 +346,15 @@ gdk_frame_clock_end_updating (GdkFrameClock *frame_clock)
GDK_FRAME_CLOCK_GET_CLASS (frame_clock)->end_updating (frame_clock);
}
static void
static inline void
_gdk_frame_clock_freeze (GdkFrameClock *clock)
{
g_return_if_fail (GDK_IS_FRAME_CLOCK (clock));
GDK_FRAME_CLOCK_GET_CLASS (clock)->freeze (clock);
}
static void
static inline void
_gdk_frame_clock_thaw (GdkFrameClock *clock)
{
g_return_if_fail (GDK_IS_FRAME_CLOCK (clock));
GDK_FRAME_CLOCK_GET_CLASS (clock)->thaw (clock);
}
@@ -390,6 +386,12 @@ _gdk_frame_clock_uninhibit_freeze (GdkFrameClock *clock)
_gdk_frame_clock_freeze (clock);
}
static inline gint64
_gdk_frame_clock_get_frame_counter (GdkFrameClock *frame_clock)
{
return frame_clock->priv->frame_counter;
}
/**
* gdk_frame_clock_get_frame_counter:
* @frame_clock: a `GdkFrameClock`
@@ -404,13 +406,15 @@ _gdk_frame_clock_uninhibit_freeze (GdkFrameClock *clock)
gint64
gdk_frame_clock_get_frame_counter (GdkFrameClock *frame_clock)
{
GdkFrameClockPrivate *priv;
g_return_val_if_fail (GDK_IS_FRAME_CLOCK (frame_clock), 0);
priv = frame_clock->priv;
return _gdk_frame_clock_get_frame_counter (frame_clock);
}
return priv->frame_counter;
static inline gint64
_gdk_frame_clock_get_history_start (GdkFrameClock *frame_clock)
{
return frame_clock->priv->frame_counter + 1 - frame_clock->priv->n_timings;
}
/**
@@ -433,13 +437,9 @@ gdk_frame_clock_get_frame_counter (GdkFrameClock *frame_clock)
gint64
gdk_frame_clock_get_history_start (GdkFrameClock *frame_clock)
{
GdkFrameClockPrivate *priv;
g_return_val_if_fail (GDK_IS_FRAME_CLOCK (frame_clock), 0);
priv = frame_clock->priv;
return priv->frame_counter + 1 - priv->n_timings;
return _gdk_frame_clock_get_history_start (frame_clock);
}
void
@@ -470,6 +470,24 @@ _gdk_frame_clock_begin_frame (GdkFrameClock *frame_clock)
priv->timings[priv->current] = _gdk_frame_timings_new (priv->frame_counter);
}
static inline GdkFrameTimings *
_gdk_frame_clock_get_timings (GdkFrameClock *frame_clock,
gint64 frame_counter)
{
GdkFrameClockPrivate *priv = frame_clock->priv;
int pos;
if (frame_counter > priv->frame_counter)
return NULL;
if (frame_counter <= priv->frame_counter - priv->n_timings)
return NULL;
pos = (priv->current - (priv->frame_counter - frame_counter) + FRAME_HISTORY_MAX_LENGTH) % FRAME_HISTORY_MAX_LENGTH;
return priv->timings[pos];
}
/**
* gdk_frame_clock_get_timings:
* @frame_clock: a `GdkFrameClock`
@@ -490,22 +508,9 @@ GdkFrameTimings *
gdk_frame_clock_get_timings (GdkFrameClock *frame_clock,
gint64 frame_counter)
{
GdkFrameClockPrivate *priv;
int pos;
g_return_val_if_fail (GDK_IS_FRAME_CLOCK (frame_clock), NULL);
priv = frame_clock->priv;
if (frame_counter > priv->frame_counter)
return NULL;
if (frame_counter <= priv->frame_counter - priv->n_timings)
return NULL;
pos = (priv->current - (priv->frame_counter - frame_counter) + FRAME_HISTORY_MAX_LENGTH) % FRAME_HISTORY_MAX_LENGTH;
return priv->timings[pos];
return _gdk_frame_clock_get_timings (frame_clock, frame_counter);
}
/**
@@ -528,11 +533,9 @@ gdk_frame_clock_get_current_timings (GdkFrameClock *frame_clock)
priv = frame_clock->priv;
return gdk_frame_clock_get_timings (frame_clock, priv->frame_counter);
return _gdk_frame_clock_get_timings (frame_clock, priv->frame_counter);
}
#ifdef G_ENABLE_DEBUG
void
_gdk_frame_clock_debug_print_timings (GdkFrameClock *clock,
GdkFrameTimings *timings)
@@ -541,8 +544,8 @@ _gdk_frame_clock_debug_print_timings (GdkFrameClock *clock,
gint64 previous_frame_time = 0;
gint64 previous_smoothed_frame_time = 0;
GdkFrameTimings *previous_timings = gdk_frame_clock_get_timings (clock,
timings->frame_counter - 1);
GdkFrameTimings *previous_timings = _gdk_frame_clock_get_timings (clock,
timings->frame_counter - 1);
if (previous_timings != NULL)
{
@@ -579,7 +582,6 @@ _gdk_frame_clock_debug_print_timings (GdkFrameClock *clock,
g_message ("%s", str->str);
g_string_free (str, TRUE);
}
#endif /* G_ENABLE_DEBUG */
#define DEFAULT_REFRESH_INTERVAL 16667 /* 16.7ms (1/60th second) */
#define MAX_HISTORY_AGE 150000 /* 150ms */
@@ -614,11 +616,11 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock,
g_return_if_fail (GDK_IS_FRAME_CLOCK (frame_clock));
frame_counter = gdk_frame_clock_get_frame_counter (frame_clock);
frame_counter = _gdk_frame_clock_get_frame_counter (frame_clock);
while (TRUE)
{
GdkFrameTimings *timings = gdk_frame_clock_get_timings (frame_clock, frame_counter);
GdkFrameTimings *timings = _gdk_frame_clock_get_timings (frame_clock, frame_counter);
gint64 presentation_time;
gint64 refresh_interval;
@@ -730,15 +732,15 @@ guess_refresh_interval (GdkFrameClock *frame_clock)
interval = G_MAXINT64;
for (i = gdk_frame_clock_get_history_start (frame_clock);
i < gdk_frame_clock_get_frame_counter (frame_clock);
for (i = _gdk_frame_clock_get_history_start (frame_clock);
i < _gdk_frame_clock_get_frame_counter (frame_clock);
i++)
{
GdkFrameTimings *t, *before;
gint64 ts, before_ts;
t = gdk_frame_clock_get_timings (frame_clock, i);
before = gdk_frame_clock_get_timings (frame_clock, i - 1);
t = _gdk_frame_clock_get_timings (frame_clock, i);
before = _gdk_frame_clock_get_timings (frame_clock, i - 1);
if (t == NULL || before == NULL)
continue;
@@ -773,12 +775,12 @@ gdk_frame_clock_get_fps (GdkFrameClock *frame_clock)
gint64 start_timestamp, end_timestamp;
gint64 interval;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
start_counter = _gdk_frame_clock_get_history_start (frame_clock);
end_counter = _gdk_frame_clock_get_frame_counter (frame_clock);
start = _gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = _gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end = _gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
return 0.0;

View File

@@ -585,14 +585,15 @@ gdk_frame_clock_paint_idle (void *data)
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
{
int iter;
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_LAYOUT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT))
timings->layout_start_time = g_get_monotonic_time ();
{
if (timings)
timings->layout_start_time = g_get_monotonic_time ();
}
}
#endif
priv->phase = GDK_FRAME_CLOCK_PHASE_LAYOUT;
/* We loop in the layout phase, because we don't want to progress
@@ -616,14 +617,15 @@ gdk_frame_clock_paint_idle (void *data)
case GDK_FRAME_CLOCK_PHASE_PAINT:
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
{
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_PAINT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT))
timings->paint_start_time = g_get_monotonic_time ();
{
if (timings)
timings->paint_start_time = g_get_monotonic_time ();
}
}
#endif
priv->phase = GDK_FRAME_CLOCK_PHASE_PAINT;
if (priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT)
@@ -643,13 +645,11 @@ gdk_frame_clock_paint_idle (void *data)
*/
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
}
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
{
if (timings)
timings->frame_end_time = g_get_monotonic_time ();
}
#endif /* G_ENABLE_DEBUG */
G_GNUC_FALLTHROUGH;
case GDK_FRAME_CLOCK_PHASE_RESUME_EVENTS:

View File

@@ -95,11 +95,9 @@ struct _GdkFrameTimings
gint64 refresh_interval;
gint64 predicted_presentation_time;
#ifdef G_ENABLE_DEBUG
gint64 layout_start_time;
gint64 paint_start_time;
gint64 frame_end_time;
#endif /* G_ENABLE_DEBUG */
guint complete : 1;
guint slept_before : 1;

View File

@@ -78,7 +78,7 @@
#include "gdkdebugprivate.h"
#include "gdkdisplayprivate.h"
#include <glib/gi18n-lib.h>
#include "gdkdmabufeglprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkprofilerprivate.h"
@@ -87,6 +87,8 @@
#include "gdkprivate.h"
#include <glib/gi18n-lib.h>
#ifdef GDK_WINDOWING_WIN32
# include "gdk/win32/gdkwin32.h"
#endif
@@ -104,10 +106,15 @@
#define DEFAULT_ALLOWED_APIS GDK_GL_API_GL | GDK_GL_API_GLES
typedef struct {
typedef struct _GdkGLContextPrivate GdkGLContextPrivate;
struct _GdkGLContextPrivate
{
GdkGLVersion required;
GdkGLVersion gl_version;
GdkGLMemoryFlags memory_flags[GDK_MEMORY_N_FORMATS];
guint has_khr_debug : 1;
guint use_khr_debug : 1;
guint has_half_float : 1;
@@ -115,7 +122,6 @@ typedef struct {
guint has_unpack_subimage : 1;
guint has_debug_output : 1;
guint has_bgra : 1;
guint has_image_storage : 1;
guint extensions_checked : 1;
guint debug_enabled : 1;
guint forward_compatible : 1;
@@ -130,7 +136,7 @@ typedef struct {
EGLContext egl_context;
EGLBoolean (*eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
#endif
} GdkGLContextPrivate;
};
enum {
PROP_0,
@@ -352,6 +358,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
api == GDK_GL_API_GLES ? "yes" : "no");
supported_versions = gdk_gl_versions_get_for_api (api);
ctx = EGL_NO_CONTEXT;
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
@@ -361,11 +368,11 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
egl_config,
share ? share_priv->egl_context : EGL_NO_CONTEXT,
context_attribs);
if (ctx != NULL)
if (ctx != EGL_NO_CONTEXT)
break;
}
if (ctx == NULL)
if (ctx == EGL_NO_CONTEXT)
return 0;
GDK_DISPLAY_DEBUG (display, OPENGL, "Created EGL context[%p]", ctx);
@@ -390,17 +397,24 @@ gdk_gl_context_realize_egl (GdkGLContext *context,
{
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_display_get_gl_context (display);
GdkDebugFlags flags;
GdkGLAPI api, preferred_api;
gboolean prefer_legacy;
flags = gdk_display_get_debug_flags(display);
if (share && gdk_gl_context_is_api_allowed (context,
gdk_gl_context_get_api (share),
NULL))
preferred_api = gdk_gl_context_get_api (share);
else if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
else if ((flags & GDK_DEBUG_GL_PREFER_GL) != 0 &&
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
preferred_api = GDK_GL_API_GL;
else if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL))
preferred_api = GDK_GL_API_GLES;
else if ((flags & GDK_DEBUG_GL_PREFER_GL) == 0 &&
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
preferred_api = GDK_GL_API_GL;
else
{
g_set_error_literal (error, GDK_GL_ERROR,
@@ -409,8 +423,7 @@ gdk_gl_context_realize_egl (GdkGLContext *context,
return 0;
}
prefer_legacy = (gdk_display_get_debug_flags(display) & GDK_DEBUG_GL_LEGACY) ||
(share != NULL && gdk_gl_context_is_legacy (share));
prefer_legacy = share != NULL && gdk_gl_context_is_legacy (share);
if (preferred_api == GDK_GL_API_GL)
{
@@ -1278,18 +1291,38 @@ gdk_gl_context_is_api_allowed (GdkGLContext *self,
GError **error)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
GdkDebugFlags flags;
GdkGLAPI allowed_apis;
if (gdk_display_get_debug_flags (gdk_gl_context_get_display (self)) & GDK_DEBUG_GL_GLES)
allowed_apis = priv->allowed_apis;
flags = gdk_display_get_debug_flags (gdk_gl_context_get_display (self));
if (flags & GDK_DEBUG_GL_DISABLE_GLES)
{
if (!(api & GDK_GL_API_GLES))
if (api == GDK_GL_API_GLES)
{
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
_("Anything but OpenGL ES disabled via GDK_DEBUG"));
_("OpenGL ES disabled via GDK_DEBUG"));
return FALSE;
}
allowed_apis &= ~GDK_GL_API_GLES;
}
if (priv->allowed_apis & api)
if (flags & GDK_DEBUG_GL_DISABLE_GL)
{
if (api == GDK_GL_API_GL)
{
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
_("OpenGL disabled via GDK_DEBUG"));
return FALSE;
}
allowed_apis &= ~GDK_GL_API_GL;
}
if (allowed_apis & api)
return TRUE;
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
@@ -1498,6 +1531,132 @@ gdk_gl_context_realize (GdkGLContext *context,
return priv->api;
}
static void
gdk_gl_context_init_memory_flags (GdkGLContext *self)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
gsize i;
if (!gdk_gl_context_get_use_es (self))
{
for (i = 0; i < G_N_ELEMENTS (priv->memory_flags); i++)
{
priv->memory_flags[i] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
}
return;
}
/* GLES 2.0 spec, tables 3.2 and 3.3 */
priv->memory_flags[GDK_MEMORY_R8G8B8] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8A8] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
#if 0
/* GLES2 can do these, but GTK can't */
priv->memory_flags[GDK_MEMORY_A8] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G8] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G8A8_PREMULTIPLIED] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G8A8] = GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
#endif
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
{
/* GLES 3.0.6 spec, table 3.13 */
priv->memory_flags[GDK_MEMORY_G8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_A8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G8A8_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G8A8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8A8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8X8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16_FLOAT] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE;
priv->memory_flags[GDK_MEMORY_A16_FLOAT] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32_FLOAT] |= GDK_GL_FORMAT_USABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT] |= GDK_GL_FORMAT_USABLE;
priv->memory_flags[GDK_MEMORY_A32_FLOAT] |= GDK_GL_FORMAT_USABLE;
/* no changes in GLES 3.1 spec, table 8.13 */
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 2)))
{
/* GLES 3.2 spec, table 8.10 */
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT] |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_A16_FLOAT] |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT] |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_A32_FLOAT] |= GDK_GL_FORMAT_FILTERABLE;
}
}
if (epoxy_has_gl_extension ("GL_OES_rgb8_rgba8"))
{
priv->memory_flags[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8A8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R8G8B8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
priv->memory_flags[GDK_MEMORY_R8G8B8X8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
}
if (epoxy_has_gl_extension ("GL_EXT_abgr"))
{
priv->memory_flags[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_A8B8G8R8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
priv->memory_flags[GDK_MEMORY_X8B8G8R8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
}
if (epoxy_has_gl_extension ("GL_EXT_texture_format_BGRA8888"))
{
priv->memory_flags[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_B8G8R8A8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
priv->memory_flags[GDK_MEMORY_B8G8R8X8] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
}
/* Technically, those extensions are supported on GLES2.
* However, GTK uses the wrong format/type pairs with them, so we don't enable them.
*/
if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
{
if (epoxy_has_gl_extension ("GL_EXT_texture_norm16"))
{
priv->memory_flags[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16A16] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G16A16_PREMULTIPLIED] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G16A16] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_G16] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_A16] |= GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_RENDERABLE | GDK_GL_FORMAT_FILTERABLE;
}
if (epoxy_has_gl_extension ("GL_OES_texture_half_float"))
{
GdkGLMemoryFlags flags = GDK_GL_FORMAT_USABLE;
if (epoxy_has_gl_extension ("GL_EXT_color_buffer_half_float"))
flags |= GDK_GL_FORMAT_RENDERABLE;
if (epoxy_has_gl_extension ("GL_OES_texture_half_float_linear"))
flags |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] |= flags;
priv->memory_flags[GDK_MEMORY_R16G16B16A16_FLOAT] |= flags;
priv->memory_flags[GDK_MEMORY_R16G16B16_FLOAT] |= flags;
priv->memory_flags[GDK_MEMORY_A16_FLOAT] |= flags;
}
if (epoxy_has_gl_extension ("GL_OES_texture_float"))
{
GdkGLMemoryFlags flags = GDK_GL_FORMAT_USABLE;
if (epoxy_has_gl_extension ("GL_EXT_color_buffer_float"))
flags |= GDK_GL_FORMAT_RENDERABLE;
if (epoxy_has_gl_extension ("GL_OES_texture_float_linear"))
flags |= GDK_GL_FORMAT_FILTERABLE;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] |= flags;
priv->memory_flags[GDK_MEMORY_R32G32B32A32_FLOAT] |= flags;
priv->memory_flags[GDK_MEMORY_R32G32B32_FLOAT] |= flags;
priv->memory_flags[GDK_MEMORY_A32_FLOAT] |= flags;
}
}
}
void
gdk_gl_version_init_epoxy (GdkGLVersion *version)
{
@@ -1564,9 +1723,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
epoxy_has_gl_extension ("GL_ARB_sync") ||
epoxy_has_gl_extension ("GL_APPLE_sync");
priv->has_image_storage = epoxy_has_gl_extension ("GL_EXT_EGL_image_storage");
gdk_gl_context_init_memory_flags (context);
#ifdef G_ENABLE_DEBUG
{
int max_texture_size;
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size);
@@ -1577,10 +1735,9 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
"* Extensions checked:\n"
" - GL_KHR_debug: %s\n"
" - GL_EXT_unpack_subimage: %s\n"
" - GL_EXT_texture_format_BGRA8888: %s\n"
" - GL_EXT_EGL_image_storage: %s\n"
" - half float: %s\n"
" - sync: %s",
" - sync: %s\n"
" - bgra: %s",
gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL",
gdk_gl_version_get_major (&priv->gl_version), gdk_gl_version_get_minor (&priv->gl_version),
priv->is_legacy ? "legacy" : "core",
@@ -1588,12 +1745,10 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
max_texture_size,
priv->has_khr_debug ? "yes" : "no",
priv->has_unpack_subimage ? "yes" : "no",
priv->has_bgra ? "yes" : "no",
priv->has_image_storage ? "yes" : "no",
priv->has_half_float ? "yes" : "no",
priv->has_sync ? "yes" : "no");
priv->has_sync ? "yes" : "no",
priv->has_bgra ? "yes" : "no");
}
#endif
priv->extensions_checked = TRUE;
}
@@ -1853,6 +2008,15 @@ gdk_gl_context_get_current (void)
return context;
}
GdkGLMemoryFlags
gdk_gl_context_get_format_flags (GdkGLContext *self,
GdkMemoryFormat format)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
return priv->memory_flags[format];
}
gboolean
gdk_gl_context_has_debug (GdkGLContext *self)
{
@@ -1907,14 +2071,6 @@ gdk_gl_context_has_vertex_arrays (GdkGLContext *self)
}
}
gboolean
gdk_gl_context_has_image_storage (GdkGLContext *self)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
return priv->has_image_storage;
}
/* This is currently private! */
/* When using GL/ES, don't flip the 'R' and 'B' bits on Windows/ANGLE for glReadPixels() */
gboolean
@@ -1996,80 +2152,25 @@ gdk_gl_backend_use (GdkGLBackend backend_type)
g_assert (the_gl_backend_type == backend_type);
}
guint
gdk_gl_context_import_dmabuf (GdkGLContext *self,
int width,
int height,
const GdkDmabuf *dmabuf,
int target)
static guint
gdk_gl_context_import_dmabuf_for_target (GdkGLContext *self,
int width,
int height,
const GdkDmabuf *dmabuf,
int target)
{
#if defined(HAVE_EGL) && defined(HAVE_DMABUF)
GdkDisplay *display = gdk_gl_context_get_display (self);
EGLDisplay egl_display = gdk_display_get_egl_display (display);
EGLint attribs[64];
int i;
EGLImage image;
guint texture_id;
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), 0);
g_return_val_if_fail (width > 0, 0);
g_return_val_if_fail (height > 0, 0);
g_return_val_if_fail (1 <= dmabuf->n_planes && dmabuf->n_planes <= 4, 0);
g_return_val_if_fail (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES, 0);
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_import)
return 0;
GDK_DEBUG (DMABUF,
"Importing dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %u) into GL",
(char *) &dmabuf->fourcc, dmabuf->modifier, dmabuf->n_planes);
i = 0;
attribs[i++] = EGL_IMAGE_PRESERVED_KHR;
attribs[i++] = EGL_TRUE;
attribs[i++] = EGL_WIDTH;
attribs[i++] = width;
attribs[i++] = EGL_HEIGHT;
attribs[i++] = height;
attribs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[i++] = dmabuf->fourcc;
#define ADD_PLANE(plane) \
{ \
if (dmabuf->modifier != DRM_FORMAT_MOD_INVALID) \
{ \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_MODIFIER_LO_EXT; \
attribs[i++] = dmabuf->modifier & 0xFFFFFFFF; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ## _MODIFIER_HI_EXT; \
attribs[i++] = dmabuf->modifier >> 32; \
} \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_FD_EXT; \
attribs[i++] = dmabuf->planes[plane].fd; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_PITCH_EXT; \
attribs[i++] = dmabuf->planes[plane].stride; \
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_OFFSET_EXT; \
attribs[i++] = dmabuf->planes[plane].offset; \
}
ADD_PLANE (0);
if (dmabuf->n_planes > 1) ADD_PLANE (1);
if (dmabuf->n_planes > 2) ADD_PLANE (2);
if (dmabuf->n_planes > 3) ADD_PLANE (3);
attribs[i++] = EGL_NONE;
image = eglCreateImageKHR (egl_display,
EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
(EGLClientBuffer)NULL,
attribs);
image = gdk_dmabuf_egl_create_image (display,
width,
height,
dmabuf,
target);
if (image == EGL_NO_IMAGE)
{
GDK_DEBUG (DMABUF, "Creating EGLImage for dmabuf failed: %#x", eglGetError ());
return 0;
}
return 0;
glGenTextures (1, &texture_id);
glBindTexture (target, texture_id);
@@ -2077,7 +2178,7 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
eglDestroyImageKHR (egl_display, image);
eglDestroyImageKHR (gdk_display_get_egl_display (display), image);
return texture_id;
#else
@@ -2085,6 +2186,70 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
#endif
}
guint
gdk_gl_context_import_dmabuf (GdkGLContext *self,
int width,
int height,
const GdkDmabuf *dmabuf,
gboolean *external)
{
GdkDisplay *display = gdk_gl_context_get_display (self);
guint texture_id;
gdk_display_init_dmabuf (display);
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
{
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_2D);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
gboolean
gdk_gl_context_export_dmabuf (GdkGLContext *self,
unsigned int texture_id,
@@ -2111,9 +2276,13 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
g_return_val_if_fail (dmabuf != NULL, FALSE);
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_export)
return 0;
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't export dmabufs from GL, missing EGL or EGL_EXT_image_dma_buf_export");
return 0;
}
GDK_DEBUG (DMABUF, "Exporting GL texture to dmabuf");
GDK_DISPLAY_DEBUG (display, DMABUF, "Exporting GL texture to dmabuf");
i = 0;
attribs[i++] = EGL_IMAGE_PRESERVED_KHR;
@@ -2129,7 +2298,8 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
if (image == EGL_NO_IMAGE)
{
GDK_DEBUG (DMABUF, "Creating EGLImage for dmabuf failed: %#x", eglGetError ());
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating EGLImage for dmabuf failed: %#x", eglGetError ());
return FALSE;
}
@@ -2139,13 +2309,15 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
&n_planes,
&modifier))
{
GDK_DEBUG (DMABUF, "eglExportDMABUFImageQueryMESA failed: %#x", eglGetError ());
GDK_DISPLAY_DEBUG (display, DMABUF,
"eglExportDMABUFImageQueryMESA failed: %#x", eglGetError ());
goto out;
}
if (n_planes < 1 || n_planes > GDK_DMABUF_MAX_PLANES)
{
GDK_DEBUG (DMABUF, "dmabufs with %d planes are not supported", n_planes);
GDK_DISPLAY_DEBUG (display, DMABUF,
"dmabufs with %d planes are not supported", n_planes);
goto out;
}
@@ -2179,8 +2351,8 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
dmabuf->planes[i].offset = (int) offsets[i];
}
GDK_DEBUG (DMABUF,
"Exported GL texture to dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %d)",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Exported GL texture to dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %d)",
(char *)&fourcc, modifier, n_planes);
result = TRUE;

View File

@@ -35,6 +35,17 @@ typedef enum {
GDK_GL_CGL
} GdkGLBackend;
typedef enum {
/* The format is supported for glTexImage2D() */
GDK_GL_FORMAT_USABLE = 1 << 0,
/* The format can be rendered to.
* GL/GLES spec term: "color-renderable" */
GDK_GL_FORMAT_RENDERABLE = 1 << 1,
/* GL_LINEAR/GL_MIPMAP_LINEAR can be used for textures in this format.
* GLES spec term: "texture-filterable" */
GDK_GL_FORMAT_FILTERABLE = 1 << 2
} GdkGLMemoryFlags;
/* The maximum amount of buffers we track update regions for.
* Note that this is equal to the max buffer age value we
* can provide a damage region for */
@@ -150,6 +161,8 @@ void gdk_gl_context_label_object_printf (GdkGLContext
const char * gdk_gl_context_get_glsl_version_string (GdkGLContext *self);
GdkGLMemoryFlags gdk_gl_context_get_format_flags (GdkGLContext *self,
GdkMemoryFormat format) G_GNUC_PURE;
gboolean gdk_gl_context_has_debug (GdkGLContext *self) G_GNUC_PURE;
gboolean gdk_gl_context_use_es_bgra (GdkGLContext *context);
@@ -162,15 +175,13 @@ gboolean gdk_gl_context_has_bgra (GdkGLContext
gboolean gdk_gl_context_has_vertex_arrays (GdkGLContext *self) G_GNUC_PURE;
gboolean gdk_gl_context_has_image_storage (GdkGLContext *self) G_GNUC_PURE;
double gdk_gl_context_get_scale (GdkGLContext *self);
guint gdk_gl_context_import_dmabuf (GdkGLContext *self,
int width,
int height,
const GdkDmabuf *dmabuf,
int target);
gboolean *external);
gboolean gdk_gl_context_export_dmabuf (GdkGLContext *self,
unsigned int texture_id,

View File

@@ -151,15 +151,18 @@ gdk_gl_texture_find_format (GdkGLContext *context,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLenum q_internal_format, q_format, q_type;
GLint q_internal_format;
GLenum q_format, q_type;
GLint q_swizzle[4];
if (gdk_memory_format_alpha (format) != alpha)
continue;
if (!gdk_memory_format_gl_format (format, context, &q_internal_format, &q_format, &q_type, q_swizzle))
if (!(gdk_gl_context_get_format_flags (context, format) & GDK_GL_FORMAT_RENDERABLE))
continue;
gdk_memory_format_gl_format (format, &q_internal_format, &q_format, &q_type, q_swizzle);
if (q_format != gl_format || q_type != gl_type)
continue;
@@ -179,18 +182,19 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
GLint gl_internal_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
format = gdk_texture_get_format (texture),
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
if (!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (format,
context,
&gl_internal_format,
&gl_format, &gl_type, gl_swizzle))
((gdk_gl_context_get_format_flags (context, format) & GDK_GL_FORMAT_USABLE) == GDK_GL_FORMAT_USABLE))
{
gdk_memory_format_gl_format (format,
&gl_internal_format,
&gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride &&
download->format == format)
{
@@ -228,7 +232,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
else
{
GdkMemoryFormat actual_format;
GLint gl_read_format, gl_read_type;
GLenum gl_read_format, gl_read_type;
GLuint fbo;
glGenFramebuffers (1, &fbo);
@@ -236,26 +240,34 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
{
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (context, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format))
GLint read_format, read_type;
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &read_type);
if (gdk_gl_texture_find_format (context, gdk_memory_format_alpha (format), read_format, read_type, &actual_format))
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
gl_read_format = read_format;
gl_read_type = read_type;
}
else
{
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format));
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
actual_format = gdk_memory_format_get_straight (actual_format);
gdk_memory_format_gl_format (actual_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
}
else
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format));
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
actual_format = gdk_memory_format_get_straight (actual_format);
gdk_memory_format_gl_format (actual_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
if (download->format == actual_format &&

View File

@@ -213,7 +213,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
gobject_class->set_property = gdk_gl_texture_builder_set_property;
/**
* GdkGLTextureBuilder:context: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_context org.gdk.Property.set=gdk_gl_texture_builder_set_context)
* GdkGLTextureBuilder:context: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_context org.gtk.Property.set=gdk_gl_texture_builder_set_context)
*
* The context owning the texture.
*
@@ -225,7 +225,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:format: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_format org.gdk.Property.set=gdk_gl_texture_builder_set_format)
* GdkGLTextureBuilder:format: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_format org.gtk.Property.set=gdk_gl_texture_builder_set_format)
*
* The format when downloading the texture.
*
@@ -238,7 +238,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:has-mipmap: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_has_mipmap org.gdk.Property.set=gdk_gl_texture_builder_set_has_mipmap)
* GdkGLTextureBuilder:has-mipmap: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_has_mipmap org.gtk.Property.set=gdk_gl_texture_builder_set_has_mipmap)
*
* If the texture has a mipmap.
*
@@ -250,7 +250,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:height: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_height org.gdk.Property.set=gdk_gl_texture_builder_set_height)
* GdkGLTextureBuilder:height: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_height org.gtk.Property.set=gdk_gl_texture_builder_set_height)
*
* The height of the texture.
*
@@ -262,7 +262,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:id: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_id org.gdk.Property.set=gdk_gl_texture_builder_set_id)
* GdkGLTextureBuilder:id: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_id org.gtk.Property.set=gdk_gl_texture_builder_set_id)
*
* The texture ID to use.
*
@@ -274,7 +274,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:sync: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_sync org.gdk.Property.set=gdk_gl_texture_builder_set_sync)
* GdkGLTextureBuilder:sync: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_sync org.gtk.Property.set=gdk_gl_texture_builder_set_sync)
*
* An optional `GLSync` object.
*
@@ -287,7 +287,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:update-region: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_update_region org.gdk.Property.set=gdk_gl_texture_builder_set_update_region)
* GdkGLTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_region org.gtk.Property.set=gdk_gl_texture_builder_set_update_region)
*
* The update region for [property@Gdk.GLTextureBuilder:update-texture].
*
@@ -299,7 +299,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:update-texture: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_update_texture org.gdk.Property.set=gdk_gl_texture_builder_set_update_texture)
* GdkGLTextureBuilder:update-texture: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_texture org.gtk.Property.set=gdk_gl_texture_builder_set_update_texture)
*
* The texture [property@Gdk.GLTextureBuilder:update-region] is an update for.
*
@@ -311,7 +311,7 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:width: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_width org.gdk.Property.set=gdk_gl_texture_builder_set_width)
* GdkGLTextureBuilder:width: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_width org.gtk.Property.set=gdk_gl_texture_builder_set_width)
*
* The width of the texture.
*
@@ -347,7 +347,7 @@ gdk_gl_texture_builder_new (void)
}
/**
* gdk_gl_texture_builder_get_context: (attributes org.gdk.Method.get_property=context)
* gdk_gl_texture_builder_get_context: (attributes org.gtk.Method.get_property=context)
* @self: a `GdkGLTextureBuilder`
*
* Gets the context previously set via gdk_gl_texture_builder_set_context() or
@@ -366,7 +366,7 @@ gdk_gl_texture_builder_get_context (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_context: (attributes org.gdk.Method.set_property=context)
* gdk_gl_texture_builder_set_context: (attributes org.gtk.Method.set_property=context)
* @self: a `GdkGLTextureBuilder`
* @context: (nullable): The context the texture beongs to or %NULL to unset
*
@@ -391,7 +391,7 @@ gdk_gl_texture_builder_set_context (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_height: (attributes org.gdk.Method.get_property=height)
* gdk_gl_texture_builder_get_height: (attributes org.gtk.Method.get_property=height)
* @self: a `GdkGLTextureBuilder`
*
* Gets the height previously set via gdk_gl_texture_builder_set_height() or
@@ -410,7 +410,7 @@ gdk_gl_texture_builder_get_height (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_height: (attributes org.gdk.Method.set_property=height)
* gdk_gl_texture_builder_set_height: (attributes org.gtk.Method.set_property=height)
* @self: a `GdkGLTextureBuilder`
* @height: The texture's height or 0 to unset
*
@@ -435,7 +435,7 @@ gdk_gl_texture_builder_set_height (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_id: (attributes org.gdk.Method.get_property=id)
* gdk_gl_texture_builder_get_id: (attributes org.gtk.Method.get_property=id)
* @self: a `GdkGLTextureBuilder`
*
* Gets the texture id previously set via gdk_gl_texture_builder_set_id() or
@@ -454,7 +454,7 @@ gdk_gl_texture_builder_get_id (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_id: (attributes org.gdk.Method.set_property=id)
* gdk_gl_texture_builder_set_id: (attributes org.gtk.Method.set_property=id)
* @self: a `GdkGLTextureBuilder`
* @id: The texture id to be used for creating the texture
*
@@ -481,7 +481,7 @@ gdk_gl_texture_builder_set_id (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_width: (attributes org.gdk.Method.get_property=width)
* gdk_gl_texture_builder_get_width: (attributes org.gtk.Method.get_property=width)
* @self: a `GdkGLTextureBuilder`
*
* Gets the width previously set via gdk_gl_texture_builder_set_width() or
@@ -500,7 +500,7 @@ gdk_gl_texture_builder_get_width (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_width: (attributes org.gdk.Method.set_property=width)
* gdk_gl_texture_builder_set_width: (attributes org.gtk.Method.set_property=width)
* @self: a `GdkGLTextureBuilder`
* @width: The texture's width or 0 to unset
*
@@ -525,7 +525,7 @@ gdk_gl_texture_builder_set_width (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_has_mipmap: (attributes org.gdk.Method.get_property=has-mipmap)
* gdk_gl_texture_builder_get_has_mipmap: (attributes org.gtk.Method.get_property=has-mipmap)
* @self: a `GdkGLTextureBuilder`
*
* Gets whether the texture has a mipmap.
@@ -543,7 +543,7 @@ gdk_gl_texture_builder_get_has_mipmap (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_has_mipmap: (attributes org.gdk.Method.set_property=has-mipmap)
* gdk_gl_texture_builder_set_has_mipmap: (attributes org.gtk.Method.set_property=has-mipmap)
* @self: a `GdkGLTextureBuilder`
* @has_mipmap: Whether the texture has a mipmap
*
@@ -569,7 +569,7 @@ gdk_gl_texture_builder_set_has_mipmap (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_sync: (attributes org.gdk.Method.get_property=sync)
* gdk_gl_texture_builder_get_sync: (attributes org.gtk.Method.get_property=sync)
* @self: a `GdkGLTextureBuilder`
*
* Gets the `GLsync` previously set via gdk_gl_texture_builder_set_sync().
@@ -587,7 +587,7 @@ gdk_gl_texture_builder_get_sync (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_sync: (attributes org.gdk.Method.set_property=sync)
* gdk_gl_texture_builder_set_sync: (attributes org.gtk.Method.set_property=sync)
* @self: a `GdkGLTextureBuilder`
* @sync: (nullable): the GLSync object
*
@@ -617,7 +617,7 @@ gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_format: (attributes org.gdk.Method.get_property=format)
* gdk_gl_texture_builder_get_format: (attributes org.gtk.Method.get_property=format)
* @self: a `GdkGLTextureBuilder`
*
* Gets the format previously set via gdk_gl_texture_builder_set_format().
@@ -635,7 +635,7 @@ gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_format: (attributes org.gdk.Method.set_property=format)
* gdk_gl_texture_builder_set_format: (attributes org.gtk.Method.set_property=format)
* @self: a `GdkGLTextureBuilder`
* @format: The texture's format
*
@@ -673,7 +673,7 @@ gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_update_texture: (attributes org.gdk.Method.get_property=update_texture)
* gdk_gl_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
* @self: a `GdkGLTextureBuilder`
*
* Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or
@@ -692,7 +692,7 @@ gdk_gl_texture_builder_get_update_texture (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_update_texture: (attributes org.gdk.Method.set_property=update_texture)
* gdk_gl_texture_builder_set_update_texture: (attributes org.gtk.Method.set_property=update-texture)
* @self: a `GdkGLTextureBuilder`
* @texture: (nullable): the texture to update
*
@@ -715,7 +715,7 @@ gdk_gl_texture_builder_set_update_texture (GdkGLTextureBuilder *self,
}
/**
* gdk_gl_texture_builder_get_update_region: (attributes org.gdk.Method.get_property=update_region)
* gdk_gl_texture_builder_get_update_region: (attributes org.gtk.Method.get_property=update-region)
* @self: a `GdkGLTextureBuilder`
*
* Gets the region previously set via gdk_gl_texture_builder_set_update_region() or
@@ -734,7 +734,7 @@ gdk_gl_texture_builder_get_update_region (GdkGLTextureBuilder *self)
}
/**
* gdk_gl_texture_builder_set_update_region: (attributes org.gdk.Method.set_property=update_region)
* gdk_gl_texture_builder_set_update_region: (attributes org.gtk.Method.set_property=update-region)
* @self: a `GdkGLTextureBuilder`
* @region: (nullable): the region to update
*

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