Compare commits
8 Commits
4.13.5
...
dmabug-tex
Author | SHA1 | Date | |
---|---|---|---|
|
b27592c6d1 | ||
|
c362840b3f | ||
|
ea98ea1217 | ||
|
e6b11c8668 | ||
|
2a3fdf78d7 | ||
|
a8a0292f20 | ||
|
e83dcc4cab | ||
|
4957bed573 |
@@ -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:v49"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v48"
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
@@ -66,8 +66,7 @@ style-check-diff:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gl.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles2.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
|
||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||
paths:
|
||||
@@ -104,9 +103,8 @@ fedora-x86_64:
|
||||
${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- .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
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
|
||||
release-build:
|
||||
extends: .build-fedora-default
|
||||
@@ -131,9 +129,7 @@ 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 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
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
|
||||
fedora-clang:
|
||||
extends: .build-fedora-default
|
||||
@@ -427,12 +423,11 @@ asan-build:
|
||||
-Df16c=disabled
|
||||
_build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland gtk
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
|
||||
|
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
FROM fedora:39
|
||||
FROM fedora:38
|
||||
|
||||
RUN dnf -y install \
|
||||
adwaita-icon-theme \
|
||||
|
@@ -324,7 +324,7 @@ for line in args.infile:
|
||||
units.append(unit)
|
||||
|
||||
report = {}
|
||||
report['date'] = datetime.datetime.now(datetime.UTC)
|
||||
report['date'] = datetime.datetime.utcnow()
|
||||
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.now(datetime.UTC).isoformat(timespec='minutes'))
|
||||
testsuites.set('timestamp', datetime.datetime.utcnow().isoformat(timespec='minutes'))
|
||||
|
||||
suites = {}
|
||||
for line in args.infile:
|
||||
|
@@ -1,29 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set +x
|
||||
set +e
|
||||
|
||||
srcdir=$( pwd )
|
||||
builddir=$1
|
||||
setup=$2
|
||||
suite=$3
|
||||
backend=$2
|
||||
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 "${setup}" in
|
||||
x11*)
|
||||
case "${backend}" in
|
||||
x11)
|
||||
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
||||
meson test -C ${builddir} \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${setup} \
|
||||
--suite=${suite//,/ --suite=} \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=${setup}_failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=headless \
|
||||
--no-suite=gsk-compare-broadway
|
||||
@@ -44,19 +42,19 @@ case "${setup}" in
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${setup} \
|
||||
--suite=${suite//,/ --suite=} \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--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 &
|
||||
@@ -67,10 +65,9 @@ case "${setup}" in
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${setup} \
|
||||
--suite=${suite//,/ --suite=} \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=${setup}_failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=headless \
|
||||
--no-suite=gsk-compare-opengl
|
||||
@@ -79,7 +76,7 @@ case "${setup}" in
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Failed to add ${setup} to .gitlab-ci/run-tests.sh"
|
||||
echo "Failed to add ${backend} to .gitlab-ci/run-tests.sh"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
@@ -89,17 +86,17 @@ cd ${builddir}
|
||||
|
||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${setup}" \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--output="report-${setup}.xml" \
|
||||
"meson-logs/testlog-${setup}.json"
|
||||
--output="report-${backend}.xml" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
|
||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${setup}" \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--reftest-output-dir="testsuite/reftests/output/${setup}" \
|
||||
--output="report-${setup}.html" \
|
||||
"meson-logs/testlog-${setup}.json"
|
||||
--reftest-output-dir="testsuite/reftests/output/${backend}" \
|
||||
--output="report-${backend}.html" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
|
||||
exit $exit_code
|
||||
|
@@ -6,7 +6,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
|
||||
|
||||
:: FIXME: make warnings fatal
|
||||
pip3 install --upgrade --user meson~=0.64 || goto :error
|
||||
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled _build || goto :error
|
||||
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
|
||||
ninja -C _build || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
@@ -33,8 +33,7 @@ pacman --noconfirm -S --needed \
|
||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
||||
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
||||
mingw-w64-$MSYS2_ARCH-python-gobject \
|
||||
mingw-w64-$MSYS2_ARCH-shaderc \
|
||||
mingw-w64-$MSYS2_ARCH-vulkan
|
||||
mingw-w64-$MSYS2_ARCH-shaderc
|
||||
|
||||
mkdir -p _ccache
|
||||
export CCACHE_BASEDIR="$(pwd)"
|
||||
@@ -48,6 +47,7 @@ meson \
|
||||
-Dx11-backend=false \
|
||||
-Dwayland-backend=false \
|
||||
-Dwin32-backend=true \
|
||||
-Dvulkan=disabled \
|
||||
-Dintrospection=enabled \
|
||||
-Dgtk:werror=true \
|
||||
_build
|
||||
|
169
NEWS
169
NEWS
@@ -1,173 +1,6 @@
|
||||
Overview of Changes in 4.13.5, 07 01 2024
|
||||
Overview of Changes in 4.13.2, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
This release adds two new GSK renderers called vulkan and ngl,
|
||||
that are built from the same sources. The new renderers can
|
||||
handle many corner cases correctly that the current gl renderer
|
||||
does not handle, and they offer advantages such as antialiasing
|
||||
and supersampled gradients.
|
||||
|
||||
The new renderers are still considered experimental, and GTK
|
||||
will only use them if they are explicitly selected using the
|
||||
GSK_RENDERER environment variable.
|
||||
|
||||
As part of this work, the GSK include files have been rearranged.
|
||||
It is no longer necessary to include renderer-specific headers for
|
||||
ngl and vulkan (and doing so will trigger deprecation warnings),
|
||||
and their constructors are always available.
|
||||
|
||||
The previously available experimental GdkVulkanContext APIs and
|
||||
the old Vulkan renderer have been removed.
|
||||
|
||||
Vulkan is now enabled by default, and Linux distributions should
|
||||
build GTK with Vulkan support. This requires the glslc shader
|
||||
compiler as a new dependency.
|
||||
|
||||
Vulkan is now also used for dmabuf support.
|
||||
|
||||
* GtkDropdown:
|
||||
- Fix display of initial selection
|
||||
|
||||
* GtkShortcutsWindow:
|
||||
- Make the window adapt to smaller screen widths
|
||||
|
||||
* GtkTextView:
|
||||
- Fix a possible NULL dereference in history
|
||||
|
||||
* GDK:
|
||||
- Make the png loader safer against overflows
|
||||
|
||||
* GL:
|
||||
- Fix some errors in handling of texture formats and mipmaps
|
||||
|
||||
|
||||
Overview of Changes in 4.13.4, 30-12-2023
|
||||
=========================================
|
||||
|
||||
* GtkFileDialog:
|
||||
- Return an error if no file is selected
|
||||
|
||||
* GtkFileLauncher:
|
||||
- Add a writable property
|
||||
|
||||
* GtkFileChooserNative:
|
||||
- Make closing portal file dialogs work
|
||||
|
||||
* GtkEmojiChooser:
|
||||
- Update Emoji data to CLDR v43
|
||||
|
||||
* GtkStringList:
|
||||
- Add item-type and n-itmes properties
|
||||
|
||||
* Input:
|
||||
- Respect GTK grabs on DND events
|
||||
- Fix crossing event generation for enter/leave
|
||||
|
||||
* Wayland:
|
||||
- Avoid recreating wl_buffers needlessly
|
||||
- Be more careful when loading cursors
|
||||
|
||||
* Dmabuf:
|
||||
- Add support for all Dmabuf formats
|
||||
- Tweak the offload code a bit, allow offloading translucent
|
||||
textures, as long as they are raised. Decline to offload
|
||||
with fractional scales.
|
||||
|
||||
* Accessibility:
|
||||
- Add a few more accessible roles
|
||||
|
||||
* GL:
|
||||
- Use GLES by default
|
||||
- Tweak GDK_DEBUG values. The new values are
|
||||
gl-disable-gl, gl-disable-gles and gl-prefer-gl.
|
||||
The gl-legacy and nograbs values have been dropped.
|
||||
|
||||
* Css:
|
||||
- Reduce memory consumption during theme loading
|
||||
- Fix opacity handling
|
||||
|
||||
* Theme:
|
||||
- Refresh some of the included symbolic icons
|
||||
|
||||
* MacOs:
|
||||
- Silence secure-restore message
|
||||
|
||||
* Build:
|
||||
- Require Vulkan 1.3
|
||||
|
||||
* Translation updates:
|
||||
Chinese (China)
|
||||
Czech
|
||||
Hebrew
|
||||
Icelandic
|
||||
Polish
|
||||
Russian
|
||||
|
||||
|
||||
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
|
||||
=========================================
|
||||
|
||||
* GtkPrintdialog:
|
||||
- New async-style api to replace GtkPrintOperation
|
||||
|
||||
* GtkEmojiChooser:
|
||||
- Add more languages: Bengali, Hindi, Japanese, Finnish,
|
||||
Thai and Norwegian bokmål
|
||||
|
||||
* Accessibility:
|
||||
- Fix some utf8 handling issues
|
||||
|
||||
* GDK:
|
||||
- Add support for dmabuf textures, with GdkDmabufTextureBuilder
|
||||
- Add a few more supported memory formats for textures
|
||||
|
||||
* GSK:
|
||||
- Add a fast-path for masking color
|
||||
- Add support for importing dmabuf textures
|
||||
- Handle GLES better by using some extensions
|
||||
|
||||
* Translation updates:
|
||||
Catalan
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.13.1, 28-09-2023
|
||||
=========================================
|
||||
|
||||
|
@@ -1,41 +0,0 @@
|
||||
#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\"",
|
||||
dialog = gtk_alert_dialog_new ("You activated action: \"%s\n",
|
||||
g_action_get_name (G_ACTION (action)));
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
|
@@ -18,7 +18,8 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __BLUR_OVERLAY_H__
|
||||
#define __BLUR_OVERLAY_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -59,3 +60,5 @@ void blur_overlay_set_child (BlurOverlay *overlay,
|
||||
GtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __BLUR_OVERLAY_H__ */
|
||||
|
@@ -75,9 +75,7 @@ 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')
|
||||
|
@@ -18,7 +18,8 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __DEMO_TAGGED_ENTRY_H__
|
||||
#define __DEMO_TAGGED_ENTRY_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -56,3 +57,5 @@ void demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *
|
||||
gboolean has_close_button);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __DEMO_TAGGED_ENTRY_H__ */
|
||||
|
@@ -15,7 +15,8 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __GTK_FONT_PLANE_H__
|
||||
#define __GTK_FONT_PLANE_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -59,3 +60,5 @@ GtkWidget * gtk_font_plane_new (GtkAdjustment *width_adj,
|
||||
GtkAdjustment *weight_adj);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FONT_PLANE_H__ */
|
||||
|
@@ -17,7 +17,8 @@
|
||||
* Authors: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __GSK_SHADER_PAINTABLE_H__
|
||||
#define __GSK_SHADER_PAINTABLE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gsk/gsk.h>
|
||||
@@ -41,3 +42,5 @@ void gsk_shader_paintable_update_time (GskShaderPaintable *self
|
||||
int time_idx,
|
||||
gint64 frame_time);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_SHADER_PAINTABLE_H__ */
|
||||
|
@@ -15,7 +15,8 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __GTK_FISHBOWL_H__
|
||||
#define __GTK_FISHBOWL_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -64,3 +65,5 @@ void gtk_fishbowl_set_creation_func (GtkFishbowl *fishbowl,
|
||||
GtkFishCreationFunc creation_func);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FISHBOWL_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __GTK_GEARS_H__
|
||||
#define __GTK_GEARS_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -43,3 +44,5 @@ void gtk_gears_set_fps_label (GtkGears *gears,
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_GEARS_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __GTK_SHADER_BIN_H__
|
||||
#define __GTK_SHADER_BIN_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -18,3 +19,5 @@ void gtk_shader_bin_set_child (GtkShaderBin *self,
|
||||
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHADER_BIN_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __GTK_SHADER_STACK_H__
|
||||
#define __GTK_SHADER_STACK_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -18,3 +19,5 @@ void gtk_shader_stack_set_active (GtkShaderStack *self,
|
||||
int index);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHADER_STACK_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __GTK_SHADERTOY_H__
|
||||
#define __GTK_SHADERTOY_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -29,3 +30,5 @@ void gtk_shadertoy_set_image_shader (GtkShadertoy *shadertoy,
|
||||
const char *shader);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHADERTOY_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef LANGUAGE_NAMES_H
|
||||
#define LANGUAGE_NAMES_H
|
||||
|
||||
#include <pango/pango.h>
|
||||
|
||||
@@ -8,3 +9,5 @@ const char * get_language_name (PangoLanguage *language);
|
||||
const char * get_language_name_for_tag (guint32 tag);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __PAINTABLE_H__
|
||||
#define __PAINTABLE_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -12,3 +13,5 @@ void gtk_nuclear_snapshot (GtkSnapshot *snapshot,
|
||||
GdkPaintable * gtk_nuclear_icon_new (double rotation);
|
||||
GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background);
|
||||
GtkMediaStream *gtk_nuclear_media_stream_new (void);
|
||||
|
||||
#endif /* __PAINTABLE_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __PUZZLE_PIECE_H__
|
||||
#define __PUZZLE_PIECE_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -18,3 +19,5 @@ GdkPaintable * gtk_puzzle_piece_new (GdkPaintable *puzzle,
|
||||
GdkPaintable * gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self);
|
||||
guint gtk_puzzle_piece_get_x (GtkPuzzlePiece *self);
|
||||
guint gtk_puzzle_piece_get_y (GtkPuzzlePiece *self);
|
||||
|
||||
#endif /* __PUZZLE_PIECE_H__ */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SCRIPT_NAMES_H
|
||||
#define SCRIPT_NAMES_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -8,3 +9,5 @@ const char * get_script_name (GUnicodeScript script);
|
||||
const char * get_script_name_for_tag (guint32 tag);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@@ -139,7 +139,6 @@ 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 ();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __ICON_BROWSER_APP_H
|
||||
#define __ICON_BROWSER_APP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -13,3 +14,6 @@ typedef struct _IconBrowserAppClass IconBrowserAppClass;
|
||||
|
||||
GType icon_browser_app_get_type (void);
|
||||
IconBrowserApp *icon_browser_app_new (void);
|
||||
|
||||
|
||||
#endif /* __ICON_BROWSER_APP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __ICON_BROWSER_WIN_H
|
||||
#define __ICON_BROWSER_WIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "iconbrowserapp.h"
|
||||
@@ -14,3 +15,6 @@ typedef struct _IconBrowserWindowClass IconBrowserWindowClass;
|
||||
|
||||
GType icon_browser_window_get_type (void);
|
||||
IconBrowserWindow *icon_browser_window_new (IconBrowserApp *app);
|
||||
|
||||
|
||||
#endif /* __ICON_BROWSER_WIN_H */
|
||||
|
@@ -17,7 +17,8 @@
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __GTK_RENDERER_PAINTABLE_H__
|
||||
#define __GTK_RENDERER_PAINTABLE_H__
|
||||
|
||||
#include <gsk/gsk.h>
|
||||
|
||||
@@ -38,3 +39,5 @@ void gtk_renderer_paintable_set_paintable (GtkRendererPaintable
|
||||
GdkPaintable * gtk_renderer_paintable_get_paintable (GtkRendererPaintable *self) G_GNUC_PURE;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDERER_PAINTABLE_H__ */
|
||||
|
@@ -17,7 +17,8 @@
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __NODE_EDITOR_APPLICATION_H__
|
||||
#define __NODE_EDITOR_APPLICATION_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -32,3 +33,6 @@ typedef struct _NodeEditorApplicationClass NodeEditorApplicationClass;
|
||||
|
||||
GType node_editor_application_get_type (void);
|
||||
NodeEditorApplication *node_editor_application_new (void);
|
||||
|
||||
|
||||
#endif /* __NODE_EDITOR_APPLICATION_H__ */
|
||||
|
@@ -24,9 +24,13 @@
|
||||
#include "gtkrendererpaintableprivate.h"
|
||||
|
||||
#include "gsk/gskrendernodeparserprivate.h"
|
||||
#include "gsk/gl/gskglrenderer.h"
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include "gsk/broadway/gskbroadwayrenderer.h"
|
||||
#endif
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
#include "gsk/vulkan/gskvulkanrenderer.h"
|
||||
#endif
|
||||
|
||||
#include <cairo.h>
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
@@ -790,7 +794,7 @@ create_cairo_texture (NodeEditorWindow *self)
|
||||
return NULL;
|
||||
|
||||
renderer = gsk_cairo_renderer_new ();
|
||||
gsk_renderer_realize_for_display (renderer, gtk_widget_get_display (GTK_WIDGET (self)), NULL);
|
||||
gsk_renderer_realize (renderer, NULL, NULL);
|
||||
|
||||
texture = gsk_renderer_render_texture (renderer, node, NULL);
|
||||
gsk_render_node_unref (node);
|
||||
@@ -862,11 +866,11 @@ export_image_response_cb (GObject *source,
|
||||
GskRenderer *renderer;
|
||||
|
||||
renderer = gsk_gl_renderer_new ();
|
||||
if (!gsk_renderer_realize_for_display (renderer, gdk_display_get_default (), NULL))
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_object_unref (renderer);
|
||||
renderer = gsk_cairo_renderer_new ();
|
||||
if (!gsk_renderer_realize_for_display (renderer, gdk_display_get_default (), NULL))
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -1117,11 +1121,8 @@ node_editor_window_add_renderer (NodeEditorWindow *self,
|
||||
const char *description)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (self));
|
||||
|
||||
if (!gsk_renderer_realize_for_display (renderer, display, NULL))
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (self));
|
||||
g_assert (surface != NULL);
|
||||
@@ -1156,9 +1157,6 @@ node_editor_window_realize (GtkWidget *widget)
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_gl_renderer_new (),
|
||||
"OpenGL");
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_ngl_renderer_new (),
|
||||
"NGL");
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_vulkan_renderer_new (),
|
||||
|
@@ -17,7 +17,8 @@
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __NODE_EDITOR_WINDOW_H__
|
||||
#define __NODE_EDITOR_WINDOW_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -37,3 +38,5 @@ NodeEditorWindow * node_editor_window_new (NodeEditorApplication
|
||||
|
||||
gboolean node_editor_window_load (NodeEditorWindow *self,
|
||||
GFile *file);
|
||||
|
||||
#endif /* __NODE_EDITOR_WINDOW_H__ */
|
||||
|
BIN
demos/widget-factory/icons/16x16/actions/insert-image.png
Normal file
BIN
demos/widget-factory/icons/16x16/actions/insert-image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 533 B |
Binary file not shown.
After Width: | Height: | Size: 127 B |
@@ -0,0 +1 @@
|
||||
<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>
|
After Width: | Height: | Size: 654 B |
@@ -25,12 +25,14 @@
|
||||
<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>
|
||||
@@ -86,6 +88,7 @@
|
||||
<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,8 +685,6 @@ 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,4 +1,6 @@
|
||||
----
|
||||
Title: Cairo interaction
|
||||
----
|
||||
|
||||
## Functions to support using cairo
|
||||
|
||||
|
@@ -107,5 +107,4 @@ 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"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Title: Keyboard Codes, Groups, And Modifiers
|
||||
Title: Key Values
|
||||
|
||||
## 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
|
||||
[`func@Gdk.keyval_name`]. The reverse function, converting a string to a key
|
||||
value, is provided by [`func@Gdk.keyval_from_name`].
|
||||
gdk_keyval_name(). The reverse function, converting a string to a key value,
|
||||
is provided by gdk_keyval_from_name().
|
||||
|
||||
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`].
|
||||
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().
|
||||
|
||||
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`].
|
||||
When it makes sense, key values can be converted to and from
|
||||
Unicode characters with gdk_keyval_to_unicode() and 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,8 +91,9 @@ 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
|
||||
@@ -101,11 +102,12 @@ 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,5 +62,4 @@ 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,6 +1,8 @@
|
||||
Title: Building GTK
|
||||
Title: Compiling the GTK Libraries
|
||||
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,6 +1,8 @@
|
||||
Title: Coordinate systems in GTK
|
||||
Title: Coordinate systems
|
||||
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_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -183,7 +183,7 @@ activate (GtkApplication *app,
|
||||
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -331,7 +331,8 @@ activate (GtkApplication *app,
|
||||
*/
|
||||
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
@@ -553,7 +554,7 @@ activate (GtkApplication *app,
|
||||
|
||||
g_signal_connect (press, "pressed", G_CALLBACK (pressed), drawing_area);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -630,7 +631,7 @@ activate (GtkApplication *app,
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
/* We do not need the builder any more */
|
||||
g_object_unref (builder);
|
||||
|
@@ -35,11 +35,6 @@ 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,5 +245,4 @@ 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,6 +1,8 @@
|
||||
Title: Initializing GTK
|
||||
----
|
||||
Title: Initialization
|
||||
----
|
||||
|
||||
## 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
|
||||
@@ -47,7 +49,7 @@ main (int argc, char **argv)
|
||||
// ...
|
||||
|
||||
// Show the application window
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
|
||||
// Enter the main event loop, and wait for user interaction
|
||||
while (!done)
|
||||
@@ -64,5 +66,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,6 +2,5 @@ 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://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).
|
||||
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).
|
||||
|
@@ -31,11 +31,10 @@ 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.
|
||||
|
@@ -170,47 +170,41 @@ This variable can be set to a list of debug options, which cause GDK to
|
||||
print out different types of debugging information. Some of these options
|
||||
are only available when GTK has been configured with `-Ddebug=true`.
|
||||
|
||||
`misc`
|
||||
: Miscellaneous information
|
||||
|
||||
`events`
|
||||
: Information about events
|
||||
|
||||
`dnd`
|
||||
: Information about drag-and-drop
|
||||
|
||||
`input`
|
||||
: Information about input (mostly Windows)
|
||||
`cursor`
|
||||
: Information about cursor objects (only win32)
|
||||
|
||||
`eventloop`
|
||||
: Information about event loop operation (mostly macOS)
|
||||
|
||||
`misc`
|
||||
: Miscellaneous information
|
||||
|
||||
`frames`
|
||||
: Information about the frame clock
|
||||
|
||||
`settings`
|
||||
: Information about xsettings
|
||||
|
||||
`opengl`
|
||||
: Information about OpenGL
|
||||
|
||||
`vulkan`
|
||||
: Information about Vulkan
|
||||
|
||||
`selection`
|
||||
: Information about selections
|
||||
|
||||
`clipboard`
|
||||
: Information about clipboards
|
||||
|
||||
`dmabuf`
|
||||
: Information about dmabuf handling (Linux-only)
|
||||
`dnd`
|
||||
: Information about drag-and-drop
|
||||
|
||||
`offload`
|
||||
: Information about subsurfaces and graphics offload (Wayland-only)
|
||||
`opengl`
|
||||
: Information about OpenGL
|
||||
|
||||
`vulkan`
|
||||
: Information about Vulkan
|
||||
|
||||
A number of options affect behavior instead of logging:
|
||||
|
||||
`nograbs`
|
||||
: Turn off all pointer and keyboard grabs
|
||||
|
||||
`portals`
|
||||
: Force the use of [portals](https://docs.flatpak.org/en/latest/portals.html)
|
||||
|
||||
@@ -223,17 +217,11 @@ A number of options affect behavior instead of logging:
|
||||
`gl-fractional`
|
||||
: Enable fractional scaling for OpenGL. This is experimental
|
||||
|
||||
`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-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-gles`
|
||||
: Use a GLES OpenGL context
|
||||
|
||||
`gl-egl`
|
||||
: Use an EGL context on X11 or Windows
|
||||
@@ -256,12 +244,6 @@ A number of options affect behavior instead of logging:
|
||||
`high-depth`
|
||||
: Use high bit depth rendering if possible
|
||||
|
||||
`no-vsync`
|
||||
: Repaint instantly (uses 100% CPU with animations)
|
||||
|
||||
`dmabuf-disable`
|
||||
: Disable dmabuf support
|
||||
|
||||
The special value `all` can be used to turn on all debug options. The special
|
||||
value `help` can be used to obtain a list of all supported debug options.
|
||||
|
||||
@@ -274,46 +256,46 @@ are only available when GTK has been configured with `-Ddebug=true`.
|
||||
`renderer`
|
||||
: General renderer information
|
||||
|
||||
`cairo`
|
||||
: cairo renderer information
|
||||
|
||||
`opengl`
|
||||
: OpenGL renderer information
|
||||
|
||||
`shaders`
|
||||
: Shaders
|
||||
|
||||
`surface`
|
||||
: Surfaces
|
||||
|
||||
`vulkan`
|
||||
: Vulkan renderer information
|
||||
|
||||
`shaders`
|
||||
: Information about shaders
|
||||
|
||||
`surface`
|
||||
: Information about surfaces
|
||||
|
||||
`fallback`
|
||||
: Information about fallback usage in renderers
|
||||
: Information about fallbacks
|
||||
|
||||
`glyphcache`
|
||||
: Information about glyph caching
|
||||
|
||||
`verbose`
|
||||
: Print verbose output while rendering
|
||||
|
||||
A number of options affect behavior instead of logging:
|
||||
|
||||
`diff`
|
||||
: Show differences
|
||||
|
||||
`geometry`
|
||||
: Show borders (when using cairo)
|
||||
: Show borders
|
||||
|
||||
`full-redraw`
|
||||
: Force full redraws
|
||||
: Force full redraws for every frame
|
||||
|
||||
`sync`
|
||||
: Sync after each frame
|
||||
|
||||
`staging`
|
||||
: Use a staging image for texture upload (Vulkan only)
|
||||
`vulkan-staging-image`
|
||||
: Use a staging image for Vulkan texture upload
|
||||
|
||||
`offload-disable`
|
||||
: Disable graphics offload to subsurfaces
|
||||
|
||||
`cairo`
|
||||
: Overlay error pattern over cairo drawing (finds fallbacks)
|
||||
`vulkan-staging-buffer`
|
||||
: Use a staging buffer for Vulkan texture upload
|
||||
|
||||
The special value `all` can be used to turn on all debug options. The special
|
||||
value `help` can be used to obtain a list of all supported debug options.
|
||||
@@ -354,40 +336,6 @@ the default selection of the device that is used for Vulkan rendering.
|
||||
The special value `list` can be used to obtain a list of all Vulkan
|
||||
devices.
|
||||
|
||||
### `GDK_VULKAN_SKIP`
|
||||
|
||||
This variable can be set to a list of values, which cause GDK to
|
||||
disable features of the Vulkan support.
|
||||
Note that these features may already be disabled if the Vulkan driver
|
||||
does not support them.
|
||||
|
||||
`dmabuf`
|
||||
: Never import Dmabufs
|
||||
|
||||
`ycbr`
|
||||
: Do not support Ycbcr textures
|
||||
|
||||
`descriptor-indexing`
|
||||
: Force slow descriptor set layout codepath
|
||||
|
||||
`dynamic-indexing`
|
||||
: Hardcode small number of buffer and texure arrays
|
||||
|
||||
`nonuniform-indexing`
|
||||
: Split draw calls to ensure uniform texture accesses
|
||||
|
||||
`semaphore-export`
|
||||
: Disable sync of exported dmabufs
|
||||
|
||||
`semaphore-import`
|
||||
: Disable sync of imported dmabufs
|
||||
|
||||
`incremental-present`
|
||||
: Do not send damage regions
|
||||
|
||||
The special value `all` can be used to turn on all values. The special
|
||||
value `help` can be used to obtain a list of all supported values.
|
||||
|
||||
### `GSK_RENDERER`
|
||||
|
||||
If set, selects the GSK renderer to use. The following renderers can
|
||||
@@ -409,9 +357,6 @@ using and the GDK backend supports them:
|
||||
`gl`
|
||||
: Selects the "gl" OpenGL renderer
|
||||
|
||||
`ngl`
|
||||
: Selects the "ngl" OpenGL renderer
|
||||
|
||||
`vulkan`
|
||||
: Selects the Vulkan renderer
|
||||
|
||||
@@ -429,32 +374,6 @@ to rememdy this on the GTK side; the best bet before trying the above
|
||||
workarounds is to try to update your graphics drivers and Nahimic
|
||||
installation.
|
||||
|
||||
### `GSK_GPU_SKIP`
|
||||
|
||||
This variable can be set to a list of values, which cause GSK to
|
||||
disable certain optimizations of the "ngl" and "vulkan" renderer.
|
||||
|
||||
`uber`
|
||||
: Don't use the uber shader
|
||||
|
||||
`clear`
|
||||
: Use shaders instead of vkCmdClearAttachment()/glClear()
|
||||
|
||||
`blit`
|
||||
: Use shaders instead of vkCmdBlit()/glBlitFramebuffer()
|
||||
|
||||
`gradients`
|
||||
: Don't supersample gradients
|
||||
|
||||
`mipmap`
|
||||
: Avoid creating mipmaps
|
||||
|
||||
`gl-baseinstance`
|
||||
: Assume no ARB/EXT_base_instance support
|
||||
|
||||
The special value `all` can be used to turn on all values. The special
|
||||
value `help` can be used to obtain a list of all supported values.
|
||||
|
||||
### `GSK_MAX_TEXTURE_SIZE`
|
||||
|
||||
Limit texture size to the minimum of this value and the OpenGL limit
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -7,3 +8,6 @@
|
||||
G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPPREFS_H
|
||||
#define __EXAMPLEAPPPREFS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleappwin.h"
|
||||
@@ -9,3 +10,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
|
||||
|
||||
|
||||
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPPREFS_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPPREFS_H
|
||||
#define __EXAMPLEAPPPREFS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleappwin.h"
|
||||
@@ -9,3 +10,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
|
||||
|
||||
|
||||
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPPREFS_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPPREFS_H
|
||||
#define __EXAMPLEAPPPREFS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleappwin.h"
|
||||
@@ -9,3 +10,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
|
||||
|
||||
|
||||
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPPREFS_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPP_H
|
||||
#define __EXAMPLEAPP_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -8,3 +9,6 @@ G_DECLARE_FINAL_TYPE (ExampleApp, example_app, EXAMPLE, APP, GtkApplication)
|
||||
|
||||
|
||||
ExampleApp *example_app_new (void);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPP_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPPREFS_H
|
||||
#define __EXAMPLEAPPPREFS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleappwin.h"
|
||||
@@ -9,3 +10,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppPrefs, example_app_prefs, EXAMPLE, APP_PREFS, Gt
|
||||
|
||||
|
||||
ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPPREFS_H */
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef __EXAMPLEAPPWIN_H
|
||||
#define __EXAMPLEAPPWIN_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "exampleapp.h"
|
||||
@@ -11,3 +12,6 @@ G_DECLARE_FINAL_TYPE (ExampleAppWindow, example_app_window, EXAMPLE, APP_WINDOW,
|
||||
ExampleAppWindow *example_app_window_new (ExampleApp *app);
|
||||
void example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file);
|
||||
|
||||
|
||||
#endif /* __EXAMPLEAPPWIN_H */
|
||||
|
@@ -209,11 +209,13 @@ _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,12 +369,14 @@ 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);
|
||||
}
|
||||
@@ -424,12 +426,14 @@ 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))
|
||||
|
55
gdk/gdk.c
55
gdk/gdk.c
@@ -117,26 +117,22 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "vulkan", GDK_DEBUG_VULKAN, "Information about Vulkan" },
|
||||
{ "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" },
|
||||
|
||||
{ "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" },
|
||||
{ "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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -197,6 +193,13 @@ 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)
|
||||
@@ -228,6 +231,12 @@ 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;
|
||||
}
|
||||
@@ -251,7 +260,8 @@ gdk_parse_debug_var (const char *variable,
|
||||
|
||||
fprintf (stderr, "Supported %s values:\n", variable);
|
||||
for (i = 0; i < nkeys; i++) {
|
||||
fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
|
||||
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", "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");
|
||||
@@ -264,7 +274,8 @@ gdk_parse_debug_var (const char *variable,
|
||||
|
||||
for (i = 0; i < nkeys; i++)
|
||||
{
|
||||
all_flags |= keys[i].value;
|
||||
if (debug_enabled || keys[i].always_enabled)
|
||||
all_flags |= keys[i].value;
|
||||
}
|
||||
|
||||
result = all_flags & (~result);
|
||||
|
@@ -215,11 +215,7 @@ gdk_array(splice) (GdkArray *self,
|
||||
gsize pos,
|
||||
gsize removed,
|
||||
gboolean stolen,
|
||||
#ifdef GDK_ARRAY_BY_VALUE
|
||||
const _T_ *additions,
|
||||
#else
|
||||
_T_ *additions,
|
||||
#endif
|
||||
gsize added)
|
||||
{
|
||||
gsize size;
|
||||
|
@@ -529,9 +529,8 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
|
||||
* exit. Depending on the platform, the functionality may not be available
|
||||
* unless a "clipboard manager" is running.
|
||||
*
|
||||
* This function is called automatically when a
|
||||
* [GtkApplication](../gtk4/class.Application.html)
|
||||
* is shut down, so you likely don't need to call it.
|
||||
* This function is called automatically when a [class@Gtk.Application] is
|
||||
* shut down, so you likely don't need to call it.
|
||||
*/
|
||||
void
|
||||
gdk_clipboard_store_async (GdkClipboard *clipboard,
|
||||
|
@@ -47,8 +47,7 @@
|
||||
* Cursors by themselves are not very interesting: they must be bound to a
|
||||
* window for users to see them. This is done with [method@Gdk.Surface.set_cursor]
|
||||
* or [method@Gdk.Surface.set_device_cursor]. Applications will typically
|
||||
* use higher-level GTK functions such as [gtk_widget_set_cursor()](../gtk4/method.Widget.set_cursor.html)
|
||||
* instead.
|
||||
* use higher-level GTK functions such as [method@Gtk.Widget.set_cursor] instead.
|
||||
*
|
||||
* Cursors are not bound to a given [class@Gdk.Display], so they can be shared.
|
||||
* However, the appearance of cursors may vary when used on different
|
||||
|
@@ -36,28 +36,23 @@ typedef enum {
|
||||
GDK_DEBUG_VULKAN = 1 << 8,
|
||||
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_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,
|
||||
GDK_DEBUG_NOGRABS = 1 << 11,
|
||||
GDK_DEBUG_PORTALS = 1 << 12,
|
||||
GDK_DEBUG_NO_PORTALS = 1 << 13,
|
||||
GDK_DEBUG_GL_DISABLE = 1 << 14,
|
||||
GDK_DEBUG_GL_FRACTIONAL = 1 << 15,
|
||||
GDK_DEBUG_GL_LEGACY = 1 << 16,
|
||||
GDK_DEBUG_GL_GLES = 1 << 17,
|
||||
GDK_DEBUG_GL_DEBUG = 1 << 18,
|
||||
GDK_DEBUG_GL_EGL = 1 << 19,
|
||||
GDK_DEBUG_GL_GLX = 1 << 20,
|
||||
GDK_DEBUG_GL_WGL = 1 << 21,
|
||||
GDK_DEBUG_VULKAN_DISABLE = 1 << 22,
|
||||
GDK_DEBUG_VULKAN_VALIDATE = 1 << 23,
|
||||
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 24,
|
||||
GDK_DEBUG_HIGH_DEPTH = 1 << 25,
|
||||
GDK_DEBUG_NO_VSYNC = 1 << 26,
|
||||
} GdkDebugFlags;
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
@@ -66,24 +61,13 @@ GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
|
||||
void gdk_display_set_debug_flags (GdkDisplay *display,
|
||||
GdkDebugFlags flags);
|
||||
|
||||
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;
|
||||
|
||||
va_start (args, format);
|
||||
s = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
#ifdef GLIB_USING_SYSTEM_PRINTF
|
||||
fprintf (stderr, "%s\n", s);
|
||||
#define gdk_debug_message(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
g_fprintf (stderr, "%s\n", s);
|
||||
#define gdk_debug_message(format, ...) g_fprintf (stderr, format "\n", ##__VA_ARGS__)
|
||||
#endif
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
#define GDK_DISPLAY_DEBUG_CHECK(display,type) \
|
||||
G_UNLIKELY (gdk_display_get_debug_flags (display) & GDK_DEBUG_##type)
|
||||
@@ -94,6 +78,13 @@ gdk_debug_message (const char *format, ...)
|
||||
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__)
|
||||
|
||||
@@ -102,6 +93,7 @@ typedef struct
|
||||
const char *key;
|
||||
guint value;
|
||||
const char *help;
|
||||
gboolean always_enabled;
|
||||
} GdkDebugKey;
|
||||
|
||||
guint gdk_parse_debug_var (const char *variable,
|
||||
|
245
gdk/gdkdisplay.c
245
gdk/gdkdisplay.c
@@ -31,23 +31,21 @@
|
||||
#include "gdkclipboardprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkdmabufeglprivate.h"
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkmonitorprivate.h"
|
||||
#include "gdkrectangle.h"
|
||||
#include "gdkvulkancontextprivate.h"
|
||||
#include "gdkvulkancontext.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SYSMACROS_H
|
||||
#include <sys/sysmacros.h>
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
#include <drm/drm_fourcc.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
@@ -253,13 +251,6 @@ gdk_display_class_init (GdkDisplayClass *class)
|
||||
TRUE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDisplay:dmabuf-formats:
|
||||
*
|
||||
* The dma-buf formats that are supported on this display
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
props[PROP_DMABUF_FORMATS] =
|
||||
g_param_spec_boxed ("dmabuf-formats", NULL, NULL,
|
||||
GDK_TYPE_DMABUF_FORMATS,
|
||||
@@ -399,31 +390,11 @@ gdk_display_dispose (GObject *object)
|
||||
{
|
||||
GdkDisplay *display = GDK_DISPLAY (object);
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (display);
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (display->dmabuf_downloaders); i++)
|
||||
{
|
||||
if (display->dmabuf_downloaders[i] == NULL)
|
||||
continue;
|
||||
|
||||
gdk_dmabuf_downloader_close (display->dmabuf_downloaders[i]);
|
||||
g_clear_object (&display->dmabuf_downloaders[i]);
|
||||
}
|
||||
|
||||
_gdk_display_manager_remove_display (gdk_display_manager_get (), display);
|
||||
|
||||
g_queue_clear (&display->queued_events);
|
||||
|
||||
g_clear_pointer (&display->egl_dmabuf_formats, gdk_dmabuf_formats_unref);
|
||||
g_clear_pointer (&display->egl_external_formats, gdk_dmabuf_formats_unref);
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
if (display->vk_dmabuf_formats)
|
||||
{
|
||||
gdk_display_unref_vulkan (display);
|
||||
g_assert (display->vk_dmabuf_formats == NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_clear_object (&priv->gl_context);
|
||||
#ifdef HAVE_EGL
|
||||
g_clear_pointer (&priv->egl_display, eglTerminate);
|
||||
@@ -1196,9 +1167,9 @@ _gdk_display_get_next_serial (GdkDisplay *display)
|
||||
* Indicates to the GUI environment that the application has
|
||||
* finished loading, using a given identifier.
|
||||
*
|
||||
* GTK will call this function automatically for [GtkWindow](../gtk4/class.Window.html)
|
||||
* GTK will call this function automatically for [class@Gtk.Window]
|
||||
* with custom startup-notification identifier unless
|
||||
* [gtk_window_set_auto_startup_notification()](../gtk4/method.Window.set_auto_startup_notification.html)
|
||||
* [method@Gtk.Window.set_auto_startup_notification]
|
||||
* is called to disable that feature.
|
||||
*
|
||||
* Deprecated: 4.10: Using [method@Gdk.Toplevel.set_startup_id] is sufficient
|
||||
@@ -1267,14 +1238,12 @@ gdk_display_get_keymap (GdkDisplay *display)
|
||||
/*<private>
|
||||
* gdk_display_create_vulkan_context:
|
||||
* @self: a `GdkDisplay`
|
||||
* @surface: (nullable): the `GdkSurface` to use or %NULL for a surfaceless
|
||||
* context
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Creates a new `GdkVulkanContext` for use with @display.
|
||||
*
|
||||
* If @surface is NULL, the context can not be used to draw to surfaces,
|
||||
* it can only be used for custom rendering or compute.
|
||||
* The context can not be used to draw to surfaces, it can only be
|
||||
* used for custom rendering or compute.
|
||||
*
|
||||
* If the creation of the `GdkVulkanContext` failed, @error will be set.
|
||||
*
|
||||
@@ -1283,11 +1252,9 @@ gdk_display_get_keymap (GdkDisplay *display)
|
||||
*/
|
||||
GdkVulkanContext *
|
||||
gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
GdkSurface *surface,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (gdk_display_get_debug_flags (self) & GDK_DEBUG_VULKAN_DISABLE)
|
||||
@@ -1304,33 +1271,11 @@ gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (surface)
|
||||
{
|
||||
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
|
||||
NULL,
|
||||
error,
|
||||
"surface", surface,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
|
||||
NULL,
|
||||
error,
|
||||
"display", self,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_display_has_vulkan_feature (GdkDisplay *self,
|
||||
GdkVulkanFeatures feature)
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
return !!(self->vulkan_features & feature);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
|
||||
NULL,
|
||||
error,
|
||||
"display", self,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1483,6 +1428,7 @@ gdk_display_get_gl_context (GdkDisplay *self)
|
||||
}
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
@@ -1539,6 +1485,7 @@ 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)
|
||||
@@ -1742,23 +1689,6 @@ 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,
|
||||
@@ -1846,8 +1776,6 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_pixel_format_float");
|
||||
self->have_egl_dma_buf_import =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
|
||||
self->have_egl_dma_buf_export =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
|
||||
|
||||
if (self->have_egl_no_config_context)
|
||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||
@@ -1856,22 +1784,15 @@ 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"
|
||||
@@ -1880,12 +1801,6 @@ 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);
|
||||
@@ -1893,6 +1808,7 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
g_free (std_cfg);
|
||||
g_free (ext);
|
||||
}
|
||||
#endif
|
||||
|
||||
gdk_profiler_end_mark (start_time, "init EGL", NULL);
|
||||
|
||||
@@ -1929,67 +1845,95 @@ gdk_display_get_egl_display (GdkDisplay *self)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
static void
|
||||
gdk_display_add_dmabuf_downloader (GdkDisplay *display,
|
||||
GdkDmabufDownloader *downloader)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
if (downloader == NULL)
|
||||
return;
|
||||
|
||||
/* dmabuf_downloaders is NULL-terminated */
|
||||
for (i = 0; i < G_N_ELEMENTS (display->dmabuf_downloaders) - 1; i++)
|
||||
{
|
||||
if (display->dmabuf_downloaders[i] == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (i < G_N_ELEMENTS (display->dmabuf_downloaders) - 1);
|
||||
|
||||
display->dmabuf_downloaders[i] = downloader;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* GdkDmabufFormat:
|
||||
* @fourcc: the format code
|
||||
* @modifiers: the format modifier
|
||||
*
|
||||
* The `GdkDmabufFormat` struct represents a dma-buf format
|
||||
* as defined in the `drm_fourcc.h` header.
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
|
||||
/* To support a drm format, we must be able to import it into GL
|
||||
* using the relevant EGL extensions, and download it into a memory
|
||||
* texture, possibly doing format conversion with shaders (in GSK).
|
||||
*/
|
||||
void
|
||||
gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
static void
|
||||
init_dmabuf_formats (GdkDisplay *display)
|
||||
{
|
||||
GdkDmabufFormatsBuilder *builder;
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (display);
|
||||
|
||||
if (self->dmabuf_formats != NULL)
|
||||
if (display->dmabuf_formats != NULL)
|
||||
return;
|
||||
|
||||
GDK_DISPLAY_DEBUG (self, DMABUF,
|
||||
"Beginning initialization of dmabuf support");
|
||||
gdk_display_prepare_gl (display, NULL);
|
||||
|
||||
builder = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
if (!GDK_DISPLAY_DEBUG_CHECK (self, DMABUF_DISABLE))
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
gdk_display_add_dmabuf_downloader (self, gdk_vulkan_get_dmabuf_downloader (self, builder));
|
||||
#endif
|
||||
gdk_gl_context_make_current (priv->gl_context);
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (self, builder));
|
||||
#endif
|
||||
if (priv->egl_display != EGL_NO_DISPLAY &&
|
||||
display->have_egl_dma_buf_import)
|
||||
{
|
||||
int num_formats;
|
||||
int *formats;
|
||||
GArray *array;
|
||||
|
||||
gdk_dmabuf_formats_builder_add_formats (builder,
|
||||
gdk_dmabuf_get_mmap_formats ());
|
||||
eglQueryDmaBufFormatsEXT (priv->egl_display, 0, NULL, &num_formats);
|
||||
formats = g_new (int, num_formats);
|
||||
eglQueryDmaBufFormatsEXT (priv->egl_display, num_formats, formats, &num_formats);
|
||||
|
||||
array = g_array_new (FALSE, FALSE, sizeof (GdkDmabufFormat));
|
||||
|
||||
for (int i = 0; i < num_formats; i++)
|
||||
{
|
||||
int num_modifiers;
|
||||
uint64_t *modifiers;
|
||||
unsigned int *external_only;
|
||||
|
||||
// if (!gdk_dmabuf_texture_may_support ((unsigned int)formats[i]))
|
||||
// continue;
|
||||
|
||||
eglQueryDmaBufModifiersEXT (priv->egl_display, formats[i], 0, NULL, NULL, &num_modifiers);
|
||||
modifiers = g_new (uint64_t, num_modifiers);
|
||||
external_only = g_new (unsigned int, num_modifiers);
|
||||
eglQueryDmaBufModifiersEXT (priv->egl_display, formats[i], num_modifiers, modifiers, external_only, &num_modifiers);
|
||||
|
||||
for (int j = 0; j < num_modifiers; j++)
|
||||
{
|
||||
if (1 || !external_only[j])
|
||||
{
|
||||
GDK_DEBUG (MISC, "supported EGL dmabuf format %c%c%c%c:%#lx %s",
|
||||
formats[i] & 0xff,
|
||||
(formats[i] >> 8) & 0xff,
|
||||
(formats[i] >> 16) & 0xff,
|
||||
(formats[i] >> 24) & 0xff,
|
||||
modifiers[j],
|
||||
external_only[j] ? "EXT" : "");
|
||||
g_array_append_val (array, ((GdkDmabufFormat){ formats[i], modifiers[j] }));
|
||||
}
|
||||
}
|
||||
g_array_append_val (array, ((GdkDmabufFormat){ formats[i], DRM_FORMAT_MOD_INVALID }));
|
||||
|
||||
g_free (modifiers);
|
||||
}
|
||||
|
||||
g_free (formats);
|
||||
|
||||
display->dmabuf_formats = gdk_dmabuf_formats_new ((GdkDmabufFormat *)array->data, array->len);
|
||||
g_array_free (array, TRUE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
GdkDmabufFormat *formats;
|
||||
gsize n_formats;
|
||||
|
||||
self->dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (builder);
|
||||
|
||||
GDK_DISPLAY_DEBUG (self, DMABUF,
|
||||
"Initialized support for %zu dmabuf formats",
|
||||
gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats));
|
||||
formats = gdk_dmabuf_texture_get_supported_formats (&n_formats);
|
||||
display->dmabuf_formats = gdk_dmabuf_formats_new (formats, n_formats);
|
||||
g_free (formats);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2001,11 +1945,6 @@ gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
* GTK may use OpenGL or Vulkan to support some formats.
|
||||
* Calling this function will then initialize them if they aren't yet.
|
||||
*
|
||||
* 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
|
||||
@@ -2013,7 +1952,7 @@ gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
GdkDmabufFormats *
|
||||
gdk_display_get_dmabuf_formats (GdkDisplay *display)
|
||||
{
|
||||
gdk_display_init_dmabuf (display);
|
||||
init_dmabuf_formats (display);
|
||||
|
||||
return display->dmabuf_formats;
|
||||
}
|
||||
|
@@ -25,8 +25,7 @@
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdmabufprivate.h"
|
||||
#include "gdkdmabufdownloaderprivate.h"
|
||||
#include "gdkdmabufformats.h"
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
@@ -41,17 +40,6 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkDisplayClass GdkDisplayClass;
|
||||
|
||||
typedef enum {
|
||||
GDK_VULKAN_FEATURE_DMABUF = 1 << 0,
|
||||
GDK_VULKAN_FEATURE_YCBCR = 1 << 1,
|
||||
GDK_VULKAN_FEATURE_DESCRIPTOR_INDEXING = 1 << 2,
|
||||
GDK_VULKAN_FEATURE_DYNAMIC_INDEXING = 1 << 3,
|
||||
GDK_VULKAN_FEATURE_NONUNIFORM_INDEXING = 1 << 4,
|
||||
GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT = 1 << 5,
|
||||
GDK_VULKAN_FEATURE_SEMAPHORE_IMPORT = 1 << 6,
|
||||
GDK_VULKAN_FEATURE_INCREMENTAL_PRESENT = 1 << 7,
|
||||
} GdkVulkanFeatures;
|
||||
|
||||
/* Tracks information about the device grab on this display */
|
||||
typedef struct
|
||||
{
|
||||
@@ -118,8 +106,6 @@ struct _GdkDisplay
|
||||
char *vk_pipeline_cache_etag;
|
||||
guint vk_save_pipeline_cache_source;
|
||||
GHashTable *vk_shader_modules;
|
||||
GdkDmabufFormats *vk_dmabuf_formats;
|
||||
GdkVulkanFeatures vulkan_features;
|
||||
|
||||
guint vulkan_refcount;
|
||||
#endif /* GDK_RENDERING_VULKAN */
|
||||
@@ -129,14 +115,8 @@ struct _GdkDisplay
|
||||
guint have_egl_no_config_context : 1;
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
guint have_egl_dma_buf_import : 1;
|
||||
guint have_egl_dma_buf_export : 1;
|
||||
|
||||
GdkDmabufFormats *dmabuf_formats;
|
||||
GdkDmabufDownloader *dmabuf_downloaders[4];
|
||||
|
||||
/* Cached data the EGL dmabuf downloader */
|
||||
GdkDmabufFormats *egl_dmabuf_formats;
|
||||
GdkDmabufFormats *egl_external_formats;
|
||||
};
|
||||
|
||||
struct _GdkDisplayClass
|
||||
@@ -231,12 +211,7 @@ gulong _gdk_display_get_next_serial (GdkDisplay *display
|
||||
void _gdk_display_pause_events (GdkDisplay *display);
|
||||
void _gdk_display_unpause_events (GdkDisplay *display);
|
||||
|
||||
void gdk_display_init_dmabuf (GdkDisplay *self);
|
||||
|
||||
gboolean gdk_display_has_vulkan_feature (GdkDisplay *self,
|
||||
GdkVulkanFeatures feature);
|
||||
GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
GdkSurface *surface,
|
||||
GError **error);
|
||||
|
||||
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);
|
||||
|
2350
gdk/gdkdmabuf.c
2350
gdk/gdkdmabuf.c
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdmabufdownloaderprivate.h"
|
||||
|
||||
G_DEFINE_INTERFACE (GdkDmabufDownloader, gdk_dmabuf_downloader, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gdk_dmabuf_downloader_default_init (GdkDmabufDownloaderInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dmabuf_downloader_close (GdkDmabufDownloader *self)
|
||||
{
|
||||
GdkDmabufDownloaderInterface *iface;
|
||||
|
||||
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
|
||||
iface->close (self);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_dmabuf_downloader_supports (GdkDmabufDownloader *self,
|
||||
GdkDmabufTexture *texture,
|
||||
GError **error)
|
||||
{
|
||||
GdkDmabufDownloaderInterface *iface;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_DOWNLOADER (self), FALSE);
|
||||
|
||||
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
|
||||
return iface->supports (self, texture, error);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
|
||||
GdkDmabufTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
GdkDmabufDownloaderInterface *iface;
|
||||
|
||||
g_return_if_fail (GDK_IS_DMABUF_DOWNLOADER (self));
|
||||
|
||||
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
|
||||
iface->download (self, texture, format, data, stride);
|
||||
}
|
||||
|
@@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DMABUF_DOWNLOADER (gdk_dmabuf_downloader_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (GdkDmabufDownloader, gdk_dmabuf_downloader, GDK, DMABUF_DOWNLOADER, GObject)
|
||||
|
||||
struct _GdkDmabufDownloaderInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
void (* close) (GdkDmabufDownloader *downloader);
|
||||
gboolean (* supports) (GdkDmabufDownloader *downloader,
|
||||
GdkDmabufTexture *texture,
|
||||
GError **error);
|
||||
void (* download) (GdkDmabufDownloader *downloader,
|
||||
GdkDmabufTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride);
|
||||
};
|
||||
|
||||
void gdk_dmabuf_downloader_close (GdkDmabufDownloader *downloader);
|
||||
gboolean gdk_dmabuf_downloader_supports (GdkDmabufDownloader *downloader,
|
||||
GdkDmabufTexture *texture,
|
||||
GError **error);
|
||||
void gdk_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
|
||||
GdkDmabufTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -1,275 +0,0 @@
|
||||
/* gdkdmabufegl.c
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if defined(HAVE_DMABUF) && defined (HAVE_EGL)
|
||||
#include "gdkdmabufeglprivate.h"
|
||||
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdktexturedownloader.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
/* A dmabuf downloader implementation that downloads buffers via
|
||||
* gsk_renderer_render_texture + GL texture download.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *formats,
|
||||
GdkDmabufFormatsBuilder *external)
|
||||
{
|
||||
GdkGLContext *context = gdk_display_get_gl_context (display);
|
||||
EGLDisplay egl_display = gdk_display_get_egl_display (display);
|
||||
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 EGL dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
external_only[j] ? "external " : "",
|
||||
(char *) &fourccs[i],
|
||||
modifiers[j]);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], modifiers[j]);
|
||||
}
|
||||
if (external_only[j])
|
||||
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
|
||||
else
|
||||
all_external = FALSE;
|
||||
}
|
||||
|
||||
/* Accept implicit modifiers as long as we accept the format at all.
|
||||
* This is a bit of a crapshot, but unfortunately needed for a bunch
|
||||
* of drivers.
|
||||
*
|
||||
* As an extra wrinkle, treat the implicit modifier as 'external only'
|
||||
* if all formats with the same fourcc are 'external only'.
|
||||
*/
|
||||
if (!all_external || gdk_gl_context_get_use_es (context))
|
||||
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], DRM_FORMAT_MOD_INVALID);
|
||||
if (all_external)
|
||||
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
g_free (modifiers);
|
||||
g_free (external_only);
|
||||
g_free (fourccs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hack. We don't include gsk/gsk.h here to avoid a build order problem
|
||||
* with the generated header gskenumtypes.h, so we need to hack around
|
||||
* a bit to access the gsk api we need.
|
||||
*/
|
||||
|
||||
typedef struct _GskRenderer GskRenderer;
|
||||
|
||||
extern GskRenderer * gsk_gl_renderer_new (void);
|
||||
extern gboolean gsk_renderer_realize_for_display (GskRenderer *renderer,
|
||||
GdkDisplay *display,
|
||||
GError **error);
|
||||
|
||||
GdkDmabufDownloader *
|
||||
gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *builder)
|
||||
{
|
||||
GdkDmabufFormatsBuilder *formats;
|
||||
GdkDmabufFormatsBuilder *external;
|
||||
gboolean retval = FALSE;
|
||||
GError *error = NULL;
|
||||
GskRenderer *renderer;
|
||||
|
||||
g_assert (display->egl_dmabuf_formats == NULL);
|
||||
g_assert (display->egl_external_formats == NULL);
|
||||
|
||||
if (!gdk_display_prepare_gl (display, NULL))
|
||||
return NULL;
|
||||
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
external = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
retval = gdk_dmabuf_egl_downloader_collect_formats (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);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
|
||||
renderer = gsk_gl_renderer_new ();
|
||||
|
||||
if (!gsk_renderer_realize_for_display (renderer, display, &error))
|
||||
{
|
||||
g_warning ("Failed to realize GL renderer: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (renderer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GDK_DMABUF_DOWNLOADER (renderer);
|
||||
}
|
||||
|
||||
EGLImage
|
||||
gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
||||
int width,
|
||||
int height,
|
||||
const GdkDmabuf *dmabuf,
|
||||
int target)
|
||||
{
|
||||
EGLDisplay egl_display = gdk_display_get_egl_display (display);
|
||||
EGLint attribs[64];
|
||||
int i;
|
||||
EGLImage image;
|
||||
|
||||
g_return_val_if_fail (width > 0, 0);
|
||||
g_return_val_if_fail (height > 0, 0);
|
||||
g_return_val_if_fail (1 <= dmabuf->n_planes && dmabuf->n_planes <= 4, 0);
|
||||
g_return_val_if_fail (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES, 0);
|
||||
|
||||
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_import)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Can't import dmabufs into GL, missing EGL or EGL_EXT_image_dma_buf_import_modifiers");
|
||||
return EGL_NO_IMAGE;
|
||||
}
|
||||
|
||||
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;
|
||||
attribs[i++] = EGL_TRUE;
|
||||
attribs[i++] = EGL_WIDTH;
|
||||
attribs[i++] = width;
|
||||
attribs[i++] = EGL_HEIGHT;
|
||||
attribs[i++] = height;
|
||||
attribs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
|
||||
attribs[i++] = dmabuf->fourcc;
|
||||
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
|
||||
attribs[i++] = EGL_ITU_REC601_EXT;
|
||||
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
|
||||
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
|
||||
|
||||
#define ADD_PLANE(plane) \
|
||||
{ \
|
||||
if (dmabuf->modifier != DRM_FORMAT_MOD_INVALID) \
|
||||
{ \
|
||||
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_MODIFIER_LO_EXT; \
|
||||
attribs[i++] = dmabuf->modifier & 0xFFFFFFFF; \
|
||||
attribs[i++] = EGL_DMA_BUF_PLANE## plane ## _MODIFIER_HI_EXT; \
|
||||
attribs[i++] = dmabuf->modifier >> 32; \
|
||||
} \
|
||||
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_FD_EXT; \
|
||||
attribs[i++] = dmabuf->planes[plane].fd; \
|
||||
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_PITCH_EXT; \
|
||||
attribs[i++] = dmabuf->planes[plane].stride; \
|
||||
attribs[i++] = EGL_DMA_BUF_PLANE## plane ##_OFFSET_EXT; \
|
||||
attribs[i++] = dmabuf->planes[plane].offset; \
|
||||
}
|
||||
|
||||
ADD_PLANE (0);
|
||||
|
||||
if (dmabuf->n_planes > 1) ADD_PLANE (1);
|
||||
if (dmabuf->n_planes > 2) ADD_PLANE (2);
|
||||
if (dmabuf->n_planes > 3) ADD_PLANE (3);
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
image = eglCreateImageKHR (egl_display,
|
||||
EGL_NO_CONTEXT,
|
||||
EGL_LINUX_DMA_BUF_EXT,
|
||||
(EGLClientBuffer)NULL,
|
||||
attribs);
|
||||
|
||||
if (image == EGL_NO_IMAGE)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Creating EGLImage for dmabuf failed: %#x",
|
||||
eglGetError ());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
#endif /* HAVE_DMABUF && HAVE_EGL */
|
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(HAVE_DMABUF) && defined (HAVE_EGL)
|
||||
|
||||
#include "gdkdmabufprivate.h"
|
||||
#include "gdkdmabufdownloaderprivate.h"
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
|
||||
GdkDmabufDownloader * gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *builder);
|
||||
EGLImage gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
||||
int width,
|
||||
int height,
|
||||
const GdkDmabuf *dmabuf,
|
||||
int target);
|
||||
|
||||
#endif /* HAVE_DMABUF && HAVE_EGL */
|
@@ -37,10 +37,6 @@
|
||||
* The list of supported formats is sorted by preference,
|
||||
* with the best formats coming first.
|
||||
*
|
||||
* The list may contains (format, modifier) 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.
|
||||
*
|
||||
@@ -152,10 +148,10 @@ gdk_dmabuf_formats_get_format (GdkDmabufFormats *formats,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_formats_contains:
|
||||
* gdk_dmabuf_format_contains:
|
||||
* @formats: a `GdkDmabufFormats`
|
||||
* @fourcc: a format code
|
||||
* @modifier: a format modifier
|
||||
* @modfier: a format modifier
|
||||
*
|
||||
* Returns whether a given format is contained in @formats.
|
||||
*
|
||||
@@ -211,9 +207,3 @@ gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
const GdkDmabufFormat *
|
||||
gdk_dmabuf_formats_peek_formats (GdkDmabufFormats *self)
|
||||
{
|
||||
return self->formats;
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ GDK_AVAILABLE_IN_4_14
|
||||
void gdk_dmabuf_formats_unref (GdkDmabufFormats *formats);
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
gsize gdk_dmabuf_formats_get_n_formats (GdkDmabufFormats *formats) G_GNUC_PURE;
|
||||
gsize gdk_dmabuf_formats_get_n_formats (GdkDmabufFormats *formats);
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
void gdk_dmabuf_formats_get_format (GdkDmabufFormats *formats,
|
||||
@@ -49,6 +49,6 @@ void gdk_dmabuf_formats_get_format (GdkDmabufFormats *formats
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
gboolean gdk_dmabuf_formats_contains (GdkDmabufFormats *formats,
|
||||
guint32 fourcc,
|
||||
guint64 modifier) G_GNUC_PURE;
|
||||
guint64 modifier);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -1,134 +0,0 @@
|
||||
/* gdkdmabufformats.c
|
||||
*
|
||||
* 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 "gdkdmabufformatsbuilderprivate.h"
|
||||
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
|
||||
|
||||
#define GDK_ARRAY_NAME gdk_dmabuf_formats_builder
|
||||
#define GDK_ARRAY_TYPE_NAME GdkDmabufFormatsBuilder
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GdkDmabufFormat
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 1024
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
/* NB: We keep duplicates in the list for ease of use. Only when creating the final
|
||||
* GdkDmabufFormats do we actually remove duplicates.
|
||||
*/
|
||||
|
||||
GdkDmabufFormatsBuilder *
|
||||
gdk_dmabuf_formats_builder_new (void)
|
||||
{
|
||||
GdkDmabufFormatsBuilder *result = g_new (GdkDmabufFormatsBuilder, 1);
|
||||
|
||||
gdk_dmabuf_formats_builder_init (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_dmabuf_format_compare (gconstpointer data_a,
|
||||
gconstpointer data_b)
|
||||
{
|
||||
const GdkDmabufFormat *a = data_a;
|
||||
const GdkDmabufFormat *b = data_b;
|
||||
|
||||
if (a->fourcc == b->fourcc)
|
||||
return (a->modifier - b->modifier) >> 8 * (sizeof (gint64) - sizeof (gint));
|
||||
else
|
||||
return a->fourcc - b->fourcc;
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dmabuf_format_equal (gconstpointer data_a,
|
||||
gconstpointer data_b)
|
||||
{
|
||||
const GdkDmabufFormat *a = data_a;
|
||||
const GdkDmabufFormat *b = data_b;
|
||||
|
||||
return a->fourcc == b->fourcc &&
|
||||
a->modifier == b->modifier;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_formats_builder_sort (GdkDmabufFormatsBuilder *self)
|
||||
{
|
||||
qsort (gdk_dmabuf_formats_builder_get_data (self),
|
||||
gdk_dmabuf_formats_builder_get_size (self),
|
||||
sizeof (GdkDmabufFormat),
|
||||
gdk_dmabuf_format_compare);
|
||||
}
|
||||
|
||||
/* list must be sorted */
|
||||
static void
|
||||
gdk_dmabuf_formats_builder_remove_duplicates (GdkDmabufFormatsBuilder *self)
|
||||
{
|
||||
gsize i, j;
|
||||
|
||||
for (i = 1, j = 0; i < gdk_dmabuf_formats_builder_get_size (self); i++)
|
||||
{
|
||||
if (gdk_dmabuf_format_equal (gdk_dmabuf_formats_builder_get (self, i),
|
||||
gdk_dmabuf_formats_builder_get (self, j)))
|
||||
continue;
|
||||
|
||||
j++;
|
||||
if (i != j)
|
||||
*gdk_dmabuf_formats_builder_index (self, j) = *gdk_dmabuf_formats_builder_index (self, i);
|
||||
}
|
||||
}
|
||||
|
||||
GdkDmabufFormats *
|
||||
gdk_dmabuf_formats_builder_free_to_formats (GdkDmabufFormatsBuilder *self)
|
||||
{
|
||||
GdkDmabufFormats *formats;
|
||||
|
||||
gdk_dmabuf_formats_builder_sort (self);
|
||||
gdk_dmabuf_formats_builder_remove_duplicates (self);
|
||||
|
||||
formats = gdk_dmabuf_formats_new (gdk_dmabuf_formats_builder_get_data (self),
|
||||
gdk_dmabuf_formats_builder_get_size (self));
|
||||
gdk_dmabuf_formats_builder_clear (self);
|
||||
g_free (self);
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
|
||||
guint32 fourcc,
|
||||
guint64 modifier)
|
||||
{
|
||||
gdk_dmabuf_formats_builder_append (self, &(GdkDmabufFormat) { fourcc, modifier });
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dmabuf_formats_builder_add_formats (GdkDmabufFormatsBuilder *self,
|
||||
GdkDmabufFormats *formats)
|
||||
{
|
||||
gdk_dmabuf_formats_builder_splice (self,
|
||||
gdk_dmabuf_formats_builder_get_size (self),
|
||||
0,
|
||||
FALSE,
|
||||
gdk_dmabuf_formats_peek_formats (formats),
|
||||
gdk_dmabuf_formats_get_n_formats (formats));
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkdmabufformats.h"
|
||||
|
||||
typedef struct GdkDmabufFormatsBuilder GdkDmabufFormatsBuilder;
|
||||
|
||||
GdkDmabufFormatsBuilder * gdk_dmabuf_formats_builder_new (void);
|
||||
GdkDmabufFormats * gdk_dmabuf_formats_builder_free_to_formats (GdkDmabufFormatsBuilder *self);
|
||||
|
||||
void gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
|
||||
guint32 fourcc,
|
||||
guint64 modifier);
|
||||
void gdk_dmabuf_formats_builder_add_formats (GdkDmabufFormatsBuilder *self,
|
||||
GdkDmabufFormats *formats);
|
@@ -9,7 +9,5 @@ struct _GdkDmabufFormat
|
||||
guint64 modifier;
|
||||
};
|
||||
|
||||
GdkDmabufFormats * gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
|
||||
gsize n_formats);
|
||||
|
||||
const GdkDmabufFormat * gdk_dmabuf_formats_peek_formats (GdkDmabufFormats *self);
|
||||
GdkDmabufFormats *gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
|
||||
gsize n_formats);
|
||||
|
@@ -1,380 +0,0 @@
|
||||
#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
|
@@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
||||
#define GDK_DMABUF_MAX_PLANES 4
|
||||
|
||||
typedef struct _GdkDmabuf GdkDmabuf;
|
||||
|
||||
struct _GdkDmabuf
|
||||
{
|
||||
guint32 fourcc;
|
||||
guint64 modifier;
|
||||
unsigned int n_planes;
|
||||
struct {
|
||||
int fd;
|
||||
unsigned int stride;
|
||||
unsigned int offset;
|
||||
} planes[GDK_DMABUF_MAX_PLANES];
|
||||
};
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
|
||||
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
|
||||
void gdk_dmabuf_download_mmap (GdkTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride);
|
||||
|
||||
|
||||
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,
|
||||
const GdkDmabuf *src,
|
||||
GError **error);
|
||||
|
||||
gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf);
|
||||
|
||||
gboolean gdk_dmabuf_fourcc_is_yuv (guint32 fourcc,
|
||||
gboolean *is_yuv);
|
||||
gboolean gdk_dmabuf_get_memory_format (guint32 fourcc,
|
||||
gboolean premultiplied,
|
||||
GdkMemoryFormat *out_format);
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
gboolean gdk_dmabuf_vk_get_nth (gsize n,
|
||||
guint32 *fourcc,
|
||||
VkFormat *vk_format);
|
||||
VkFormat gdk_dmabuf_get_vk_format (guint32 fourcc,
|
||||
VkComponentMapping *out_components);
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -21,15 +21,29 @@
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkdmabufdownloaderprivate.h"
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabufprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
#include <gdk/gdkglcontext.h>
|
||||
#include <gdk/gdkgltexturebuilder.h>
|
||||
#include <gdk/gdktexturedownloader.h>
|
||||
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <drm/drm_fourcc.h>
|
||||
#include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
/* We don't include gsk/gsk.h here to avoid a build order problem
|
||||
* with the generated header gskenumtypes.h
|
||||
*/
|
||||
#include <gsk/gskenums.h>
|
||||
#include <gsk/gsktypes.h>
|
||||
#include <gsk/gskrenderer.h>
|
||||
#include <gsk/gskrendernode.h>
|
||||
#include <gsk/gl/gskglrenderer.h>
|
||||
|
||||
/**
|
||||
* GdkDmabufTexture:
|
||||
*
|
||||
@@ -39,8 +53,6 @@
|
||||
* [class@Gdk.DmabufTextureBuilder] object.
|
||||
*
|
||||
* Dma-buf textures can only be created on Linux.
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
|
||||
struct _GdkDmabufTexture
|
||||
@@ -48,9 +60,16 @@ struct _GdkDmabufTexture
|
||||
GdkTexture parent_instance;
|
||||
|
||||
GdkDisplay *display;
|
||||
GdkDmabufDownloader *downloader;
|
||||
|
||||
GdkDmabuf dmabuf;
|
||||
guint32 fourcc;
|
||||
guint64 modifier;
|
||||
|
||||
unsigned int n_planes;
|
||||
|
||||
/* Per-plane properties */
|
||||
int fds[MAX_DMABUF_PLANES];
|
||||
unsigned int strides[MAX_DMABUF_PLANES];
|
||||
unsigned int offsets[MAX_DMABUF_PLANES];
|
||||
|
||||
GDestroyNotify destroy;
|
||||
gpointer data;
|
||||
@@ -61,10 +80,14 @@ struct _GdkDmabufTextureClass
|
||||
GdkTextureClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
|
||||
|
||||
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_init (GdkDmabufTexture *self)
|
||||
{
|
||||
self->fds[0] = self->fds[1] = self->fds[2] = self->fds[3] = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_dispose (GObject *object)
|
||||
{
|
||||
@@ -73,60 +96,13 @@ gdk_dmabuf_texture_dispose (GObject *object)
|
||||
if (self->destroy)
|
||||
self->destroy (self->data);
|
||||
|
||||
g_clear_object (&self->downloader);
|
||||
g_clear_object (&self->display);
|
||||
|
||||
G_OBJECT_CLASS (gdk_dmabuf_texture_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
typedef struct _Download Download;
|
||||
|
||||
struct _Download
|
||||
{
|
||||
GdkDmabufTexture *texture;
|
||||
GdkMemoryFormat format;
|
||||
guchar *data;
|
||||
gsize stride;
|
||||
volatile int spinlock;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gdk_dmabuf_texture_invoke_callback (gpointer data)
|
||||
{
|
||||
Download *download = data;
|
||||
|
||||
gdk_dmabuf_downloader_download (download->texture->downloader,
|
||||
download->texture,
|
||||
download->format,
|
||||
download->data,
|
||||
download->stride);
|
||||
|
||||
g_atomic_int_set (&download->spinlock, 1);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_download (GdkTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (texture);
|
||||
Download download = { self, format, data, stride, 0 };
|
||||
|
||||
if (self->downloader == NULL)
|
||||
{
|
||||
#ifdef HAVE_DMABUF
|
||||
gdk_dmabuf_download_mmap (texture, format, data, stride);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
g_main_context_invoke (NULL, gdk_dmabuf_texture_invoke_callback, &download);
|
||||
|
||||
while (g_atomic_int_get (&download.spinlock) == 0);
|
||||
}
|
||||
static void gdk_dmabuf_texture_download (GdkTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride);
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_class_init (GdkDmabufTextureClass *klass)
|
||||
@@ -139,107 +115,311 @@ gdk_dmabuf_texture_class_init (GdkDmabufTextureClass *klass)
|
||||
gobject_class->dispose = gdk_dmabuf_texture_dispose;
|
||||
}
|
||||
|
||||
guint32
|
||||
gdk_dmabuf_texture_get_fourcc (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->fourcc;
|
||||
}
|
||||
|
||||
guint64
|
||||
gdk_dmabuf_texture_get_modifier (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->modifier;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
gdk_dmabuf_texture_get_n_planes (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->n_planes;
|
||||
}
|
||||
|
||||
int *
|
||||
gdk_dmabuf_texture_get_fds (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->fds;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
gdk_dmabuf_texture_get_strides (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->strides;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
gdk_dmabuf_texture_get_offsets (GdkDmabufTexture *texture)
|
||||
{
|
||||
return texture->offsets;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
|
||||
typedef struct _GdkDrmFormatInfo GdkDrmFormatInfo;
|
||||
struct _GdkDrmFormatInfo
|
||||
{
|
||||
guint32 fourcc;
|
||||
GdkMemoryFormat premultiplied_memory_format;
|
||||
GdkMemoryFormat unpremultiplied_memory_format;
|
||||
gboolean requires_gl;
|
||||
};
|
||||
|
||||
static GdkDrmFormatInfo supported_formats[] = {
|
||||
{ DRM_FORMAT_ARGB8888, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, GDK_MEMORY_A8R8G8B8, FALSE },
|
||||
{ DRM_FORMAT_RGBA8888, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, GDK_MEMORY_R8G8B8A8, FALSE },
|
||||
{ DRM_FORMAT_BGRA8888, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, GDK_MEMORY_B8G8R8A8, FALSE },
|
||||
{ DRM_FORMAT_ABGR16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, GDK_MEMORY_R16G16B16A16_FLOAT, FALSE },
|
||||
{ DRM_FORMAT_RGB888, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8, FALSE },
|
||||
{ DRM_FORMAT_BGR888, GDK_MEMORY_B8G8R8, GDK_MEMORY_B8G8R8, FALSE },
|
||||
};
|
||||
|
||||
static GdkDrmFormatInfo *
|
||||
get_drm_format_info (guint32 fourcc)
|
||||
{
|
||||
for (int i = 0; i < G_N_ELEMENTS (supported_formats); i++)
|
||||
{
|
||||
if (supported_formats[i].fourcc == fourcc)
|
||||
return &supported_formats[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_init (GdkDmabufTexture *self)
|
||||
do_indirect_download (GdkDmabufTexture *self,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
GskRenderer *renderer;
|
||||
int width, height;
|
||||
GskRenderNode *node;
|
||||
GdkTexture *gl_texture;
|
||||
GdkTextureDownloader *downloader;
|
||||
GError *error = NULL;
|
||||
|
||||
GDK_DEBUG (MISC, "Using gsk_renderer_render_texture import for downloading a dmabuf");
|
||||
|
||||
g_assert (GDK_IS_DISPLAY (self->display));
|
||||
g_assert (GDK_IS_GL_CONTEXT (gdk_display_get_gl_context (self->display)));
|
||||
|
||||
renderer = gsk_gl_renderer_new ();
|
||||
if (!gsk_renderer_realize (renderer, NULL, &error))
|
||||
{
|
||||
g_warning ("Failed to realize GL renderer: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (renderer);
|
||||
return;
|
||||
}
|
||||
|
||||
width = gdk_texture_get_width (GDK_TEXTURE (self));
|
||||
height = gdk_texture_get_height (GDK_TEXTURE (self));
|
||||
|
||||
node = gsk_texture_node_new (GDK_TEXTURE (self), &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gl_texture = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
gsk_renderer_unrealize (renderer);
|
||||
g_object_unref (renderer);
|
||||
|
||||
downloader = gdk_texture_downloader_new (gl_texture);
|
||||
|
||||
gdk_texture_downloader_set_format (downloader, format);
|
||||
|
||||
gdk_texture_downloader_download_into (downloader, data, stride);
|
||||
|
||||
gdk_texture_downloader_free (downloader);
|
||||
g_object_unref (gl_texture);
|
||||
}
|
||||
|
||||
GdkDisplay *
|
||||
gdk_dmabuf_texture_get_display (GdkDmabufTexture *self)
|
||||
static void
|
||||
do_direct_download (GdkDmabufTexture *self,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
return self->display;
|
||||
gsize size;
|
||||
unsigned int height;
|
||||
gsize src_stride;
|
||||
guchar *src_data;
|
||||
int bpp;
|
||||
|
||||
GDK_DEBUG (MISC, "Using mmap() and memcpy() for downloading a dmabuf");
|
||||
|
||||
height = gdk_texture_get_height (GDK_TEXTURE (self));
|
||||
bpp = gdk_memory_format_bytes_per_pixel (gdk_texture_get_format (GDK_TEXTURE (self)));
|
||||
|
||||
src_stride = self->strides[0];
|
||||
size = self->strides[0] * height;
|
||||
|
||||
if (ioctl (self->fds[0], DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0)
|
||||
g_warning ("Failed to sync dma-buf: %s", g_strerror (errno));
|
||||
|
||||
src_data = mmap (NULL, size, PROT_READ, MAP_SHARED, self->fds[0], self->offsets[0]);
|
||||
|
||||
if (stride == src_stride)
|
||||
memcpy (data, src_data, size);
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < height; i++)
|
||||
memcpy (data + i * stride, src_data + i * src_stride, height * bpp);
|
||||
}
|
||||
|
||||
munmap (src_data, size);
|
||||
|
||||
if (ioctl (self->fds[0], DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_END|DMA_BUF_SYNC_READ }) < 0)
|
||||
g_warning ("Failed to sync dma-buf: %s", g_strerror (errno));
|
||||
}
|
||||
|
||||
const GdkDmabuf *
|
||||
gdk_dmabuf_texture_get_dmabuf (GdkDmabufTexture *self)
|
||||
#endif /* HAVE_LINUX_DMA_BUF_H */
|
||||
|
||||
GdkDmabufFormat *
|
||||
gdk_dmabuf_texture_get_supported_formats (gsize *n_formats)
|
||||
{
|
||||
return &self->dmabuf;
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
|
||||
GdkDmabufFormat *formats;
|
||||
|
||||
*n_formats = G_N_ELEMENTS (supported_formats);
|
||||
formats = g_new (GdkDmabufFormat, sizeof (GdkDmabufFormat) * *n_formats);
|
||||
|
||||
for (gsize i = 0; i < *n_formats; i++)
|
||||
{
|
||||
formats[i].fourcc = supported_formats[i].fourcc;
|
||||
formats[i].modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
}
|
||||
|
||||
return formats;
|
||||
|
||||
#else
|
||||
|
||||
*n_formats = 0;
|
||||
return NULL;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_dmabuf_texture_may_support (guint32 fourcc)
|
||||
{
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
|
||||
for (gsize i = 0; i < G_N_ELEMENTS (supported_formats); i++)
|
||||
{
|
||||
if (supported_formats[i].fourcc == fourcc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_dmabuf_texture_download (GdkTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (texture);
|
||||
GdkMemoryFormat src_format = gdk_texture_get_format (texture);
|
||||
GdkDrmFormatInfo *info;
|
||||
|
||||
info = get_drm_format_info (self->fourcc);
|
||||
|
||||
g_assert (info != NULL);
|
||||
|
||||
if (info->requires_gl || self->n_planes > 1 || self->modifier != DRM_FORMAT_MOD_LINEAR)
|
||||
do_indirect_download (self, format, data, stride);
|
||||
else if (format == src_format)
|
||||
do_direct_download (self, data, stride);
|
||||
else
|
||||
{
|
||||
unsigned int width, height;
|
||||
guchar *src_data;
|
||||
gsize src_stride;
|
||||
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
|
||||
src_stride = self->strides[0];
|
||||
src_data = g_new (guchar, src_stride * height);
|
||||
|
||||
do_direct_download (self, src_data, src_stride);
|
||||
|
||||
gdk_memory_convert (data, stride, format,
|
||||
src_data, src_stride, src_format,
|
||||
width, height);
|
||||
|
||||
g_free (src_data);
|
||||
}
|
||||
#endif /* HAVE_LINUX_DMA_BUF_H */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
display_supports_format (GdkDisplay *display,
|
||||
guint32 fourcc,
|
||||
guint64 modifier)
|
||||
{
|
||||
GdkDmabufFormats *formats;
|
||||
|
||||
if (!display)
|
||||
return FALSE;
|
||||
|
||||
formats = gdk_display_get_dmabuf_formats (display);
|
||||
|
||||
return gdk_dmabuf_formats_contains (formats, fourcc, modifier);
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
gpointer data)
|
||||
{
|
||||
#ifdef HAVE_DMABUF
|
||||
#ifdef HAVE_LINUX_DMA_BUF_H
|
||||
GdkDmabufTexture *self;
|
||||
GdkTexture *update_texture;
|
||||
GdkDisplay *display;
|
||||
GdkDmabuf dmabuf;
|
||||
GError *local_error = NULL;
|
||||
int width, height;
|
||||
gboolean premultiplied;
|
||||
gsize i;
|
||||
GdkDisplay *display = gdk_dmabuf_texture_builder_get_display (builder);
|
||||
guint32 fourcc = gdk_dmabuf_texture_builder_get_fourcc (builder);
|
||||
guint64 modifier = gdk_dmabuf_texture_builder_get_modifier (builder);
|
||||
gboolean premultiplied = gdk_dmabuf_texture_builder_get_premultiplied (builder);
|
||||
unsigned int n_planes = gdk_dmabuf_texture_builder_get_n_planes (builder);
|
||||
GdkDrmFormatInfo *info;
|
||||
|
||||
display = gdk_dmabuf_texture_builder_get_display (builder);
|
||||
width = gdk_dmabuf_texture_builder_get_width (builder);
|
||||
height = gdk_dmabuf_texture_builder_get_height (builder);
|
||||
premultiplied = gdk_dmabuf_texture_builder_get_premultiplied (builder);
|
||||
info = get_drm_format_info (fourcc);
|
||||
|
||||
if (!gdk_dmabuf_sanitize (&dmabuf,
|
||||
width,
|
||||
height,
|
||||
gdk_dmabuf_texture_builder_get_dmabuf (builder),
|
||||
error))
|
||||
return NULL;
|
||||
if ((!info || info->requires_gl || n_planes > 1 || modifier != DRM_FORMAT_MOD_LINEAR) && !display_supports_format (display, fourcc, modifier))
|
||||
{
|
||||
g_warning ("Unsupported dmabuf format %c%c%c%c:%#lx",
|
||||
fourcc & 0xff, (fourcc >> 8) & 0xff, (fourcc >> 16) & 0xff, (fourcc >> 24) & 0xff, modifier);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdk_display_init_dmabuf (display);
|
||||
GDK_DEBUG (MISC, "Dmabuf texture in format %c%c%c%c:%#lx",
|
||||
fourcc & 0xff, (fourcc >> 8) & 0xff, (fourcc >> 16) & 0xff, (fourcc >> 24) & 0xff, modifier);
|
||||
|
||||
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"width", gdk_dmabuf_texture_builder_get_width (builder),
|
||||
"height", gdk_dmabuf_texture_builder_get_height (builder),
|
||||
NULL);
|
||||
|
||||
g_set_object (&self->display, display);
|
||||
self->dmabuf = dmabuf;
|
||||
|
||||
if (!gdk_dmabuf_get_memory_format (dmabuf.fourcc, premultiplied, &(GDK_TEXTURE (self)->format)))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Falling back to generic RGBA for dmabuf format %.4s",
|
||||
(char *) &dmabuf.fourcc);
|
||||
GDK_TEXTURE (self)->format = premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED
|
||||
: GDK_MEMORY_R8G8B8A8;
|
||||
}
|
||||
|
||||
if (!gdk_dmabuf_formats_contains (gdk_dmabuf_get_mmap_formats (), dmabuf.fourcc, dmabuf.modifier))
|
||||
{
|
||||
for (i = 0; display->dmabuf_downloaders[i] != NULL; i++)
|
||||
{
|
||||
if (local_error && g_error_matches (local_error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT))
|
||||
g_clear_error (&local_error);
|
||||
|
||||
if (gdk_dmabuf_downloader_supports (display->dmabuf_downloaders[i],
|
||||
self,
|
||||
local_error ? NULL : &local_error))
|
||||
{
|
||||
self->downloader = g_object_ref (display->dmabuf_downloaders[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (self->downloader == NULL)
|
||||
{
|
||||
g_propagate_error (error, local_error);
|
||||
g_object_unref (self);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Creating dmabuf texture, format %.4s:%#" G_GINT64_MODIFIER "x, %s%u planes, memory format %u, downloader %s",
|
||||
(char *) &dmabuf.fourcc, dmabuf.modifier,
|
||||
gdk_dmabuf_texture_builder_get_premultiplied (builder) ? " premultiplied, " : "",
|
||||
dmabuf.n_planes,
|
||||
GDK_TEXTURE (self)->format,
|
||||
self->downloader ? G_OBJECT_TYPE_NAME (self->downloader) : "none");
|
||||
|
||||
/* Set this only once we know that the texture will be created.
|
||||
* Otherwise dispose() will run the callback */
|
||||
self->destroy = destroy;
|
||||
self->data = data;
|
||||
|
||||
if (info)
|
||||
GDK_TEXTURE (self)->format = premultiplied ? info->premultiplied_memory_format
|
||||
: info->unpremultiplied_memory_format;
|
||||
else
|
||||
GDK_TEXTURE (self)->format = premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED : GDK_MEMORY_A8R8G8B8;
|
||||
|
||||
g_set_object (&self->display, display);
|
||||
|
||||
self->fourcc = fourcc;
|
||||
self->modifier = modifier;
|
||||
self->n_planes = n_planes;
|
||||
|
||||
memcpy (self->fds, gdk_dmabuf_texture_builder_get_fds (builder), sizeof (int) * MAX_DMABUF_PLANES);
|
||||
memcpy (self->strides, gdk_dmabuf_texture_builder_get_strides (builder), sizeof (unsigned int) * MAX_DMABUF_PLANES);
|
||||
memcpy (self->offsets, gdk_dmabuf_texture_builder_get_offsets (builder), sizeof (unsigned int) * MAX_DMABUF_PLANES);
|
||||
|
||||
update_texture = gdk_dmabuf_texture_builder_get_update_texture (builder);
|
||||
if (update_texture)
|
||||
{
|
||||
@@ -258,10 +438,7 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
|
||||
return GDK_TEXTURE (self);
|
||||
|
||||
#else /* !HAVE_DMABUF */
|
||||
g_set_error_literal (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
|
||||
"dmabuf support disabled at compile-time.");
|
||||
#else /* !HAVE_LINUX_DMA_BUF_H */
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -32,16 +32,12 @@ G_BEGIN_DECLS
|
||||
#define GDK_DMABUF_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_DMABUF_TEXTURE, GdkDmabufTexture))
|
||||
#define GDK_IS_DMABUF_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_DMABUF_TEXTURE))
|
||||
|
||||
#define GDK_DMABUF_ERROR (gdk_dmabuf_error_quark ())
|
||||
|
||||
typedef struct _GdkDmabufTexture GdkDmabufTexture;
|
||||
typedef struct _GdkDmabufTextureClass GdkDmabufTextureClass;
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
GType gdk_dmabuf_texture_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
GQuark gdk_dmabuf_error_quark (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDmabufTexture, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "gdkdmabuftexturebuilder.h"
|
||||
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
@@ -36,9 +35,16 @@ struct _GdkDmabufTextureBuilder
|
||||
GdkDisplay *display;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
guint32 fourcc;
|
||||
guint64 modifier;
|
||||
gboolean premultiplied;
|
||||
|
||||
GdkDmabuf dmabuf;
|
||||
unsigned int n_planes;
|
||||
|
||||
/* per-plane properties */
|
||||
int fds[MAX_DMABUF_PLANES];
|
||||
unsigned int strides[MAX_DMABUF_PLANES];
|
||||
unsigned int offsets[MAX_DMABUF_PLANES];
|
||||
|
||||
GdkTexture *update_texture;
|
||||
cairo_region_t *update_region;
|
||||
@@ -80,36 +86,24 @@ 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`
|
||||
* by a 32-bit integer. These format identifiers are defined in the header file
|
||||
* [drm/drm_fourcc.h](https://github.com/torvalds/linux/blob/master/include/uapi/drm/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.
|
||||
*
|
||||
* The required properties for a dma-buf texture are
|
||||
*
|
||||
* * The width and height in pixels
|
||||
*
|
||||
* * The `fourcc` code and `modifier` which identify the format and memory layout of the dma-buf
|
||||
*
|
||||
* * The file descriptor, offset and stride for each of the planes
|
||||
* - The width and height in pixels
|
||||
* - The `fourcc` code and `modifier` which identify the format and memory layout of the dma-buf
|
||||
* - The file descriptor, offset and stride for each of the planes
|
||||
*
|
||||
* `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
|
||||
*/
|
||||
|
||||
@@ -167,11 +161,11 @@ gdk_dmabuf_texture_builder_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_FOURCC:
|
||||
g_value_set_uint (value, self->dmabuf.fourcc);
|
||||
g_value_set_uint (value, self->fourcc);
|
||||
break;
|
||||
|
||||
case PROP_MODIFIER:
|
||||
g_value_set_uint64 (value, self->dmabuf.modifier);
|
||||
g_value_set_uint64 (value, self->modifier);
|
||||
break;
|
||||
|
||||
case PROP_PREMULTIPLIED:
|
||||
@@ -179,7 +173,7 @@ gdk_dmabuf_texture_builder_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_N_PLANES:
|
||||
g_value_set_uint (value, self->dmabuf.n_planes);
|
||||
g_value_set_uint (value, self->n_planes);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
@@ -258,7 +252,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
gobject_class->set_property = gdk_dmabuf_texture_builder_set_property;
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:display: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_display org.gtk.Property.set=gdk_dmabuf_texture_builder_set_display)
|
||||
* GdkDmabufTextureBuilder:display: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_display org.gdk.Property.set=gdk_dmabuf_texture_builder_set_display)
|
||||
*
|
||||
* The display that this texture will be used on.
|
||||
*
|
||||
@@ -270,7 +264,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:width: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_width org.gtk.Property.set=gdk_dmabuf_texture_builder_set_width)
|
||||
* GdkDmabufTextureBuilder:width: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_width org.gdk.Property.set=gdk_dmabuf_texture_builder_set_width)
|
||||
*
|
||||
* The width of the texture.
|
||||
*
|
||||
@@ -282,7 +276,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:height: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_height org.gtk.Property.set=gdk_dmabuf_texture_builder_set_height)
|
||||
* GdkDmabufTextureBuilder:height: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_height org.gdk.Property.set=gdk_dmabuf_texture_builder_set_height)
|
||||
*
|
||||
* The height of the texture.
|
||||
*
|
||||
@@ -294,7 +288,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:fourcc: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_fourcc org.gtk.Property.set=gdk_dmabuf_texture_builder_set_fourcc)
|
||||
* GdkDmabufTextureBuilder:fourcc: (attributes org.gdk.Property.get=gdk_dmabuf_texture_builder_get_fourcc org.gdk.Property.set=gdk_dmabuf_texture_builder_set_fourcc)
|
||||
*
|
||||
* The format of the texture, as a fourcc value.
|
||||
*
|
||||
@@ -332,7 +326,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.gtk.Property.get=gdk_dmabuf_texture_builder_get_n_planes org.gtk.Property.set=gdk_dmabuf_texture_builder_set_n_planes)
|
||||
* 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)
|
||||
*
|
||||
* The number of planes of the texture.
|
||||
*
|
||||
@@ -343,11 +337,11 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
*/
|
||||
properties[PROP_N_PLANES] =
|
||||
g_param_spec_uint ("n-planes", NULL, NULL,
|
||||
1, GDK_DMABUF_MAX_PLANES, 1,
|
||||
0, 4, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* 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)
|
||||
*
|
||||
* The update region for [property@Gdk.GLTextureBuilder:update-texture].
|
||||
*
|
||||
@@ -359,9 +353,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.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_texture org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_texture)
|
||||
* 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)
|
||||
*
|
||||
* The texture [property@Gdk.DmabufTextureBuilder:update-region] is an update for.
|
||||
* The texture [property@Gdk.GLTextureBuilder:update-region] is an update for.
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
@@ -376,12 +370,8 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
static void
|
||||
gdk_dmabuf_texture_builder_init (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
self->fds[0] = self->fds[1] = self->fds[2] = self->fds[3] = -1;
|
||||
self->premultiplied = TRUE;
|
||||
self->display = gdk_display_get_default ();
|
||||
self->dmabuf.n_planes = 1;
|
||||
|
||||
for (int i = 0; i < GDK_DMABUF_MAX_PLANES; i++)
|
||||
self->dmabuf.planes[i].fd = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,7 +396,7 @@ gdk_dmabuf_texture_builder_new (void)
|
||||
* Returns the display that this texture builder is
|
||||
* associated with.
|
||||
*
|
||||
* Returns: (transfer none): the display
|
||||
* Returns: (transfer none) (nullable): the display
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
@@ -436,14 +426,13 @@ gdk_dmabuf_texture_builder_set_display (GdkDmabufTextureBuilder *self,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
if (g_set_object (&self->display, display))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DISPLAY]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_width: (attributes org.gtk.Method.get_property=width)
|
||||
* gdk_dmabuf_texture_builder_get_width: (attributes org.gdk.Method.get_property=width)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the width previously set via gdk_dmabuf_texture_builder_set_width() or
|
||||
@@ -462,7 +451,7 @@ gdk_dmabuf_texture_builder_get_width (GdkDmabufTextureBuilder *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_width: (attributes org.gtk.Method.set_property=width)
|
||||
* gdk_dmabuf_texture_builder_set_width: (attributes org.gdk.Method.set_property=width)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @width: The texture's width or 0 to unset
|
||||
*
|
||||
@@ -487,7 +476,7 @@ gdk_dmabuf_texture_builder_set_width (GdkDmabufTextureBuilder *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_height: (attributes org.gtk.Method.get_property=height)
|
||||
* gdk_dmabuf_texture_builder_get_height: (attributes org.gdk.Method.get_property=height)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the height previously set via gdk_dmabuf_texture_builder_set_height() or
|
||||
@@ -506,7 +495,7 @@ gdk_dmabuf_texture_builder_get_height (GdkDmabufTextureBuilder *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_height: (attributes org.gtk.Method.set_property=height)
|
||||
* gdk_dmabuf_texture_builder_set_height: (attributes org.gdk.Method.set_property=height)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @height: the texture's height or 0 to unset
|
||||
*
|
||||
@@ -531,7 +520,7 @@ gdk_dmabuf_texture_builder_set_height (GdkDmabufTextureBuilder *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_fourcc: (attributes org.gtk.Method.get_property=fourcc)
|
||||
* gdk_dmabuf_texture_builder_get_fourcc: (attributes org.gdk.Method.get_property=fourcc)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the format previously set via gdk_dmabuf_texture_builder_set_fourcc()
|
||||
@@ -548,11 +537,11 @@ gdk_dmabuf_texture_builder_get_fourcc (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->dmabuf.fourcc;
|
||||
return self->fourcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_fourcc: (attributes org.gtk.Method.set_property=fourcc)
|
||||
* gdk_dmabuf_texture_builder_set_fourcc: (attributes org.gdk.Method.set_property=fourcc)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @fourcc: the texture's format or 0 to unset
|
||||
*
|
||||
@@ -570,10 +559,10 @@ gdk_dmabuf_texture_builder_set_fourcc (GdkDmabufTextureBuilder *self,
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->dmabuf.fourcc == fourcc)
|
||||
if (self->fourcc == fourcc)
|
||||
return;
|
||||
|
||||
self->dmabuf.fourcc = fourcc;
|
||||
self->fourcc = fourcc;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FOURCC]);
|
||||
}
|
||||
@@ -593,7 +582,7 @@ gdk_dmabuf_texture_builder_get_modifier (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->dmabuf.modifier;
|
||||
return self->modifier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,16 +600,16 @@ gdk_dmabuf_texture_builder_set_modifier (GdkDmabufTextureBuilder *self,
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->dmabuf.modifier == modifier)
|
||||
if (self->modifier == modifier)
|
||||
return;
|
||||
|
||||
self->dmabuf.modifier = modifier;
|
||||
self->modifier = modifier;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODIFIER]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_n_planes: (attributes org.gtk.Method.get_property=n-planes)
|
||||
* gdk_dmabuf_texture_builder_get_n_planes: (attributes org.gdk.Method.get_property=n-planes)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the number of planes.
|
||||
@@ -634,7 +623,7 @@ gdk_dmabuf_texture_builder_get_n_planes (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->dmabuf.n_planes;
|
||||
return self->n_planes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,7 +671,7 @@ gdk_dmabuf_texture_builder_set_premultiplied (GdkDmabufTextureBuilder *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_n_planes: (attributes org.gtk.Method.set_property=n-planes)
|
||||
* gdk_dmabuf_texture_builder_set_n_planes: (attributes org.gdk.Method.set_property=n-planes)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @n_planes: the number of planes
|
||||
*
|
||||
@@ -695,12 +684,11 @@ gdk_dmabuf_texture_builder_set_n_planes (GdkDmabufTextureBuilder *self,
|
||||
unsigned int n_planes)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (n_planes > 0 && n_planes <= GDK_DMABUF_MAX_PLANES);
|
||||
|
||||
if (self->dmabuf.n_planes == n_planes)
|
||||
if (self->n_planes == n_planes)
|
||||
return;
|
||||
|
||||
self->dmabuf.n_planes = n_planes;
|
||||
self->n_planes = n_planes;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_PLANES]);
|
||||
}
|
||||
@@ -721,9 +709,9 @@ gdk_dmabuf_texture_builder_get_fd (GdkDmabufTextureBuilder *self,
|
||||
unsigned int plane)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES, 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES, 0);
|
||||
|
||||
return self->dmabuf.planes[plane].fd;
|
||||
return self->fds[plane];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,12 +730,12 @@ gdk_dmabuf_texture_builder_set_fd (GdkDmabufTextureBuilder *self,
|
||||
int fd)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES);
|
||||
g_return_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES);
|
||||
|
||||
if (self->dmabuf.planes[plane].fd == fd)
|
||||
if (self->fds[plane] == fd)
|
||||
return;
|
||||
|
||||
self->dmabuf.planes[plane].fd = fd;
|
||||
self->fds[plane] = fd;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -766,9 +754,9 @@ gdk_dmabuf_texture_builder_get_stride (GdkDmabufTextureBuilder *self,
|
||||
unsigned int plane)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES, 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES, 0);
|
||||
|
||||
return self->dmabuf.planes[plane].stride;
|
||||
return self->strides[plane];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -789,12 +777,12 @@ gdk_dmabuf_texture_builder_set_stride (GdkDmabufTextureBuilder *self,
|
||||
unsigned int stride)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES);
|
||||
g_return_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES);
|
||||
|
||||
if (self->dmabuf.planes[plane].stride == stride)
|
||||
if (self->strides[plane] == stride)
|
||||
return;
|
||||
|
||||
self->dmabuf.planes[plane].stride = stride;
|
||||
self->strides[plane] = stride;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,9 +801,9 @@ gdk_dmabuf_texture_builder_get_offset (GdkDmabufTextureBuilder *self,
|
||||
unsigned int plane)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES, 0);
|
||||
g_return_val_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES, 0);
|
||||
|
||||
return self->dmabuf.planes[plane].offset;
|
||||
return self->offsets[plane];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -834,16 +822,16 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
|
||||
unsigned int offset)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (0 <= plane && plane < GDK_DMABUF_MAX_PLANES);
|
||||
g_return_if_fail (0 <= plane && plane < MAX_DMABUF_PLANES);
|
||||
|
||||
if (self->dmabuf.planes[plane].offset == offset)
|
||||
if (self->offsets[plane] == offset)
|
||||
return;
|
||||
|
||||
self->dmabuf.planes[plane].offset = offset;
|
||||
self->offsets[plane] = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
|
||||
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gdk.Method.get_property=update_texture)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the texture previously set via gdk_dmabuf_texture_builder_set_update_texture() or
|
||||
@@ -862,7 +850,7 @@ gdk_dmabuf_texture_builder_get_update_texture (GdkDmabufTextureBuilder *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_update_texture: (attributes org.gtk.Method.set_property=update-texture)
|
||||
* gdk_dmabuf_texture_builder_set_update_texture: (attributes org.gdk.Method.set_property=update_texture)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @texture: (nullable): the texture to update
|
||||
*
|
||||
@@ -885,7 +873,7 @@ gdk_dmabuf_texture_builder_set_update_texture (GdkDmabufTextureBuilder *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_update_region: (attributes org.gtk.Method.get_property=update-region)
|
||||
* gdk_dmabuf_texture_builder_get_update_region: (attributes org.gdk.Method.get_property=update_region)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the region previously set via gdk_dmabuf_texture_builder_set_update_region() or
|
||||
@@ -904,7 +892,7 @@ gdk_dmabuf_texture_builder_get_update_region (GdkDmabufTextureBuilder *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_update_region: (attributes org.gtk.Method.set_property=update-region)
|
||||
* gdk_dmabuf_texture_builder_set_update_region: (attributes org.gdk.Method.set_property=update_region)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @region: (nullable): the region to update
|
||||
*
|
||||
@@ -944,17 +932,14 @@ gdk_dmabuf_texture_builder_set_update_region (GdkDmabufTextureBuilder *self,
|
||||
* @destroy: (nullable): destroy function to be called when the texture is
|
||||
* released
|
||||
* @data: user data to pass to the destroy function
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Builds a new `GdkTexture` with the values set up in the builder.
|
||||
*
|
||||
* It is a programming error to call this function if any mandatory
|
||||
* property has not been set.
|
||||
*
|
||||
* If the dmabuf is not supported by GTK, %NULL will be returned and @error will be set.
|
||||
*
|
||||
* The `destroy` function gets called when the returned texture gets released.
|
||||
*
|
||||
* Note that it is a programming error to call this function if any mandatory
|
||||
* property has not been set.
|
||||
*
|
||||
* It is possible to call this function multiple times to create multiple textures,
|
||||
* possibly with changing properties in between.
|
||||
*
|
||||
@@ -972,35 +957,36 @@ gdk_dmabuf_texture_builder_set_update_region (GdkDmabufTextureBuilder *self,
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
GDestroyNotify destroy,
|
||||
gpointer data)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), NULL);
|
||||
g_return_val_if_fail (destroy == NULL || data != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
g_return_val_if_fail (self->width > 0, NULL);
|
||||
g_return_val_if_fail (self->height > 0, NULL);
|
||||
g_return_val_if_fail (self->dmabuf.fourcc != 0, NULL);
|
||||
g_return_val_if_fail (self->fourcc != 0, NULL);
|
||||
g_return_val_if_fail (self->n_planes > 0, NULL);
|
||||
|
||||
for (i = 0; i < self->dmabuf.n_planes; i++)
|
||||
g_return_val_if_fail (self->dmabuf.planes[i].fd != -1, NULL);
|
||||
for (int i = 0; i < self->n_planes; i++)
|
||||
g_return_val_if_fail (self->fds[i] != -1 || self->offsets[i] != 0, NULL);
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (self->display, DMABUF_DISABLE))
|
||||
{
|
||||
g_set_error_literal (error,
|
||||
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
|
||||
"dmabuf support disabled via GDK_DEBUG environment variable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gdk_dmabuf_texture_new_from_builder (self, destroy, data, error);
|
||||
return gdk_dmabuf_texture_new_from_builder (self, destroy, data);
|
||||
}
|
||||
|
||||
const GdkDmabuf *
|
||||
gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *self)
|
||||
int *
|
||||
gdk_dmabuf_texture_builder_get_fds (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
return &self->dmabuf;
|
||||
return self->fds;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
gdk_dmabuf_texture_builder_get_strides (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
return self->strides;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
gdk_dmabuf_texture_builder_get_offsets (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
return self->offsets;
|
||||
}
|
||||
|
@@ -115,8 +115,7 @@ void gdk_dmabuf_texture_builder_set_update_region (GdkDmabuf
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
GdkTexture * gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data,
|
||||
GError **error);
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -3,19 +3,32 @@
|
||||
#include "gdkdmabuftexture.h"
|
||||
|
||||
#include "gdkdmabuftexturebuilder.h"
|
||||
#include "gdkdmabufprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
|
||||
#define MAX_DMABUF_PLANES 4
|
||||
|
||||
int * gdk_dmabuf_texture_builder_get_fds (GdkDmabufTextureBuilder *builder);
|
||||
unsigned int * gdk_dmabuf_texture_builder_get_offsets (GdkDmabufTextureBuilder *builder);
|
||||
unsigned int * gdk_dmabuf_texture_builder_get_strides (GdkDmabufTextureBuilder *builder);
|
||||
|
||||
GdkTexture * gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data,
|
||||
GError **error);
|
||||
gpointer data);
|
||||
|
||||
guint32 gdk_dmabuf_texture_get_fourcc (GdkDmabufTexture *texture);
|
||||
guint64 gdk_dmabuf_texture_get_modifier (GdkDmabufTexture *texture);
|
||||
unsigned int gdk_dmabuf_texture_get_n_planes (GdkDmabufTexture *texture);
|
||||
int * gdk_dmabuf_texture_get_fds (GdkDmabufTexture *texture);
|
||||
unsigned int * gdk_dmabuf_texture_get_offsets (GdkDmabufTexture *texture);
|
||||
unsigned int * gdk_dmabuf_texture_get_strides (GdkDmabufTexture *texture);
|
||||
|
||||
GdkDmabufFormat * gdk_dmabuf_texture_get_supported_formats (gsize *n_formats);
|
||||
gboolean gdk_dmabuf_texture_may_support (guint32 fourcc);
|
||||
|
||||
GdkDisplay * gdk_dmabuf_texture_get_display (GdkDmabufTexture *self);
|
||||
const GdkDmabuf * gdk_dmabuf_texture_get_dmabuf (GdkDmabufTexture *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -68,12 +68,6 @@ gdk_draw_context_default_surface_resized (GdkDrawContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_default_empty_frame (GdkDrawContext *context)
|
||||
{
|
||||
g_warning ("FIXME: Implement GdkDrawContext.empty_frame in %s", G_OBJECT_TYPE_NAME (context));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_dispose (GObject *gobject)
|
||||
{
|
||||
@@ -167,7 +161,6 @@ 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)
|
||||
@@ -305,8 +298,8 @@ gdk_draw_context_get_surface (GdkDrawContext *context)
|
||||
*
|
||||
* When using GTK, the widget system automatically places calls to
|
||||
* gdk_draw_context_begin_frame() and gdk_draw_context_end_frame() via the
|
||||
* use of [GskRenderer](../gsk4/class.Renderer.html)s, so application code
|
||||
* does not need to call these functions explicitly.
|
||||
* use of [class@Gsk.Renderer]s, so application code does not need to call
|
||||
* these functions explicitly.
|
||||
*/
|
||||
void
|
||||
gdk_draw_context_begin_frame (GdkDrawContext *context,
|
||||
@@ -477,17 +470,3 @@ 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);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user