Compare commits
354 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4edaf98249 | |||
| cd6e8d9e5b | |||
| bd3afd1006 | |||
| 79009d4158 | |||
| b782f80311 | |||
| c48a3152f0 | |||
| d2d2fb4b50 | |||
| ff9c9e05c3 | |||
| e3f39bf0c3 | |||
| d692243727 | |||
| 6ad9db0bf0 | |||
| 486157f6bf | |||
| 5ca4ab3aaa | |||
| a37b3fb691 | |||
| c414889cfa | |||
| 4dfc07ef57 | |||
| cf4b0a27f8 | |||
| 393ee574b6 | |||
| e3c85be53f | |||
| 0f5fda2277 | |||
| 0889037959 | |||
| ee56ad792c | |||
| 5688b7b4bb | |||
| df1802f756 | |||
| 84de90756d | |||
| cb5a8a76da | |||
| 26c35c00e1 | |||
| 5d4879aae7 | |||
| 39b08b82ca | |||
| 2b6e7147d6 | |||
| 3a1349e8ef | |||
| 5485d806c5 | |||
| 6e7c499408 | |||
| c341da32aa | |||
| d39ec8c09e | |||
| e3299e38df | |||
| 8fd02f6fa2 | |||
| 9bc0ad9a13 | |||
| 19171c7a89 | |||
| abf942efe5 | |||
| dfe7afdb04 | |||
| 1629b072fe | |||
| 0b0a5a52af | |||
| 75d259eedf | |||
| 6fec018cbd | |||
| 6d9c950b82 | |||
| 0933ea63c5 | |||
| 8cb594696e | |||
| 9d7389aea7 | |||
| 76a1f1714d | |||
| 9af08e17e0 | |||
| 276afbca92 | |||
| 0342d23dbe | |||
| 1c10837b21 | |||
| 7cc5d5c7a5 | |||
| 6a59326dbf | |||
| 1968f331d9 | |||
| bf35836350 | |||
| 036629a491 | |||
| 8cabf59cf3 | |||
| 6a4b238641 | |||
| d4d0239ae7 | |||
| a30f32db8d | |||
| 6948a74d72 | |||
| 14ec255812 | |||
| 00ebd51d06 | |||
| 7de528b487 | |||
| 77f40d7508 | |||
| b969f4649d | |||
| f4f25e584c | |||
| b049a3501a | |||
| 0114fad8a5 | |||
| afafac6878 | |||
| 108eb43b01 | |||
| 6961c1fe4a | |||
| 606d150e0b | |||
| 96f7bb99a7 | |||
| b937c17985 | |||
| 79cb370f81 | |||
| 154b73723f | |||
| c0efed4e4a | |||
| 4402676aa2 | |||
| 9bf4a45d47 | |||
| 85ce343816 | |||
| 114d0621aa | |||
| d595aff52d | |||
| d72fd951e1 | |||
| 78706e3fbe | |||
| 98b796a371 | |||
| c99f62aef1 | |||
| 8754247a90 | |||
| fd12707162 | |||
| 34bca0ff56 | |||
| c668519d07 | |||
| 454e6eadc6 | |||
| e248a01fbd | |||
| e2bd7defa4 | |||
| 855fa6d523 | |||
| 7c620ac2b7 | |||
| d96f2f54e9 | |||
| 71c2ee3530 | |||
| 5e415ee916 | |||
| e163021b8f | |||
| 1bf88f1d81 | |||
| 72d2b8e546 | |||
| 37f7f3d60c | |||
| 8d1443994b | |||
| 39db73dff1 | |||
| 68cf5f2cf3 | |||
| 77c4097c86 | |||
| d7bc4c719b | |||
| 725857e15b | |||
| 50ee872978 | |||
| b6c82c6b54 | |||
| 1bf94b045c | |||
| 13bfe188b5 | |||
| f21175b3d0 | |||
| d78475372f | |||
| 988b9de210 | |||
| 0c19ef6c2c | |||
| 2bfd4a88d6 | |||
| de3eeb4970 | |||
| 5c2e2977e0 | |||
| 24f3ec0949 | |||
| bcab0e4254 | |||
| 253955c017 | |||
| 3a8834a437 | |||
| 48ea2ecac3 | |||
| 6d0b31128b | |||
| 0b519bc353 | |||
| bb756b35a2 | |||
| 7ba7ab1e3d | |||
| f73a7e29ca | |||
| 2eb6e3d4c5 | |||
| b28cf76f11 | |||
| 36314f28e2 | |||
| b7a1b1d7ee | |||
| 57e382b59c | |||
| a35a885902 | |||
| 5fa3a2a39f | |||
| 7f53b3d3f4 | |||
| 9b25257cbf | |||
| a90a6c4517 | |||
| e69f062c99 | |||
| 210c7f25ad | |||
| 9695791f7b | |||
| ca0da0dd83 | |||
| 5a8a839921 | |||
| eb84171cda | |||
| 5608a8978e | |||
| efefdbd5c0 | |||
| 6bea059424 | |||
| c99c06f0da | |||
| bda8f5393d | |||
| 160fa969d4 | |||
| edf33a6617 | |||
| 86587a9328 | |||
| 8691d471d0 | |||
| 463b6dd1fd | |||
| 88e1f77f90 | |||
| 1ee488f445 | |||
| eae0e15b9d | |||
| 00d551bda8 | |||
| 2dcec44714 | |||
| f04c819439 | |||
| c679ba9ebf | |||
| 9aadc2b860 | |||
| e4370cc95e | |||
| 22ceb018fb | |||
| 833d307695 | |||
| e8afb5e210 | |||
| b916c4dac1 | |||
| 699c6d6159 | |||
| 025b846fce | |||
| fcdbab3f69 | |||
| d7eac7a6ad | |||
| 52dbb3f372 | |||
| 7dc38ca12f | |||
| e858924d03 | |||
| 852aab1576 | |||
| 5eb42815ed | |||
| 0b853f62ed | |||
| fb969f5431 | |||
| ef6ed31853 | |||
| c57245b73c | |||
| f9fd78b67e | |||
| 00a63a9fcf | |||
| b4ae2377b3 | |||
| 392977d670 | |||
| 5a29e2704c | |||
| ec6c52680e | |||
| d850161b2f | |||
| 1a3504469d | |||
| be0546bb39 | |||
| d4a569057f | |||
| c5727df568 | |||
| 7406cea257 | |||
| de3f55fc5f | |||
| 010ff81b2f | |||
| c94ec8b658 | |||
| 9c1ae5374d | |||
| 4a018de0a1 | |||
| 23e50bb21d | |||
| a8e3e747df | |||
| 7fd90853f8 | |||
| 01aa4989f8 | |||
| d4fee23ff6 | |||
| b878949f00 | |||
| 3a88522a19 | |||
| 358cd28d09 | |||
| 6eb6b0cb50 | |||
| c81954120a | |||
| 4bdc44f4af | |||
| 3ab7b2d7ce | |||
| 429056c214 | |||
| acecf519bc | |||
| b2fbdcda41 | |||
| 1b08fda93e | |||
| f6b6176ec0 | |||
| 2803189afd | |||
| ad08c1444a | |||
| ef77a6fa73 | |||
| 667f02ecd8 | |||
| 160f632668 | |||
| 653bf46494 | |||
| 46d4c70cd7 | |||
| 4920ac4a57 | |||
| 5bdc9f71fd | |||
| c92761b184 | |||
| 9185f15cd9 | |||
| efec30babb | |||
| 190e7da317 | |||
| 28d38cd730 | |||
| d7a72493ae | |||
| 7299c9baa9 | |||
| 540a83327f | |||
| 04d41eaa66 | |||
| 524d681496 | |||
| 44d977844b | |||
| 6259800f5a | |||
| d3a5aa5304 | |||
| d32ab7544d | |||
| e2e7c931c5 | |||
| e202348380 | |||
| ba5403da17 | |||
| 904d44074f | |||
| c636baf6f5 | |||
| b7c2528ad1 | |||
| 48740de71a | |||
| 34c16b0df2 | |||
| d0a675ab01 | |||
| 0e0bf8ed47 | |||
| 00d7d4b17b | |||
| 9eef566b54 | |||
| 272168c94b | |||
| ca054bfdc9 | |||
| 59dbfb0843 | |||
| 223e27e7dc | |||
| efe1415429 | |||
| 489723916d | |||
| e8894ad383 | |||
| 9423d6261a | |||
| b766f92026 | |||
| a37aacf4e4 | |||
| 93959ef7df | |||
| 209a1a69cc | |||
| 982f965ea8 | |||
| f7fc90daa0 | |||
| a58424588f | |||
| f8c9b3394b | |||
| ce4d8cc6d9 | |||
| c85766ac71 | |||
| b24ae31716 | |||
| 7cf805c8b3 | |||
| 1f62c693cd | |||
| 6ae9cbfe0f | |||
| 7803aad872 | |||
| cc2d3fa7d6 | |||
| a9e4993184 | |||
| 33703bfe01 | |||
| 7ba5cf5309 | |||
| bb890f6004 | |||
| 1c7a0e7a15 | |||
| cd7e1c1387 | |||
| a2e1e727c5 | |||
| 61207f81c3 | |||
| f624586a75 | |||
| 1a93967e1f | |||
| 310ab7b531 | |||
| d55801c8ba | |||
| b1809bfd88 | |||
| deb8a35ea0 | |||
| c5ce24c82c | |||
| 54815e4771 | |||
| 5a99790a87 | |||
| 8aa7174bfb | |||
| 9df5e3cbd6 | |||
| 8b5194c016 | |||
| 9a63172cf5 | |||
| 3ade9ae184 | |||
| 76349ff6e5 | |||
| dd530b45e2 | |||
| 00ce51472c | |||
| b6bcbeae23 | |||
| cf86cc1184 | |||
| b503b60a49 | |||
| 5850055b68 | |||
| b224e66a9f | |||
| bbb0150383 | |||
| 8aef682079 | |||
| fe4b7a5159 | |||
| 7ba4ba05e1 | |||
| 85e1088171 | |||
| c1ed034367 | |||
| cc3e25b163 | |||
| bdb3e345c8 | |||
| a30e9dcfeb | |||
| 76007c4d09 | |||
| 020ef51cb0 | |||
| 1914adc344 | |||
| 6e236b9459 | |||
| 11715760f9 | |||
| f19c08ffda | |||
| d0f76b6ab4 | |||
| 4c7206343a | |||
| dfae2cb3a5 | |||
| de74d38039 | |||
| fb20542fcc | |||
| a26e289d5c | |||
| 892d3b9530 | |||
| 8477dcfeff | |||
| 25835afd9c | |||
| 06dda4e12b | |||
| 26edfe6d18 | |||
| 4a749aee6e | |||
| 99a8417142 | |||
| 20e2075a10 | |||
| d8c649b57f | |||
| bb2b8bf2c3 | |||
| eb048c91be | |||
| 358779dfb2 | |||
| 8f90ddb906 | |||
| ed54aa8acf | |||
| a90ffb117f | |||
| 29681717ed | |||
| e0cd2b756f | |||
| 2c85060b5f | |||
| 864c5b4608 | |||
| 1ab501649e | |||
| 677e78bdce | |||
| 37a5ad3a53 | |||
| 00e4dab1ef | |||
| 8367411785 | |||
| 17e37dc42a |
+14
-9
@@ -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"
|
||||
|
||||
@@ -443,8 +448,8 @@ reference:
|
||||
--force-fallback-for=gdk-pixbuf,pango
|
||||
-Dintrospection=enabled
|
||||
-Ddocumentation=true
|
||||
-Dgtk_doc=true
|
||||
-Dgdk-pixbuf:gtk_doc=true
|
||||
-Dglib:documentation=true
|
||||
-Dpango:gtk_doc=true
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-examples=false
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
FROM fedora:38
|
||||
FROM fedora:39
|
||||
|
||||
RUN dnf -y install \
|
||||
adwaita-icon-theme \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
+23
-20
@@ -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
|
||||
|
||||
@@ -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
|
||||
=========================================
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 533 B |
Binary file not shown.
|
Before Width: | Height: | Size: 127 B |
@@ -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 |
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
----
|
||||
Title: Cairo interaction
|
||||
----
|
||||
|
||||
## Functions to support using cairo
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
+37
-39
@@ -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 Don’t 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`.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
^^^^^^^^^
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
+36
-31
@@ -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,
|
||||
|
||||
+40
-5
@@ -44,6 +44,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>
|
||||
|
||||
@@ -392,6 +397,7 @@ gdk_display_dispose (GObject *object)
|
||||
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 +1433,6 @@ gdk_display_get_gl_context (GdkDisplay *self)
|
||||
}
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
@@ -1484,7 +1489,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 +1692,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 +1806,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 +1830,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 +1843,6 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
g_free (std_cfg);
|
||||
g_free (ext);
|
||||
}
|
||||
#endif
|
||||
|
||||
gdk_profiler_end_mark (start_time, "init EGL", NULL);
|
||||
|
||||
@@ -1888,7 +1921,7 @@ 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);
|
||||
|
||||
@@ -1920,6 +1953,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
|
||||
|
||||
@@ -122,6 +122,7 @@ struct _GdkDisplay
|
||||
|
||||
/* Cached data the EGL dmabuf downloader */
|
||||
gpointer egl_gsk_renderer;
|
||||
GdkDmabufFormats *egl_dmabuf_formats;
|
||||
GdkDmabufFormats *egl_external_formats;
|
||||
};
|
||||
|
||||
|
||||
+399
-64
@@ -21,6 +21,7 @@
|
||||
#include "gdkdmabufprivate.h"
|
||||
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
|
||||
@@ -28,7 +29,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <epoxy/egl.h>
|
||||
|
||||
typedef struct _GdkDrmFormatInfo GdkDrmFormatInfo;
|
||||
@@ -36,8 +36,7 @@ typedef struct _GdkDrmFormatInfo GdkDrmFormatInfo;
|
||||
struct _GdkDrmFormatInfo
|
||||
{
|
||||
guint32 fourcc;
|
||||
GdkMemoryFormat premultiplied_memory_format;
|
||||
GdkMemoryFormat unpremultiplied_memory_format;
|
||||
GdkMemoryFormat memory_format;
|
||||
void (* download) (guchar *dst_data,
|
||||
gsize dst_stride,
|
||||
GdkMemoryFormat dst_format,
|
||||
@@ -78,6 +77,55 @@ download_memcpy (guchar *dst_data,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
download_memcpy_3_1 (guchar *dst_data,
|
||||
gsize dst_stride,
|
||||
GdkMemoryFormat dst_format,
|
||||
gsize width,
|
||||
gsize height,
|
||||
const GdkDmabuf *dmabuf,
|
||||
const guchar *src_datas[GDK_DMABUF_MAX_PLANES],
|
||||
gsize sizes[GDK_DMABUF_MAX_PLANES])
|
||||
{
|
||||
guint a;
|
||||
guchar *dst_row;
|
||||
const guchar *src_data, *src_row;
|
||||
gsize src_stride;
|
||||
|
||||
g_assert (dmabuf->n_planes == 2);
|
||||
|
||||
download_memcpy (dst_data, dst_stride, dst_format, width, height, dmabuf, src_datas, sizes);
|
||||
|
||||
switch ((int)dst_format)
|
||||
{
|
||||
case GDK_MEMORY_A8R8G8B8:
|
||||
case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_A8B8G8R8:
|
||||
case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED:
|
||||
a = 0;
|
||||
break;
|
||||
case GDK_MEMORY_R8G8B8A8:
|
||||
case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_B8G8R8A8:
|
||||
case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED:
|
||||
a = 3;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
src_stride = dmabuf->planes[1].stride;
|
||||
src_data = src_datas[1];
|
||||
|
||||
for (gsize y = 0; y < height; y++)
|
||||
{
|
||||
dst_row = dst_data + y * dst_stride;
|
||||
src_row = src_data + y * src_stride;
|
||||
for (gsize x = 0; x < width; x++)
|
||||
dst_row[4 * x + a] = src_row[x];
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _YUVCoefficients YUVCoefficients;
|
||||
|
||||
struct _YUVCoefficients
|
||||
@@ -321,38 +369,147 @@ download_yuyv (guchar *dst_data,
|
||||
}
|
||||
|
||||
static const GdkDrmFormatInfo supported_formats[] = {
|
||||
{ DRM_FORMAT_BGRA8888, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, GDK_MEMORY_A8R8G8B8, download_memcpy },
|
||||
{ DRM_FORMAT_ABGR8888, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, GDK_MEMORY_R8G8B8A8, download_memcpy },
|
||||
{ DRM_FORMAT_ARGB8888, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, GDK_MEMORY_B8G8R8A8, download_memcpy },
|
||||
{ DRM_FORMAT_RGBA8888, GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, GDK_MEMORY_A8B8G8R8, download_memcpy },
|
||||
{ DRM_FORMAT_BGRX8888, GDK_MEMORY_X8R8G8B8, GDK_MEMORY_X8R8G8B8, download_memcpy },
|
||||
{ DRM_FORMAT_XBGR8888, GDK_MEMORY_R8G8B8X8, GDK_MEMORY_R8G8B8X8, download_memcpy },
|
||||
{ DRM_FORMAT_XRGB8888, GDK_MEMORY_B8G8R8X8, GDK_MEMORY_B8G8R8X8, download_memcpy },
|
||||
{ DRM_FORMAT_RGBX8888, GDK_MEMORY_X8B8G8R8, GDK_MEMORY_X8B8G8R8, download_memcpy },
|
||||
{ DRM_FORMAT_ABGR16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, GDK_MEMORY_R16G16B16A16_FLOAT, download_memcpy },
|
||||
{ DRM_FORMAT_RGB888, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_memcpy },
|
||||
{ DRM_FORMAT_BGR888, GDK_MEMORY_B8G8R8, GDK_MEMORY_B8G8R8, download_memcpy },
|
||||
/* YUV formats */
|
||||
{ DRM_FORMAT_NV12, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV21, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV16, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV61, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV24, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV42, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_YUYV, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_YVYU, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_VYUY, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_UYVY, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_YUV410, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU410, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV411, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU411, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV420, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU420, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV422, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU422, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV444, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU444, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
#if 0
|
||||
/* palette formats?! */
|
||||
{ DRM_FORMAT_C1, GDK_MEMORY_, NULL },
|
||||
{ DRM_FORMAT_C2, GDK_MEMORY_, NULL },
|
||||
{ DRM_FORMAT_C4, GDK_MEMORY_, NULL },
|
||||
{ DRM_FORMAT_C8, GDK_MEMORY_, NULL },
|
||||
#endif
|
||||
/* darkness */
|
||||
{ DRM_FORMAT_D1, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_D2, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_D4, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_D8, GDK_MEMORY_G8, NULL },
|
||||
/* red only - we treat this as gray */
|
||||
{ DRM_FORMAT_R1, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_R2, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_R4, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_R8, GDK_MEMORY_G8, NULL },
|
||||
{ DRM_FORMAT_R10, GDK_MEMORY_G16, NULL },
|
||||
{ DRM_FORMAT_R12, GDK_MEMORY_G16, NULL },
|
||||
{ DRM_FORMAT_R16, GDK_MEMORY_G16, NULL },
|
||||
/* 2 channels - FIXME: Should this be gray + alpha? */
|
||||
{ DRM_FORMAT_RG88, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_GR88, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_RG1616, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_GR1616, GDK_MEMORY_R16G16B16, NULL },
|
||||
/* <8bit per channel RGB(A) */
|
||||
{ DRM_FORMAT_RGB332, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_BGR233, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_XRGB4444, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_XBGR4444, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_RGBX4444, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_BGRX4444, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_ARGB4444, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_ABGR4444, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_RGBA4444, GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_BGRA4444, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_XRGB1555, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_XBGR1555, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_RGBX5551, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_BGRX5551, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_ARGB1555, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_ABGR1555, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_RGBA5551, GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_BGRA5551, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_RGB565, GDK_MEMORY_B8G8R8, NULL },
|
||||
{ DRM_FORMAT_BGR565, GDK_MEMORY_R8G8B8, NULL },
|
||||
/* 8bit RGB */
|
||||
{ DRM_FORMAT_RGB888, GDK_MEMORY_R8G8B8, download_memcpy },
|
||||
{ DRM_FORMAT_BGR888, GDK_MEMORY_B8G8R8, download_memcpy },
|
||||
/* 8bit RGBA */
|
||||
{ DRM_FORMAT_BGRA8888, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, download_memcpy },
|
||||
{ DRM_FORMAT_ABGR8888, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, download_memcpy },
|
||||
{ DRM_FORMAT_ARGB8888, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, download_memcpy },
|
||||
{ DRM_FORMAT_RGBA8888, GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, download_memcpy },
|
||||
{ DRM_FORMAT_BGRX8888, GDK_MEMORY_X8R8G8B8, download_memcpy },
|
||||
{ DRM_FORMAT_XBGR8888, GDK_MEMORY_R8G8B8X8, download_memcpy },
|
||||
{ DRM_FORMAT_XRGB8888, GDK_MEMORY_B8G8R8X8, download_memcpy },
|
||||
{ DRM_FORMAT_RGBX8888, GDK_MEMORY_X8B8G8R8, download_memcpy },
|
||||
{ DRM_FORMAT_ABGR16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, download_memcpy },
|
||||
/* 10bit RGB(A) */
|
||||
{ DRM_FORMAT_XRGB2101010, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_XBGR2101010, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_RGBX1010102, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_BGRX1010102, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_ARGB2101010, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_ABGR2101010, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_RGBA1010102, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_BGRA1010102, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
/* 16bit RGB(A) */
|
||||
{ DRM_FORMAT_XRGB16161616, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_XBGR16161616, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_ARGB16161616, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_ABGR16161616, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_XRGB16161616F, GDK_MEMORY_R16G16B16_FLOAT, NULL },
|
||||
{ DRM_FORMAT_XBGR16161616F, GDK_MEMORY_R16G16B16_FLOAT, NULL },
|
||||
{ DRM_FORMAT_ARGB16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_ABGR16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_AXBXGXRX106106106106, GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, NULL },
|
||||
/* 1-plane YUV formats */
|
||||
{ DRM_FORMAT_YUYV, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_YVYU, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_VYUY, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_UYVY, GDK_MEMORY_R8G8B8, download_yuyv },
|
||||
{ DRM_FORMAT_AYUV, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_AVUY8888, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_XYUV8888, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_XVUY8888, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_VUY888, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_VUY101010, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y210, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y212, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y216, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y410, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y412, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Y416, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_XVYU2101010, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_XVYU12_16161616, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_XVYU16161616, GDK_MEMORY_R16G16B16, NULL },
|
||||
/* tiled YUV */
|
||||
{ DRM_FORMAT_Y0L0, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_X0L0, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_Y0L2, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_X0L2, GDK_MEMORY_R16G16B16, NULL },
|
||||
/* non-linear YUV */
|
||||
{ DRM_FORMAT_YUV420_8BIT, GDK_MEMORY_R8G8B8, NULL },
|
||||
{ DRM_FORMAT_YUV420_10BIT, GDK_MEMORY_R16G16B16, NULL },
|
||||
/* 2 plane RGB + A */
|
||||
{ DRM_FORMAT_BGRX8888_A8, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, download_memcpy_3_1 },
|
||||
{ DRM_FORMAT_RGBX8888_A8, GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, download_memcpy_3_1 },
|
||||
{ DRM_FORMAT_XBGR8888_A8, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, download_memcpy_3_1 },
|
||||
{ DRM_FORMAT_XRGB8888_A8, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, download_memcpy_3_1 },
|
||||
{ DRM_FORMAT_RGB888_A8, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_BGR888_A8, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_RGB565_A8, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, NULL },
|
||||
{ DRM_FORMAT_BGR565_A8, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, NULL },
|
||||
/* 2-plane YUV formats */
|
||||
{ DRM_FORMAT_NV12, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV21, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV16, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV61, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV24, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV42, GDK_MEMORY_R8G8B8, download_nv12 },
|
||||
{ DRM_FORMAT_NV15, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_P210, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_P010, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_P012, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_P016, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_P030, GDK_MEMORY_R16G16B16, NULL },
|
||||
/* 3-plane YUV */
|
||||
{ DRM_FORMAT_Q410, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_Q401, GDK_MEMORY_R16G16B16, NULL },
|
||||
{ DRM_FORMAT_YUV410, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU410, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV411, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU411, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV420, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU420, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV422, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU422, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YUV444, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
{ DRM_FORMAT_YVU444, GDK_MEMORY_R8G8B8, download_yuv_3 },
|
||||
};
|
||||
|
||||
static const GdkDrmFormatInfo *
|
||||
@@ -367,6 +524,118 @@ get_drm_format_info (guint32 fourcc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_dmabuf_get_memory_format (guint32 fourcc,
|
||||
gboolean premultiplied,
|
||||
GdkMemoryFormat *out_format)
|
||||
{
|
||||
const GdkDrmFormatInfo *info = get_drm_format_info (fourcc);
|
||||
|
||||
if (info == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (premultiplied)
|
||||
*out_format = gdk_memory_format_get_premultiplied (info->memory_format);
|
||||
else
|
||||
*out_format = gdk_memory_format_get_straight (info->memory_format);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_dmabuf_get_fourcc (GdkMemoryFormat format,
|
||||
guint32 *out_fourcc)
|
||||
{
|
||||
/* we're not walking the list on purpose, so that we can keep track
|
||||
* of exact matches here. Certain DRM formats map to the same memory
|
||||
* format and we don't want the list to accidentally get mixed up.
|
||||
*/
|
||||
switch (format)
|
||||
{
|
||||
case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_B8G8R8A8:
|
||||
*out_fourcc = DRM_FORMAT_ARGB8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_A8R8G8B8:
|
||||
*out_fourcc = DRM_FORMAT_BGRA8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_A8B8G8R8:
|
||||
*out_fourcc = DRM_FORMAT_RGBA8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_R8G8B8A8:
|
||||
*out_fourcc = DRM_FORMAT_ABGR8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R8G8B8:
|
||||
*out_fourcc = DRM_FORMAT_BGR888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_B8G8R8:
|
||||
*out_fourcc = DRM_FORMAT_RGB888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_B8G8R8X8:
|
||||
*out_fourcc = DRM_FORMAT_XRGB8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_X8R8G8B8:
|
||||
*out_fourcc = DRM_FORMAT_BGRX8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R8G8B8X8:
|
||||
*out_fourcc = DRM_FORMAT_XBGR8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_X8B8G8R8:
|
||||
*out_fourcc = DRM_FORMAT_RGBX8888;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
|
||||
case GDK_MEMORY_R16G16B16A16_FLOAT:
|
||||
*out_fourcc = DRM_FORMAT_ABGR16161616F;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_R16G16B16A16:
|
||||
*out_fourcc = DRM_FORMAT_ABGR16161616;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_G8:
|
||||
*out_fourcc = DRM_FORMAT_R8;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_G16:
|
||||
*out_fourcc = DRM_FORMAT_R16;
|
||||
return TRUE;
|
||||
|
||||
case GDK_MEMORY_R16G16B16:
|
||||
case GDK_MEMORY_R16G16B16_FLOAT:
|
||||
case GDK_MEMORY_R32G32B32_FLOAT:
|
||||
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
|
||||
case GDK_MEMORY_R32G32B32A32_FLOAT:
|
||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G8A8:
|
||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G16A16:
|
||||
case GDK_MEMORY_A8:
|
||||
case GDK_MEMORY_A16:
|
||||
case GDK_MEMORY_A16_FLOAT:
|
||||
case GDK_MEMORY_A32_FLOAT:
|
||||
return FALSE;
|
||||
|
||||
case GDK_MEMORY_N_FORMATS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dmabuf_direct_downloader_add_formats (const GdkDmabufDownloader *downloader,
|
||||
GdkDisplay *display,
|
||||
@@ -376,9 +645,10 @@ gdk_dmabuf_direct_downloader_add_formats (const GdkDmabufDownloader *downloader,
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (supported_formats); i++)
|
||||
{
|
||||
GDK_DEBUG (DMABUF, "%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
downloader->name,
|
||||
(char *) &supported_formats[i].fourcc, (guint64) DRM_FORMAT_MOD_LINEAR);
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
downloader->name,
|
||||
(char *) &supported_formats[i].fourcc, (guint64) DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_format (builder,
|
||||
supported_formats[i].fourcc,
|
||||
@@ -400,7 +670,7 @@ gdk_dmabuf_direct_downloader_supports (const GdkDmabufDownloader *downloader,
|
||||
|
||||
info = get_drm_format_info (dmabuf->fourcc);
|
||||
|
||||
if (!info)
|
||||
if (!info || !info->download)
|
||||
{
|
||||
g_set_error (error,
|
||||
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT,
|
||||
@@ -418,16 +688,19 @@ gdk_dmabuf_direct_downloader_supports (const GdkDmabufDownloader *downloader,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*out_format = premultiplied ? info->premultiplied_memory_format
|
||||
: info->unpremultiplied_memory_format;
|
||||
if (premultiplied)
|
||||
*out_format = gdk_memory_format_get_premultiplied (info->memory_format);
|
||||
else
|
||||
*out_format = gdk_memory_format_get_straight (info->memory_format);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_direct_downloader_do_download (GdkTexture *texture,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
gdk_dmabuf_direct_downloader_do_download (const GdkDmabufDownloader *downloader,
|
||||
GdkTexture *texture,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
const GdkDrmFormatInfo *info;
|
||||
const GdkDmabuf *dmabuf;
|
||||
@@ -439,9 +712,11 @@ gdk_dmabuf_direct_downloader_do_download (GdkTexture *texture,
|
||||
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
|
||||
info = get_drm_format_info (dmabuf->fourcc);
|
||||
|
||||
GDK_DEBUG (DMABUF,
|
||||
"Using mmap() and memcpy() for downloading a dmabuf (format %.4s:%#lx)",
|
||||
(char *)&dmabuf->fourcc, dmabuf->modifier);
|
||||
g_return_if_fail (info && info->download);
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_dmabuf_texture_get_display (GDK_DMABUF_TEXTURE (texture)), DMABUF,
|
||||
"Using %s for downloading a dmabuf (format %.4s:%#" G_GINT64_MODIFIER "x)",
|
||||
downloader->name, (char *)&dmabuf->fourcc, dmabuf->modifier);
|
||||
|
||||
for (i = 0; i < dmabuf->n_planes; i++)
|
||||
{
|
||||
@@ -463,10 +738,10 @@ gdk_dmabuf_direct_downloader_do_download (GdkTexture *texture,
|
||||
g_warning ("Failed to seek dmabuf: %s", g_strerror (errno));
|
||||
goto out;
|
||||
}
|
||||
/* be a good citizen and seek back to the start, as the dos recommend */
|
||||
/* be a good citizen and seek back to the start, as the docs recommend */
|
||||
lseek (dmabuf->planes[i].fd, 0, SEEK_SET);
|
||||
|
||||
if (ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0)
|
||||
if (gdk_dmabuf_ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0)
|
||||
g_warning ("Failed to sync dmabuf: %s", g_strerror (errno));
|
||||
|
||||
src_data[i] = mmap (NULL, sizes[i], PROT_READ, MAP_SHARED, dmabuf->planes[i].fd, dmabuf->planes[i].offset);
|
||||
@@ -495,7 +770,7 @@ out:
|
||||
|
||||
munmap ((void *)src_data[i], sizes[i]);
|
||||
|
||||
if (ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_END|DMA_BUF_SYNC_READ }) < 0)
|
||||
if (gdk_dmabuf_ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_END|DMA_BUF_SYNC_READ }) < 0)
|
||||
g_warning ("Failed to sync dmabuf: %s", g_strerror (errno));
|
||||
}
|
||||
}
|
||||
@@ -510,7 +785,7 @@ gdk_dmabuf_direct_downloader_download (const GdkDmabufDownloader *downloader,
|
||||
GdkMemoryFormat src_format = gdk_texture_get_format (texture);
|
||||
|
||||
if (format == src_format)
|
||||
gdk_dmabuf_direct_downloader_do_download (texture, data, stride);
|
||||
gdk_dmabuf_direct_downloader_do_download (downloader, texture, data, stride);
|
||||
else
|
||||
{
|
||||
unsigned int width, height;
|
||||
@@ -523,7 +798,7 @@ gdk_dmabuf_direct_downloader_download (const GdkDmabufDownloader *downloader,
|
||||
src_stride = width * gdk_memory_format_bytes_per_pixel (src_format);
|
||||
src_data = g_new (guchar, src_stride * height);
|
||||
|
||||
gdk_dmabuf_direct_downloader_do_download (texture, src_data, src_stride);
|
||||
gdk_dmabuf_direct_downloader_do_download (downloader, texture, src_data, src_stride);
|
||||
|
||||
gdk_memory_convert (data, stride, format,
|
||||
src_data, src_stride, src_format,
|
||||
@@ -546,6 +821,75 @@ gdk_dmabuf_get_direct_downloader (void)
|
||||
return &downloader;
|
||||
}
|
||||
|
||||
int
|
||||
gdk_dmabuf_ioctl (int fd,
|
||||
unsigned long request,
|
||||
void *arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
do {
|
||||
ret = ioctl (fd, request, arg);
|
||||
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(DMA_BUF_IOCTL_IMPORT_SYNC_FILE)
|
||||
struct dma_buf_import_sync_file
|
||||
{
|
||||
__u32 flags;
|
||||
__s32 fd;
|
||||
};
|
||||
#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file)
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
gdk_dmabuf_import_sync_file (int dmabuf_fd,
|
||||
guint32 flags,
|
||||
int sync_file_fd)
|
||||
{
|
||||
struct dma_buf_import_sync_file data = {
|
||||
.flags = flags,
|
||||
.fd = sync_file_fd,
|
||||
};
|
||||
|
||||
if (gdk_dmabuf_ioctl (dmabuf_fd, DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &data) != 0)
|
||||
{
|
||||
GDK_DEBUG (DMABUF, "Importing dmabuf sync failed: %s", g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if !defined(DMA_BUF_IOCTL_EXPORT_SYNC_FILE)
|
||||
struct dma_buf_export_sync_file
|
||||
{
|
||||
__u32 flags;
|
||||
__s32 fd;
|
||||
};
|
||||
#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
|
||||
#endif
|
||||
|
||||
int
|
||||
gdk_dmabuf_export_sync_file (int dmabuf_fd,
|
||||
guint32 flags)
|
||||
{
|
||||
struct dma_buf_export_sync_file data = {
|
||||
.flags = flags,
|
||||
.fd = -1,
|
||||
};
|
||||
|
||||
if (gdk_dmabuf_ioctl (dmabuf_fd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &data) != 0)
|
||||
{
|
||||
GDK_DEBUG (DMABUF, "Exporting dmabuf sync failed: %s", g_strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return data.fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to sanitize the dmabuf to conform to the values expected
|
||||
* by Vulkan/EGL which should also be the values expected by
|
||||
@@ -559,11 +903,10 @@ gdk_dmabuf_get_direct_downloader (void)
|
||||
*
|
||||
* 1. Disallow any dmabuf format that we do not know.
|
||||
*
|
||||
* 1. Reject the INVALID modifier, accept the LINEAR one.
|
||||
* 2. Ignore non-linear modifiers.
|
||||
*
|
||||
* 2. Ignore all other modifiers.
|
||||
*
|
||||
* 3. Try and fix various inconsistencies between V4L and Mesa, like NV12.
|
||||
* 3. Try and fix various inconsistencies between V4L and Mesa
|
||||
* for linear modifiers, like the e.g. single-plane NV12.
|
||||
*
|
||||
* *** WARNING ***
|
||||
*
|
||||
@@ -592,14 +935,6 @@ gdk_dmabuf_sanitize (GdkDmabuf *dest,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (src->modifier == DRM_FORMAT_MOD_INVALID)
|
||||
{
|
||||
g_set_error (error,
|
||||
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT,
|
||||
"GTK does not support the INVALID modifier.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
info = get_drm_format_info (src->fourcc);
|
||||
|
||||
if (info == NULL)
|
||||
|
||||
+123
-190
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
@@ -30,178 +31,136 @@
|
||||
#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_collect_formats (const GdkDmabufDownloader *downloader,
|
||||
GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *formats,
|
||||
GdkDmabufFormatsBuilder *external)
|
||||
{
|
||||
GdkGLContext *context = gdk_display_get_gl_context (display);
|
||||
EGLDisplay egl_display = gdk_display_get_egl_display (display);
|
||||
int num_fourccs;
|
||||
int *fourccs;
|
||||
guint64 *modifiers;
|
||||
unsigned int *external_only;
|
||||
int n_mods;
|
||||
|
||||
if (egl_display == EGL_NO_DISPLAY ||
|
||||
!display->have_egl_dma_buf_import)
|
||||
return FALSE;
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
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;
|
||||
gboolean all_external;
|
||||
|
||||
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);
|
||||
|
||||
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%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 (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_free (modifiers);
|
||||
g_free (external_only);
|
||||
g_free (fourccs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dmabuf_egl_downloader_add_formats (const GdkDmabufDownloader *downloader,
|
||||
GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *builder)
|
||||
{
|
||||
GdkGLContext *context = gdk_display_get_gl_context (display);
|
||||
EGLDisplay egl_display = gdk_display_get_egl_display (display);
|
||||
GdkDmabufFormatsBuilder *formats;
|
||||
GdkDmabufFormatsBuilder *external;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
g_assert (display->egl_dmabuf_formats == NULL);
|
||||
g_assert (display->egl_external_formats == NULL);
|
||||
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
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;
|
||||
}
|
||||
retval = gdk_dmabuf_egl_downloader_collect_formats (downloader, display, formats, external);
|
||||
|
||||
display->egl_dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (formats);
|
||||
display->egl_external_formats = gdk_dmabuf_formats_builder_free_to_formats (external);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_dmabuf_formats);
|
||||
|
||||
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,
|
||||
@@ -210,49 +169,17 @@ gdk_dmabuf_egl_downloader_supports (const GdkDmabufDownloader *downloader,
|
||||
GdkMemoryFormat *out_format,
|
||||
GError **error)
|
||||
{
|
||||
EGLDisplay egl_display;
|
||||
GdkGLContext *context;
|
||||
int num_modifiers;
|
||||
guint64 *modifiers;
|
||||
unsigned int *external_only;
|
||||
|
||||
egl_display = gdk_display_get_egl_display (display);
|
||||
if (egl_display == EGL_NO_DISPLAY)
|
||||
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||
{
|
||||
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);
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
eglQueryDmaBufModifiersEXT (egl_display,
|
||||
dmabuf->fourcc,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&num_modifiers);
|
||||
|
||||
modifiers = g_newa (uint64_t, num_modifiers);
|
||||
external_only = g_newa (unsigned int, num_modifiers);
|
||||
|
||||
eglQueryDmaBufModifiersEXT (egl_display,
|
||||
dmabuf->fourcc,
|
||||
num_modifiers,
|
||||
modifiers,
|
||||
external_only,
|
||||
&num_modifiers);
|
||||
|
||||
for (int i = 0; i < num_modifiers; i++)
|
||||
{
|
||||
if (modifiers[i] == dmabuf->modifier)
|
||||
if (!gdk_dmabuf_get_memory_format (dmabuf->fourcc, premultiplied, out_format))
|
||||
{
|
||||
*out_format = get_memory_format (dmabuf->fourcc, premultiplied);
|
||||
return TRUE;
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Falling back to generic ARGB for dmabuf format %.4s",
|
||||
(char *) &dmabuf->fourcc);
|
||||
*out_format = premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED
|
||||
: GDK_MEMORY_R8G8B8A8;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_set_error (error,
|
||||
@@ -386,14 +313,20 @@ gdk_dmabuf_egl_downloader_download (const GdkDmabufDownloader *downloader,
|
||||
gsize stride)
|
||||
{
|
||||
Download download;
|
||||
|
||||
GDK_DEBUG (DMABUF, "Using %s for downloading a dmabuf", downloader->name);
|
||||
const GdkDmabuf *dmabuf;
|
||||
|
||||
download.texture = GDK_DMABUF_TEXTURE (texture);
|
||||
download.format = format;
|
||||
download.data = data;
|
||||
download.stride = stride;
|
||||
|
||||
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_dmabuf_texture_get_display (download.texture), DMABUF,
|
||||
"Using %s for downloading a dmabuf (format %.4s:%#" G_GINT64_MODIFIER "x)",
|
||||
downloader->name, (char *)&dmabuf->fourcc, dmabuf->modifier);
|
||||
|
||||
|
||||
gdk_dmabuf_egl_downloader_run (gdk_dmabuf_egl_downloader_do_download, &download);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -43,6 +43,15 @@ struct _GdkDmabufDownloader
|
||||
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,
|
||||
gsize height,
|
||||
@@ -51,4 +60,10 @@ gboolean gdk_dmabuf_sanitize (GdkDmabuf
|
||||
|
||||
gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf);
|
||||
|
||||
gboolean gdk_dmabuf_get_memory_format (guint32 fourcc,
|
||||
gboolean premultiplied,
|
||||
GdkMemoryFormat *out_format);
|
||||
gboolean gdk_dmabuf_get_fourcc (GdkMemoryFormat format,
|
||||
guint32 *out_fourcc);
|
||||
|
||||
#endif
|
||||
|
||||
+5
-10
@@ -22,20 +22,13 @@
|
||||
|
||||
#include "gdkdisplayprivate.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:
|
||||
*
|
||||
@@ -82,6 +75,8 @@ gdk_dmabuf_texture_dispose (GObject *object)
|
||||
if (self->destroy)
|
||||
self->destroy (self->data);
|
||||
|
||||
g_clear_object (&self->display);
|
||||
|
||||
G_OBJECT_CLASS (gdk_dmabuf_texture_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -172,8 +167,8 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GDK_DEBUG (DMABUF,
|
||||
"Dmabuf texture, format %.4s:%#lx, %s%u planes, memory format %u, downloader %s",
|
||||
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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+48
-46
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
+282
-47
@@ -104,10 +104,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 +120,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 +134,7 @@ typedef struct {
|
||||
EGLContext egl_context;
|
||||
EGLBoolean (*eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
|
||||
#endif
|
||||
} GdkGLContextPrivate;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@@ -352,6 +356,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 +366,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 +395,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 +421,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 +1289,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 +1529,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 +1721,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 +1733,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 +1743,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 +2006,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 +2069,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,12 +2150,12 @@ 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);
|
||||
@@ -2018,11 +2172,15 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
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_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Can't import dmabufs into GL, missing EGL or EGL_EXT_image_dma_buf_import_modifiers");
|
||||
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);
|
||||
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);
|
||||
|
||||
i = 0;
|
||||
attribs[i++] = EGL_IMAGE_PRESERVED_KHR;
|
||||
@@ -2033,6 +2191,10 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
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;
|
||||
|
||||
#define ADD_PLANE(plane) \
|
||||
{ \
|
||||
@@ -2067,7 +2229,9 @@ gdk_gl_context_import_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 0;
|
||||
}
|
||||
|
||||
@@ -2085,6 +2249,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 +2339,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 +2361,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 +2372,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 +2414,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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
+35
-23
@@ -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 &&
|
||||
|
||||
+27
-27
@@ -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
|
||||
*
|
||||
|
||||
+786
-298
File diff suppressed because it is too large
Load Diff
@@ -42,16 +42,25 @@ typedef enum {
|
||||
gsize gdk_memory_format_alignment (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryAlpha gdk_memory_format_alpha (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryFormat gdk_memory_format_get_premultiplied (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryFormat gdk_memory_format_get_straight (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
const GdkMemoryFormat * gdk_memory_format_get_fallbacks (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
||||
GdkMemoryDepth depth2) G_GNUC_CONST;
|
||||
GdkMemoryFormat gdk_memory_depth_get_format (GdkMemoryDepth depth) G_GNUC_CONST;
|
||||
GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth) G_GNUC_CONST;
|
||||
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
GdkGLContext *context,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type,
|
||||
GLint out_gizzle[4]);
|
||||
void gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
GLint *out_internal_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4]);
|
||||
gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
|
||||
GdkMemoryFormat *out_actual_format,
|
||||
GLint *out_internal_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4]);
|
||||
|
||||
void gdk_memory_convert (guchar *dest_data,
|
||||
gsize dest_stride,
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2023 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdktexture.h"
|
||||
|
||||
G_DEFINE_TYPE (GdkSubsurface, gdk_subsurface, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gdk_subsurface_init (GdkSubsurface *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_subsurface_finalize (GObject *object)
|
||||
{
|
||||
GdkSubsurface *subsurface = GDK_SUBSURFACE (object);
|
||||
|
||||
g_ptr_array_remove (subsurface->parent->subsurfaces, subsurface);
|
||||
g_clear_object (&subsurface->parent);
|
||||
|
||||
G_OBJECT_CLASS (gdk_subsurface_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_subsurface_class_init (GdkSubsurfaceClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = gdk_subsurface_finalize;
|
||||
}
|
||||
|
||||
GdkSurface *
|
||||
gdk_subsurface_get_parent (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), NULL);
|
||||
|
||||
return subsurface->parent;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *rect,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
|
||||
g_return_val_if_fail (rect != NULL, FALSE);
|
||||
g_return_val_if_fail (sibling == NULL || GDK_IS_SUBSURFACE (sibling), FALSE);
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface, texture, rect, above, sibling);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_subsurface_detach (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
|
||||
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->detach (subsurface);
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_subsurface_get_texture (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), NULL);
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_texture (subsurface);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_subsurface_get_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
|
||||
g_return_if_fail (rect != NULL);
|
||||
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_rect (subsurface, rect);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_subsurface_is_above_parent (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), TRUE);
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->is_above_parent (subsurface);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2023 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Uninstalled header defining types and functions internal to GDK */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdksurface.h"
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkSubsurface GdkSubsurface;
|
||||
typedef struct _GdkSubsurfaceClass GdkSubsurfaceClass;
|
||||
|
||||
#define GDK_TYPE_SUBSURFACE (gdk_subsurface_get_type ())
|
||||
#define GDK_SUBSURFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SUBSURFACE, GdkSubsurface))
|
||||
#define GDK_SUBSURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SUBSURFACE, GdkSubsurfaceClass))
|
||||
#define GDK_IS_SUBSURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SUBSURFACE))
|
||||
#define GDK_SUBSURFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SUBSURFACE, GdkSubsurfaceClass))
|
||||
|
||||
struct _GdkSubsurface
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GdkSurface *parent;
|
||||
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
|
||||
struct _GdkSubsurfaceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
gboolean (* attach) (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *rect,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void (* detach) (GdkSubsurface *subsurface);
|
||||
GdkTexture * (* get_texture) (GdkSubsurface *subsurface);
|
||||
void (* get_rect) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
gboolean (* is_above_parent) (GdkSubsurface *subsurface);
|
||||
};
|
||||
|
||||
GType gdk_subsurface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GdkSurface * gdk_subsurface_get_parent (GdkSubsurface *subsurface);
|
||||
gboolean gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *rect,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void gdk_subsurface_detach (GdkSubsurface *subsurface);
|
||||
GdkTexture * gdk_subsurface_get_texture (GdkSubsurface *subsurface);
|
||||
void gdk_subsurface_get_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+27
-26
@@ -43,6 +43,7 @@
|
||||
#include "gdkrectangle.h"
|
||||
#include "gdktoplevelprivate.h"
|
||||
#include "gdkvulkancontext.h"
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -485,6 +486,8 @@ gdk_surface_init (GdkSurface *surface)
|
||||
|
||||
surface->device_cursor = g_hash_table_new_full (NULL, NULL,
|
||||
NULL, g_object_unref);
|
||||
|
||||
surface->subsurfaces = g_ptr_array_new ();
|
||||
}
|
||||
|
||||
static double
|
||||
@@ -496,6 +499,8 @@ gdk_surface_real_get_scale (GdkSurface *surface)
|
||||
static GdkSubsurface *
|
||||
gdk_surface_real_create_subsurface (GdkSurface *surface)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), OFFLOAD,
|
||||
"Subsurfaces not supported for %s", G_OBJECT_TYPE_NAME (surface));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -764,6 +769,10 @@ gdk_surface_finalize (GObject *object)
|
||||
if (surface->parent)
|
||||
surface->parent->children = g_list_remove (surface->parent->children, surface);
|
||||
|
||||
g_assert (surface->subsurfaces->len == 0);
|
||||
|
||||
g_ptr_array_unref (surface->subsurfaces);
|
||||
|
||||
G_OBJECT_CLASS (gdk_surface_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -3065,36 +3074,28 @@ gdk_surface_leave_monitor (GdkSurface *surface,
|
||||
GdkSubsurface *
|
||||
gdk_surface_create_subsurface (GdkSurface *surface)
|
||||
{
|
||||
return GDK_SURFACE_GET_CLASS (surface)->create_subsurface (surface);
|
||||
GdkSubsurface *subsurface;
|
||||
|
||||
subsurface = GDK_SURFACE_GET_CLASS (surface)->create_subsurface (surface);
|
||||
|
||||
if (subsurface)
|
||||
{
|
||||
subsurface->parent = g_object_ref (surface);
|
||||
g_ptr_array_add (surface->subsurfaces, subsurface);
|
||||
}
|
||||
|
||||
return subsurface;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_subsurface_destroy (GdkSubsurface *subsurface)
|
||||
gsize
|
||||
gdk_surface_get_n_subsurfaces (GdkSurface *surface)
|
||||
{
|
||||
subsurface->class->destroy (subsurface);
|
||||
return surface->subsurfaces->len;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *bounds)
|
||||
GdkSubsurface *
|
||||
gdk_surface_get_subsurface (GdkSurface *surface,
|
||||
gsize idx)
|
||||
{
|
||||
subsurface->class->attach (subsurface, texture, bounds);
|
||||
return g_ptr_array_index (surface->subsurfaces, idx);
|
||||
}
|
||||
|
||||
/* If sibling is NULL, place the subsurface above its parent */
|
||||
void
|
||||
gdk_subsurface_place_above (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
subsurface->class->place_above (subsurface, sibling);
|
||||
}
|
||||
|
||||
/* If sibling is NULL, place the subsurface below its parent */
|
||||
void
|
||||
gdk_subsurface_place_below (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
subsurface->class->place_below (subsurface, sibling);
|
||||
}
|
||||
|
||||
|
||||
+7
-28
@@ -97,6 +97,8 @@ struct _GdkSurface
|
||||
cairo_region_t *opaque_region;
|
||||
|
||||
GdkSeat *current_shortcuts_inhibited_seat;
|
||||
|
||||
GPtrArray *subsurfaces;
|
||||
};
|
||||
|
||||
struct _GdkSurfaceClass
|
||||
@@ -343,33 +345,10 @@ void gdk_surface_request_motion (GdkSurface *surface);
|
||||
gboolean gdk_surface_supports_edge_constraints (GdkSurface *surface);
|
||||
|
||||
GdkSubsurface * gdk_surface_create_subsurface (GdkSurface *surface);
|
||||
|
||||
typedef struct _GdkSubsurfaceClass GdkSubsurfaceClass;
|
||||
struct _GdkSubsurfaceClass
|
||||
{
|
||||
void (* destroy) (GdkSubsurface *subsurface);
|
||||
void (* attach) (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
void (* place_above) (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling);
|
||||
void (* place_below) (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling);
|
||||
};
|
||||
|
||||
struct _GdkSubsurface
|
||||
{
|
||||
const GdkSubsurfaceClass *class;
|
||||
};
|
||||
|
||||
void gdk_subsurface_destroy (GdkSubsurface *subsurface);
|
||||
void gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
void gdk_subsurface_place_above (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling);
|
||||
void gdk_subsurface_place_below (GdkSubsurface *subsurface,
|
||||
GdkSubsurface *sibling);
|
||||
void gdk_surface_destroy_subsurface (GdkSurface *surface,
|
||||
GdkSubsurface *subsurface);
|
||||
gsize gdk_surface_get_n_subsurfaces (GdkSurface *surface);
|
||||
GdkSubsurface * gdk_surface_get_subsurface (GdkSurface *surface,
|
||||
gsize idx);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+120
-20
@@ -68,6 +68,33 @@ enum {
|
||||
|
||||
static GParamSpec *properties[N_PROPS];
|
||||
|
||||
static GdkTextureChain *
|
||||
gdk_texture_chain_new (void)
|
||||
{
|
||||
GdkTextureChain *chain = g_new0 (GdkTextureChain, 1);
|
||||
|
||||
g_atomic_ref_count_init (&chain->ref_count);
|
||||
g_mutex_init (&chain->lock);
|
||||
|
||||
return chain;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_texture_chain_ref (GdkTextureChain *chain)
|
||||
{
|
||||
g_atomic_ref_count_inc (&chain->ref_count);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_texture_chain_unref (GdkTextureChain *chain)
|
||||
{
|
||||
if (g_atomic_ref_count_dec (&chain->ref_count))
|
||||
{
|
||||
g_mutex_clear (&chain->lock);
|
||||
g_free (chain);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_texture_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
@@ -283,7 +310,30 @@ gdk_texture_dispose (GObject *object)
|
||||
{
|
||||
GdkTexture *self = GDK_TEXTURE (object);
|
||||
|
||||
g_clear_pointer (&self->diff_to_previous, cairo_region_destroy);
|
||||
if (self->chain)
|
||||
{
|
||||
g_mutex_lock (&self->chain->lock);
|
||||
|
||||
if (self->next_texture && self->previous_texture)
|
||||
{
|
||||
cairo_region_union (self->next_texture->diff_to_previous,
|
||||
self->diff_to_previous);
|
||||
self->next_texture->previous_texture = self->previous_texture;
|
||||
self->previous_texture->next_texture = self->next_texture;
|
||||
}
|
||||
else if (self->next_texture)
|
||||
self->next_texture->previous_texture = NULL;
|
||||
else if (self->previous_texture)
|
||||
self->previous_texture->next_texture = NULL;
|
||||
|
||||
self->next_texture = NULL;
|
||||
self->previous_texture = NULL;
|
||||
g_clear_pointer (&self->diff_to_previous, cairo_region_destroy);
|
||||
|
||||
g_mutex_unlock (&self->chain->lock);
|
||||
|
||||
g_clear_pointer (&self->chain, gdk_texture_chain_unref);
|
||||
}
|
||||
|
||||
gdk_texture_clear_render_data (self);
|
||||
|
||||
@@ -679,34 +729,64 @@ gdk_texture_do_download (GdkTexture *texture,
|
||||
GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, data, stride);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_texture_has_ancestor (GdkTexture *self,
|
||||
GdkTexture *other)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
for (texture = self->previous_texture;
|
||||
texture != NULL;
|
||||
texture = texture->previous_texture)
|
||||
{
|
||||
if (texture == other)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_texture_diff_from_known_ancestor (GdkTexture *self,
|
||||
GdkTexture *ancestor,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
for (texture = self; texture != ancestor; texture = texture->previous_texture)
|
||||
cairo_region_union (region, texture->diff_to_previous);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_texture_diff (GdkTexture *self,
|
||||
GdkTexture *other,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
if (self == other)
|
||||
cairo_rectangle_int_t fill = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = MAX (self->width, other->width),
|
||||
.height = MAX (self->height, other->height),
|
||||
};
|
||||
GdkTextureChain *chain;
|
||||
|
||||
if (other == self)
|
||||
return;
|
||||
|
||||
if (self->previous_texture == other &&
|
||||
g_atomic_pointer_get (&other->next_texture) == self)
|
||||
chain = g_atomic_pointer_get (&self->chain);
|
||||
if (chain == NULL || chain != g_atomic_pointer_get (&other->chain))
|
||||
{
|
||||
cairo_region_union (region, self->diff_to_previous);
|
||||
}
|
||||
else if (other->previous_texture == self &&
|
||||
g_atomic_pointer_get (&self->next_texture) == other)
|
||||
{
|
||||
cairo_region_union (region, other->diff_to_previous);
|
||||
cairo_region_union_rectangle (region, &fill);
|
||||
return;
|
||||
}
|
||||
|
||||
g_mutex_lock (&chain->lock);
|
||||
if (gdk_texture_has_ancestor (self, other))
|
||||
gdk_texture_diff_from_known_ancestor (self, other, region);
|
||||
else if (gdk_texture_has_ancestor (other, self))
|
||||
gdk_texture_diff_from_known_ancestor (other, self, region);
|
||||
else
|
||||
{
|
||||
cairo_region_union_rectangle (region,
|
||||
&(cairo_rectangle_int_t) {
|
||||
0,
|
||||
0,
|
||||
MAX (self->width, other->width),
|
||||
MAX (self->height, other->height)
|
||||
});
|
||||
}
|
||||
cairo_region_union_rectangle (region, &fill);
|
||||
g_mutex_unlock (&chain->lock);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -715,10 +795,30 @@ gdk_texture_set_diff (GdkTexture *self,
|
||||
cairo_region_t *diff)
|
||||
{
|
||||
g_assert (self->diff_to_previous == NULL);
|
||||
g_assert (self->chain == NULL);
|
||||
|
||||
self->chain = g_atomic_pointer_get (&previous->chain);
|
||||
if (self->chain == NULL)
|
||||
{
|
||||
self->chain = gdk_texture_chain_new ();
|
||||
if (!g_atomic_pointer_compare_and_exchange (&previous->chain,
|
||||
NULL,
|
||||
self->chain))
|
||||
gdk_texture_chain_unref (self->chain);
|
||||
self->chain = previous->chain;
|
||||
}
|
||||
gdk_texture_chain_ref (self->chain);
|
||||
|
||||
g_mutex_lock (&self->chain->lock);
|
||||
if (previous->next_texture)
|
||||
{
|
||||
previous->next_texture->previous_texture = NULL;
|
||||
g_clear_pointer (&previous->next_texture->diff_to_previous, cairo_region_destroy);
|
||||
}
|
||||
previous->next_texture = self;
|
||||
self->previous_texture = previous;
|
||||
self->diff_to_previous = diff;
|
||||
g_atomic_pointer_set (&previous->next_texture, self);
|
||||
g_mutex_unlock (&self->chain->lock);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
|
||||
+15
-4
@@ -6,6 +6,14 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkTextureChain GdkTextureChain;
|
||||
|
||||
struct _GdkTextureChain
|
||||
{
|
||||
gatomicrefcount ref_count;
|
||||
GMutex lock;
|
||||
};
|
||||
|
||||
#define GDK_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_TEXTURE, GdkTextureClass))
|
||||
#define GDK_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_TEXTURE))
|
||||
#define GDK_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_TEXTURE, GdkTextureClass))
|
||||
@@ -23,10 +31,13 @@ struct _GdkTexture
|
||||
GDestroyNotify render_notify;
|
||||
|
||||
/* for diffing swapchain-like textures.
|
||||
* Links are only valid if both textures agree on them */
|
||||
gpointer next_texture; /* atomic, no reference, may be invalid pointer */
|
||||
gpointer previous_texture; /* no reference, may be invalid pointer */
|
||||
cairo_region_t *diff_to_previous;
|
||||
* Textures in the same chain are connected in a double linked list which is
|
||||
* protected using the chain's shared mutex.
|
||||
*/
|
||||
GdkTextureChain *chain; /* lazy, atomic, shared by all chain links */
|
||||
GdkTexture *next_texture; /* no reference, guarded by chain lock */
|
||||
GdkTexture *previous_texture; /* no reference, guarded by chain lock */
|
||||
cairo_region_t *diff_to_previous; /* guarded by chain lock */
|
||||
};
|
||||
|
||||
struct _GdkTextureClass {
|
||||
|
||||
@@ -252,7 +252,6 @@ gdk_vulkan_strerror (VkResult result)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static const char *
|
||||
surface_present_mode_to_string (VkPresentModeKHR present_mode)
|
||||
{
|
||||
@@ -275,7 +274,6 @@ surface_present_mode_to_string (VkPresentModeKHR present_mode)
|
||||
|
||||
return "(unknown)";
|
||||
}
|
||||
#endif
|
||||
|
||||
static const VkPresentModeKHR preferred_present_modes[] = {
|
||||
VK_PRESENT_MODE_MAILBOX_KHR,
|
||||
|
||||
@@ -252,7 +252,7 @@ gdk_save_jpeg (GdkTexture *texture)
|
||||
gulong size = 0;
|
||||
guchar *input = NULL;
|
||||
GdkTextureDownloader downloader;
|
||||
GBytes *texbytes;
|
||||
GBytes *texbytes = NULL;
|
||||
const guchar *texdata;
|
||||
gsize texstride;
|
||||
guchar *row;
|
||||
|
||||
@@ -1265,6 +1265,14 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
}
|
||||
else if (is_motion_event(event_type))
|
||||
{
|
||||
NSWindow *orig_window = [nsevent window];
|
||||
|
||||
if (orig_window && GDK_IS_MACOS_WINDOW (orig_window))
|
||||
[NSApp sendEvent:nsevent];
|
||||
}
|
||||
|
||||
return fill_event (self, window, nsevent, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -1005,7 +1005,7 @@ _gdk_macos_display_get_nsevent (GdkEvent *event)
|
||||
}
|
||||
|
||||
NSEvent *
|
||||
_gdk_macos_display_get_last_nsevent ()
|
||||
_gdk_macos_display_get_last_nsevent (void)
|
||||
{
|
||||
const GdkToNSEventMap *map = g_queue_peek_tail (&event_map);
|
||||
if (map)
|
||||
|
||||
@@ -180,7 +180,6 @@ typedef enum {
|
||||
POLLING_DESCRIPTORS,
|
||||
} SelectThreadState;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static const char *const state_names[] = {
|
||||
"BEFORE_START",
|
||||
"WAITING",
|
||||
@@ -188,7 +187,6 @@ static const char *const state_names[] = {
|
||||
"POLLING_RESTART",
|
||||
"POLLING_DESCRIPTORS"
|
||||
};
|
||||
#endif
|
||||
|
||||
static SelectThreadState select_thread_state = BEFORE_START;
|
||||
|
||||
@@ -374,7 +372,6 @@ select_thread_start (void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static void
|
||||
dump_poll_result (GPollFD *ufds,
|
||||
guint nfds)
|
||||
@@ -400,7 +397,6 @@ dump_poll_result (GPollFD *ufds,
|
||||
gdk_debug_message ("%s", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
pollfds_equal (GPollFD *old_pollfds,
|
||||
@@ -468,13 +464,11 @@ select_thread_start_poll (GPollFD *ufds,
|
||||
n_ready = old_poll_func (ufds, nfds, 0);
|
||||
if (n_ready > 0 || timeout == 0)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if ((_gdk_debug_flags & GDK_DEBUG_EVENTLOOP) && n_ready > 0)
|
||||
if (GDK_DEBUG_CHECK (EVENTLOOP) && n_ready > 0)
|
||||
{
|
||||
gdk_debug_message ("EventLoop: Found ready file descriptors before waiting");
|
||||
dump_poll_result (ufds, nfds);
|
||||
}
|
||||
#endif
|
||||
|
||||
return n_ready;
|
||||
}
|
||||
@@ -612,13 +606,11 @@ select_thread_collect_poll (GPollFD *ufds, guint nfds)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (_gdk_debug_flags & GDK_DEBUG_EVENTLOOP)
|
||||
if (GDK_DEBUG_CHECK (EVENTLOOP))
|
||||
{
|
||||
gdk_debug_message ("EventLoop: Found ready file descriptors after waiting");
|
||||
dump_poll_result (ufds, nfds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SELECT_THREAD_UNLOCK ();
|
||||
|
||||
@@ -55,6 +55,7 @@ gdk_public_sources = files([
|
||||
'gdktexture.c',
|
||||
'gdktexturedownloader.c',
|
||||
'gdkvulkancontext.c',
|
||||
'gdksubsurface.c',
|
||||
'gdksurface.c',
|
||||
'gdkpopuplayout.c',
|
||||
'gdkprofiler.c',
|
||||
|
||||
@@ -194,6 +194,23 @@ gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
|
||||
self->paint_surface = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_cairo_context_empty_frame (GdkDrawContext *draw_context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (!impl->has_pending_subsurface_commits)
|
||||
return;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_cairo_context_clear_all_cairo_surfaces (GdkWaylandCairoContext *self)
|
||||
{
|
||||
@@ -241,6 +258,7 @@ gdk_wayland_cairo_context_class_init (GdkWaylandCairoContextClass *klass)
|
||||
|
||||
draw_context_class->begin_frame = gdk_wayland_cairo_context_begin_frame;
|
||||
draw_context_class->end_frame = gdk_wayland_cairo_context_end_frame;
|
||||
draw_context_class->empty_frame = gdk_wayland_cairo_context_empty_frame;
|
||||
draw_context_class->surface_resized = gdk_wayland_cairo_context_surface_resized;
|
||||
|
||||
cairo_context_class->cairo_create = gdk_wayland_cairo_context_cairo_create;
|
||||
|
||||
@@ -225,14 +225,12 @@ gdk_wayland_clipboard_read_async (GdkClipboard *clipboard,
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_wayland_clipboard_read_async);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)), CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: read for %s", cb, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
mime_type = gdk_content_formats_match_mime_type (formats, cb->offer_formats);
|
||||
if (mime_type == NULL)
|
||||
{
|
||||
@@ -245,7 +243,7 @@ gdk_wayland_clipboard_read_async (GdkClipboard *clipboard,
|
||||
|
||||
g_task_set_task_data (task, (gpointer) mime_type, NULL);
|
||||
|
||||
if (!g_unix_open_pipe (pipe_fd, FD_CLOEXEC, &error))
|
||||
if (!g_unix_open_pipe (pipe_fd, O_CLOEXEC, &error))
|
||||
{
|
||||
g_task_return_error (task, error);
|
||||
return;
|
||||
@@ -322,14 +320,12 @@ gdk_wayland_clipboard_claim_remote (GdkWaylandClipboard *cb,
|
||||
|
||||
gdk_wayland_clipboard_discard_offer (cb);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)), CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: remote clipboard claim for %s", cb, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
cb->offer_formats = formats;
|
||||
cb->offer = offer;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c)
|
||||
if (c && c->image_count > 0)
|
||||
{
|
||||
struct wl_cursor_image *image;
|
||||
int cursor_scale;
|
||||
|
||||
@@ -274,7 +274,10 @@ wl_shm_format (void *data,
|
||||
struct wl_shm *wl_shm,
|
||||
uint32_t format)
|
||||
{
|
||||
GDK_DEBUG (MISC, "supported shm pixel format %.4s (0x%X)", (char *) &format, format);
|
||||
GDK_DEBUG (MISC, "supported shm pixel format %.4s (0x%X)",
|
||||
format == 0 ? "ARGB8888"
|
||||
: (format == 1 ? "XRGB8888"
|
||||
: (char *) &format), format);
|
||||
}
|
||||
|
||||
static const struct wl_shm_listener wl_shm_listener = {
|
||||
@@ -307,7 +310,7 @@ linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev = *(dev_t *)device->data;
|
||||
dev_t dev G_GNUC_UNUSED = *(dev_t *)device->data;
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf main device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
@@ -324,7 +327,7 @@ linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev = *(dev_t *)device->data;
|
||||
dev_t dev G_GNUC_UNUSED = *(dev_t *)device->data;
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche target device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
@@ -341,9 +344,9 @@ linux_dmabuf_tranche_formats (void *data,
|
||||
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
LinuxDmabufFormat *fmt = &display_wayland->linux_dmabuf_formats[*pos];
|
||||
uint32_t f = fmt->fourcc;
|
||||
uint64_t m = fmt->modifier;
|
||||
LinuxDmabufFormat *fmt G_GNUC_UNUSED = &display_wayland->linux_dmabuf_formats[*pos];
|
||||
uint32_t f G_GNUC_UNUSED = fmt->fourcc;
|
||||
uint64_t m G_GNUC_UNUSED = fmt->modifier;
|
||||
GDK_DEBUG (MISC, " %.4s:%#" G_GINT64_MODIFIER "x", (char *) &f, m);
|
||||
}
|
||||
}
|
||||
@@ -374,13 +377,11 @@ server_decoration_manager_default_mode (void
|
||||
uint32_t mode)
|
||||
{
|
||||
g_assert (mode <= ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *modes[] = {
|
||||
[ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE] = "none",
|
||||
[ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT] = "client",
|
||||
[ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER] = "server",
|
||||
};
|
||||
#endif
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
GDK_DISPLAY_DEBUG (GDK_DISPLAY (data), MISC, "Compositor prefers decoration mode '%s'", modes[mode]);
|
||||
display_wayland->server_decoration_mode = mode;
|
||||
@@ -2319,8 +2320,6 @@ gdk_wayland_display_get_setting (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static const char *
|
||||
subpixel_to_string (int layout)
|
||||
{
|
||||
@@ -2367,8 +2366,6 @@ transform_to_string (int transform)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
update_scale (GdkDisplay *display)
|
||||
{
|
||||
|
||||
@@ -340,14 +340,12 @@ gdk_wayland_drag_create_data_source (GdkDrag *drag)
|
||||
|
||||
mimetypes = gdk_content_formats_get_mime_types (formats, &n_mimetypes);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_drag_get_display (drag), EVENTS))
|
||||
{
|
||||
char *s = g_strjoinv (" ", (char **)mimetypes);
|
||||
gdk_debug_message ("create data source, mime types=%s", s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
|
||||
wl_data_source_offer (drag_wayland->data_source, GDK_WAYLAND_LOCAL_DND_MIME_TYPE);
|
||||
for (i = 0; i < n_mimetypes; i++)
|
||||
@@ -397,7 +395,7 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
drag_wayland->data_source,
|
||||
gdk_wayland_surface_get_wl_surface (surface),
|
||||
gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface),
|
||||
_gdk_wayland_seat_get_implicit_grab_serial (seat, NULL));
|
||||
_gdk_wayland_seat_get_implicit_grab_serial (seat, device, NULL));
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
|
||||
gdk_drag_set_cursor (drag, cursor);
|
||||
|
||||
@@ -191,14 +191,12 @@ gdk_wayland_drop_read_async (GdkDrop *drop,
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_wayland_drop_read_async);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_drop_get_display (drop), DND))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: read for %s", drop, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
mime_type = gdk_content_formats_match_mime_type (formats,
|
||||
gdk_drop_get_formats (drop));
|
||||
if (mime_type == NULL)
|
||||
@@ -210,7 +208,7 @@ gdk_wayland_drop_read_async (GdkDrop *drop,
|
||||
|
||||
g_task_set_task_data (task, (gpointer) mime_type, NULL);
|
||||
|
||||
if (!g_unix_open_pipe (pipe_fd, FD_CLOEXEC, &error))
|
||||
if (!g_unix_open_pipe (pipe_fd, O_CLOEXEC, &error))
|
||||
{
|
||||
g_task_return_error (task, error);
|
||||
return;
|
||||
|
||||
@@ -83,6 +83,22 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_gl_context_empty_frame (GdkDrawContext *draw_context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (impl->has_pending_subsurface_commits)
|
||||
{
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
|
||||
{
|
||||
@@ -91,6 +107,7 @@ gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
|
||||
|
||||
draw_context_class->begin_frame = gdk_wayland_gl_context_begin_frame;
|
||||
draw_context_class->end_frame = gdk_wayland_gl_context_end_frame;
|
||||
draw_context_class->empty_frame = gdk_wayland_gl_context_empty_frame;
|
||||
|
||||
context_class->backend_type = GDK_GL_EGL;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,6 @@ static void
|
||||
print_modifiers (GdkDisplay *display,
|
||||
struct xkb_keymap *keymap)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
int i, j;
|
||||
uint32_t real;
|
||||
struct xkb_state *state;
|
||||
@@ -538,7 +537,6 @@ print_modifiers (GdkDisplay *display,
|
||||
g_string_free (str, TRUE);
|
||||
|
||||
xkb_state_unref (state);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -107,14 +107,12 @@ gdk_wayland_primary_claim_remote (GdkWaylandPrimary *cb,
|
||||
|
||||
gdk_wayland_primary_discard_offer (cb);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)), CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: remote primary claim for %s", cb, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
|
||||
cb->offer_formats = formats;
|
||||
cb->offer = offer;
|
||||
@@ -270,14 +268,12 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
|
||||
{
|
||||
GdkWaylandPrimary *cb = GDK_WAYLAND_PRIMARY (clipboard);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_clipboard_get_display (clipboard), CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: claim primary (%s) for %s", cb, local ? "local" : "remote", s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
if (local)
|
||||
{
|
||||
GdkWaylandDisplay *wdisplay = GDK_WAYLAND_DISPLAY (gdk_clipboard_get_display (clipboard));
|
||||
@@ -328,14 +324,12 @@ gdk_wayland_primary_read_async (GdkClipboard *clipboard,
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_wayland_primary_read_async);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (gdk_clipboard_get_display (clipboard), CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%p: read for %s", cb, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
mime_type = gdk_content_formats_match_mime_type (formats, cb->offer_formats);
|
||||
if (mime_type == NULL)
|
||||
{
|
||||
@@ -348,7 +342,7 @@ gdk_wayland_primary_read_async (GdkClipboard *clipboard,
|
||||
|
||||
g_task_set_task_data (task, (gpointer) mime_type, NULL);
|
||||
|
||||
if (!g_unix_open_pipe (pipe_fd, FD_CLOEXEC, &error))
|
||||
if (!g_unix_open_pipe (pipe_fd, O_CLOEXEC, &error))
|
||||
{
|
||||
g_task_return_error (task, error);
|
||||
return;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <gdk/wayland/gdkdisplay-wayland.h>
|
||||
#include <gdk/wayland/gdkseat-wayland.h>
|
||||
|
||||
#include <gsk/gsk.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
|
||||
@@ -165,8 +164,9 @@ void _gdk_wayland_display_remove_seat (GdkWaylandDisplay *displa
|
||||
guint32 id);
|
||||
|
||||
GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
|
||||
uint32_t _gdk_wayland_seat_get_implicit_grab_serial(GdkSeat *seat,
|
||||
GdkEvent *event);
|
||||
uint32_t _gdk_wayland_seat_get_implicit_grab_serial (GdkSeat *seat,
|
||||
GdkDevice *event,
|
||||
GdkEventSequence *sequence);
|
||||
uint32_t _gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat *seat,
|
||||
GdkEventSequence **sequence);
|
||||
GdkSurface * gdk_wayland_device_get_focus (GdkDevice *device);
|
||||
|
||||
@@ -345,7 +345,6 @@ data_device_enter (void *data,
|
||||
GdkWaylandSeat *seat = data;
|
||||
GdkSurface *dest_surface;
|
||||
GdkContentFormats *formats;
|
||||
int origin_x, origin_y;
|
||||
GdkDevice *device;
|
||||
|
||||
dest_surface = wl_surface_get_user_data (surface);
|
||||
@@ -392,12 +391,10 @@ data_device_enter (void *data,
|
||||
|
||||
gdk_wayland_seat_discard_pending_offer (seat);
|
||||
|
||||
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
||||
|
||||
gdk_drop_emit_enter_event (seat->drop,
|
||||
FALSE,
|
||||
origin_x + seat->pointer_info.surface_x,
|
||||
origin_y + seat->pointer_info.surface_y,
|
||||
seat->pointer_info.surface_x,
|
||||
seat->pointer_info.surface_y,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
@@ -431,7 +428,6 @@ data_device_motion (void *data,
|
||||
wl_fixed_t y)
|
||||
{
|
||||
GdkWaylandSeat *seat = data;
|
||||
int origin_x, origin_y;
|
||||
|
||||
GDK_SEAT_DEBUG (seat, EVENTS,
|
||||
"data device motion, data_device = %p, time = %d, x = %f, y = %f",
|
||||
@@ -444,12 +440,10 @@ data_device_motion (void *data,
|
||||
seat->pointer_info.surface_x = wl_fixed_to_double (x);
|
||||
seat->pointer_info.surface_y = wl_fixed_to_double (y);
|
||||
|
||||
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
||||
|
||||
gdk_drop_emit_motion_event (seat->drop,
|
||||
FALSE,
|
||||
origin_x + seat->pointer_info.surface_x,
|
||||
origin_y + seat->pointer_info.surface_y,
|
||||
seat->pointer_info.surface_x,
|
||||
seat->pointer_info.surface_y,
|
||||
time);
|
||||
}
|
||||
|
||||
@@ -458,17 +452,14 @@ data_device_drop (void *data,
|
||||
struct wl_data_device *data_device)
|
||||
{
|
||||
GdkWaylandSeat *seat = data;
|
||||
int origin_x, origin_y;
|
||||
|
||||
GDK_SEAT_DEBUG (seat, EVENTS,
|
||||
"data device drop, data device %p", data_device);
|
||||
|
||||
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
||||
|
||||
gdk_drop_emit_drop_event (seat->drop,
|
||||
FALSE,
|
||||
origin_x + seat->pointer_info.surface_x,
|
||||
origin_y + seat->pointer_info.surface_y,
|
||||
seat->pointer_info.surface_x,
|
||||
seat->pointer_info.surface_y,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
@@ -877,8 +868,6 @@ pointer_handle_button (void *data,
|
||||
gdk_wayland_seat_flush_frame_event (seat);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static const char *
|
||||
get_axis_name (uint32_t axis)
|
||||
{
|
||||
@@ -893,8 +882,6 @@ get_axis_name (uint32_t axis)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
pointer_handle_axis (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
@@ -943,8 +930,6 @@ pointer_handle_frame (void *data,
|
||||
gdk_wayland_seat_flush_frame_event (seat);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static const char *
|
||||
get_axis_source_name (enum wl_pointer_axis_source source)
|
||||
{
|
||||
@@ -963,8 +948,6 @@ get_axis_source_name (enum wl_pointer_axis_source source)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
pointer_handle_axis_source (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
@@ -1090,7 +1073,6 @@ get_active_layout (GdkKeymap *keymap)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static const char *
|
||||
get_active_layout_name (GdkKeymap *keymap)
|
||||
{
|
||||
@@ -1100,7 +1082,6 @@ get_active_layout_name (GdkKeymap *keymap)
|
||||
|
||||
return xkb_keymap_layout_get_name (xkb_keymap, get_active_layout (keymap));
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
keyboard_handle_keymap (void *data,
|
||||
@@ -1126,7 +1107,6 @@ keyboard_handle_keymap (void *data,
|
||||
|
||||
_gdk_wayland_keymap_update_from_fd (seat->keymap, format, fd, size);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (seat->keymap->display, INPUT))
|
||||
{
|
||||
GString *s = g_string_new ("");
|
||||
@@ -1143,7 +1123,6 @@ keyboard_handle_keymap (void *data,
|
||||
gdk_debug_message ("layouts: %s", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_signal_emit_by_name (seat->keymap, "keys-changed");
|
||||
g_signal_emit_by_name (seat->keymap, "state-changed");
|
||||
@@ -3435,9 +3414,7 @@ static void
|
||||
tablet_pad_group_handle_done (void *data,
|
||||
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
#endif
|
||||
|
||||
GDK_SEAT_DEBUG (group->pad->seat, EVENTS,
|
||||
"tablet pad group handle done, pad group = %p",
|
||||
@@ -4344,35 +4321,39 @@ _gdk_wayland_display_remove_seat (GdkWaylandDisplay *display_wayland,
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_gdk_wayland_seat_get_implicit_grab_serial (GdkSeat *seat,
|
||||
GdkEvent *event)
|
||||
_gdk_wayland_seat_get_implicit_grab_serial (GdkSeat *seat,
|
||||
GdkDevice *device,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
GdkEventSequence *sequence = NULL;
|
||||
GdkWaylandTouchData *touch = NULL;
|
||||
|
||||
if (event)
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
||||
GList *l;
|
||||
|
||||
if (sequence)
|
||||
touch = gdk_wayland_seat_get_touch (GDK_WAYLAND_SEAT (seat),
|
||||
GDK_EVENT_SEQUENCE_TO_SLOT (sequence));
|
||||
|
||||
if (touch)
|
||||
return touch->touch_down_serial;
|
||||
|
||||
if (event)
|
||||
{
|
||||
GdkDevice *source = gdk_event_get_device (event);
|
||||
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
||||
GList *l;
|
||||
GdkWaylandTouchData *touch = NULL;
|
||||
|
||||
for (l = wayland_seat->tablets; l; l = l->next)
|
||||
{
|
||||
GdkWaylandTabletData *tablet = l->data;
|
||||
touch = gdk_wayland_seat_get_touch (GDK_WAYLAND_SEAT (seat),
|
||||
GDK_EVENT_SEQUENCE_TO_SLOT (sequence));
|
||||
if (touch)
|
||||
return touch->touch_down_serial;
|
||||
}
|
||||
else if (device == wayland_seat->logical_touch)
|
||||
{
|
||||
GdkWaylandTouchData *touch;
|
||||
GHashTableIter iter;
|
||||
|
||||
if (tablet->stylus_device == source)
|
||||
return tablet->pointer_info.press_serial;
|
||||
}
|
||||
/* Pick the first sequence */
|
||||
g_hash_table_iter_init (&iter, wayland_seat->touches);
|
||||
g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch);
|
||||
return touch->touch_down_serial;
|
||||
}
|
||||
|
||||
for (l = wayland_seat->tablets; l; l = l->next)
|
||||
{
|
||||
GdkWaylandTabletData *tablet = l->data;
|
||||
|
||||
if (tablet->logical_device == device)
|
||||
return tablet->pointer_info.press_serial;
|
||||
}
|
||||
|
||||
return GDK_WAYLAND_SEAT (seat)->pointer_info.press_serial;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
|
||||
|
||||
typedef struct _GdkWaylandSubsurface GdkWaylandSubsurface;
|
||||
typedef struct _GdkWaylandSubsurfaceClass GdkWaylandSubsurfaceClass;
|
||||
|
||||
#define GDK_TYPE_WAYLAND_SUBSURFACE (gdk_wayland_subsurface_get_type ())
|
||||
#define GDK_WAYLAND_SUBSURFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_SUBSURFACE, GdkWaylandSubsurface))
|
||||
#define GDK_WAYLAND_SUBSURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_SUBSURFACE, GdkWaylandSubsurfaceClass))
|
||||
#define GDK_IS_WAYLAND_SUBSURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_SUBSURFACE))
|
||||
#define GDK_WAYLAND_SUBSURFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_SUBSURFACE, GdkWaylandSubsurfaceClass))
|
||||
|
||||
struct _GdkWaylandSubsurface
|
||||
{
|
||||
GdkSubsurface parent_instance;
|
||||
|
||||
struct wl_surface *surface;
|
||||
struct wl_subsurface *subsurface;
|
||||
struct wp_viewport *viewport;
|
||||
|
||||
GdkTexture *texture;
|
||||
cairo_rectangle_int_t dest;
|
||||
|
||||
struct wl_region *opaque_region;
|
||||
|
||||
struct wl_callback *frame_callback;
|
||||
|
||||
gboolean above_parent;
|
||||
};
|
||||
|
||||
struct _GdkWaylandSubsurfaceClass
|
||||
{
|
||||
GdkSubsurfaceClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_wayland_subsurface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gdk_wayland_subsurface_request_frame (GdkSubsurface *subsurface);
|
||||
void gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *subsurface);
|
||||
|
||||
GdkSubsurface * gdk_wayland_surface_create_subsurface (GdkSurface *surface);
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
/*
|
||||
* Copyright © 2023 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdksubsurface-wayland-private.h"
|
||||
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdksurface-wayland-private.h"
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandSubsurface, gdk_wayland_subsurface, GDK_TYPE_SUBSURFACE)
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_init (GdkWaylandSubsurface *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (object);
|
||||
|
||||
g_clear_object (&self->texture);
|
||||
g_clear_pointer (&self->frame_callback, wl_callback_destroy);
|
||||
g_clear_pointer (&self->opaque_region, wl_region_destroy);
|
||||
g_clear_pointer (&self->viewport, wp_viewport_destroy);
|
||||
g_clear_pointer (&self->subsurface, wl_subsurface_destroy);
|
||||
g_clear_pointer (&self->surface, wl_surface_destroy);
|
||||
g_clear_pointer (&self->subsurface, wl_subsurface_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_subsurface_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_buffer_release (void *data,
|
||||
struct wl_buffer *buffer)
|
||||
{
|
||||
GdkTexture *texture = data;
|
||||
|
||||
g_object_unref (texture);
|
||||
wl_buffer_destroy (buffer);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener dmabuf_buffer_listener = {
|
||||
dmabuf_buffer_release,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct wl_buffer *buffer;
|
||||
gboolean done;
|
||||
} CreateBufferData;
|
||||
|
||||
static void
|
||||
params_buffer_created (void *data,
|
||||
struct zwp_linux_buffer_params_v1 *params,
|
||||
struct wl_buffer *buffer)
|
||||
{
|
||||
CreateBufferData *cd = data;
|
||||
|
||||
cd->buffer = buffer;
|
||||
cd->done = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
params_buffer_failed (void *data,
|
||||
struct zwp_linux_buffer_params_v1 *params)
|
||||
{
|
||||
CreateBufferData *cd = data;
|
||||
|
||||
cd->buffer = NULL;
|
||||
cd->done = TRUE;
|
||||
}
|
||||
|
||||
static const struct zwp_linux_buffer_params_v1_listener params_listener = {
|
||||
params_buffer_created,
|
||||
params_buffer_failed,
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
||||
const GdkDmabuf *dmabuf;
|
||||
struct zwp_linux_buffer_params_v1 *params;
|
||||
struct wl_buffer *buffer;
|
||||
CreateBufferData cd = { NULL, FALSE };
|
||||
struct wl_event_queue *event_queue;
|
||||
|
||||
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
|
||||
|
||||
params = zwp_linux_dmabuf_v1_create_params (display->linux_dmabuf);
|
||||
|
||||
for (gsize i = 0; i < dmabuf->n_planes; i++)
|
||||
zwp_linux_buffer_params_v1_add (params,
|
||||
dmabuf->planes[i].fd,
|
||||
i,
|
||||
dmabuf->planes[i].offset,
|
||||
dmabuf->planes[i].stride,
|
||||
dmabuf->modifier >> 32,
|
||||
dmabuf->modifier & 0xffffffff);
|
||||
|
||||
event_queue = wl_display_create_queue (display->wl_display);
|
||||
|
||||
wl_proxy_set_queue ((struct wl_proxy *) params, event_queue);
|
||||
|
||||
zwp_linux_buffer_params_v1_add_listener (params, ¶ms_listener, &cd);
|
||||
|
||||
zwp_linux_buffer_params_v1_create (params,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
dmabuf->fourcc,
|
||||
0);
|
||||
|
||||
while (!cd.done)
|
||||
gdk_wayland_display_dispatch_queue (GDK_DISPLAY (display), event_queue);
|
||||
|
||||
wl_event_queue_destroy (event_queue);
|
||||
zwp_linux_buffer_params_v1_destroy (params);
|
||||
|
||||
buffer = cd.buffer;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
wl_proxy_set_queue ((struct wl_proxy *) buffer, NULL);
|
||||
wl_buffer_add_listener (buffer, &dmabuf_buffer_listener, g_object_ref (texture));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *rect,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
GdkWaylandSurface *parent = GDK_WAYLAND_SURFACE (sub->parent);
|
||||
struct wl_buffer *buffer = NULL;
|
||||
gboolean result = FALSE;
|
||||
GdkWaylandSubsurface *sib = sibling ? GDK_WAYLAND_SUBSURFACE (sibling) : NULL;
|
||||
gboolean will_be_above;
|
||||
double scale;
|
||||
graphene_rect_t device_rect;
|
||||
cairo_rectangle_int_t device_dest;
|
||||
|
||||
if (sib)
|
||||
will_be_above = sib->above_parent;
|
||||
else
|
||||
will_be_above = above;
|
||||
|
||||
if (sub->parent == NULL)
|
||||
{
|
||||
g_warning ("Can't attach to destroyed subsurface %p", self);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->dest.x = rect->origin.x;
|
||||
self->dest.y = rect->origin.y;
|
||||
self->dest.width = rect->size.width;
|
||||
self->dest.height = rect->size.height;
|
||||
|
||||
scale = gdk_fractional_scale_to_double (&parent->scale);
|
||||
device_rect.origin.x = rect->origin.x * scale;
|
||||
device_rect.origin.y = rect->origin.y * scale;
|
||||
device_rect.size.width = rect->size.width * scale;
|
||||
device_rect.size.height = rect->size.height * scale;
|
||||
device_dest.x = device_rect.origin.x;
|
||||
device_dest.y = device_rect.origin.y;
|
||||
device_dest.width = device_rect.size.width;
|
||||
device_dest.height = device_rect.size.height;
|
||||
|
||||
if (self->dest.x != rect->origin.x ||
|
||||
self->dest.y != rect->origin.y ||
|
||||
self->dest.width != rect->size.width ||
|
||||
self->dest.height != rect->size.height)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Non-integer coordinates %g %g %g %g for %dx%d texture, hiding subsurface %p",
|
||||
rect->origin.x, rect->origin.y,
|
||||
rect->size.width, rect->size.height,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self);
|
||||
}
|
||||
else if (device_dest.x != device_rect.origin.x ||
|
||||
device_dest.y != device_rect.origin.y ||
|
||||
device_dest.width != device_rect.size.width ||
|
||||
device_dest.height != device_rect.size.height)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Non-integral device coordinates %g %g %g %g (fractional scale %.2f), hiding subsurface %p",
|
||||
device_rect.origin.x, device_rect.origin.y,
|
||||
device_rect.size.width, device_rect.size.width,
|
||||
scale,
|
||||
self);
|
||||
}
|
||||
else if (!GDK_IS_DMABUF_TEXTURE (texture))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"%dx%d %s is not a GdkDmabufTexture, hiding subsurface %p",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
G_OBJECT_TYPE_NAME (texture),
|
||||
self);
|
||||
}
|
||||
else if (!will_be_above &&
|
||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Cannot offload non-opaque %dx%d texture below, hiding subsurface %p",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean was_transparent;
|
||||
|
||||
if (self->texture)
|
||||
was_transparent = gdk_memory_format_alpha (gdk_texture_get_format (self->texture)) != GDK_MEMORY_ALPHA_OPAQUE;
|
||||
else
|
||||
was_transparent = FALSE;
|
||||
|
||||
if (g_set_object (&self->texture, texture))
|
||||
{
|
||||
buffer = get_wl_buffer (self, texture);
|
||||
if (buffer != NULL)
|
||||
{
|
||||
gboolean is_transparent;
|
||||
|
||||
is_transparent = gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE;
|
||||
if (is_transparent != was_transparent)
|
||||
{
|
||||
if (is_transparent)
|
||||
wl_surface_set_opaque_region (self->surface, NULL);
|
||||
else
|
||||
wl_surface_set_opaque_region (self->surface, self->opaque_region);
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Attached %dx%d texture to subsurface %p at %d %d %d %d",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self,
|
||||
self->dest.x, self->dest.y,
|
||||
self->dest.width, self->dest.height);
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Compositor failed to create wl_buffer for %dx%d texture, hiding subsurface %p",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = NULL;
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Moved %dx%d texture in subsurface %p to %d %d %d %d",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self,
|
||||
self->dest.x, self->dest.y,
|
||||
self->dest.width, self->dest.height);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
wl_subsurface_set_position (self->subsurface, self->dest.x, self->dest.y);
|
||||
wp_viewport_set_destination (self->viewport, self->dest.width, self->dest.height);
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
wl_surface_attach (self->surface, buffer, 0, 0);
|
||||
wl_surface_damage_buffer (self->surface,
|
||||
0, 0,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
|
||||
}
|
||||
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_object (&self->texture, NULL);
|
||||
|
||||
wl_surface_attach (self->surface, NULL, 0, 0);
|
||||
}
|
||||
|
||||
if (sib)
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface, sib->surface);
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface, sib->surface);
|
||||
|
||||
self->above_parent = sib->above_parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
self->above_parent = above;
|
||||
}
|
||||
|
||||
wl_surface_commit (self->surface);
|
||||
|
||||
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_detach (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
if (sub->parent == NULL)
|
||||
{
|
||||
g_warning ("Can't draw to destroyed subsurface %p", self);
|
||||
return;
|
||||
}
|
||||
|
||||
g_set_object (&self->texture, NULL);
|
||||
wl_surface_attach (self->surface, NULL, 0, 0);
|
||||
wl_surface_set_opaque_region (self->surface, self->opaque_region);
|
||||
wl_surface_commit (self->surface);
|
||||
|
||||
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
gdk_wayland_subsurface_get_texture (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
return self->texture;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_get_rect (GdkSubsurface *sub,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
rect->origin.x = self->dest.x;
|
||||
rect->origin.y = self->dest.y;
|
||||
rect->size.width = self->dest.width;
|
||||
rect->size.height = self->dest.height;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_subsurface_is_above_parent (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
|
||||
return self->above_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_class_init (GdkWaylandSubsurfaceClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GdkSubsurfaceClass *subsurface_class = GDK_SUBSURFACE_CLASS (class);
|
||||
|
||||
object_class->finalize = gdk_wayland_subsurface_finalize;
|
||||
|
||||
subsurface_class->attach = gdk_wayland_subsurface_attach;
|
||||
subsurface_class->detach = gdk_wayland_subsurface_detach;
|
||||
subsurface_class->get_texture = gdk_wayland_subsurface_get_texture;
|
||||
subsurface_class->get_rect = gdk_wayland_subsurface_get_rect;
|
||||
subsurface_class->is_above_parent = gdk_wayland_subsurface_is_above_parent;
|
||||
};
|
||||
|
||||
static void
|
||||
frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
GdkSubsurface *sub = data;
|
||||
|
||||
g_assert (((GdkWaylandSubsurface *)sub)->frame_callback == callback);
|
||||
g_assert (!GDK_SURFACE_DESTROYED (sub->parent));
|
||||
|
||||
gdk_wayland_surface_frame_callback (sub->parent, time);
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener frame_listener = {
|
||||
frame_callback
|
||||
};
|
||||
|
||||
void
|
||||
gdk_wayland_subsurface_request_frame (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
|
||||
self->frame_callback = wl_surface_frame (self->surface);
|
||||
wl_proxy_set_queue ((struct wl_proxy *) self->frame_callback, NULL);
|
||||
wl_callback_add_listener (self->frame_callback, &frame_listener, self);
|
||||
wl_surface_commit (self->surface);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
|
||||
g_clear_pointer (&self->frame_callback, wl_callback_destroy);
|
||||
}
|
||||
|
||||
GdkSubsurface *
|
||||
gdk_wayland_surface_create_subsurface (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display);
|
||||
GdkWaylandSubsurface *sub;
|
||||
struct wl_region *region;
|
||||
|
||||
if (disp->viewporter == NULL)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Can't use subsurfaces without viewporter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sub = g_object_new (GDK_TYPE_WAYLAND_SUBSURFACE, NULL);
|
||||
|
||||
sub->surface = wl_compositor_create_surface (disp->compositor);
|
||||
sub->subsurface = wl_subcompositor_get_subsurface (disp->subcompositor,
|
||||
sub->surface,
|
||||
impl->display_server.wl_surface);
|
||||
sub->viewport = wp_viewporter_get_viewport (disp->viewporter, sub->surface);
|
||||
|
||||
/* No input, please */
|
||||
region = wl_compositor_create_region (disp->compositor);
|
||||
wl_surface_set_input_region (sub->surface, region);
|
||||
wl_region_destroy (region);
|
||||
|
||||
/* Keep a max-sized opaque region so we don't have to update it
|
||||
* when the size of the texture changes.
|
||||
*/
|
||||
sub->opaque_region = wl_compositor_create_region (disp->compositor);
|
||||
wl_region_add (sub->opaque_region, 0, 0, G_MAXINT, G_MAXINT);
|
||||
wl_surface_set_opaque_region (sub->surface, sub->opaque_region);
|
||||
|
||||
sub->above_parent = TRUE;
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Subsurface %p of surface %p created", sub, impl);
|
||||
|
||||
return GDK_SUBSURFACE (sub);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ struct _GdkWaylandSurface
|
||||
|
||||
unsigned int initial_configure_received : 1;
|
||||
unsigned int has_uncommitted_ack_configure : 1;
|
||||
unsigned int has_pending_subsurface_commits : 1;
|
||||
unsigned int mapped : 1;
|
||||
unsigned int awaiting_frame_frozen : 1;
|
||||
|
||||
@@ -86,8 +87,6 @@ struct _GdkWaylandSurface
|
||||
uint32_t last_configure_serial;
|
||||
|
||||
int state_freeze_count;
|
||||
|
||||
GPtrArray *subsurfaces;
|
||||
};
|
||||
|
||||
typedef struct _GdkWaylandSurfaceClass GdkWaylandSurfaceClass;
|
||||
@@ -124,6 +123,9 @@ void gdk_wayland_surface_get_window_geometry (GdkSurface *surface,
|
||||
void gdk_wayland_surface_freeze_state (GdkSurface *surface);
|
||||
void gdk_wayland_surface_thaw_state (GdkSurface *surface);
|
||||
|
||||
void gdk_wayland_surface_frame_callback (GdkSurface *surface,
|
||||
uint32_t time);
|
||||
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
|
||||
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
@@ -34,10 +34,11 @@
|
||||
#include "gdktoplevelprivate.h"
|
||||
#include "gdkdevice-wayland-private.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
#include "gdksubsurface-wayland-private.h"
|
||||
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -50,6 +51,8 @@
|
||||
#include "gdksurface-wayland-private.h"
|
||||
#include "gdktoplevel-wayland-private.h"
|
||||
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
|
||||
/**
|
||||
* GdkWaylandSurface:
|
||||
@@ -157,15 +160,11 @@ wl_region_from_cairo_region (GdkWaylandDisplay *display,
|
||||
/* }}} */
|
||||
/* {{{ Surface implementation */
|
||||
|
||||
static void gdk_wayland_subsurface_destroy (GdkSubsurface *sub);
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_init (GdkWaylandSurface *impl)
|
||||
{
|
||||
impl->scale = GDK_FRACTIONAL_SCALE_INIT_INT (1);
|
||||
impl->viewport_dirty = TRUE;
|
||||
|
||||
impl->subsurfaces = g_ptr_array_new ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -200,7 +199,7 @@ get_egl_window_size (GdkSurface *surface,
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_GL_FRACTIONAL)
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_FRACTIONAL))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Using fractional scale %g for EGL window", gdk_fractional_scale_to_double (&impl->scale));
|
||||
|
||||
@@ -265,12 +264,10 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
|
||||
_gdk_surface_update_size (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
void
|
||||
gdk_wayland_surface_frame_callback (GdkSurface *surface,
|
||||
uint32_t time)
|
||||
{
|
||||
GdkSurface *surface = data;
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
@@ -280,11 +277,14 @@ frame_callback (void *data,
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "frame event");
|
||||
GDK_DISPLAY_DEBUG (GDK_DISPLAY (display_wayland), EVENTS, "frame %p", surface);
|
||||
|
||||
g_assert (impl->frame_callback == callback);
|
||||
g_assert (!GDK_SURFACE_DESTROYED (surface));
|
||||
|
||||
g_clear_pointer (&impl->frame_callback, wl_callback_destroy);
|
||||
|
||||
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
|
||||
{
|
||||
GdkSubsurface *subsurface = gdk_surface_get_subsurface (surface, i);
|
||||
gdk_wayland_subsurface_clear_frame_callback (subsurface);
|
||||
}
|
||||
|
||||
GDK_WAYLAND_SURFACE_GET_CLASS (impl)->handle_frame (impl);
|
||||
|
||||
if (impl->awaiting_frame_frozen)
|
||||
@@ -315,15 +315,26 @@ frame_callback (void *data,
|
||||
|
||||
timings->complete = TRUE;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
|
||||
_gdk_frame_clock_debug_print_timings (clock, timings);
|
||||
#endif
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
|
||||
}
|
||||
|
||||
static void
|
||||
frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
GdkSurface *surface = data;
|
||||
|
||||
g_assert (GDK_WAYLAND_SURFACE (surface)->frame_callback == callback);
|
||||
g_assert (!GDK_SURFACE_DESTROYED (surface));
|
||||
|
||||
gdk_wayland_surface_frame_callback (surface, time);
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener frame_listener = {
|
||||
frame_callback
|
||||
};
|
||||
@@ -385,6 +396,13 @@ gdk_wayland_surface_request_frame (GdkSurface *surface)
|
||||
self->frame_callback = wl_surface_frame (self->display_server.wl_surface);
|
||||
wl_proxy_set_queue ((struct wl_proxy *) self->frame_callback, NULL);
|
||||
wl_callback_add_listener (self->frame_callback, &frame_listener, surface);
|
||||
|
||||
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
|
||||
{
|
||||
GdkSubsurface *subsurface = gdk_surface_get_subsurface (surface, i);
|
||||
gdk_wayland_subsurface_request_frame (subsurface);
|
||||
}
|
||||
|
||||
self->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
||||
}
|
||||
|
||||
@@ -410,6 +428,7 @@ gdk_wayland_surface_notify_committed (GdkSurface *surface)
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
impl->has_uncommitted_ack_configure = FALSE;
|
||||
impl->has_pending_subsurface_commits = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -418,7 +437,9 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (surface->update_freeze_count == 0 && impl->has_uncommitted_ack_configure)
|
||||
if (surface->update_freeze_count == 0 &&
|
||||
(impl->has_uncommitted_ack_configure ||
|
||||
impl->has_pending_subsurface_commits))
|
||||
{
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
@@ -559,7 +580,6 @@ gdk_wayland_surface_finalize (GObject *object)
|
||||
|
||||
g_clear_pointer (&impl->opaque_region, cairo_region_destroy);
|
||||
g_clear_pointer (&impl->input_region, cairo_region_destroy);
|
||||
g_clear_pointer (&impl->subsurfaces, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -620,8 +640,27 @@ gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
|
||||
return;
|
||||
|
||||
if (impl->opaque_region != NULL)
|
||||
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
||||
impl->opaque_region);
|
||||
{
|
||||
if (gdk_surface_get_n_subsurfaces (surface) > 0)
|
||||
{
|
||||
cairo_region_t *region = cairo_region_copy (impl->opaque_region);
|
||||
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
|
||||
{
|
||||
GdkWaylandSubsurface *sub = (GdkWaylandSubsurface *)gdk_surface_get_subsurface (surface, i);
|
||||
if (sub->above_parent)
|
||||
continue;
|
||||
if (sub->texture != NULL)
|
||||
cairo_region_subtract_rectangle (region, &sub->dest);
|
||||
}
|
||||
|
||||
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
||||
region);
|
||||
cairo_region_destroy (region);
|
||||
}
|
||||
else
|
||||
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
||||
impl->opaque_region);
|
||||
}
|
||||
|
||||
wl_surface_set_opaque_region (impl->display_server.wl_surface, wl_region);
|
||||
|
||||
@@ -1019,6 +1058,7 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
|
||||
impl->has_uncommitted_ack_configure = FALSE;
|
||||
impl->has_pending_subsurface_commits = FALSE;
|
||||
|
||||
impl->last_sent_window_geometry = (GdkRectangle) { 0 };
|
||||
impl->mapped = FALSE;
|
||||
@@ -1143,17 +1183,6 @@ gdk_wayland_surface_set_input_region (GdkSurface *surface,
|
||||
impl->input_region_dirty = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_destroy_subsurfaces (GdkWaylandSurface *impl)
|
||||
{
|
||||
for (gsize i = 0; i < impl->subsurfaces->len; i++)
|
||||
{
|
||||
GdkSubsurface *sub = g_ptr_array_index (impl->subsurfaces, i);
|
||||
gdk_subsurface_destroy (sub);
|
||||
}
|
||||
g_ptr_array_set_size (impl->subsurfaces, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_destroy (GdkSurface *surface,
|
||||
gboolean foreign_destroy)
|
||||
@@ -1170,7 +1199,6 @@ gdk_wayland_surface_destroy (GdkSurface *surface,
|
||||
if (GDK_IS_TOPLEVEL (surface))
|
||||
gdk_wayland_toplevel_destroy (GDK_TOPLEVEL (surface));
|
||||
|
||||
gdk_wayland_surface_destroy_subsurfaces (GDK_WAYLAND_SURFACE (surface));
|
||||
gdk_wayland_surface_destroy_wl_surface (GDK_WAYLAND_SURFACE (surface));
|
||||
|
||||
frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
@@ -1227,8 +1255,6 @@ gdk_wayland_surface_default_hide_surface (GdkWaylandSurface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static GdkSubsurface *gdk_wayland_surface_create_subsurface (GdkSurface *surface);
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
|
||||
{
|
||||
@@ -1328,236 +1354,4 @@ gdk_wayland_surface_get_wl_surface (GdkSurface *surface)
|
||||
}
|
||||
|
||||
/* }}}} */
|
||||
/* {{{ Subsurface */
|
||||
|
||||
typedef struct {
|
||||
GdkSubsurface subsurface;
|
||||
|
||||
GdkWaylandSurface *parent;
|
||||
|
||||
struct wl_surface *wl_surface;
|
||||
struct wl_subsurface *wl_subsurface;
|
||||
struct wp_viewport *wp_viewport;
|
||||
} GdkWaylandSubsurface;
|
||||
|
||||
static void
|
||||
dmabuf_buffer_release (void *data,
|
||||
struct wl_buffer *wl_buffer)
|
||||
{
|
||||
GdkTexture *texture = data;
|
||||
|
||||
g_object_unref (texture);
|
||||
wl_buffer_destroy (wl_buffer);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener dmabuf_buffer_listener = {
|
||||
dmabuf_buffer_release,
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self->parent)));
|
||||
const GdkDmabuf *dmabuf;
|
||||
struct zwp_linux_buffer_params_v1 *params;
|
||||
struct wl_buffer *wl_buffer;
|
||||
|
||||
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
|
||||
|
||||
params = zwp_linux_dmabuf_v1_create_params (display->linux_dmabuf);
|
||||
|
||||
for (gsize i = 0; i < dmabuf->n_planes; i++)
|
||||
zwp_linux_buffer_params_v1_add (params,
|
||||
dmabuf->planes[i].fd,
|
||||
i,
|
||||
dmabuf->planes[i].offset,
|
||||
dmabuf->planes[i].stride,
|
||||
dmabuf->modifier >> 32,
|
||||
dmabuf->modifier & 0xffffffff);
|
||||
|
||||
wl_buffer = zwp_linux_buffer_params_v1_create_immed (params,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
dmabuf->fourcc,
|
||||
0);
|
||||
|
||||
wl_buffer_add_listener (wl_buffer, &dmabuf_buffer_listener, g_object_ref (texture));
|
||||
|
||||
return wl_buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
shm_buffer_release (void *data,
|
||||
struct wl_buffer *wl_buffer)
|
||||
{
|
||||
cairo_surface_t *surface = data;
|
||||
|
||||
/* Note: the wl_buffer is destroyed as cairo user data */
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener shm_buffer_listener = {
|
||||
shm_buffer_release,
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_shm_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self->parent)));
|
||||
int width, height;
|
||||
cairo_surface_t *surface;
|
||||
GdkTextureDownloader *downloader;
|
||||
struct wl_buffer *wl_buffer;
|
||||
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
surface = gdk_wayland_display_create_shm_surface (display, width, height, &GDK_FRACTIONAL_SCALE_INIT_INT (1));
|
||||
|
||||
downloader = gdk_texture_downloader_new (texture);
|
||||
|
||||
gdk_texture_downloader_download_into (downloader,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
|
||||
gdk_texture_downloader_free (downloader);
|
||||
|
||||
wl_buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
|
||||
wl_buffer_add_listener (wl_buffer, &shm_buffer_listener, surface);
|
||||
|
||||
return wl_buffer;
|
||||
}
|
||||
|
||||
static struct wl_buffer *
|
||||
get_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
if (GDK_IS_DMABUF_TEXTURE (texture))
|
||||
return get_dmabuf_wl_buffer (self, texture);
|
||||
else
|
||||
return get_shm_wl_buffer (self, texture);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
|
||||
GDK_DEBUG (DMABUF,
|
||||
"Attaching texture %p at %f %f %f %f",
|
||||
texture,
|
||||
rect->origin.x, rect->origin.y, rect->size.width, rect->size.height);
|
||||
|
||||
if (rect)
|
||||
{
|
||||
wl_subsurface_set_position (self->wl_subsurface,
|
||||
floorf (rect->origin.x),
|
||||
floorf (rect->origin.y));
|
||||
wp_viewport_set_destination (self->wp_viewport,
|
||||
ceilf (rect->origin.x + rect->size.width) - floorf (rect->origin.x),
|
||||
ceilf (rect->origin.y + rect->size.height) - floorf (rect->origin.y));
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
wl_surface_attach (self->wl_surface, get_wl_buffer (self, texture), 0, 0);
|
||||
wl_surface_damage_buffer (self->wl_surface,
|
||||
0, 0,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_surface_attach (self->wl_surface, NULL, 0, 0);
|
||||
}
|
||||
|
||||
wl_surface_commit (self->wl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_destroy (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
|
||||
g_clear_pointer (&self->wp_viewport, wp_viewport_destroy);
|
||||
g_clear_pointer (&self->wl_subsurface, wl_subsurface_destroy);
|
||||
g_clear_pointer (&self->wl_surface, wl_surface_destroy);
|
||||
|
||||
g_ptr_array_remove (self->parent->subsurfaces, self);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_place_above (GdkSubsurface *sub,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
GdkWaylandSubsurface *sib = (GdkWaylandSubsurface *)sibling;
|
||||
|
||||
g_return_if_fail (sib == NULL || self->parent == sib->parent);
|
||||
|
||||
wl_subsurface_place_above (self->wl_subsurface,
|
||||
sib ? sib->wl_surface : self->parent->display_server.wl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_place_below (GdkSubsurface *sub,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
GdkWaylandSubsurface *self = (GdkWaylandSubsurface *)sub;
|
||||
GdkWaylandSubsurface *sib = (GdkWaylandSubsurface *)sibling;
|
||||
|
||||
g_return_if_fail (sib == NULL || self->parent == sib->parent);
|
||||
|
||||
wl_subsurface_place_below (self->wl_subsurface,
|
||||
sib ? sib->wl_surface : self->parent->display_server.wl_surface);
|
||||
}
|
||||
|
||||
static const GdkSubsurfaceClass subsurface_class = {
|
||||
gdk_wayland_subsurface_destroy,
|
||||
gdk_wayland_subsurface_attach,
|
||||
gdk_wayland_subsurface_place_above,
|
||||
gdk_wayland_subsurface_place_below,
|
||||
};
|
||||
|
||||
static GdkSubsurface *
|
||||
gdk_wayland_surface_create_subsurface (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
GdkWaylandSubsurface *sub;
|
||||
struct wl_region *wl_region;
|
||||
|
||||
if (display->viewporter == NULL)
|
||||
{
|
||||
GDK_DEBUG (DMABUF, "Can't use subsurfaces without viewporter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sub = g_new0 (GdkWaylandSubsurface, 1);
|
||||
|
||||
sub->subsurface.class = &subsurface_class;
|
||||
|
||||
sub->parent = impl;
|
||||
g_ptr_array_add (sub->parent->subsurfaces, sub);
|
||||
|
||||
sub->wl_surface = wl_compositor_create_surface (display->compositor);
|
||||
wl_region = wl_compositor_create_region (display->compositor);
|
||||
wl_surface_set_input_region (sub->wl_surface, wl_region);
|
||||
wl_region_destroy (wl_region);
|
||||
sub->wl_subsurface = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
sub->wl_surface,
|
||||
impl->display_server.wl_surface);
|
||||
sub->wp_viewport = wp_viewporter_get_viewport (display->viewporter, sub->wl_surface);
|
||||
|
||||
GDK_DEBUG (DMABUF, "Subsurface created");
|
||||
|
||||
return (GdkSubsurface *) sub;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
|
||||
@@ -1904,7 +1904,9 @@ gdk_wayland_toplevel_show_window_menu (GdkToplevel *toplevel,
|
||||
wl_seat = gdk_wayland_seat_get_wl_seat (seat);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
|
||||
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, event);
|
||||
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_event_sequence (event));
|
||||
|
||||
switch (display_wayland->shell_variant)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "gdkwaylanddisplay.h"
|
||||
#include "gdkwaylandsurface.h"
|
||||
#include "gdksurface-wayland-private.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandVulkanContext, gdk_wayland_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
|
||||
@@ -72,6 +73,22 @@ gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_wayland_empty_frame (GdkDrawContext *context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (!impl->has_pending_subsurface_commits)
|
||||
return;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_vulkan_context_class_init (GdkWaylandVulkanContextClass *klass)
|
||||
{
|
||||
@@ -80,6 +97,7 @@ gdk_wayland_vulkan_context_class_init (GdkWaylandVulkanContextClass *klass)
|
||||
|
||||
vulkan_context_class->create_surface = gdk_wayland_vulkan_context_create_surface;
|
||||
draw_context_class->end_frame = gdk_vulkan_context_wayland_end_frame;
|
||||
draw_context_class->empty_frame = gdk_vulkan_context_wayland_empty_frame;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -18,6 +18,7 @@ gdk_wayland_sources = files([
|
||||
'gdkprimary-wayland.c',
|
||||
'gdkseat-wayland.c',
|
||||
'gdksurface-wayland.c',
|
||||
'gdksubsurface-wayland.c',
|
||||
'gdktoplevel-wayland.c',
|
||||
'gdkpopup-wayland.c',
|
||||
'gdkvulkancontext-wayland.c',
|
||||
|
||||
@@ -149,7 +149,7 @@ GTK might also call gdk_clipboard_store_async(), which instructs
|
||||
the W32 backend to put the data into the OS clipboard manager by
|
||||
sending WM_RENDERALLFORMATS to itself and then handling it normally.
|
||||
|
||||
Every time W32 backend gets WM_DRAWCLIPBOARD or WM_CLIPBOARDUPDATE,
|
||||
Every time W32 backend gets WM_CLIPBOARDUPDATE,
|
||||
it calls GetUpdatedClipboardFormats() and GetClipboardSequenceNumber()
|
||||
and caches the results of both. These calls do not require the clipboard
|
||||
to be opened.
|
||||
@@ -245,7 +245,7 @@ When clipboard owner changes, the old owner receives WM_DESTROYCLIPBOARD message
|
||||
the clipboard thread schedules a call to gdk_clipboard_claim_remote()
|
||||
in the main thread, with an empty list of formats,
|
||||
to indicate that the clipboard is now owned by a remote process.
|
||||
Later the OS will send WM_DRAWCLIPBOARD or WM_CLIPBOARDUPDATE to indicate
|
||||
Later the OS will send WM_CLIPBOARDUPDATE to indicate
|
||||
the new clipboard contents (see above).
|
||||
|
||||
DND:
|
||||
@@ -416,8 +416,6 @@ struct _GdkWin32ClipboardThread
|
||||
*/
|
||||
HWND clipboard_opened_for;
|
||||
|
||||
HWND hwnd_next_viewer;
|
||||
|
||||
/* We can't peek the queue or "unpop" queue items,
|
||||
* so the items that we can't act upon (yet) got
|
||||
* to be stored *somewhere*.
|
||||
@@ -1171,7 +1169,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_DESTROY: /* remove us from chain */
|
||||
case WM_DESTROY: /* unregister the clipboard listener */
|
||||
{
|
||||
if (clipboard_thread_data == NULL)
|
||||
{
|
||||
@@ -1179,34 +1177,15 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
return DefWindowProcW (hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
ChangeClipboardChain (hwnd, clipboard_thread_data->hwnd_next_viewer);
|
||||
RemoveClipboardFormatListener (hwnd);
|
||||
PostQuitMessage (0);
|
||||
return 0;
|
||||
}
|
||||
case WM_CHANGECBCHAIN:
|
||||
{
|
||||
HWND hwndRemove = (HWND) wparam; /* handle of window being removed */
|
||||
HWND hwndNext = (HWND) lparam; /* handle of next window in chain */
|
||||
|
||||
if (clipboard_thread_data == NULL)
|
||||
{
|
||||
g_warning ("Clipboard thread got an actionable message with no thread data");
|
||||
return DefWindowProcW (hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
if (hwndRemove == clipboard_thread_data->hwnd_next_viewer)
|
||||
clipboard_thread_data->hwnd_next_viewer = hwndNext == hwnd ? NULL : hwndNext;
|
||||
else if (clipboard_thread_data->hwnd_next_viewer != NULL)
|
||||
return SendMessage (clipboard_thread_data->hwnd_next_viewer, message, wparam, lparam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_DESTROYCLIPBOARD:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case WM_CLIPBOARDUPDATE:
|
||||
case WM_DRAWCLIPBOARD:
|
||||
{
|
||||
HWND hwnd_owner;
|
||||
HWND hwnd_opener;
|
||||
@@ -1228,8 +1207,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
|
||||
GDK_NOTE (DND, g_print (" drawclipboard owner: %p; opener %p ", hwnd_owner, hwnd_opener));
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (_gdk_debug_flags & GDK_DEBUG_DND)
|
||||
if (GDK_DEBUG_CHECK (DND))
|
||||
{
|
||||
/* FIXME: grab and print clipboard formats without opening the clipboard
|
||||
if (clipboard_thread_data->clipboard_opened_for != INVALID_HANDLE_VALUE ||
|
||||
@@ -1249,7 +1227,6 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
GDK_NOTE (DND, g_print (" \n"));
|
||||
|
||||
@@ -1272,9 +1249,6 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_owner_changed, NULL, NULL);
|
||||
}
|
||||
|
||||
if (clipboard_thread_data->hwnd_next_viewer != NULL)
|
||||
return SendMessage (clipboard_thread_data->hwnd_next_viewer, message, wparam, lparam);
|
||||
|
||||
/* clear error to avoid confusing SetClipboardViewer() return */
|
||||
SetLastError (0);
|
||||
|
||||
@@ -1386,7 +1360,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
* OpenClipboard() is required/possible
|
||||
*/
|
||||
GDK_NOTE (DND,
|
||||
g_print (" SetClipboardData (%s, %p)",
|
||||
g_print (" SetClipboardData (%s, %p)\n",
|
||||
_gdk_win32_cf_to_string (wparam),
|
||||
returned_render->main_thread_data_handle));
|
||||
|
||||
@@ -1426,7 +1400,7 @@ _clipboard_window_procedure (HWND hwnd,
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a hidden window and adds it to the clipboard chain
|
||||
* Creates a hidden window and add a clipboard listener
|
||||
*/
|
||||
static gboolean
|
||||
register_clipboard_notification ()
|
||||
@@ -1452,9 +1426,8 @@ register_clipboard_notification ()
|
||||
goto failed;
|
||||
|
||||
SetLastError (0);
|
||||
clipboard_thread_data->hwnd_next_viewer = SetClipboardViewer (clipboard_thread_data->clipboard_window);
|
||||
|
||||
if (clipboard_thread_data->hwnd_next_viewer == NULL && GetLastError() != NO_ERROR)
|
||||
if (AddClipboardFormatListener (clipboard_thread_data->clipboard_window) == FALSE)
|
||||
{
|
||||
DestroyWindow (clipboard_thread_data->clipboard_window);
|
||||
goto failed;
|
||||
@@ -1462,11 +1435,6 @@ register_clipboard_notification ()
|
||||
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_window_created, (gpointer) clipboard_thread_data->clipboard_window, NULL);
|
||||
|
||||
/* FIXME: http://msdn.microsoft.com/en-us/library/ms649033(v=VS.85).aspx */
|
||||
/* This is only supported by Vista, and not yet by mingw64 */
|
||||
/* if (AddClipboardFormatListener (hwnd) == FALSE) */
|
||||
/* goto failed; */
|
||||
|
||||
return TRUE;
|
||||
|
||||
failed:
|
||||
|
||||
@@ -548,6 +548,9 @@ _gdk_win32_display_open (const char *display_name)
|
||||
|
||||
g_signal_emit_by_name (_gdk_display, "opened");
|
||||
|
||||
/* Precalculate keymap, see #6203 */
|
||||
(void) _gdk_win32_display_get_keymap (_gdk_display);
|
||||
|
||||
GDK_NOTE (MISC, g_print ("... _gdk_display now set up\n"));
|
||||
|
||||
return _gdk_display;
|
||||
@@ -1170,6 +1173,9 @@ gdk_win32_display_get_setting (GdkDisplay *display,
|
||||
const char *name,
|
||||
GValue *value)
|
||||
{
|
||||
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_DEFAULT_SETTINGS)
|
||||
return FALSE;
|
||||
|
||||
return _gdk_win32_get_setting (name, value);
|
||||
}
|
||||
|
||||
@@ -1195,7 +1201,7 @@ gdk_win32_display_init_gl (GdkDisplay *display,
|
||||
* Disable defaulting to EGL as EGL is used more as a compatibility layer
|
||||
* on Windows rather than being a native citizen on Windows
|
||||
*/
|
||||
if (gdk_display_get_debug_flags (display) & (GDK_DEBUG_GL_EGL|GDK_DEBUG_GL_GLES))
|
||||
if (gdk_display_get_debug_flags (display) & (GDK_DEBUG_GL_EGL|GDK_DEBUG_GL_DISABLE_GL))
|
||||
{
|
||||
init_gl_hdc = GetDC (display_win32->hwnd);
|
||||
|
||||
|
||||
@@ -714,8 +714,6 @@ build_pointer_event_state (MSG *msg)
|
||||
return state;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static void
|
||||
print_event_state (guint state)
|
||||
{
|
||||
@@ -860,8 +858,6 @@ decode_key_lparam (LPARAM lParam)
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
fixup_event (GdkEvent *event)
|
||||
{
|
||||
@@ -2936,7 +2932,6 @@ gdk_event_translate (MSG *msg,
|
||||
break;
|
||||
|
||||
case WM_WINDOWPOSCHANGING:
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
{
|
||||
char buf[256];
|
||||
GDK_NOTE (EVENTS, (windowpos = (WINDOWPOS *) msg->lParam,
|
||||
@@ -2951,7 +2946,6 @@ gdk_event_translate (MSG *msg,
|
||||
windowpos->cx, windowpos->cy, windowpos->x, windowpos->y,
|
||||
GetNextWindow (msg->hwnd, GW_HWNDPREV))));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (window))
|
||||
{
|
||||
@@ -2986,7 +2980,6 @@ gdk_event_translate (MSG *msg,
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
windowpos = (WINDOWPOS *) msg->lParam;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
{
|
||||
char buf[256];
|
||||
GDK_NOTE (EVENTS, g_print (" %s %s %dx%d@%+d%+d",
|
||||
@@ -2999,7 +2992,6 @@ gdk_event_translate (MSG *msg,
|
||||
buf))))),
|
||||
windowpos->cx, windowpos->cy, windowpos->x, windowpos->y));
|
||||
}
|
||||
#endif
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
|
||||
@@ -339,7 +339,6 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if G_ENABLE_DEBUG
|
||||
{
|
||||
int major, minor;
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
@@ -357,7 +356,6 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
|
||||
display_win32->hasWglEXTSwapControl ? "yes" : "no",
|
||||
display_win32->hasWglOMLSyncControl ? "yes" : "no"));
|
||||
}
|
||||
#endif
|
||||
|
||||
wglMakeCurrent (NULL, NULL);
|
||||
|
||||
@@ -677,9 +675,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
||||
* A legacy context cannot be shared with core profile ones, so this means we
|
||||
* must stick to a legacy context if the shared context is a legacy context
|
||||
*/
|
||||
legacy_bit = (gdk_display_get_debug_flags (display) & GDK_DEBUG_GL_LEGACY)
|
||||
? TRUE
|
||||
: share != NULL && gdk_gl_context_is_legacy (share);
|
||||
legacy_bit = share != NULL && gdk_gl_context_is_legacy (share);
|
||||
|
||||
if (surface != NULL)
|
||||
hdc = GDK_WIN32_SURFACE (surface)->hdc;
|
||||
|
||||
@@ -125,8 +125,6 @@ _gdk_other_api_failed (const char *where,
|
||||
}
|
||||
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
/*
|
||||
* Like g_strdup_printf, but to a static buffer. Return value does not
|
||||
* have to be g_free()d. The buffer is of bounded size and reused
|
||||
@@ -796,5 +794,3 @@ _gdk_win32_rect_to_string (const RECT *rect)
|
||||
(rect->right - rect->left), (rect->bottom - rect->top),
|
||||
rect->left, rect->top);
|
||||
}
|
||||
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
@@ -31,20 +31,12 @@
|
||||
|
||||
/* Old debug macros */
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
#define GDK_NOTE(type,action) \
|
||||
G_STMT_START { \
|
||||
if (GDK_DEBUG_CHECK (type)) \
|
||||
{ action; }; \
|
||||
} G_STMT_END
|
||||
|
||||
#else
|
||||
|
||||
#define GDK_NOTE(type,action)
|
||||
|
||||
#endif
|
||||
|
||||
/* According to
|
||||
* http://blog.airesoft.co.uk/2009/11/wm_messages/
|
||||
* this is the actual internal name MS uses for this undocumented message.
|
||||
@@ -102,7 +94,6 @@ gboolean _gdk_modal_blocked (GdkSurface *window);
|
||||
gboolean gdk_win32_ensure_com (void);
|
||||
gboolean gdk_win32_ensure_ole (void);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
void _gdk_win32_print_dc (HDC hdc);
|
||||
|
||||
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
|
||||
@@ -117,7 +108,6 @@ char *_gdk_win32_cf_to_string (UINT format);
|
||||
char *_gdk_win32_rect_to_string (const RECT *rect);
|
||||
|
||||
void _gdk_win32_print_event (GdkEvent *event);
|
||||
#endif
|
||||
|
||||
void _gdk_win32_api_failed (const char *where,
|
||||
const char *api);
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
#include "gdkprivate.h"
|
||||
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_DESKTOPAPPINFO
|
||||
#include <gio/gdesktopappinfo.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -355,11 +353,10 @@ gdk_x11_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
|
||||
workspace_str = g_strdup_printf ("%d", ctx->workspace);
|
||||
else
|
||||
workspace_str = NULL;
|
||||
#ifdef HAVE_DESKTOPAPPINFO
|
||||
|
||||
if (G_IS_DESKTOP_APP_INFO (info))
|
||||
application_id = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (info));
|
||||
else
|
||||
#endif
|
||||
application_id = NULL;
|
||||
|
||||
startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu",
|
||||
|
||||
@@ -65,7 +65,6 @@ print_atoms (GdkX11Clipboard *cb,
|
||||
const Atom *atoms,
|
||||
gsize n_atoms)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, CLIPBOARD))
|
||||
@@ -82,7 +81,6 @@ print_atoms (GdkX11Clipboard *cb,
|
||||
gdk_debug_message ("%s", str->str);
|
||||
g_string_free (str, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -330,14 +328,12 @@ gdk_x11_clipboard_request_targets_finish (GObject *source_object,
|
||||
formats = gdk_x11_clipboard_formats_from_atoms (display,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes) / sizeof (Atom));
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, CLIPBOARD))
|
||||
{
|
||||
char *s = gdk_content_formats_to_string (formats);
|
||||
gdk_debug_message ("%s: got formats: %s", cb->selection, s);
|
||||
g_free (s);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* union with previously loaded formats */
|
||||
formats = gdk_content_formats_union (formats, gdk_clipboard_get_formats (GDK_CLIPBOARD (cb)));
|
||||
@@ -481,20 +477,16 @@ gdk_x11_clipboard_xevent (GdkDisplay *display,
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.selection != cb->xselection)
|
||||
return FALSE;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
|
||||
if (xevent->xselectionrequest.property == None)
|
||||
property = target;
|
||||
else
|
||||
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
|
||||
#endif
|
||||
|
||||
if (!gdk_clipboard_is_local (GDK_CLIPBOARD (cb)))
|
||||
{
|
||||
|
||||
+8
-11
@@ -333,17 +333,14 @@ gdk_x11_device_xi2_grab (GdkDevice *device,
|
||||
event_mask,
|
||||
&mask.mask_len);
|
||||
|
||||
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_NOGRABS)
|
||||
status = GrabSuccess;
|
||||
else
|
||||
status = XIGrabDevice (GDK_DISPLAY_XDISPLAY (display),
|
||||
device_xi2->device_id,
|
||||
xwindow,
|
||||
time_,
|
||||
xcursor,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
owner_events,
|
||||
&mask);
|
||||
status = XIGrabDevice (GDK_DISPLAY_XDISPLAY (display),
|
||||
device_xi2->device_id,
|
||||
xwindow,
|
||||
time_,
|
||||
xcursor,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
owner_events,
|
||||
&mask);
|
||||
|
||||
g_free (mask.mask);
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static const char notify_modes[][19] = {
|
||||
"NotifyNormal",
|
||||
"NotifyGrab",
|
||||
@@ -57,7 +56,6 @@ static const char notify_details[][23] = {
|
||||
"NotifyPointerRoot",
|
||||
"NotifyDetailNone"
|
||||
};
|
||||
#endif
|
||||
|
||||
#define HAS_FOCUS(toplevel) \
|
||||
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
|
||||
@@ -226,7 +224,6 @@ translate_valuator_class (GdkDisplay *display,
|
||||
}
|
||||
|
||||
_gdk_device_add_axis (device, use, min, max, resolution);
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, INPUT))
|
||||
{
|
||||
const char *label;
|
||||
@@ -238,7 +235,6 @@ translate_valuator_class (GdkDisplay *display,
|
||||
|
||||
gdk_debug_message ("\n\taxis: %s %s", label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -521,7 +517,6 @@ create_device (GdkX11DeviceManagerXI2 *device_manager,
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, INPUT))
|
||||
{
|
||||
const char *type_names[] = { "logical", "physical", "floating" };
|
||||
@@ -533,7 +528,6 @@ create_device (GdkX11DeviceManagerXI2 *device_manager,
|
||||
dev->use == XIMasterPointer,
|
||||
num_touches);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dev->use != XIMasterKeyboard &&
|
||||
dev->use != XIMasterPointer)
|
||||
@@ -1919,7 +1913,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
GdkTouchpadGesturePhase phase;
|
||||
double x, y;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *event_name = "";
|
||||
switch (xev->evtype)
|
||||
{
|
||||
@@ -1935,7 +1928,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
GDK_DEBUG (EVENTS, "pinch gesture %s:\twindow %ld\n\tfinger_count: %u%s",
|
||||
event_name,
|
||||
@@ -1979,7 +1971,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
GdkTouchpadGesturePhase phase;
|
||||
double x, y;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *event_name = "";
|
||||
switch (xev->evtype)
|
||||
{
|
||||
@@ -1995,7 +1986,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
GDK_DEBUG (EVENTS, "swipe gesture %s:\twindow %ld\n\tfinger_count: %u%s",
|
||||
event_name,
|
||||
|
||||
@@ -745,7 +745,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
break;
|
||||
|
||||
case VisibilityNotify:
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, EVENTS))
|
||||
switch (xevent->xvisibility.state)
|
||||
{
|
||||
@@ -764,7 +763,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
/* not handled */
|
||||
break;
|
||||
|
||||
@@ -1229,13 +1227,11 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
timings->refresh_interval = refresh_interval;
|
||||
|
||||
timings->complete = TRUE;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, FRAMES))
|
||||
_gdk_frame_clock_debug_print_timings (clock, timings);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1658,20 +1658,16 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
case SelectionRequest:
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.selection != xselection)
|
||||
return FALSE;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
|
||||
if (xevent->xselectionrequest.property == None)
|
||||
property = target;
|
||||
else
|
||||
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.requestor == None)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user