Compare commits

..

10 Commits

Author SHA1 Message Date
Matthias Clasen
611e707022 wip: test download of dmabuf textures 2023-10-16 10:58:31 -04:00
Matthias Clasen
7bc67ff5cf untested: Do indirect download without gsk
Do the necessary GL gymnastics ourselves.

For testing this, there is currently an
env var to select:

DMABUF_DOWNLOAD_METHOD=gl
2023-10-16 10:58:31 -04:00
Matthias Clasen
8b9fb596b7 Make a test with dma heaps
This uses the dma-heap kernel api to create a dma-buf
and use it for a GdkDmabufTexture. It supports a few
formats to test how well GL conversion of YUV works.

The YUV code is adapted from weston tests.
2023-10-16 10:58:31 -04:00
Matthias Clasen
79cb80f783 dmabuf: Cache the renderer
Creating a GL renderer is relatively expensive
(since we create a new GL context). Therefore,
cache the renderer we use for indirect download
of dmabuf textures on the display.
2023-10-16 10:58:31 -04:00
Matthias Clasen
f0e5a0a41f dmabuf: Support indirect download
For dmabufs with formats that are supported by EGL,
but can't be handled with mmap+memcpy, use GL for
downloading.
2023-10-16 10:58:31 -04:00
Matthias Clasen
5ceb2ed671 gsk: Support dmabuf textures
Defer handling of dmabuf textures to the driver,
and add the necessary code in load_texture.
2023-10-16 10:58:31 -04:00
Matthias Clasen
7e185f39d2 display: Take gl into account for dmabuf formats
Construct the list of formats by appending
the basic formats to the gl formats.
2023-10-16 10:58:31 -04:00
Matthias Clasen
0b45acd2a7 gl context: Add private dmabuf API
Add API to import a dmabuf into a texture,
export a texture to a dmabuf and to get
the supported dma-buf formats.

All this is implemented using the relevant
EGL and GL extensions.
2023-10-16 10:58:31 -04:00
Matthias Clasen
0693c51870 gl context: Check another extension
This will be used in future commits.
2023-10-15 19:27:04 -04:00
Matthias Clasen
81c00901c1 display: Check for more EGL extensions
We are going to rely on this in future commits.
2023-10-15 19:22:02 -04:00
748 changed files with 27390 additions and 56861 deletions

View File

@@ -26,7 +26,7 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora: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.

View File

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

View File

@@ -324,7 +324,7 @@ for line in args.infile:
units.append(unit)
report = {}
report['date'] = datetime.datetime.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

View File

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

View File

@@ -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

129
NEWS
View File

@@ -1,133 +1,6 @@
Overview of Changes in 4.13.5, xx-xx-xxxx
Overview of Changes in 4.13.2, xx-xx-xxxx
=========================================
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
=========================================

View File

@@ -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

View File

@@ -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);

View File

@@ -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__ */

View File

@@ -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')

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -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

View File

@@ -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 ();

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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__ */

View File

@@ -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__ */

View File

@@ -1157,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 (),

View File

@@ -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__ */

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

View File

@@ -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

View File

@@ -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>

View 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

View File

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

View File

@@ -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"

View File

@@ -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 Dont 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`.

View File

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

View File

@@ -62,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"

View File

@@ -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

View File

@@ -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

View File

@@ -41,7 +41,7 @@ activate (GtkApplication* app,
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
gtk_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);

View File

@@ -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
^^^^^^^^^

View File

@@ -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"

View File

@@ -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

View File

@@ -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).

View File

@@ -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.

View File

@@ -206,11 +206,11 @@ are only available when GTK has been configured with `-Ddebug=true`.
`dmabuf`
: Information about dmabuf handling (Linux-only)
`offload`
: Information about subsurfaces and graphics offload (Wayland-only)
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)
@@ -226,14 +226,11 @@ A number of options affect behavior instead of logging:
`gl-debug`
: Insert debugging information in OpenGL
`gl-disable-gl`
: Don't allow the use of OpenGL GL API. This forces GLES to be used
`gl-legacy`
: Use a legacy OpenGL context
`gl-disable-gles`
: Don't allow the use of OpenGL GLES API. This forces GL to be used
`gl-prefer-gl`
: Prefer OpenGL over OpenGL ES. This was the default behavior before GTK 4.14.
`gl-gles`
: Use a GLES OpenGL context
`gl-egl`
: Use an EGL context on X11 or Windows
@@ -274,46 +271,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,38 +351,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 certain features of the Vulkan support.
`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
@@ -407,9 +372,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
@@ -427,32 +389,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 features 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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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
}
}

View File

@@ -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))

View File

@@ -118,25 +118,24 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "selection", GDK_DEBUG_SELECTION, "Information about selections" },
{ "clipboard", GDK_DEBUG_CLIPBOARD, "Information about clipboards" },
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
{ "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 },
{ "dmabuf-disable", GDK_DEBUG_DMABUF_DISABLE, "Disable dmabuf support", TRUE },
};
@@ -197,6 +196,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 +234,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 +263,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 +277,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);

View File

@@ -37,27 +37,25 @@ typedef enum {
GDK_DEBUG_SELECTION = 1 << 9,
GDK_DEBUG_CLIPBOARD = 1 << 10,
GDK_DEBUG_DMABUF = 1 << 11,
GDK_DEBUG_OFFLOAD = 1 << 12,
/* flags below are influencing behavior */
GDK_DEBUG_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 << 12,
GDK_DEBUG_PORTALS = 1 << 13,
GDK_DEBUG_NO_PORTALS = 1 << 14,
GDK_DEBUG_GL_DISABLE = 1 << 15,
GDK_DEBUG_GL_FRACTIONAL = 1 << 16,
GDK_DEBUG_GL_LEGACY = 1 << 17,
GDK_DEBUG_GL_GLES = 1 << 18,
GDK_DEBUG_GL_DEBUG = 1 << 19,
GDK_DEBUG_GL_EGL = 1 << 20,
GDK_DEBUG_GL_GLX = 1 << 21,
GDK_DEBUG_GL_WGL = 1 << 22,
GDK_DEBUG_VULKAN_DISABLE = 1 << 23,
GDK_DEBUG_VULKAN_VALIDATE = 1 << 24,
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 25,
GDK_DEBUG_HIGH_DEPTH = 1 << 26,
GDK_DEBUG_NO_VSYNC = 1 << 27,
GDK_DEBUG_DMABUF_DISABLE = 1 << 28,
} GdkDebugFlags;
extern guint _gdk_debug_flags;
@@ -66,24 +64,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 +81,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 +96,7 @@ typedef struct
const char *key;
guint value;
const char *help;
gboolean always_enabled;
} GdkDebugKey;
guint gdk_parse_debug_var (const char *variable,

View File

@@ -31,7 +31,6 @@
#include "gdkclipboardprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkdmabufeglprivate.h"
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabufformatsprivate.h"
#include "gdkdmabuftextureprivate.h"
@@ -40,16 +39,11 @@
#include "gdkglcontextprivate.h"
#include "gdkmonitorprivate.h"
#include "gdkrectangle.h"
#include "gdkvulkancontextprivate.h"
#include "gdkvulkancontext.h"
#ifdef HAVE_EGL
#include <epoxy/egl.h>
#endif
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <math.h>
#include <stdlib.h>
@@ -253,13 +247,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 +386,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);
@@ -1457,6 +1424,7 @@ gdk_display_get_gl_context (GdkDisplay *self)
}
#ifdef HAVE_EGL
#ifdef G_ENABLE_DEBUG
static int
strvcmp (gconstpointer p1,
gconstpointer p2)
@@ -1513,6 +1481,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)
@@ -1716,23 +1685,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,
@@ -1830,22 +1782,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"
@@ -1854,12 +1799,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);
@@ -1867,6 +1806,7 @@ gdk_display_init_egl (GdkDisplay *self,
g_free (std_cfg);
g_free (ext);
}
#endif
gdk_profiler_end_mark (start_time, "init EGL", NULL);
@@ -1903,67 +1843,32 @@ 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
/* 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)
{
GdkDisplayPrivate *priv = gdk_display_get_instance_private (display);
GdkDmabufFormatsBuilder *builder;
if (self->dmabuf_formats != NULL)
if (display->dmabuf_formats != NULL)
return;
GDK_DISPLAY_DEBUG (self, DMABUF,
"Beginning initialization of dmabuf support");
builder = gdk_dmabuf_formats_builder_new ();
#ifdef HAVE_DMABUF
if (!GDK_DISPLAY_DEBUG_CHECK (self, DMABUF_DISABLE))
if (!GDK_DEBUG_CHECK (DMABUF_DISABLE))
{
#ifdef GDK_RENDERING_VULKAN
gdk_display_add_dmabuf_downloader (self, gdk_vulkan_get_dmabuf_downloader (self, builder));
#endif
gdk_display_prepare_gl (display, NULL);
#ifdef HAVE_EGL
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (self, builder));
#endif
gdk_dmabuf_texture_add_supported_formats (builder);
gdk_dmabuf_formats_builder_add_formats (builder,
gdk_dmabuf_get_mmap_formats ());
if (priv->gl_context)
gdk_gl_context_add_dmabuf_formats (priv->gl_context, builder);
}
#endif
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));
display->dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (builder);
}
/**
@@ -1975,11 +1880,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
@@ -1987,7 +1887,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;
}

View File

@@ -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 */
@@ -132,11 +118,6 @@ struct _GdkDisplay
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,8 +212,6 @@ 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);
GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self,
GError **error);

File diff suppressed because it is too large Load Diff

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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 (GskRenderer *renderer,
GdkSurface *surface,
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 (renderer, NULL, &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 */

View File

@@ -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 */

View File

@@ -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.
*

View File

@@ -22,7 +22,6 @@
#include "gdkdmabufformatsprivate.h"
#define GDK_ARRAY_NAME gdk_dmabuf_formats_builder
#define GDK_ARRAY_TYPE_NAME GdkDmabufFormatsBuilder
#define GDK_ARRAY_ELEMENT_TYPE GdkDmabufFormat

View File

@@ -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

View File

@@ -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

View File

@@ -21,15 +21,23 @@
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkdmabufdownloaderprivate.h"
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabufprivate.h"
#include "gdktextureprivate.h"
#include <gdk/gdkglcontext.h>
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include <gdk/gdkglcontextprivate.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
#include <graphene.h>
/**
* GdkDmabufTexture:
*
@@ -39,8 +47,6 @@
* [class@Gdk.DmabufTextureBuilder] object.
*
* Dma-buf textures can only be created on Linux.
*
* Since: 4.14
*/
struct _GdkDmabufTexture
@@ -48,9 +54,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;
@@ -65,6 +78,12 @@ 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 +92,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,21 +111,672 @@ 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;
};
/* These are the dma-buf formats that we can support just with memcpy,
* as long as they are combined with DRM_FORMAT_MOD_LINEAR
*/
static GdkDrmFormatInfo supported_formats[] = {
{ DRM_FORMAT_ARGB8888, GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, GDK_MEMORY_A8R8G8B8 },
{ DRM_FORMAT_RGBA8888, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, GDK_MEMORY_R8G8B8A8 },
{ DRM_FORMAT_BGRA8888, GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, GDK_MEMORY_B8G8R8A8 },
{ DRM_FORMAT_ABGR16161616F, GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, GDK_MEMORY_R16G16B16A16_FLOAT },
{ DRM_FORMAT_RGB888, GDK_MEMORY_R8G8B8, GDK_MEMORY_R8G8B8 },
{ DRM_FORMAT_BGR888, GDK_MEMORY_B8G8R8, GDK_MEMORY_B8G8R8 },
};
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;
}
/* 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 gpointer GskRenderer;
typedef gpointer GskRenderNode;
extern GskRenderer * gsk_gl_renderer_new (void);
extern gboolean gsk_renderer_realize (GskRenderer *renderer,
GdkSurface *surface,
GError **error);
extern void gsk_renderer_unrealize (GskRenderer *renderer);
extern GdkTexture * gsk_renderer_render_texture (GskRenderer *renderer,
GskRenderNode *node,
const graphene_rect_t *bounds);
extern GskRenderNode * gsk_texture_node_new (GdkTexture *texture,
const graphene_rect_t *viewport);
extern void gsk_render_node_unref (GskRenderNode *node);
static int
gl_format_for_memory_format (GdkMemoryFormat format)
{
switch (gdk_memory_format_get_depth (format))
{
case GDK_MEMORY_U8:
return GL_RGBA8;
case GDK_MEMORY_U16:
return GL_RGBA16;
case GDK_MEMORY_FLOAT16:
return GL_RGBA16F;
case GDK_MEMORY_FLOAT32:
return GL_RGBA32F;
default:
g_assert_not_reached ();
}
}
static int
gl_type_for_gl_format (int format)
{
switch (format)
{
case GL_RGBA8:
return GL_UNSIGNED_BYTE;
case GL_RGBA16:
return GL_UNSIGNED_SHORT;
case GL_RGBA16F:
return GL_HALF_FLOAT;
case GL_RGBA32F:
return GL_FLOAT;
default:
g_assert_not_reached ();
}
}
static void
gdk_dmabuf_texture_init (GdkDmabufTexture *self)
create_render_target (int width,
int height,
int format,
unsigned int *fbo_id,
unsigned int *texture_id)
{
int type;
unsigned int texture, fbo;
type = gl_type_for_gl_format (format);
glGenTextures (1, &texture);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, texture);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D (GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, NULL);
glGenFramebuffers (1, &fbo);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
g_assert (glCheckFramebufferStatus (GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
*fbo_id = fbo;
*texture_id = texture;
}
GdkDisplay *
gdk_dmabuf_texture_get_display (GdkDmabufTexture *self)
static const char vertex_shader_source[] = ""
"#version 150\n"
"in vec2 in_position;\n"
"void main() {\n"
" gl_Position = vec4(in_position, 0.0, 1.0);\n"
"}";
static const char fragment_shader_source[] = ""
"#version 150\n"
"uniform sampler2D source;\n"
"uniform vec2 size;\n"
"out vec4 out_color;\n"
"void main() {\n"
" vec4 in_color = texture(source, gl_FragCoord.xy / size);\n"
" out_color = in_color;\n"
"}";
static unsigned int
create_shader (int type,
const char *src)
{
return self->display;
unsigned int shader;
int status;
shader = glCreateShader (type);
glShaderSource (shader, 1, &src, NULL);
glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
int log_len;
char *buffer;
glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc (log_len + 1);
glGetShaderInfoLog (shader, log_len, NULL, buffer);
g_warning ("Compile failure in %s shader:\n%s",
type == GL_VERTEX_SHADER ? "vertex" : "fragment",
buffer);
g_free (buffer);
glDeleteShader (shader);
return 0;
}
return shader;
}
const GdkDmabuf *
gdk_dmabuf_texture_get_dmabuf (GdkDmabufTexture *self)
static unsigned int
compile_program (const char *vs,
const char *fs,
unsigned int *source_location,
unsigned int *size_location)
{
return &self->dmabuf;
unsigned int vertex, fragment, program;
int status;
vertex = create_shader (GL_VERTEX_SHADER, vs);
if (vertex == 0)
return 0;
fragment = create_shader (GL_FRAGMENT_SHADER, fs);
if (fragment == 0)
{
glDeleteShader (vertex);
return 0;
}
program = glCreateProgram ();
glAttachShader (program, vertex);
glAttachShader (program, fragment);
glLinkProgram (program);
glGetProgramiv (program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
int log_len;
char *buffer;
glGetProgramiv (program, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc (log_len + 1);
glGetProgramInfoLog (program, log_len, NULL, buffer);
g_warning ("Linking failure:\n%s", buffer);
g_free (buffer);
glDeleteProgram (program);
program = 0;
goto out;
}
*source_location = glGetUniformLocation (program, "source");
*size_location = glGetUniformLocation (program, "size");
glDetachShader (program, vertex);
glDetachShader (program, fragment);
out:
glDeleteShader (vertex);
glDeleteShader (fragment);
return program;
}
typedef struct {
unsigned int program;
unsigned int source_location;
unsigned int size_location;
} ProgramData;
static unsigned int
get_blit_program (GdkGLContext *context,
unsigned int *source_location,
unsigned int *size_location)
{
ProgramData *data;
data = g_object_get_data (G_OBJECT (context), "dmabuf-blit-program-data");
if (!data)
{
data = g_new0 (ProgramData, 1);
data->program = compile_program (vertex_shader_source,
fragment_shader_source,
&data->source_location,
&data->size_location);
g_object_set_data (G_OBJECT (context), "dmabuf-blit-program-data", data);
}
*source_location = data->source_location;
*size_location = data->size_location;
return data->program;
}
static void
blit_texture (GdkGLContext *context,
int width,
int height,
unsigned int texture,
unsigned int fbo)
{
unsigned int program;
unsigned int source_location;
unsigned int size_location;
unsigned int vao;
unsigned int buffer;
const float vertices[] = {
-1.0f, 1.0f,
-1.0f, -1.0f,
1.0f, 1.0f,
1.0f, -1.0f
};
program = get_blit_program (context, &source_location, &size_location);
glGenVertexArrays (1, &vao);
glBindVertexArray (vao);
glGenBuffers (1, &buffer);
glBindBuffer (GL_ARRAY_BUFFER, buffer);
glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer (0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray (0);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, texture);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glUseProgram (program);
glUniform1i (source_location, texture);
glUniform2f (size_location, width, height);
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
glUseProgram (0);
glDisableVertexAttribArray (0);
glBindBuffer (GL_ARRAY_BUFFER, 0);
glDeleteBuffers (1, &buffer);
glDeleteVertexArrays (1, &vao);
}
static void
do_indirect_download_gl (GdkDmabufTexture *self,
GdkMemoryFormat format,
guchar *data,
gsize stride)
{
GdkGLContext *context;
unsigned int texture_id;
unsigned int texture_id2;
unsigned int fbo;
int width, height;
int gl_format;
GdkGLTextureBuilder *builder;
GdkTexture *gl_texture;
gpointer sync;
GdkTextureDownloader *downloader;
GDK_DEBUG (DMABUF, "Using gl for downloading a dmabuf");
context = gdk_display_get_gl_context (self->display);
gdk_gl_context_make_current (context);
gl_format = gl_format_for_memory_format (format),
width = gdk_texture_get_width (GDK_TEXTURE (self));
height = gdk_texture_get_height (GDK_TEXTURE (self));
/* 1. import the dmabuf as GL texture */
texture_id = gdk_gl_context_import_dmabuf (context, width, height,
self->fourcc,
self->modifier,
self->n_planes,
self->fds,
self->strides,
self->offsets);
/* 2. create a texture to render into */
create_render_target (width, height, gl_format, &fbo, &texture_id2);
/* 3. copy from texture_id1 to texture_id2, using a blit shader */
glClear (GL_COLOR_BUFFER_BIT);
blit_texture (context, width, height, texture_id, fbo);
sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
/* 4. create a GdkGLTexture from the rendered texture */
builder = gdk_gl_texture_builder_new ();
gdk_gl_texture_builder_set_context (builder, context);
gdk_gl_texture_builder_set_id (builder, texture_id2);
gdk_gl_texture_builder_set_width (builder, width);
gdk_gl_texture_builder_set_height (builder, height);
gdk_gl_texture_builder_set_format (builder, format);
gdk_gl_texture_builder_set_sync (builder, sync);
gl_texture = gdk_gl_texture_builder_build (builder, NULL, NULL);
/* 5. download it */
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);
/* 6. cleanup */
glDeleteFramebuffers (1, &fbo);
glDeleteTextures (1, &texture_id);
glDeleteTextures (1, &texture_id2);
}
static void
do_indirect_download_gsk (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 (DMABUF, "Using gsk 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 = g_object_get_data (G_OBJECT (self->display), "dmabuf-gl-renderer");
if (!renderer)
{
renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (renderer, NULL, &error))
{
g_warning ("Failed to realize GL renderer: %s", error->message);
g_error_free (error);
g_object_unref (renderer);
return;
}
g_object_set_data_full (G_OBJECT (self->display), "dmabuf-gl-renderer",
renderer, g_object_unref);
}
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);
}
static void
do_direct_download (GdkDmabufTexture *self,
guchar *data,
gsize stride)
{
gsize size;
unsigned int height;
gsize src_stride;
guchar *src_data;
int bpp;
GDK_DEBUG (DMABUF, "Using mmap 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 dmabuf: %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 dmabuf: %s", g_strerror (errno));
}
/* A helper to determine suitable download memory formats for drm formats */
static GdkMemoryFormat
compute_memory_format (guint32 fourcc,
gboolean premultiplied)
{
switch (fourcc)
{
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_XRGB8888_A8:
case DRM_FORMAT_XBGR8888_A8:
return premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED : GDK_MEMORY_A8R8G8B8;
case DRM_FORMAT_RGBA8888:
case DRM_FORMAT_RGBX8888_A8:
return premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED : GDK_MEMORY_R8G8B8A8;
case DRM_FORMAT_BGRA8888:
return premultiplied ? GDK_MEMORY_B8G8R8A8_PREMULTIPLIED : GDK_MEMORY_B8G8R8A8;
case DRM_FORMAT_RGB888:
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_RGBX8888:
case DRM_FORMAT_BGRX8888:
return GDK_MEMORY_R8G8B8;
case DRM_FORMAT_BGR888:
return GDK_MEMORY_B8G8R8;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010:
case DRM_FORMAT_RGBX1010102:
case DRM_FORMAT_BGRX1010102:
case DRM_FORMAT_XRGB16161616:
case DRM_FORMAT_XBGR16161616:
return GDK_MEMORY_R16G16B16;
case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGBA1010102:
case DRM_FORMAT_BGRA1010102:
case DRM_FORMAT_ARGB16161616:
case DRM_FORMAT_ABGR16161616:
return premultiplied ? GDK_MEMORY_R16G16B16A16_PREMULTIPLIED : GDK_MEMORY_R16G16B16A16;
case DRM_FORMAT_ARGB16161616F:
case DRM_FORMAT_ABGR16161616F:
return premultiplied ? GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED : GDK_MEMORY_R16G16B16A16_FLOAT;
case DRM_FORMAT_XRGB16161616F:
case DRM_FORMAT_XBGR16161616F:
return GDK_MEMORY_R16G16B16_FLOAT;
case DRM_FORMAT_YUYV:
case DRM_FORMAT_YVYU:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_VYUY:
case DRM_FORMAT_XYUV8888:
case DRM_FORMAT_XVUY8888:
case DRM_FORMAT_VUY888:
return GDK_MEMORY_R8G8B8;
/* Add more formats here */
default:
return premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED : GDK_MEMORY_A8R8G8B8;
}
}
#endif /* HAVE_LINUX_DMA_BUF_H */
void
gdk_dmabuf_texture_add_supported_formats (GdkDmabufFormatsBuilder *builder)
{
#ifdef HAVE_LINUX_DMA_BUF_H
gsize i;
for (i = 0; i < G_N_ELEMENTS (supported_formats); i++)
{
gdk_dmabuf_formats_builder_add_format (builder,
supported_formats[i].fourcc,
DRM_FORMAT_MOD_LINEAR);
}
#endif
}
static void
do_indirect_download (GdkDmabufTexture *self,
GdkMemoryFormat format,
guchar *data,
gsize stride)
{
const char *method = g_getenv ("DMABUF_DOWNLOAD_METHOD");
if (g_strcmp0 (method, "gl") == 0)
do_indirect_download_gl (self, format, data, stride);
else
do_indirect_download_gsk (self, format, data, stride);
}
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);
if (!info || self->n_planes > 1 || self->modifier != DRM_FORMAT_MOD_LINEAR ||
g_getenv ("DMABUF_DOWNLOAD_METHOD") != NULL)
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 *
@@ -162,84 +785,59 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
gpointer data,
GError **error)
{
#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;
gboolean can_download_directly;
gboolean can_download_indirectly;
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;
can_download_directly = info != NULL && n_planes == 1 && modifier == DRM_FORMAT_MOD_LINEAR;
can_download_indirectly = display_supports_format (display, fourcc, modifier);
gdk_display_init_dmabuf (display);
if (!can_download_directly && !can_download_indirectly)
{
g_set_error (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT,
"Unsupported dmabuf format: %.4s:%#lx, planes: %u",
(char *) &fourcc, modifier, n_planes);
return NULL;
}
GDK_DEBUG (DMABUF,
"Create dmabuf texture (format: %.4s:%#lx, planes: %u)",
(char *) &fourcc, modifier, n_planes);
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 (can_download_directly)
GDK_TEXTURE (self)->format = premultiplied ? info->premultiplied_memory_format
: info->unpremultiplied_memory_format;
else
GDK_TEXTURE (self)->format = compute_memory_format (fourcc, premultiplied);
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 +856,9 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
return GDK_TEXTURE (self);
#else /* !HAVE_DMABUF */
#else /* !HAVE_LINUX_DMA_BUF_H */
g_set_error_literal (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
"dmabuf support disabled at compile-time.");
return NULL;
#endif
}

View File

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

View File

@@ -36,9 +36,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 +87,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 +162,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 +174,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 +253,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 +265,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 +277,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 +289,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 +327,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 +338,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 +354,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 +371,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 +397,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 +427,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 +452,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 +477,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 +496,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 +521,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 +538,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 +560,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 +583,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 +601,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 +624,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 +672,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 +685,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 +710,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 +731,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 +755,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 +778,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 +802,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 +823,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 +851,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 +874,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 +893,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
*
@@ -976,22 +965,20 @@ gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
gpointer data,
GError **error)
{
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))
if (GDK_DEBUG_CHECK (DMABUF_DISABLE))
{
g_set_error_literal (error,
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
g_set_error_literal (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
"dmabuf support disabled via GDK_DEBUG environment variable");
return NULL;
}
@@ -999,8 +986,20 @@ gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
return gdk_dmabuf_texture_new_from_builder (self, destroy, data, error);
}
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;
}

View File

@@ -3,19 +3,33 @@
#include "gdkdmabuftexture.h"
#include "gdkdmabuftexturebuilder.h"
#include "gdkdmabufprivate.h"
#include "gdkdmabufformatsbuilderprivate.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);
GdkDisplay * gdk_dmabuf_texture_get_display (GdkDmabufTexture *self);
const GdkDmabuf * gdk_dmabuf_texture_get_dmabuf (GdkDmabufTexture *self);
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);
void gdk_dmabuf_texture_add_supported_formats (GdkDmabufFormatsBuilder *builder);
G_END_DECLS

View File

@@ -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");
}
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)
@@ -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);
}

View File

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

View File

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

View File

@@ -684,7 +684,7 @@ gdk_drop_read_async (GdkDrop *self,
* gdk_drop_read_finish:
* @self: a `GdkDrop`
* @result: a `GAsyncResult`
* @out_mime_type: (out) (type utf8) (transfer none): return location for the used mime type
* @out_mime_type: (out) (type utf8): return location for the used mime type
* @error: (nullable): location to store error information on failure
*
* Finishes an async drop read operation.

View File

@@ -114,15 +114,6 @@ typedef enum
*/
typedef enum
{
/**
* GDK_NO_MODIFIER_MASK:
*
* No modifier.
*
* Since: 4.14
*/
GDK_NO_MODIFIER_MASK GDK_AVAILABLE_ENUMERATOR_IN_4_14 = 0,
GDK_SHIFT_MASK = 1 << 0,
GDK_LOCK_MASK = 1 << 1,
GDK_CONTROL_MASK = 1 << 2,
@@ -160,8 +151,6 @@ typedef enum
* reasons
*
* Error enumeration for `GdkDmabufTexture`.
*
* Since: 4.14
*/
typedef enum {
GDK_DMABUF_ERROR_NOT_AVAILABLE,
@@ -309,16 +298,10 @@ typedef enum
* The color values are premultiplied with the alpha value.
* @GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: 4 bytes; for red, green, blue, alpha
* The color values are premultiplied with the alpha value.
* @GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: 4 bytes; for alpha, blue, green, red,
* The color values are premultiplied with the alpha value. Since 4.14
* @GDK_MEMORY_B8G8R8A8: 4 bytes; for blue, green, red, alpha.
* @GDK_MEMORY_A8R8G8B8: 4 bytes; for alpha, red, green, blue.
* @GDK_MEMORY_R8G8B8A8: 4 bytes; for red, green, blue, alpha.
* @GDK_MEMORY_A8B8G8R8: 4 bytes; for alpha, blue, green, red.
* @GDK_MEMORY_B8G8R8X8: 4 bytes; for blue, green, red, unused. Since 4.14
* @GDK_MEMORY_X8R8G8B8: 4 bytes; for unused, red, green, blue. Since 4.14
* @GDK_MEMORY_R8G8B8X8: 4 bytes; for red, green, blue, unused. Since 4.14
* @GDK_MEMORY_X8B8G8R8: 4 bytes; for unused, blue, green, red. Since 4.14
* @GDK_MEMORY_R8G8B8: 3 bytes; for red, green, blue. The data is opaque.
* @GDK_MEMORY_B8G8R8: 3 bytes; for blue, green, red. The data is opaque.
* @GDK_MEMORY_R16G16B16: 3 guint16 values; for red, green, blue. Since: 4.6
@@ -399,11 +382,6 @@ typedef enum {
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A16_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A32_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A8B8G8R8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_14,
GDK_MEMORY_B8G8R8X8 GDK_AVAILABLE_ENUMERATOR_IN_4_14,
GDK_MEMORY_X8R8G8B8 GDK_AVAILABLE_ENUMERATOR_IN_4_14,
GDK_MEMORY_R8G8B8X8 GDK_AVAILABLE_ENUMERATOR_IN_4_14,
GDK_MEMORY_X8B8G8R8 GDK_AVAILABLE_ENUMERATOR_IN_4_14,
GDK_MEMORY_N_FORMATS
} GdkMemoryFormat;

View File

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

View File

@@ -165,18 +165,12 @@ typedef struct _GdkTouchpadEvent GdkTouchpadEvent;
* @GDK_PAD_RING: A tablet pad axis event from a "ring".
* @GDK_PAD_STRIP: A tablet pad axis event from a "strip".
* @GDK_PAD_GROUP_MODE: A tablet pad group mode change.
* @GDK_TOUCHPAD_HOLD: A touchpad hold gesture event, the current state
* is determined by its phase field. Since: 4.6
* @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration.
*
* Specifies the type of the event.
*/
/**
* GDK_TOUCHPAD_HOLD:
*
* A touchpad hold gesture event, the current state is determined by its phase
* field.
*
* Since: 4.6
*/
typedef enum
{
GDK_DELETE,

View File

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

View File

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

View File

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

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