Compare commits
2 Commits
wip/otte/h
...
compile-ui
Author | SHA1 | Date | |
---|---|---|---|
|
7b68ef7669 | ||
|
11b9b1759a |
@@ -25,7 +25,7 @@ variables:
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v35"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v34"
|
||||
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
|
||||
|
||||
.only-default:
|
||||
@@ -91,7 +91,6 @@ fedora-x86_64:
|
||||
- meson compile -C _build_hello
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build waylandgles
|
||||
- .gitlab-ci/run-tests.sh _build broadway
|
||||
|
||||
release-build:
|
||||
@@ -158,7 +157,6 @@ msys2-mingw64:
|
||||
CHERE_INVOKING: "yes"
|
||||
|
||||
macos:
|
||||
allow_failure: true
|
||||
extends: .only-default
|
||||
only:
|
||||
- branches@GNOME/gtk
|
||||
|
@@ -76,7 +76,6 @@ RUN dnf -y install \
|
||||
pcre-devel \
|
||||
pcre-static \
|
||||
python3 \
|
||||
python3-docutils \
|
||||
python3-gobject \
|
||||
python3-jinja2 \
|
||||
python3-markdown \
|
||||
|
@@ -44,24 +44,6 @@ case "${backend}" in
|
||||
kill ${compositor}
|
||||
;;
|
||||
|
||||
waylandgles)
|
||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||
|
||||
weston --backend=headless-backend.so --socket=wayland-6 --idle-time=0 &
|
||||
compositor=$!
|
||||
export WAYLAND_DISPLAY=wayland-6
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=gsk-compare-broadway
|
||||
|
||||
exit_code=$?
|
||||
kill ${compositor}
|
||||
;;
|
||||
|
||||
broadway)
|
||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||
|
||||
@@ -80,12 +62,6 @@ case "${backend}" in
|
||||
exit_code=0
|
||||
kill ${server}
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Failed to add ${backend} to .gitlab-ci/run-tests.sh"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
cd ${builddir}
|
||||
|
@@ -114,7 +114,7 @@ can be found in the file:
|
||||
docs/reference/gtk/html/gtk-building.html
|
||||
```
|
||||
|
||||
Or [online](https://docs.gtk.org/gtk4/building.html)
|
||||
Or [online](https://developer.gnome.org/gtk4/stable/gtk-building.html)
|
||||
|
||||
How to report bugs
|
||||
------------------
|
||||
|
@@ -59,18 +59,16 @@ update_image (void)
|
||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||
|
||||
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
if (hint)
|
||||
{
|
||||
if (strcmp (hint, "none") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
else if (strcmp (hint, "slight") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
else if (strcmp (hint, "medium") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
else if (strcmp (hint, "full") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
}
|
||||
if (strcmp (hint, "none") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
else if (strcmp (hint, "slight") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
else if (strcmp (hint, "medium") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
else if (strcmp (hint, "full") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
else
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
cairo_font_options_set_hint_style (fopt, hintstyle);
|
||||
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (hint_metrics)))
|
||||
|
@@ -874,8 +874,8 @@ gtk_gears_tick (GtkWidget *widget,
|
||||
{
|
||||
GtkGears *gears = GTK_GEARS (widget);
|
||||
GtkGearsPrivate *priv = gtk_gears_get_instance_private (gears);
|
||||
GdkFrameTimings *previous_timings;
|
||||
gint64 previous_frame_time;
|
||||
GdkFrameTimings *timings, *previous_timings;
|
||||
gint64 previous_frame_time = 0;
|
||||
gint64 frame_time;
|
||||
gint64 history_start, history_len;
|
||||
gint64 frame;
|
||||
@@ -915,6 +915,12 @@ gtk_gears_tick (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
timings = gdk_frame_clock_get_current_timings (frame_clock);
|
||||
previous_timings = gdk_frame_clock_get_timings (frame_clock,
|
||||
gdk_frame_timings_get_frame_counter (timings) - 1);
|
||||
if (previous_timings != NULL)
|
||||
previous_frame_time = gdk_frame_timings_get_frame_time (previous_timings);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
|
@@ -156,74 +156,10 @@ demos_h = custom_target('gtk4 demo header',
|
||||
command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
|
||||
)
|
||||
|
||||
objcopy_supports_add_symbol = false
|
||||
objcopy = find_program('objcopy', required : false)
|
||||
if objcopy.found()
|
||||
objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
|
||||
endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
gtkdemo_gresource = custom_target('gtkdemo.gresource',
|
||||
input : 'demo.gresource.xml',
|
||||
output : 'gtkdemo.gresource',
|
||||
depfile : 'gtkdemo.gresource.d',
|
||||
command : [glib_compile_resources,
|
||||
'--generate',
|
||||
'--target=@OUTPUT@',
|
||||
'--dependency-file=@DEPFILE@',
|
||||
'--sourcedir=' + meson.current_source_dir(),
|
||||
'--sourcedir=' + meson.current_build_dir(),
|
||||
'@INPUT@'])
|
||||
|
||||
# Create resource data file
|
||||
gtkdemo_resources_c = custom_target('gtkdemo_resources.c',
|
||||
input : 'demo.gresource.xml',
|
||||
output : 'gtkdemo_resources.c',
|
||||
depfile : 'gtkdemo_resources.c.d',
|
||||
command : [glib_compile_resources,
|
||||
'--generate-source',
|
||||
'--target=@OUTPUT@',
|
||||
'--dependency-file=@DEPFILE@',
|
||||
'--sourcedir=' + meson.current_source_dir(),
|
||||
'--sourcedir=' + meson.current_build_dir(),
|
||||
'--external-data',
|
||||
'--c-name', '_g_binary_gtkdemo',
|
||||
'@INPUT@'])
|
||||
|
||||
# Create object file containing resource data
|
||||
gtkdemo_resources_binary = custom_target('gtkdemo_resources.o',
|
||||
input : gtkdemo_gresource,
|
||||
output : 'gtkdemo_resources.o',
|
||||
command : [ld,
|
||||
'-r',
|
||||
'-b','binary',
|
||||
'@INPUT@',
|
||||
'-o','@OUTPUT@'])
|
||||
|
||||
# Rename symbol to match the one in the C file
|
||||
gtkdemo_resources_o = custom_target('gtkdemo_resources2.o',
|
||||
input : gtkdemo_resources_binary,
|
||||
output : 'gtkdemo_resources2.o',
|
||||
command : [objcopy,
|
||||
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
|
||||
'@INPUT@',
|
||||
'@OUTPUT@'])
|
||||
|
||||
gtkdemo_resources = [
|
||||
gtkdemo_resources_c,
|
||||
gtkdemo_resources_o,
|
||||
]
|
||||
else
|
||||
gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
|
||||
'demo.gresource.xml',
|
||||
source_dir: '.',
|
||||
)
|
||||
endif
|
||||
gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
|
||||
'demo.gresource.xml',
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
# Use a subset of compiler flags
|
||||
demo_cflags = []
|
||||
|
@@ -33,7 +33,7 @@
|
||||
<developer_name>Matthias Clasen and others</developer_name>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="@BUILD_VERSION@">
|
||||
<release version="@BUILD_VERSION@" date="@BUILD_DATE@">
|
||||
<description>
|
||||
<p>A new build of GTK.</p>
|
||||
</description>
|
||||
|
@@ -32,7 +32,7 @@
|
||||
<developer_name>Matthias Clasen and others</developer_name>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="@BUILD_VERSION@">
|
||||
<release version="@BUILD_VERSION@" date="@BUILD_DATE@">
|
||||
<description>
|
||||
<p>A new build of GTK.</p>
|
||||
</description>
|
||||
|
@@ -12,9 +12,19 @@ demo_conf_h = declare_dependency(
|
||||
)
|
||||
|
||||
# appdata
|
||||
today = 'unknown'
|
||||
date = find_program('date',
|
||||
required: false)
|
||||
if date.found()
|
||||
r = run_command(date, '-I')
|
||||
if r.returncode() == 0
|
||||
today = r.stdout().strip()
|
||||
endif
|
||||
endif
|
||||
|
||||
appdata_config = configuration_data()
|
||||
appdata_config.set('BUILD_VERSION', meson.project_version())
|
||||
appdata_config.set('BUILD_DATE', today)
|
||||
|
||||
subdir('constraint-editor')
|
||||
subdir('gtk-demo')
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include "gtkrendererpaintableprivate.h"
|
||||
|
||||
#include "gsk/gskrendernodeparserprivate.h"
|
||||
#include "gsk/gl/gskglrenderer.h"
|
||||
#include "gsk/ngl/gsknglrenderer.h"
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include "gsk/broadway/gskbroadwayrenderer.h"
|
||||
#endif
|
||||
@@ -646,6 +646,7 @@ create_cairo_texture (NodeEditorWindow *self)
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *node;
|
||||
GdkTexture *texture;
|
||||
GdkSurface *surface;
|
||||
|
||||
paintable = gtk_picture_get_paintable (GTK_PICTURE (self->picture));
|
||||
if (paintable == NULL ||
|
||||
@@ -658,8 +659,9 @@ create_cairo_texture (NodeEditorWindow *self)
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
|
||||
renderer = gsk_cairo_renderer_new ();
|
||||
gsk_renderer_realize (renderer, NULL, NULL);
|
||||
gsk_renderer_realize (renderer, surface, NULL);
|
||||
|
||||
texture = gsk_renderer_render_texture (renderer, node, NULL);
|
||||
gsk_render_node_unref (node);
|
||||
@@ -837,18 +839,16 @@ node_editor_window_add_renderer (NodeEditorWindow *self,
|
||||
GskRenderer *renderer,
|
||||
const char *description)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (self));
|
||||
g_assert (surface != NULL);
|
||||
surface = gtk_native_get_surface (GTK_NATIVE (self));
|
||||
g_assert (surface != NULL);
|
||||
|
||||
if (!gsk_renderer_realize (renderer, surface, NULL))
|
||||
{
|
||||
g_object_unref (renderer);
|
||||
return;
|
||||
}
|
||||
if (renderer != NULL && !gsk_renderer_realize (renderer, surface, NULL))
|
||||
{
|
||||
g_object_unref (renderer);
|
||||
return;
|
||||
}
|
||||
|
||||
paintable = gtk_renderer_paintable_new (renderer, gtk_picture_get_paintable (GTK_PICTURE (self->picture)));
|
||||
@@ -872,7 +872,7 @@ node_editor_window_realize (GtkWidget *widget)
|
||||
"Default");
|
||||
#endif
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_gl_renderer_new (),
|
||||
gsk_ngl_renderer_new (),
|
||||
"OpenGL");
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
node_editor_window_add_renderer (self,
|
||||
|
Binary file not shown.
@@ -1,73 +1,9 @@
|
||||
# demos/widget-factory
|
||||
|
||||
objcopy_supports_add_symbol = false
|
||||
objcopy = find_program('objcopy', required : false)
|
||||
if objcopy.found()
|
||||
objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
|
||||
endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
widgetfactory_gresource = custom_target('widgetfactory.gresource',
|
||||
input : 'widget-factory.gresource.xml',
|
||||
output : 'widgetfactory.gresource',
|
||||
depfile: 'widgetfactory.gresource.d',
|
||||
command : [glib_compile_resources,
|
||||
'--generate',
|
||||
'--target=@OUTPUT@',
|
||||
'--dependency-file=@DEPFILE@',
|
||||
'--sourcedir=' + meson.current_source_dir(),
|
||||
'--sourcedir=' + meson.current_build_dir(),
|
||||
'@INPUT@'])
|
||||
|
||||
# Create resource data file
|
||||
widgetfactory_resources_c = custom_target('widgetfactory_resources.c',
|
||||
input : 'widget-factory.gresource.xml',
|
||||
output : 'widgetfactory_resources.c',
|
||||
depfile: 'widgetfactory_resources.c.d',
|
||||
command : [glib_compile_resources,
|
||||
'--generate-source',
|
||||
'--target=@OUTPUT@',
|
||||
'--dependency-file=@DEPFILE@',
|
||||
'--sourcedir=' + meson.current_source_dir(),
|
||||
'--sourcedir=' + meson.current_build_dir(),
|
||||
'--external-data',
|
||||
'--c-name', '_g_binary_widgetfactory',
|
||||
'@INPUT@'])
|
||||
|
||||
# Create object file containing resource data
|
||||
widgetfactory_resources_binary = custom_target('widgetfactory_resources.o',
|
||||
input : widgetfactory_gresource,
|
||||
output : 'widgetfactory_resources.o',
|
||||
command : [ld,
|
||||
'-r',
|
||||
'-b','binary',
|
||||
'@INPUT@',
|
||||
'-o','@OUTPUT@'])
|
||||
|
||||
# Rename symbol to match the one in the C file
|
||||
widgetfactory_resources_o = custom_target('widgetfactory_resources2.o',
|
||||
input : widgetfactory_resources_binary,
|
||||
output : 'widgetfactory_resources2.o',
|
||||
command : [objcopy,
|
||||
'--add-symbol','_g_binary_widgetfactory_resource_data=.data:0',
|
||||
'@INPUT@',
|
||||
'@OUTPUT@'])
|
||||
|
||||
widgetfactory_resources = [
|
||||
widgetfactory_resources_c,
|
||||
widgetfactory_resources_o,
|
||||
]
|
||||
else
|
||||
widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
|
||||
'widget-factory.gresource.xml',
|
||||
source_dir: '.',
|
||||
)
|
||||
endif
|
||||
widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
|
||||
'widget-factory.gresource.xml',
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
executable('gtk4-widget-factory',
|
||||
sources: ['widget-factory.c', widgetfactory_resources],
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<developer_name>Matthias Clasen and others</developer_name>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="@BUILD_VERSION@">
|
||||
<release version="@BUILD_VERSION@" date="@BUILD_DATE@">
|
||||
<description>
|
||||
<p>A new build of GTK.</p>
|
||||
</description>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gtk/WidgetFactory4">
|
||||
<file preprocess="xml-stripblanks">widget-factory.ui</file>
|
||||
<file alias='widget-factory.ui'>widget-factory.uic</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/WidgetFactory4">
|
||||
<file>widget-factory.css</file>
|
||||
|
File diff suppressed because it is too large
Load Diff
BIN
demos/widget-factory/widget-factory.uic
Normal file
BIN
demos/widget-factory/widget-factory.uic
Normal file
Binary file not shown.
@@ -13,5 +13,4 @@ baseURLs = [
|
||||
[ 'Gtk', 'https://docs.gtk.org/gtk4/' ],
|
||||
[ 'Pango', 'https://docs.gtk.org/Pango/' ],
|
||||
[ 'PangoCairo', 'https://docs.gtk.org/PangoCairo/' ],
|
||||
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
||||
]
|
||||
|
@@ -13,5 +13,4 @@ baseURLs = [
|
||||
[ 'Gtk', 'https://docs.gtk.org/gtk4/' ],
|
||||
[ 'Pango', 'https://docs.gtk.org/Pango/' ],
|
||||
[ 'PangoCairo', 'https://docs.gtk.org/PangoCairo/' ],
|
||||
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
||||
]
|
||||
|
@@ -3,13 +3,13 @@ Slug: gtk-getting-started
|
||||
|
||||
GTK is a [widget toolkit](http://en.wikipedia.org/wiki/Widget_toolkit).
|
||||
Each user interface created by GTK consists of widgets. This is implemented
|
||||
in C using [class@GObject.Object], an object-oriented framework for C. Widgets
|
||||
in C using [GObject](#gobject), an object-oriented framework for C. Widgets
|
||||
are organized in a hierarchy. The window widget is the main container.
|
||||
The user interface is then built by adding buttons, drop-down menus, input
|
||||
fields, and other widgets to the window. If you are creating complex user
|
||||
interfaces it is recommended to use GtkBuilder and its GTK-specific markup
|
||||
description language, instead of assembling the interface manually. You can
|
||||
also use a visual user interface editor, like [Glade](https://glade.gnome.org/).
|
||||
also use a visual user interface editor, like [glade](https://glade.gnome.org/).
|
||||
|
||||
GTK is event-driven. The toolkit listens for events such as a click
|
||||
on a button, and passes the event to your application.
|
||||
@@ -17,7 +17,7 @@ on a button, and passes the event to your application.
|
||||
This chapter contains some tutorial information to get you started with
|
||||
GTK programming. It assumes that you have GTK, its dependencies and a C
|
||||
compiler installed and ready to use. If you need to build GTK itself first,
|
||||
refer to the [Compiling the GTK libraries](building.html) section in this
|
||||
refer to the [Compiling the GTK libraries](#gtk-compiling) section in this
|
||||
reference.
|
||||
|
||||
## Basics
|
||||
@@ -68,7 +68,7 @@ gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs
|
||||
```
|
||||
|
||||
For more information on how to compile a GTK application, please
|
||||
refer to the [Compiling GTK Applications](compiling.html)
|
||||
refer to the [Compiling GTK Applications](#gtk-compiling)
|
||||
section in this reference.
|
||||
|
||||
All GTK applications will, of course, include `gtk/gtk.h`, which declares
|
||||
@@ -106,16 +106,16 @@ The call to [ctor@Gtk.ApplicationWindow.new] will create a new
|
||||
window will have a frame, a title bar, and window controls depending on the
|
||||
platform.
|
||||
|
||||
A window title is set using [`method@Gtk.Window.set_title`]. This function
|
||||
A window title is set using [method@Gtk.Window.set_title]. This function
|
||||
takes a `GtkWindow` pointer and a string as input. As our `window` pointer
|
||||
is a `GtkWidget` pointer, we need to cast it to `GtkWindow`; instead of
|
||||
casting `window` via a typical C cast like `(GtkWindow*)`, `window` can be
|
||||
cast using the macro `GTK_WINDOW()`. `GTK_WINDOW()` will check if the
|
||||
pointer is an instance of the `GtkWindow` class, before casting, and emit a
|
||||
warning if the check fails. More information about this convention can be
|
||||
found [in the GObject documentation](https://docs.gtk.org/gobject/concepts.html#conventions).
|
||||
found [here](https://developer.gnome.org/gobject/stable/gtype-conventions.html).
|
||||
|
||||
Finally the window size is set using [`method@Gtk.Window.set_default_size`]
|
||||
Finally the window size is set using [method@Gtk.Window.set_default_size]
|
||||
and the window is then shown by GTK via [method@Gtk.Widget.show].
|
||||
|
||||
When you close the window, by (for example) pressing the X button, the
|
||||
@@ -161,24 +161,19 @@ activate (GtkApplication *app,
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *button;
|
||||
GtkWidget *box;
|
||||
|
||||
window = gtk_application_window_new (app);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Window");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
button = gtk_button_new_with_label ("Hello World");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
gtk_window_set_child (GTK_WINDOW (window), button);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
@@ -217,10 +212,10 @@ The `GtkBox` widget is created with [ctor@Gtk.Box.new], which takes a
|
||||
this box will contain can either be laid out horizontally or vertically.
|
||||
This does not matter in this particular case, as we are dealing with only
|
||||
one button. After initializing box with the newly created `GtkBox`, the code
|
||||
adds the box widget to the window widget using [`method@Gtk.Window.set_child`].
|
||||
adds the box widget to the window widget using [method@Gtk.Window.set_child].
|
||||
|
||||
Next the `button` variable is initialized in similar manner.
|
||||
[`ctor@Gtk.Button.new_with_label`] is called which returns a
|
||||
[ctor@Gtk.Button.new_with_label] is called which returns a
|
||||
[class@Gtk.Button] to be stored in `button`. Afterwards `button` is added to
|
||||
our `box`.
|
||||
|
||||
@@ -246,8 +241,8 @@ More information about creating buttons can be found
|
||||
[here](https://wiki.gnome.org/HowDoI/Buttons).
|
||||
|
||||
The rest of the code in `example-1.c` is identical to `example-0.c`. The next
|
||||
section will elaborate further on how to add several [class@Gtk.Widget]s to your
|
||||
GTK application.
|
||||
section will elaborate further on how to add several GtkWidgets to your GTK
|
||||
application.
|
||||
|
||||
## Packing
|
||||
|
||||
@@ -256,18 +251,10 @@ a window. When you do so, it becomes important to control how each widget is
|
||||
positioned and sized. This is where packing comes in.
|
||||
|
||||
GTK comes with a large variety of _layout containers_ whose purpose it
|
||||
is to control the layout of the child widgets that are added to them, like:
|
||||
is to control the layout of the child widgets that are added to them.
|
||||
See [Layout containers](#LayoutContainers) for an overview.
|
||||
|
||||
- [class@Gtk.Box]
|
||||
- [class@Gtk.Grid]
|
||||
- [class@Gtk.Revealer]
|
||||
- [class@Gtk.Stack]
|
||||
- [class@Gtk.Overlay]
|
||||
- [class@Gtk.Paned]
|
||||
- [class@Gtk.Expander]
|
||||
- [class@Gtk.Fixed]
|
||||
|
||||
The following example shows how the [class@Gtk.Grid] container lets you
|
||||
The following example shows how the GtkGrid container lets you
|
||||
arrange several buttons:
|
||||
|
||||

|
||||
@@ -366,11 +353,11 @@ draw function.
|
||||
The contents of a widget often need to be partially or fully redrawn, e.g.
|
||||
when another window is moved and uncovers part of the widget, or when the
|
||||
window containing it is resized. It is also possible to explicitly cause a
|
||||
widget to be redrawn, by calling [`method@Gtk.Widget.queue_draw`]. GTK takes
|
||||
widget to be redrawn, by calling [method@Gtk.Widget.queue_draw]. GTK takes
|
||||
care of most of the details by providing a ready-to-use cairo context to the
|
||||
draw function.
|
||||
|
||||
The following example shows how to use a draw function with [class@Gtk.DrawingArea].
|
||||
The following example shows how to use a draw function with GtkDrawingArea.
|
||||
It is a bit more complicated than the previous examples, since it also
|
||||
demonstrates input event handling with event controllers.
|
||||
|
||||
@@ -415,9 +402,9 @@ resize_cb (GtkWidget *widget,
|
||||
if (gtk_native_get_surface (gtk_widget_get_native (widget)))
|
||||
{
|
||||
surface = gdk_surface_create_similar_surface (gtk_native_get_surface (gtk_widget_get_native (widget)),
|
||||
CAIRO_CONTENT_COLOR,
|
||||
gtk_widget_get_width (widget),
|
||||
gtk_widget_get_height (widget));
|
||||
CAIRO_CONTENT_COLOR,
|
||||
gtk_widget_get_width (widget),
|
||||
gtk_widget_get_height (widget));
|
||||
|
||||
/* Initialize the surface to white */
|
||||
clear_surface ();
|
||||
@@ -703,16 +690,16 @@ gcc $( pkg-config --cflags gtk4 ) -o example-3 example-3.c $( pkg-config --libs
|
||||
|
||||
Note that `GtkBuilder` can also be used to construct objects that are
|
||||
not widgets, such as tree models, adjustments, etc. That is the reason
|
||||
the method we use here is called [`method@Gtk.Builder.get_object`] and
|
||||
returns a `GObject` instead of a `GtkWidget`.
|
||||
the method we use here is called [method@Gtk.Builder.get_object] and returns
|
||||
a `GObject` instead of a `GtkWidget`.
|
||||
|
||||
Normally, you would pass a full path to [`method@Gtk.Builder.add_from_file`] to
|
||||
Normally, you would pass a full path to [method@Gtk.Builder.add_from_file] to
|
||||
make the execution of your program independent of the current directory.
|
||||
A common location to install UI descriptions and similar data is
|
||||
`/usr/share/appname`.
|
||||
|
||||
It is also possible to embed the UI description in the source code as a
|
||||
string and use [`method@Gtk.Builder.add_from_string`] to load it. But keeping the
|
||||
string and use [method@Gtk.Builder.add_from_string] to load it. But keeping the
|
||||
UI description in a separate file has several advantages: It is then possible
|
||||
to make minor adjustments to the UI without recompiling your program, and,
|
||||
more importantly, graphical UI editors such as [Glade](http://glade.gnome.org)
|
||||
@@ -775,17 +762,17 @@ main (int argc, char *argv[])
|
||||
```
|
||||
|
||||
All the application logic is in the application class, which is a subclass of
|
||||
`GtkApplication`. Our example does not yet have any interesting functionality.
|
||||
GtkApplication. Our example does not yet have any interesting functionality.
|
||||
All it does is open a window when it is activated without arguments, and open
|
||||
the files it is given, if it is started with arguments.
|
||||
|
||||
To handle these two cases, we override the `activate()` vfunc, which gets
|
||||
To handle these two cases, we override the activate() vfunc, which gets
|
||||
called when the application is launched without commandline arguments, and
|
||||
the `open()` virtual function, which gets called when the application is
|
||||
launched with commandline arguments.
|
||||
|
||||
To learn more about `GApplication` entry points, consult the GIO
|
||||
[documentation](https://docs.gtk.org/gio/class.Application.html).
|
||||
[documentation](https://developer.gnome.org/gio/stable/GApplication.html#GApplication.description).
|
||||
|
||||
```c
|
||||
#include <gtk/gtk.h>
|
||||
@@ -854,8 +841,8 @@ example_app_new (void)
|
||||
```
|
||||
|
||||
Another important class that is part of the application support in GTK is
|
||||
[class@Gtk.ApplicationWindow]. It is typically subclassed as well. Our
|
||||
subclass does not do anything yet, so we will just get an empty window.
|
||||
`GtkApplicationWindow`. It is typically subclassed as well. Our subclass does
|
||||
not do anything yet, so we will just get an empty window.
|
||||
|
||||
```c
|
||||
#include <gtk/gtk.h>
|
||||
@@ -920,10 +907,10 @@ and it accepts files as commandline arguments.
|
||||
|
||||
### Populating the window
|
||||
|
||||
In this step, we use a `GtkBuilder` template to associate a
|
||||
`GtkBuilder` ui file with our application window class.
|
||||
In this step, we use a GtkBuilder template to associate a
|
||||
GtkBuilder ui file with our application window class.
|
||||
|
||||
Our simple ui file gives the window a title, and puts a `GtkStack`
|
||||
Our simple ui file gives the window a title, and puts a GtkStack
|
||||
widget as the main content.
|
||||
|
||||
```xml
|
||||
@@ -947,9 +934,9 @@ widget as the main content.
|
||||
|
||||
To make use of this file in our application, we revisit our
|
||||
`GtkApplicationWindow` subclass, and call
|
||||
[`method@Gtk.WidgetClass.set_template_from_resource`] from the class init
|
||||
`gtk_widget_class_set_template_from_resource()` from the class init
|
||||
function to set the ui file as template for this class. We also
|
||||
add a call to [`method@Gtk.Widget.init_template`] in the instance init
|
||||
add a call to `gtk_widget_init_template()` in the instance init
|
||||
function to instantiate the template for each instance of our
|
||||
class.
|
||||
|
||||
@@ -976,7 +963,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
|
||||
You may have noticed that we used the `_from_resource()` variant of the function
|
||||
that sets a template. Now we need to use
|
||||
[GLib's resource functionality](https://docs.gtk.org/gio/struct.Resource.html)
|
||||
[GLib's resource functionality](https://developer.gnome.org/gio/stable/GResource.html)
|
||||
to include the ui file in the binary. This is commonly done by listing all resources
|
||||
in a `.gresource.xml` file, such as this:
|
||||
|
||||
@@ -998,7 +985,7 @@ glib-compile-resources exampleapp.gresource.xml --target=resources.c --generate-
|
||||
```
|
||||
|
||||
The gnome module of the [Meson build system](https://mesonbuild.com)
|
||||
provides the [`gnome.compile_resources()`](https://mesonbuild.com/Gnome-module.html#gnomecompile_resources)
|
||||
provides the [gnome.compile_resources()](https://mesonbuild.com/Gnome-module.html#gnomecompile_resources)
|
||||
method for this task.
|
||||
|
||||
Our application now looks like this:
|
||||
@@ -1014,7 +1001,7 @@ To this end, we add a member to the struct of our application window subclass
|
||||
and keep a reference to the `GtkStack` there. The first member of the struct
|
||||
should be the parent type from which the class is derived. Here,
|
||||
`ExampleAppWindow` is derived from `GtkApplicationWindow`. The
|
||||
[`func@Gtk.widget_class_bind_template_child`] function arranges things so that after
|
||||
`gtk_widget_class_bind_template_child()` function arranges things so that after
|
||||
instantiating the template, the `stack` member of the struct will point to the
|
||||
widget of the same name from the template.
|
||||
|
||||
@@ -1094,7 +1081,7 @@ tell it to display information about our stack.
|
||||
|
||||
The stack switcher gets all its information it needs to display tabs from
|
||||
the stack that it belongs to. Here, we are passing the label to show for
|
||||
each file as the last argument to the [`method@Gtk.Stack.add_titled`]
|
||||
each file as the last argument to the [method@Gtk.Stack.add_titled]
|
||||
function.
|
||||
|
||||
Our application is beginning to take shape:
|
||||
@@ -1134,7 +1121,7 @@ resulting menu model with the menu button that we've added to the headerbar.
|
||||
Since menus work by activating GActions, we also have to add a suitable set
|
||||
of actions to our application.
|
||||
|
||||
Adding the actions is best done in the `startup()` vfunc, which is guaranteed
|
||||
Adding the actions is best done in the startup() vfunc, which is guaranteed
|
||||
to be called once for each primary application instance:
|
||||
|
||||
```c
|
||||
@@ -1192,7 +1179,7 @@ example_app_class_init (ExampleAppClass *class)
|
||||
|
||||
Our preferences menu item does not do anything yet, but the Quit menu item
|
||||
is fully functional. Note that it can also be activated by the usual Ctrl-Q
|
||||
shortcut. The shortcut was added with [`method@Gtk.Application.set_accels_for_action`].
|
||||
shortcut. The shortcut was added with `gtk_application_set_accels_for_action()`.
|
||||
|
||||
The application menu looks like this:
|
||||
|
||||
@@ -1204,7 +1191,7 @@ A typical application will have a some preferences that should be remembered
|
||||
from one run to the next. Even for our simple example application, we may
|
||||
want to change the font that is used for the content.
|
||||
|
||||
We are going to use [class@Gio.Settings] to store our preferences. `GSettings` requires
|
||||
We are going to use `GSettings` to store our preferences. `GSettings` requires
|
||||
a schema that describes our settings:
|
||||
|
||||
```xml
|
||||
@@ -1231,9 +1218,10 @@ a schema that describes our settings:
|
||||
```
|
||||
|
||||
Before we can make use of this schema in our application, we need to compile
|
||||
it into the binary form that GSettings expects. GIO provides macros to do
|
||||
this in Autotools-based projects, and the gnome module of the Meson build
|
||||
system provides the [`gnome.compile_schemas()`](https://mesonbuild.com/Gnome-module.html#gnomecompile_schemas)
|
||||
it into the binary form that GSettings expects. GIO provides
|
||||
[macros](https://developer.gnome.org/gio/2.36/ch31s06.html) to do this in
|
||||
autotools-based projects, and the gnome module of the Meson build system
|
||||
provides the [gnome.compile_schemas()](https://mesonbuild.com/Gnome-module.html#gnomecompile_schemas)
|
||||
method for this task.
|
||||
|
||||
Next, we need to connect our settings to the widgets that they are supposed
|
||||
@@ -1693,8 +1681,7 @@ What our application looks like now:
|
||||
Widgets and other objects have many useful properties.
|
||||
|
||||
Here we show some ways to use them in new and flexible ways, by wrapping
|
||||
them in actions with [class@Gio.PropertyAction] or by binding them with
|
||||
[class@GObject.Binding].
|
||||
them in actions with `GPropertyAction` or by binding them with `GBinding`.
|
||||
|
||||
To set this up, we add two labels to the header bar in our window template,
|
||||
named `lines_label` and `lines`, and bind them to struct members in the
|
||||
|
@@ -1,57 +0,0 @@
|
||||
.. _gtk4-broadwayd(1):
|
||||
|
||||
==============
|
||||
gtk4-broadwayd
|
||||
==============
|
||||
|
||||
---------------------------
|
||||
The Broadway display server
|
||||
---------------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>
|
||||
| **gtk4-broadwayd** --port=PORT --address=ADDRESS <DISPLAY>
|
||||
| **gtk4-broadwayd** --unixaddress=ADDRESS <DISPLAY>
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-broadwayd`` is a display server for the Broadway GDK backend. It allows
|
||||
multiple GTK applications to display their windows in the same web browser, by
|
||||
connecting to gtk4-broadwayd.
|
||||
|
||||
When using gtk4-broadwayd, specify the display number to use, prefixed with a
|
||||
colon, similar to X. The default display number is 0.
|
||||
|
||||
::
|
||||
|
||||
gtk4-broadwayd :5
|
||||
|
||||
|
||||
Then point your web browser at ``http://127.0.0.1:8085``.
|
||||
|
||||
Start your applications like this:
|
||||
|
||||
::
|
||||
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
|
||||
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``--port PORT``
|
||||
|
||||
Use the given ``PORT`` for the HTTP connection, instead of the default ``8080 + (DISPLAY - 1)``.
|
||||
|
||||
``--address ADDRESS``
|
||||
|
||||
Use the given ``address`` for the HTTP connection, instead of the default ``http://127.0.0.1``.
|
||||
|
||||
``--unixsocket ADDRESS``
|
||||
|
||||
Use the given ``address`` as the unix domain socket address. This option
|
||||
overrides ``--address`` and ``--port``, and it is available only on Unix-like
|
||||
systems.
|
84
docs/reference/gtk/gtk4-broadwayd.xml
Normal file
84
docs/reference/gtk/gtk4-broadwayd.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-broadwayd">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-broadwayd</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Alexander</firstname>
|
||||
<surname>Larsson</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-broadwayd</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-broadwayd</refname>
|
||||
<refpurpose>Broadway display server</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-broadwayd</command>
|
||||
<arg choice="opt">--port <replaceable>PORT</replaceable></arg>
|
||||
<arg choice="opt">--address <replaceable>ADDRESS</replaceable></arg>
|
||||
<arg choice="opt">--unixsocket <replaceable>ADDRESS</replaceable></arg>
|
||||
<arg choice="opt"><replaceable>:DISPLAY</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-broadwayd</command> is a display server for the Broadway
|
||||
GDK backend. It allows multiple GTK applications to display their
|
||||
windows in the same web browser, by connecting to gtk4-broadwayd.
|
||||
</para>
|
||||
<para>
|
||||
When using gtk4-broadwayd, specify the display number to use, prefixed
|
||||
with a colon, similar to X. The default display number is 0.
|
||||
<programlisting>
|
||||
gtk4-broadwayd :5
|
||||
</programlisting>
|
||||
Then point your web browser at <literal>http://127.0.0.1:8085</literal>.
|
||||
Start your applications like this:
|
||||
<programlisting>
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>--port</term>
|
||||
<listitem><para>Use <replaceable>PORT</replaceable> as the HTTP
|
||||
port, instead of the default 8080 + (<replaceable>DISPLAY</replaceable> - 1).
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>--address</term>
|
||||
<listitem><para>Use <replaceable>ADDRESS</replaceable> as the HTTP
|
||||
address, instead of the default <literal>http://127.0.0.1:<replaceable>PORT</replaceable></literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>--unixsocket</term>
|
||||
<listitem><para>Use <replaceable>ADDRESS</replaceable> as the unix domain socket
|
||||
address. This option overrides <literal>--address</literal> and <literal>--port</literal>.
|
||||
It is available only on Unix-like systems.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,85 +0,0 @@
|
||||
.. _gtk4-builder-tool(1):
|
||||
|
||||
=================
|
||||
gtk4-builder-tool
|
||||
=================
|
||||
|
||||
-----------------------
|
||||
GtkBuilder File Utility
|
||||
-----------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||
|
|
||||
| **gtk4-builder-tool** validate <FILE>
|
||||
| **gtk4-builder-tool** enumerate <FILE>
|
||||
| **gtk4-builder-tool** simplify [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** preview [OPTIONS...] <FILE>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-builder-tool`` can perform various operations on GtkBuilder UI definition
|
||||
files.
|
||||
|
||||
COMMANDS
|
||||
--------
|
||||
|
||||
Validation
|
||||
^^^^^^^^^^
|
||||
|
||||
The ``validate`` command validates the given UI definition file and reports
|
||||
errors to ``stderr``.
|
||||
|
||||
Enumeration
|
||||
^^^^^^^^^^^
|
||||
|
||||
The ``enumerate`` command lists all the named objects that are present in the UI
|
||||
definition file.
|
||||
|
||||
Preview
|
||||
^^^^^^^
|
||||
|
||||
The ``preview`` command displays the UI dfinition file.
|
||||
|
||||
This command accepts options to specify the ID of the toplevel object and a CSS
|
||||
file to use.
|
||||
|
||||
``--id=ID``
|
||||
|
||||
The ID of the object to preview. If not specified, gtk4-builder-tool will
|
||||
choose a suitable object on its own.
|
||||
|
||||
``--css=FILE``
|
||||
|
||||
Load style information from the given CSS file.
|
||||
|
||||
Simplification
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
The ``simplify`` command simplifies the UI definition file by removing
|
||||
properties that are set to their default values and writes the resulting XML to
|
||||
the standard output, or back to the input file.
|
||||
|
||||
When the ``--3to4`` option is specified, the ``simplify`` command interprets the
|
||||
input as a GTK 3 UI definuition file and attempts to convert it to GTK 4
|
||||
equivalents. It performs various conversions, such as renaming properties,
|
||||
translating child properties to layout properties, rewriting the setup for
|
||||
GtkNotebook, GtkStack, GtkAssistant or changing toolbars into boxes.
|
||||
|
||||
You should always test the modified UI definition files produced by
|
||||
gtk4-builder-tool before using them in production.
|
||||
|
||||
Note in particular that the conversion done with ``--3to4`` is meant as a
|
||||
starting point for a port from GTK 3 to GTK 4. It is expected that you will have
|
||||
to do manual fixups after the initial conversion.
|
||||
|
||||
``--replace``
|
||||
|
||||
Write the content back to the UI definition file instead of using the standard
|
||||
output.
|
||||
|
||||
``--3to4``
|
||||
|
||||
Transform a GTK 3 UI definition file to the equivalent GTK 4 definitions.
|
110
docs/reference/gtk/gtk4-builder-tool.xml
Normal file
110
docs/reference/gtk/gtk4-builder-tool.xml
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-builder-tool">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-builder-tool</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-builder-tool</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-builder-tool</refname>
|
||||
<refpurpose>GtkBuilder file utility</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-builder-tool</command>
|
||||
<arg choice="opt"><replaceable>COMMAND</replaceable></arg>
|
||||
<arg choice="opt" rep="repeat"><replaceable>OPTION</replaceable></arg>
|
||||
<arg choice="plain"><replaceable>FILE</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-builder-tool</command> can perform various operations
|
||||
on GtkBuilder .ui files.
|
||||
</para>
|
||||
<para>
|
||||
The <option>validate</option> command validates the .ui file and reports
|
||||
errors to stderr.
|
||||
</para>
|
||||
<para>
|
||||
The <option>enumerate</option> command lists all the named objects that
|
||||
are created in the .ui file.
|
||||
</para>
|
||||
<para>
|
||||
The <option>preview</option> command displays the .ui file. This command
|
||||
accepts options to specify the ID of the toplevel object and a .css file
|
||||
to use.
|
||||
</para>
|
||||
<para>
|
||||
The <option>simplify</option> command simplifies the .ui file by removing
|
||||
properties that are set to their default values and writes the resulting XML
|
||||
to stdout, or back to the input file.
|
||||
</para>
|
||||
<para>
|
||||
When the <option>--3to4</option> is specified, <option>simplify</option>
|
||||
interprets the input as a GTK 3 ui file and attempts to convert it to GTK 4
|
||||
equivalents. It performs various conversions, such as renaming properties,
|
||||
translating child properties to layout properties, rewriting the setup for
|
||||
GtkNotebook, GtkStack, GtkAssistant or changing toolbars into boxes.
|
||||
</para>
|
||||
<para>
|
||||
You should always test the modified .ui files produced by gtk4-builder-tool
|
||||
before using them in production.
|
||||
</para>
|
||||
<para>
|
||||
Note in particular that the conversion
|
||||
done with <option>--3to4</option> is meant as a starting point for a port
|
||||
from GTK 3 to GTK 4. It is expected that you will have to do manual fixups
|
||||
after the initial conversion.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Simplify Options</title>
|
||||
<para>The <option>simplify</option> command accepts the following options:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>--replace</option></term>
|
||||
<listitem><para>Write the content back to the .ui file instead of stdout.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--3to4</option></term>
|
||||
<listitem><para>Transform a GTK 3 ui file to GTK 4</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Preview Options</title>
|
||||
<para>The <option>preview</option> command accepts the following options:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>--id=<arg choice="plain">ID</arg></option></term>
|
||||
<listitem><para>The ID of the object to preview. If not specified,
|
||||
gtk4-builder-tool will choose a suitable object on its own.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--css=<arg choice="plain">FILE</arg></option></term>
|
||||
<listitem><para>Load style information from the given .css file.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,22 +0,0 @@
|
||||
.. _gtk4-demo-application(1):
|
||||
|
||||
=====================
|
||||
gtk4-demo-application
|
||||
=====================
|
||||
|
||||
--------------------------
|
||||
Demonstrate GtkApplication
|
||||
--------------------------
|
||||
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-demo-application**
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-demo-application`` is an example application used by ``gtk4-demo``.
|
||||
|
||||
There is no need to call it manually.
|
44
docs/reference/gtk/gtk4-demo-application.xml
Normal file
44
docs/reference/gtk/gtk4-demo-application.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-demo-application">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-demo-application</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-demo-application</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-demo-application</refname>
|
||||
<refpurpose>Demonstrate GtkApplication</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-demo-application</command>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-demo-application</command> is an example application
|
||||
used by <command>gtk4-demo</command>. There is no need to call it
|
||||
manually.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,48 +0,0 @@
|
||||
.. _gtk4-demo(1):
|
||||
|
||||
=========
|
||||
gtk4-demo
|
||||
=========
|
||||
|
||||
-----------------------
|
||||
Demonstrate GTK widgets
|
||||
-----------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-demo** [OPTIONS...]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-demo`` is a collection of examples.
|
||||
|
||||
Its purpose is to demonstrate many GTK widgets in a form that is useful to
|
||||
application developers.
|
||||
|
||||
The application shows the source code for each example, as well as other used
|
||||
resources, such as UI description files and image assets.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-h, --help``
|
||||
|
||||
Show help options.
|
||||
|
||||
``--version``
|
||||
|
||||
Show program version.
|
||||
|
||||
``--list``
|
||||
|
||||
List available examples.
|
||||
|
||||
``--run EXAMPLE``
|
||||
|
||||
Run the named example. Use ``--list`` to see the available examples.
|
||||
|
||||
``--autoquit``
|
||||
|
||||
Quit after a short timeout. This is intended for use with ``--run``, e.g. when profiling.
|
81
docs/reference/gtk/gtk4-demo.xml
Normal file
81
docs/reference/gtk/gtk4-demo.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-demo">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-demo</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-demo</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-demo</refname>
|
||||
<refpurpose>Demonstrate GTK widgets</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-demo</command>
|
||||
<arg choice="opt">--help</arg>
|
||||
<arg choice="opt">--version</arg>
|
||||
<arg choice="opt">--list</arg>
|
||||
<arg choice="opt">--run <replaceable>EXAMPLE</replaceable></arg>
|
||||
<arg choice="opt">--autoquit</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-demo</command> is a collection of examples.
|
||||
Its purpose is to demonstrate many GTK widgets in a form
|
||||
that is useful to application developers.
|
||||
</para>
|
||||
<para>
|
||||
The application shows the source code for each example, as well as
|
||||
other used resources, such as ui files and icons.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<para>The following options are understood:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-h</option>, <option>--help</option></term>
|
||||
<listitem><para>Show help options</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
<listitem><para>Show program version</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--list</option></term>
|
||||
<listitem><para>List available examples.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-run <replaceable>EXAMPLE</replaceable></option></term>
|
||||
<listitem><para>Run the named example. Use <option>--list</option> to
|
||||
see the available examples.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--autoquit</option></term>
|
||||
<listitem><para>Quit after a short timeout. This is intended for use
|
||||
with <option>--run</option>, e.g. when profiling.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,40 +0,0 @@
|
||||
.. _gtk4-encode-symbolic-svg(1):
|
||||
|
||||
========================
|
||||
gtk4-encode-symbolic-svg
|
||||
========================
|
||||
|
||||
--------------------------------
|
||||
Symbolic icon conversion utility
|
||||
--------------------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-encode-symbolic-svg** [OPTIONS...] <PATH> <WIDTH>x<HEIGHT>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-encode-symbolic-svg`` converts symbolic SVG icons into specially prepared
|
||||
PNG files. GTK can load and recolor these PNGs, just like original SVGs, but
|
||||
loading them is much faster.
|
||||
|
||||
``PATH`` is the name of a symbolic SVG file, ``WIDTH`` x ``HEIGHT`` are the
|
||||
desired dimensions for the generated PNG file.
|
||||
|
||||
To distinguish them from ordinary PNGs, the generated files have the extension
|
||||
``.symbolic.png``.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-o, --output DIRECTORY``
|
||||
|
||||
Write png files to ``DIRECTORY`` instead of the current working directory.
|
||||
|
||||
``--debug``
|
||||
|
||||
Generate PNG files of the various channels during the conversion. If these
|
||||
files are not monochrome green, they are often helpful in pinpointing the
|
||||
problematic parts of the source SVG.
|
74
docs/reference/gtk/gtk4-encode-symbolic-svg.xml
Normal file
74
docs/reference/gtk/gtk4-encode-symbolic-svg.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-encode-symbolic-svg">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-encode-symbolic-svg</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Alexander</firstname>
|
||||
<surname>Larsson</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-encode-symbolic-svg</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-encode-symbolic-svg</refname>
|
||||
<refpurpose>Symbolic icon conversion utility</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-encode-symbolic-svg</command>
|
||||
<arg choice="opt">OPTION...</arg>
|
||||
<arg choice="plain"><replaceable>PATH</replaceable></arg>
|
||||
<arg choice="plain"><replaceable>WIDTH</replaceable>x<replaceable>HEIGHT</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-encode-symbolic-svg</command> converts symbolic svg icons into
|
||||
specially prepared png files. GTK can load and recolor these pngs, just like
|
||||
original svgs, but loading them is much faster.
|
||||
</para>
|
||||
<para>
|
||||
<replaceable>PATH</replaceable> is the name of a symbolic svg file,
|
||||
<replaceable>WIDTH</replaceable>x<replaceable>HEIGHT</replaceable> are the
|
||||
desired dimensions for the generated png file.
|
||||
</para>
|
||||
<para>
|
||||
To distinguish them from ordinary pngs, the generated files have the extension
|
||||
<filename>.symbolic.png</filename>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-o <replaceable>DIRECTORY</replaceable></term>
|
||||
<term>--output <replaceable>DIRECTORY</replaceable></term>
|
||||
<listitem><para>Write png files to <replaceable>DIRECTORY</replaceable>
|
||||
instead of the current working directory.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>--debug</term>
|
||||
<listitem><para>Generate png files of the various channels during
|
||||
the conversion. If these files are not monochrome green, they
|
||||
are often helpful in pinpointing the problematic parts of
|
||||
the source svg.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,28 +0,0 @@
|
||||
.. _gtk4-icon-browser(1):
|
||||
|
||||
=================
|
||||
gtk4-icon-browser
|
||||
=================
|
||||
|
||||
-----------------
|
||||
List themed icons
|
||||
-----------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-icon-browser** [OPTIONS...]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-icon-browser`` is a utility to explore the icons in the current icon
|
||||
theme. It shows icons in various sizes, their symbolic variants where available,
|
||||
as well as a description of the icon and its context.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-h, --help``
|
||||
|
||||
Show the application help.
|
55
docs/reference/gtk/gtk4-icon-browser.xml
Normal file
55
docs/reference/gtk/gtk4-icon-browser.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-icon-browser">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-icon-browser</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-icon-browser</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-icon-browser</refname>
|
||||
<refpurpose>List themed icons</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-icon-browser</command>
|
||||
<arg choice="opt">--help</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-icon-browser</command> is a utility to explore the icons
|
||||
in the current icon theme. It shows icons in various sizes, their symbolic
|
||||
variants where available, as well as a description of the icon and its context.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<para>The following options are understood:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-h</option>, <option>--help</option></term>
|
||||
<listitem><para>Show help options</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,50 +0,0 @@
|
||||
.. _gtk4-launch(1):
|
||||
|
||||
===========
|
||||
gtk4-launch
|
||||
===========
|
||||
|
||||
---------------------
|
||||
Launch an application
|
||||
---------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-launch** [OPTIONS...] <APPLICATION> [URI...]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-launch`` launches an application using the given name. The application is
|
||||
started with proper startup notification on a default display, unless specified
|
||||
otherwise.
|
||||
|
||||
``gtk4-launch`` takes at least one argument, the name of the application to
|
||||
launch. The name should match application desktop file name, as residing in the
|
||||
applications subdirectories of the XDG data directories, with or without the
|
||||
``.desktop`` suffix.
|
||||
|
||||
If called with more than one argument, the rest of them besides the application
|
||||
name are considered URI locations and are passed as arguments to the launched
|
||||
application.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-?, -h, --help``
|
||||
|
||||
Print the command's help and exit.
|
||||
|
||||
``--version``
|
||||
|
||||
Print the command's version and exit.
|
||||
|
||||
ENVIRONMENT
|
||||
-----------
|
||||
|
||||
Some environment variables affect the behavior of ``gtk4-launch``:
|
||||
|
||||
``XDG_DATA_HOME, XDG_DATA_DIRS``
|
||||
|
||||
The environment variables specifying the XDG data directories.
|
85
docs/reference/gtk/gtk4-launch.xml
Normal file
85
docs/reference/gtk/gtk4-launch.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-launch">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-launch</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Tomáš</firstname>
|
||||
<surname>Bžatek</surname>
|
||||
<email>tbzatek@redhat.com</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-launch</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-launch</refname>
|
||||
<refpurpose>Launch an application</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-launch</command>
|
||||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
<arg choice="plain">APPLICATION</arg>
|
||||
<arg choice="opt" rep="repeat">URI</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-launch</command> launches an application using the given name.
|
||||
The application is started with proper startup notification on a default
|
||||
display, unless specified otherwise.
|
||||
</para>
|
||||
<para>
|
||||
<command>gtk4-launch</command> takes at least one argument, the name of
|
||||
the application to launch. The name should match application desktop file name,
|
||||
as residing in the applications subdirectories of the XDG data directories, with
|
||||
or without the '.desktop' suffix.
|
||||
</para>
|
||||
<para>
|
||||
If called with more than one argument, the rest of them besides the application
|
||||
name are considered URI locations and are passed as arguments to the launched
|
||||
application.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<para>The following options are understood:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-?</option>, <option>--help</option></term>
|
||||
<listitem><para>Prints a short help text and exits.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
<listitem><para>Prints the program version and exits.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Environment</title>
|
||||
<para>Some environment variables affect the behavior of <command>gtk4-launch</command>.</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>XDG_DATA_HOME</option>, <option>XDG_DATA_DIRS</option></term>
|
||||
<listitem><para>The environment variables specifying the XDG dta directories.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,21 +0,0 @@
|
||||
.. _gtk4-query-settings(1):
|
||||
|
||||
===================
|
||||
gtk4-query-settings
|
||||
===================
|
||||
|
||||
------------------------------------
|
||||
Print name and value of GTK settings
|
||||
------------------------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-query-settings** [PATTERN]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-query-settings`` prints both name and value of all properties available
|
||||
in the ``GtkSettings`` class. Optionally, you can filter which properties to
|
||||
list by specifying a ``PATTERN``.
|
45
docs/reference/gtk/gtk4-query-settings.xml
Normal file
45
docs/reference/gtk/gtk4-query-settings.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-query-settings">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-query-settings</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Timm</firstname>
|
||||
<surname>Bäder</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-query-settings</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-query-settings</refname>
|
||||
<refpurpose>Utility to print name and value of all GtkSettings properties</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-query-settings</command>
|
||||
<arg choice="opt"><replaceable>PATTERN</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-query-settings</command> prints both name and value of all properties
|
||||
available in the GtkSettings class. Optionally, you can filter which properties
|
||||
to list by specifying a PATTERN.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,65 +0,0 @@
|
||||
.. _gtk4-update-icon-cache(1):
|
||||
|
||||
======================
|
||||
gtk4-update-icon-cache
|
||||
======================
|
||||
|
||||
--------------------------
|
||||
Icon theme caching utility
|
||||
--------------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-update-icon-cache** [OPTIONS...] <PATH>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-update-icon-cache`` creates ``mmap(2)``-able cache files for icon themes.
|
||||
|
||||
It expects to be given the ``PATH`` to an icon theme directory containing an
|
||||
``index.theme``, e.g. ``/usr/share/icons/hicolor``, and writes a
|
||||
``icon-theme.cache`` containing cached information about the icons in the
|
||||
directory tree below the given directory.
|
||||
|
||||
GTK can use the cache files created by ``gtk4-update-icon-cache`` to avoid a lot
|
||||
of system call and disk seek overhead when the application starts. Since the
|
||||
format of the cache files allows them to be shared across multiple processes,
|
||||
for instance using the POSIX ``mmap(2)`` system call, the overall memory
|
||||
consumption is reduced as well.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-f, --force``
|
||||
|
||||
Overwrite an existing cache file even if it appears to be up-to-date.
|
||||
|
||||
``-t, --ignore-theme-index``
|
||||
|
||||
Don't check for the existence of ``index.theme`` in the icon theme directory.
|
||||
Without this option, ``gtk4-update-icon-cache`` refuses to create an icon
|
||||
cache in a directory which does not appear to be the toplevel directory of an
|
||||
icon theme.
|
||||
|
||||
``-i, --index-only``
|
||||
|
||||
Don't include image data in the cache.
|
||||
|
||||
``--include-image-data``
|
||||
|
||||
Include image data in the cache.
|
||||
|
||||
``-c, --source <NAME>``
|
||||
|
||||
Output a C header file declaring a constant ``NAME`` with the contents of the
|
||||
icon cache.
|
||||
|
||||
``-q, --quiet``
|
||||
|
||||
Turn off verbose output.
|
||||
|
||||
``-v, --validate``
|
||||
|
||||
Validate existing icon cache.
|
123
docs/reference/gtk/gtk4-update-icon-cache.xml
Normal file
123
docs/reference/gtk/gtk4-update-icon-cache.xml
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-update-icon-cache">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-update-icon-cache</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-update-icon-cache</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-update-icon-cache</refname>
|
||||
<refpurpose>Icon theme caching utility</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-update-icon-cache</command>
|
||||
<arg choice="opt">--force</arg>
|
||||
<arg choice="opt">--ignore-theme-index</arg>
|
||||
<group>
|
||||
<arg choice="plain">--index-only</arg>
|
||||
<arg choice="plain">--include-image-data</arg>
|
||||
</group>
|
||||
<arg choice="opt">--source <arg choice="plain"><replaceable>NAME</replaceable></arg></arg>
|
||||
<arg choice="opt">--quiet</arg>
|
||||
<arg choice="opt">--validate</arg>
|
||||
<arg choice="plain"><replaceable>PATH</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-update-icon-cache</command> creates mmapable cache
|
||||
files for icon themes.
|
||||
</para>
|
||||
<para>
|
||||
It expects to be given the <replaceable>PATH</replaceable> to an icon theme
|
||||
directory containing an <filename>index.theme</filename>, e.g.
|
||||
<filename>/usr/share/icons/hicolor</filename>, and writes a
|
||||
<filename>icon-theme.cache</filename> containing cached information about
|
||||
the icons in the directory tree below the given directory.
|
||||
</para>
|
||||
<para>
|
||||
GTK can use the cache files created by <command>gtk4-update-icon-cache</command>
|
||||
to avoid a lot of system call and disk seek overhead when the application
|
||||
starts. Since the format of the cache files allows them to be shared across
|
||||
multiple processes, for instance using the POSIX <command>mmap()</command> system
|
||||
call, the overall memory consumption is reduced as well.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>--force</term>
|
||||
<term>-f</term>
|
||||
<listitem><para>Overwrite an existing cache file even if it appears to be
|
||||
up-to-date.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--ignore-theme-index</term>
|
||||
<term>-t</term>
|
||||
<listitem><para>Don't check for the existence of <filename>index.theme</filename>
|
||||
in the icon theme directory. Without this option, <command>gtk4-update-icon-cache</command>
|
||||
refuses to create an icon cache in a directory which does not appear to
|
||||
be the toplevel directory of an icon theme.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--index-only</term>
|
||||
<term>-i</term>
|
||||
<listitem><para>Don't include image data in the cache.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--include-image-data</term>
|
||||
<listitem><para>Include image data in the cache.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--source</term>
|
||||
<term>-c</term>
|
||||
<listitem><para>Output a C header file declaring a constant
|
||||
<replaceable>NAME</replaceable> with the contents of the icon
|
||||
cache.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--quiet</term>
|
||||
<term>-q</term>
|
||||
<listitem><para>Turn off verbose output.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>--validate</term>
|
||||
<term>-v</term>
|
||||
<listitem><para>Validate existing icon cache.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -1,34 +0,0 @@
|
||||
.. _gtk4-widget-factory(1):
|
||||
|
||||
===================
|
||||
gtk4-widget-factory
|
||||
===================
|
||||
|
||||
-------------------------------
|
||||
Showcase GTK widgets and styles
|
||||
-------------------------------
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
| **gtk4-widget-factory** [OPTIONS...]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-widget-factory`` is a collection of examples.
|
||||
|
||||
Its purpose is to demonstrate many GTK widgets in a form that is useful to GTK theme developers.
|
||||
|
||||
The application shows widgets in different, typical combinations and states.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
``-h, --help``
|
||||
|
||||
Show the application help.
|
||||
|
||||
``--version``
|
||||
|
||||
Show the application version.
|
63
docs/reference/gtk/gtk4-widget-factory.xml
Normal file
63
docs/reference/gtk/gtk4-widget-factory.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk4-widget-factory">
|
||||
|
||||
<refentryinfo>
|
||||
<title>gtk4-widget-factory</title>
|
||||
<productname>GTK</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Matthias</firstname>
|
||||
<surname>Clasen</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>gtk4-widget-factory</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>gtk4-widget-factory</refname>
|
||||
<refpurpose>Demonstrate GTK widgets</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>gtk4-widget-factory</command>
|
||||
<arg choice="opt">--help</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>
|
||||
<command>gtk4-widget-factory</command> is a collection of examples.
|
||||
Its purpose is to demonstrate many GTK widgets in a form
|
||||
that is useful to GTK theme developers.
|
||||
</para>
|
||||
<para>
|
||||
The application shows widgets in different, typical combinations
|
||||
and states.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Options</title>
|
||||
<para>The following options are understood:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-h</option>, <option>--help</option></term>
|
||||
<listitem><para>Show help options</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
<listitem><para>Show program version</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -59,15 +59,24 @@ if get_option('gtk_doc')
|
||||
)
|
||||
endif
|
||||
|
||||
rst2man = find_program('rst2man', required: false)
|
||||
if get_option('man-pages') and not rst2man.found()
|
||||
error('No rst2man found, but man pages were explicitly enabled')
|
||||
xsltproc = find_program('xsltproc', required: false)
|
||||
if get_option('man-pages') and not xsltproc.found()
|
||||
error('No xsltproc found, but man pages were explicitly enabled')
|
||||
endif
|
||||
|
||||
if get_option('man-pages') and rst2man.found()
|
||||
rst_files = [
|
||||
[ 'gtk4-broadwayd', '1' ],
|
||||
[ 'gtk4-builder-tool', '1' ],
|
||||
if get_option('man-pages') and xsltproc.found()
|
||||
xlstproc_flags = [
|
||||
'--nonet',
|
||||
'--stringparam', 'man.output.quietly', '1',
|
||||
'--stringparam', 'funcsynopsis.style', 'ansi',
|
||||
'--stringparam', 'man.th.extra1.suppress', '1',
|
||||
'--stringparam', 'man.authors.section.enabled', '0',
|
||||
'--stringparam', 'man.copyright.section.enabled', '0',
|
||||
]
|
||||
|
||||
man_files = [
|
||||
[ 'gtk4-broadwayd', '1', ],
|
||||
[ 'gtk4-builder-tool', '1', ],
|
||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||
[ 'gtk4-launch', '1', ],
|
||||
[ 'gtk4-query-settings', '1', ],
|
||||
@@ -75,7 +84,7 @@ if get_option('man-pages') and rst2man.found()
|
||||
]
|
||||
|
||||
if get_option('demos')
|
||||
rst_files += [
|
||||
man_files += [
|
||||
[ 'gtk4-demo', '1', ],
|
||||
[ 'gtk4-demo-application', '1', ],
|
||||
[ 'gtk4-widget-factory', '1', ],
|
||||
@@ -83,25 +92,21 @@ if get_option('man-pages') and rst2man.found()
|
||||
]
|
||||
endif
|
||||
|
||||
rst2man_flags = [
|
||||
'--syntax-highlight=none',
|
||||
]
|
||||
|
||||
foreach rst: rst_files
|
||||
man_name = rst[0]
|
||||
man_section = rst.get(1, '1')
|
||||
|
||||
custom_target('man-@0@'.format(man_name),
|
||||
input: '@0@.rst'.format(man_name),
|
||||
foreach man: man_files
|
||||
man_name = man.get(0)
|
||||
man_section = man.get(1, '1')
|
||||
custom_target('@0@.@1@'.format(man_name, man_section),
|
||||
input: '@0@.xml'.format(man_name),
|
||||
output: '@0@.@1@'.format(man_name, man_section),
|
||||
command: [
|
||||
rst2man,
|
||||
rst2man_flags,
|
||||
xsltproc,
|
||||
xlstproc_flags,
|
||||
'-o', '@OUTPUT@',
|
||||
'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
|
||||
'@INPUT@',
|
||||
],
|
||||
capture: true,
|
||||
install: true,
|
||||
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
|
||||
install_dir: join_paths(get_option('mandir'), 'man@0@'.format(man_section)),
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
|
@@ -668,21 +668,18 @@ box children as necessary.
|
||||
### Adapt to `GtkWindow` API changes
|
||||
|
||||
Following the `GdkSurface` changes, a number of `GtkWindow` APIs that were
|
||||
X11-specific have been removed. This includes `gtk_window_set_position()`,
|
||||
`gtk_window_set_geometry_hints()`, `gtk_window_set_gravity()`,
|
||||
`gtk_window_move()`, `gtk_window_parse_geometry()`,
|
||||
X11-specific have been removed. This includes `gtk_window_set_geometry_hints()`,
|
||||
`gtk_window_set_gravity()`, `gtk_window_move()`, `gtk_window_parse_geometry()`,
|
||||
`gtk_window_set_keep_above()`, `gtk_window_set_keep_below()`,
|
||||
`gtk_window_begin_resize_drag()`, `gtk_window_begin_move_drag()`.
|
||||
Most likely, you should just stop using them. In some cases, you can
|
||||
fall back to using the underlying `GdkToplevel` APIs (for example,
|
||||
[`method@Gdk.Toplevel.begin_resize`]); alternatively, you will need to get
|
||||
the native windowing system surface from the `GtkWindow` and call platform
|
||||
specific API.
|
||||
[method@Gdk.Toplevel.begin_resize]).
|
||||
|
||||
The APIs for controlling `GtkWindow` size have changed to be better aligned
|
||||
with the way size changes are integrated in the frame cycle. `gtk_window_resize()`
|
||||
and `gtk_window_get_size()` have been removed. Instead, use
|
||||
[`method@Gtk.Window.set_default_size`] and [`method@Gtk.Window.get_default_size`].
|
||||
[method@Gtk.Window.set_default_size] and [method@Gtk.Window.get_default_size].
|
||||
|
||||
### Adapt to `GtkHeaderBar` and `GtkActionBar` API changes
|
||||
|
||||
@@ -1335,18 +1332,6 @@ pointer coordinates as inout arguments any more, but as normal in ones.
|
||||
|
||||
See: [method@Gtk.TreeView.get_tooltip_context], [method@Gtk.IconView.get_tooltip_context]
|
||||
|
||||
### Adapt to GtkPopover changes
|
||||
|
||||
In GTK 3, a `GtkPopover` could be attached to any widget, using the `relative-to`
|
||||
property. This is no longer possible in GTK 4. The parent widget has to be aware
|
||||
of its popover children, and manage their size allocation. Therefore, only widgets
|
||||
with dedicated popover support can have them, such as [class@Gtk.MenuButton] or
|
||||
[class@Gtk.PopoverMenuBar].
|
||||
|
||||
If you want to make a custom widget that has an attached popover, you need to call
|
||||
[method@Gtk.Popover.present] in your [vfunc@Gtk.Widget.size_allocate] vfunc, in order
|
||||
to update the positioning of the popover.
|
||||
|
||||
### Stop using GtkFileChooserButton
|
||||
|
||||
The `GtkFileChooserButton` widget was removed, due to its shortcomings in
|
||||
|
101
docs/reference/gtk/overview.xml
Normal file
101
docs/reference/gtk/overview.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE partintro PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<partintro>
|
||||
<para>
|
||||
GTK is a library for creating graphical user interfaces. It
|
||||
works on many UNIX-like platforms, Windows, and OS X.
|
||||
GTK is released under the GNU Library General Public License
|
||||
(GNU LGPL), which allows for flexible licensing of client
|
||||
applications. GTK has a C-based object-oriented architecture that
|
||||
allows for maximum flexibility. Bindings for many other languages have
|
||||
been written, including C++, Objective-C, Guile/Scheme, Perl, Python,
|
||||
TOM, Ada95, Free Pascal, and Eiffel. The GTK library itself contains
|
||||
<firstterm>widgets</firstterm>, that is, GUI components such as GtkButton
|
||||
or GtkTextView.
|
||||
|
||||
</para>
|
||||
<para>
|
||||
GTK depends on the following libraries:
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term>GLib</term>
|
||||
<listitem><para>
|
||||
A general-purpose utility library, not specific to graphical user interfaces.
|
||||
GLib provides many useful data types, macros, type conversions,
|
||||
string utilities, file utilities, a main loop abstraction, and so on.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>GObject</term>
|
||||
<listitem><para>A library that provides a type system, a collection of
|
||||
fundamental types including an object type, a signal system.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>GIO</term>
|
||||
<listitem><para>A modern, easy-to-use VFS API including abstractions for
|
||||
files, drives, volumes, stream IO, as well as network programming and
|
||||
DBus communication.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>cairo</term>
|
||||
<listitem><para>Cairo is a 2D graphics library with support for multiple
|
||||
output devices.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Pango</term>
|
||||
<listitem><para>
|
||||
Pango is a library for internationalized text handling. It centers
|
||||
around the PangoLayout object, representing a paragraph of text.
|
||||
Pango provides the engine for GtkTextView, GtkLabel, GtkEntry, and
|
||||
other widgets that display text.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>GdkPixbuf</term>
|
||||
<listitem><para>
|
||||
This is a small library which allows you to create GdkPixbuf
|
||||
("pixel buffer") objects from image data or image files.
|
||||
Use a GdkPixbuf in combination with GtkImage to display images.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>graphene</term>
|
||||
<listitem><para>
|
||||
This is a small library which provides vector and matrix datatypes
|
||||
and operations. graphene provides optimized implementations using
|
||||
various SIMD instruction sets such as SSE.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>GDK</term>
|
||||
<listitem><para>
|
||||
GDK is the abstraction layer that allows GTK to support multiple
|
||||
windowing systems. GDK provides window system facilities on Wayland,
|
||||
X11, Windows, and OS X.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>GSK</term>
|
||||
<listitem><para>
|
||||
GSK is a library for creating a scene graph from render nodes,
|
||||
and rendering it using different rendering APIs. GSK provides renderers
|
||||
for OpenGL, Vulkan and cairo.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</partintro>
|
@@ -13,5 +13,4 @@ baseURLs = [
|
||||
[ 'Gtk', 'https://docs.gtk.org/gtk4/' ],
|
||||
[ 'Pango', 'https://docs.gtk.org/Pango/' ],
|
||||
[ 'PangoCairo', 'https://docs.gtk.org/PangoCairo/' ],
|
||||
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
||||
]
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include "gdktypes.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@@ -609,46 +609,56 @@ open_shared_memory (void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
gsize size;
|
||||
} PngData;
|
||||
|
||||
static cairo_status_t
|
||||
write_png_cb (void *closure,
|
||||
const guchar *data,
|
||||
unsigned int length)
|
||||
{
|
||||
PngData *png_data = closure;
|
||||
int fd = png_data->fd;
|
||||
|
||||
while (length)
|
||||
{
|
||||
gssize ret = write (fd, data, length);
|
||||
|
||||
if (ret <= 0)
|
||||
return CAIRO_STATUS_WRITE_ERROR;
|
||||
|
||||
png_data->size += ret;
|
||||
length -= ret;
|
||||
data += ret;
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
guint32
|
||||
gdk_broadway_server_upload_texture (GdkBroadwayServer *server,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
guint32 id;
|
||||
cairo_surface_t *surface = gdk_texture_download_surface (texture);
|
||||
BroadwayRequestUploadTexture msg;
|
||||
GBytes *bytes;
|
||||
const guchar *data;
|
||||
gsize size;
|
||||
int fd;
|
||||
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
fd = open_shared_memory ();
|
||||
data = g_bytes_get_data (bytes, &size);
|
||||
PngData data;
|
||||
|
||||
id = server->next_texture_id++;
|
||||
|
||||
data.fd = open_shared_memory ();
|
||||
data.size = 0;
|
||||
cairo_surface_write_to_png_stream (surface, write_png_cb, &data);
|
||||
|
||||
msg.id = id;
|
||||
msg.offset = 0;
|
||||
msg.size = 0;
|
||||
|
||||
while (msg.size < size)
|
||||
{
|
||||
gssize ret = write (fd, data + msg.size, size - msg.size);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
msg.size += ret;
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
msg.size = data.size;
|
||||
|
||||
/* This passes ownership of fd */
|
||||
gdk_broadway_server_send_fd_message (server, msg,
|
||||
BROADWAY_REQUEST_UPLOAD_TEXTURE, fd);
|
||||
BROADWAY_REQUEST_UPLOAD_TEXTURE, data.fd);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@@ -2,10 +2,8 @@
|
||||
#define __GDK_BROADWAY_SERVER__
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#include "gdkdeviceprivate.h"
|
||||
|
||||
#include "broadway-protocol.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
typedef struct _GdkBroadwayServer GdkBroadwayServer;
|
||||
typedef struct _GdkBroadwayServerClass GdkBroadwayServerClass;
|
||||
|
@@ -34,7 +34,6 @@ gdk_broadway_cairo_context_dispose (GObject *object)
|
||||
|
||||
static void
|
||||
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "gdkmonitor-broadway.h"
|
||||
#include "gdkseatdefaultprivate.h"
|
||||
#include "gdkdevice-broadway.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
#include "gdk-private.h"
|
||||
@@ -213,7 +214,7 @@ _gdk_broadway_display_open (const char *display_name)
|
||||
broadway_display->server = _gdk_broadway_server_new (display, display_name, &error);
|
||||
if (broadway_display->server == NULL)
|
||||
{
|
||||
GDK_NOTE (MISC, g_message ("Unable to init Broadway server: %s\n", error->message));
|
||||
g_printerr ("Unable to init Broadway server: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkkeys.h"
|
||||
#include "gdksurface.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkbroadway-server.h"
|
||||
#include "gdkmonitorprivate.h"
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkprivate-broadway.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdisplay-broadway.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@@ -34,7 +34,6 @@ gdk_broadway_draw_context_dispose (GObject *object)
|
||||
|
||||
static void
|
||||
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
|
||||
|
@@ -19,9 +19,8 @@
|
||||
|
||||
#include "gdkeventsource.h"
|
||||
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkframeclockprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkframeclockprivate.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkprivate-broadway.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdisplay-broadway.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkkeysyms.h"
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#define __GDK_PRIVATE_BROADWAY_H__
|
||||
|
||||
#include <gdk/gdkcursor.h>
|
||||
#include <gdk/gdkinternals.h>
|
||||
#include "gdksurface-broadway.h"
|
||||
#include "gdkdisplay-broadway.h"
|
||||
#include "gdkdrawcontext-broadway.h"
|
||||
|
@@ -35,12 +35,13 @@
|
||||
#include "gdkdragsurfaceprivate.h"
|
||||
#include "gdkeventsource.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkpopupprivate.h"
|
||||
#include "gdkprivate-broadway.h"
|
||||
#include "gdkseatprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdktoplevelprivate.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <graphene.h>
|
||||
#include <stdlib.h>
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <gdk/gdksurfaceprivate.h>
|
||||
#include "gdkbroadwaysurface.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -64,7 +64,7 @@ libgdk_broadway = static_library('gdk-broadway',
|
||||
|
||||
# gtk4-broadwayd
|
||||
|
||||
broadwayd_syslib = os_win32 ? cc.find_library('ws2_32') : shmlib
|
||||
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
|
||||
|
||||
executable('gtk4-broadwayd',
|
||||
sources: [
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#ifndef __GDK__PRIVATE_H__
|
||||
#define __GDK__PRIVATE_H__
|
||||
|
||||
#include "gdk/gdktypes.h"
|
||||
#include <gdk/gdk.h>
|
||||
#include "gdk/gdkinternals.h"
|
||||
|
||||
/* Private API for use in GTK+ */
|
||||
|
||||
@@ -32,6 +33,10 @@ PangoDirection gdk_unichar_direction (gunichar ch) G_GNUC_CONST;
|
||||
PangoDirection gdk_find_base_dir (const char *text,
|
||||
int len);
|
||||
|
||||
void gdk_surface_set_widget (GdkSurface *surface,
|
||||
gpointer widget);
|
||||
gpointer gdk_surface_get_widget (GdkSurface *surface);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *key;
|
||||
|
25
gdk/gdk.c
25
gdk/gdk.c
@@ -26,15 +26,19 @@
|
||||
|
||||
#include "gdkversionmacros.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
#include "gdkresources.h"
|
||||
|
||||
#include "gdkconstructor.h"
|
||||
#include "gdkdebug.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include "gdkconstructor.h"
|
||||
|
||||
#ifndef HAVE_XCONVERTCASE
|
||||
#include "gdkkeysyms.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -121,7 +125,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "gl-software", GDK_DEBUG_GL_SOFTWARE, "Force OpenGL software rendering" },
|
||||
{ "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT, "Use OpenGL texture rectangle extension" },
|
||||
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
|
||||
{ "gl-gles", GDK_DEBUG_GL_GLES, "Only allow OpenGL GLES API" },
|
||||
{ "gl-gles", GDK_DEBUG_GL_GLES, "Use a GLES OpenGL context" },
|
||||
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
||||
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows" },
|
||||
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
|
||||
@@ -129,7 +133,6 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "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", TRUE },
|
||||
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible", TRUE },
|
||||
};
|
||||
|
||||
|
||||
@@ -296,14 +299,6 @@ gdk_pre_parse (void)
|
||||
gdk_debug_keys,
|
||||
G_N_ELEMENTS (gdk_debug_keys));
|
||||
|
||||
/* These are global */
|
||||
if (GDK_DEBUG_CHECK (GL_EGL))
|
||||
gdk_gl_backend_use (GDK_GL_EGL);
|
||||
else if (GDK_DEBUG_CHECK (GL_GLX))
|
||||
gdk_gl_backend_use (GDK_GL_GLX);
|
||||
else if (GDK_DEBUG_CHECK (GL_WGL))
|
||||
gdk_gl_backend_use (GDK_GL_WGL);
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_desktop_startup_notification_id ();
|
||||
#endif
|
||||
|
@@ -47,7 +47,6 @@
|
||||
#include <gdk/gdkdragsurface.h>
|
||||
#include <gdk/gdkdrawcontext.h>
|
||||
#include <gdk/gdkdrop.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdkenumtypes.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdkframeclock.h>
|
||||
|
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_APP_LAUNCH_CONTEXT (gdk_app_launch_context_get_type ())
|
||||
#define GDK_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_APP_LAUNCH_CONTEXT, GdkAppLaunchContext))
|
||||
#define GDK_IS_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_APP_LAUNCH_CONTEXT))
|
||||
#define GDK_IS_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_APP_LAUNCH_CONTEXT))
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@@ -17,7 +17,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcairoprivate.h"
|
||||
#include "gdkcairo.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -91,7 +93,11 @@ void
|
||||
gdk_cairo_surface_paint_pixbuf (cairo_surface_t *surface,
|
||||
const GdkPixbuf *pixbuf)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
int width, height;
|
||||
guchar *gdk_pixels, *cairo_pixels;
|
||||
int gdk_rowstride, cairo_stride;
|
||||
int n_channels;
|
||||
int j;
|
||||
|
||||
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
|
||||
return;
|
||||
@@ -107,11 +113,71 @@ gdk_cairo_surface_paint_pixbuf (cairo_surface_t *surface,
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (GDK_PIXBUF (pixbuf));
|
||||
gdk_texture_download (texture,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
g_object_unref (texture);
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
cairo_stride = cairo_image_surface_get_stride (surface);
|
||||
cairo_pixels = cairo_image_surface_get_data (surface);
|
||||
|
||||
for (j = height; j; j--)
|
||||
{
|
||||
guchar *p = gdk_pixels;
|
||||
guchar *q = cairo_pixels;
|
||||
|
||||
if (n_channels == 3)
|
||||
{
|
||||
guchar *end = p + 3 * width;
|
||||
|
||||
while (p < end)
|
||||
{
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
q[0] = p[2];
|
||||
q[1] = p[1];
|
||||
q[2] = p[0];
|
||||
q[3] = 0xFF;
|
||||
#else
|
||||
q[0] = 0xFF;
|
||||
q[1] = p[0];
|
||||
q[2] = p[1];
|
||||
q[3] = p[2];
|
||||
#endif
|
||||
p += 3;
|
||||
q += 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar *end = p + 4 * width;
|
||||
guint t1,t2,t3;
|
||||
|
||||
#define MULT(d,c,a,t) G_STMT_START { t = c * a + 0x80; d = ((t >> 8) + t) >> 8; } G_STMT_END
|
||||
|
||||
while (p < end)
|
||||
{
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
MULT(q[0], p[2], p[3], t1);
|
||||
MULT(q[1], p[1], p[3], t2);
|
||||
MULT(q[2], p[0], p[3], t3);
|
||||
q[3] = p[3];
|
||||
#else
|
||||
q[0] = p[3];
|
||||
MULT(q[1], p[0], p[3], t1);
|
||||
MULT(q[2], p[1], p[3], t2);
|
||||
MULT(q[3], p[2], p[3], t3);
|
||||
#endif
|
||||
|
||||
p += 4;
|
||||
q += 4;
|
||||
}
|
||||
|
||||
#undef MULT
|
||||
}
|
||||
|
||||
gdk_pixels += gdk_rowstride;
|
||||
cairo_pixels += cairo_stride;
|
||||
}
|
||||
|
||||
cairo_surface_mark_dirty (surface);
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "gdkcairocontextprivate.h"
|
||||
|
||||
#include "gdkcairo.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
/**
|
||||
* GdkCairoContext:
|
||||
|
@@ -18,8 +18,6 @@
|
||||
#ifndef __GDK_CAIRO_PRIVATE_H__
|
||||
#define __GDK_CAIRO_PRIVATE_H__
|
||||
|
||||
#include "gdkcairo.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <cairo.h>
|
||||
|
||||
|
@@ -1008,13 +1008,11 @@ init (void)
|
||||
if (!g_get_charset (&charset))
|
||||
{
|
||||
char *mime = g_strdup_printf ("text/plain;charset=%s", charset);
|
||||
|
||||
gdk_content_register_deserializer (mime,
|
||||
G_TYPE_STRING,
|
||||
string_deserializer,
|
||||
(gpointer) charset,
|
||||
g_free);
|
||||
g_free (mime);
|
||||
}
|
||||
gdk_content_register_deserializer ("text/plain",
|
||||
G_TYPE_STRING,
|
||||
|
@@ -808,13 +808,8 @@ gdk_content_formats_builder_add_mime_type (GdkContentFormatsBuilder *builder,
|
||||
builder->n_mime_types++;
|
||||
}
|
||||
|
||||
/* {{{ GdkFileList */
|
||||
|
||||
/* We're using GdkFileList* and GSList* interchangeably, counting on the
|
||||
* fact that we're just passing around gpointers; the only reason why we
|
||||
* have a GdkFileList opaque type is for language bindings, because they
|
||||
* can have no idea what a GSList of GFiles is.
|
||||
*/
|
||||
/* G_DEFINE_BOXED wants this */
|
||||
typedef gpointer GdkFileList;
|
||||
|
||||
static gpointer
|
||||
gdk_file_list_copy (gpointer list)
|
||||
@@ -829,23 +824,3 @@ gdk_file_list_free (gpointer list)
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GdkFileList, gdk_file_list, gdk_file_list_copy, gdk_file_list_free)
|
||||
|
||||
/**
|
||||
* gdk_file_list_get_files:
|
||||
* @file_list: the file list
|
||||
*
|
||||
* Retrieves the list of files inside a `GdkFileList`.
|
||||
*
|
||||
* This function is meant for language bindings.
|
||||
*
|
||||
* Returns: (transfer container) (element-type GFile): the files inside the list
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
GSList *
|
||||
gdk_file_list_get_files (GdkFileList *file_list)
|
||||
{
|
||||
return g_slist_copy ((GSList *) file_list);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
@@ -109,19 +109,8 @@ void gdk_content_formats_builder_add_gtype (GdkContentForma
|
||||
/* dunno where else to put this */
|
||||
#define GDK_TYPE_FILE_LIST (gdk_file_list_get_type ())
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_file_list_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_file_list_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* GdkFileList:
|
||||
*
|
||||
* An opaque type representing a list of files.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
typedef struct _GdkFileList GdkFileList;
|
||||
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
GSList * gdk_file_list_get_files (GdkFileList *file_list);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -641,7 +641,11 @@ pixbuf_serializer (GdkContentSerializer *serializer)
|
||||
else if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE))
|
||||
{
|
||||
GdkTexture *texture = g_value_get_object (value);
|
||||
pixbuf = gdk_pixbuf_get_from_texture (texture);
|
||||
cairo_surface_t *surface = gdk_texture_download_surface (texture);
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface,
|
||||
0, 0,
|
||||
gdk_texture_get_width (texture), gdk_texture_get_height (texture));
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "gdkcursorprivate.h"
|
||||
#include "gdktexture.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
@@ -18,12 +18,9 @@
|
||||
#ifndef __GDK_DEBUG_H__
|
||||
#define __GDK_DEBUG_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gdktypes.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef enum {
|
||||
GDK_DEBUG_MISC = 1 << 0,
|
||||
GDK_DEBUG_EVENTS = 1 << 1,
|
||||
@@ -50,7 +47,6 @@ typedef enum {
|
||||
GDK_DEBUG_VULKAN_DISABLE = 1 << 21,
|
||||
GDK_DEBUG_VULKAN_VALIDATE = 1 << 22,
|
||||
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 23,
|
||||
GDK_DEBUG_HIGH_DEPTH = 1 << 24,
|
||||
} GdkDebugFlags;
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdevicetool.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
|
||||
@@ -330,7 +331,7 @@ gdk_device_class_init (GdkDeviceClass *klass)
|
||||
* GdkDevice::changed:
|
||||
* @device: the `GdkDevice`
|
||||
*
|
||||
* Emitted either when the number of either axes or keys changes.
|
||||
* Emitted either when the the number of either axes or keys changes.
|
||||
*
|
||||
* On X11 this will normally happen when the physical device
|
||||
* routing events through the logical device changes (for
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "gdkdevicetoolprivate.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
/**
|
||||
|
@@ -22,9 +22,8 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
487
gdk/gdkdisplay.c
487
gdk/gdkdisplay.c
@@ -27,20 +27,16 @@
|
||||
#include "gdkintl.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include "gdkapplaunchcontext.h"
|
||||
#include "gdkclipboardprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkevents.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkmonitorprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#include <epoxy/egl.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
/**
|
||||
* GdkDisplay:
|
||||
@@ -91,12 +87,6 @@ struct _GdkDisplayPrivate {
|
||||
GdkGLContext *gl_context;
|
||||
GError *gl_error;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
EGLDisplay egl_display;
|
||||
EGLConfig egl_config;
|
||||
EGLConfig egl_config_high_depth;
|
||||
#endif
|
||||
|
||||
guint rgba : 1;
|
||||
guint composited : 1;
|
||||
guint input_shapes : 1;
|
||||
@@ -156,26 +146,6 @@ gdk_display_default_init_gl (GdkDisplay *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_display_default_rate_egl_config (GdkDisplay *display,
|
||||
gpointer egl_display,
|
||||
gpointer config)
|
||||
{
|
||||
guint distance = 0;
|
||||
#ifdef HAVE_EGL
|
||||
int tmp;
|
||||
|
||||
if (!eglGetConfigAttrib (egl_display, config, EGL_SAMPLE_BUFFERS, &tmp) || tmp != 0)
|
||||
distance += 0x20000;
|
||||
|
||||
if (!eglGetConfigAttrib (egl_display, config, EGL_DEPTH_SIZE, &tmp) || tmp != 0 ||
|
||||
!eglGetConfigAttrib (egl_display, config, EGL_STENCIL_SIZE, &tmp) || tmp != 0)
|
||||
distance += 0x10000;
|
||||
#endif
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
static GdkSeat *
|
||||
gdk_display_real_get_default_seat (GdkDisplay *display)
|
||||
{
|
||||
@@ -203,7 +173,6 @@ gdk_display_class_init (GdkDisplayClass *class)
|
||||
class->make_default = gdk_display_real_make_default;
|
||||
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
|
||||
class->init_gl = gdk_display_default_init_gl;
|
||||
class->rate_egl_config = gdk_display_default_rate_egl_config;
|
||||
class->get_default_seat = gdk_display_real_get_default_seat;
|
||||
class->opened = gdk_display_real_opened;
|
||||
|
||||
@@ -383,9 +352,6 @@ gdk_display_dispose (GObject *object)
|
||||
g_queue_clear (&display->queued_events);
|
||||
|
||||
g_clear_object (&priv->gl_context);
|
||||
#ifdef HAVE_EGL
|
||||
g_clear_pointer (&priv->egl_display, eglTerminate);
|
||||
#endif
|
||||
g_clear_error (&priv->gl_error);
|
||||
|
||||
G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
|
||||
@@ -1267,8 +1233,6 @@ gdk_display_init_gl (GdkDisplay *self)
|
||||
*/
|
||||
priv->gl_context = context;
|
||||
|
||||
gdk_gl_backend_use (GDK_GL_CONTEXT_GET_CLASS (context)->backend_type);
|
||||
|
||||
gdk_profiler_end_mark (before, "initialize OpenGL", NULL);
|
||||
}
|
||||
|
||||
@@ -1325,38 +1289,6 @@ gdk_display_prepare_gl (GdkDisplay *self,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_create_gl_context:
|
||||
* @self: a `GdkDisplay`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Creates a new `GdkGLContext` for the `GdkDisplay`.
|
||||
*
|
||||
* The context is disconnected from any particular surface or surface
|
||||
* and cannot be used to draw to any surface. It can only be used to
|
||||
* draw to non-surface framebuffers like textures.
|
||||
*
|
||||
* If the creation of the `GdkGLContext` failed, @error will be set.
|
||||
* Before using the returned `GdkGLContext`, you will need to
|
||||
* call [method@Gdk.GLContext.make_current] or [method@Gdk.GLContext.realize].
|
||||
*
|
||||
* Returns: (transfer full): the newly created `GdkGLContext`
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
GdkGLContext *
|
||||
gdk_display_create_gl_context (GdkDisplay *self,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (!gdk_display_prepare_gl (self, error))
|
||||
return NULL;
|
||||
|
||||
return gdk_gl_context_new (self, NULL);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_get_gl_context:
|
||||
* @self: the `GdkDisplay`
|
||||
@@ -1378,417 +1310,6 @@ gdk_display_get_gl_context (GdkDisplay *self)
|
||||
return priv->gl_context;
|
||||
}
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const char * const *s1 = p1;
|
||||
const char * const *s2 = p2;
|
||||
|
||||
return strcmp (*s1, *s2);
|
||||
}
|
||||
|
||||
static char *
|
||||
describe_extensions (EGLDisplay egl_display)
|
||||
{
|
||||
const char *extensions;
|
||||
char **exts;
|
||||
char *ext;
|
||||
|
||||
extensions = eglQueryString (egl_display, EGL_EXTENSIONS);
|
||||
|
||||
exts = g_strsplit (extensions, " ", -1);
|
||||
qsort (exts, g_strv_length (exts), sizeof (char *), strvcmp);
|
||||
|
||||
ext = g_strjoinv ("\n\t", exts);
|
||||
if (ext[0] == '\n')
|
||||
ext[0] = ' ';
|
||||
|
||||
g_strfreev (exts);
|
||||
|
||||
return g_strstrip (ext);
|
||||
}
|
||||
|
||||
static char *
|
||||
describe_egl_config (EGLDisplay egl_display,
|
||||
EGLConfig egl_config)
|
||||
{
|
||||
EGLint red, green, blue, alpha, type;
|
||||
|
||||
if (egl_config == NULL)
|
||||
return g_strdup ("-");
|
||||
|
||||
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_RED_SIZE, &red) ||
|
||||
!eglGetConfigAttrib (egl_display, egl_config, EGL_GREEN_SIZE, &green) ||
|
||||
!eglGetConfigAttrib (egl_display, egl_config, EGL_BLUE_SIZE, &blue) ||
|
||||
!eglGetConfigAttrib (egl_display, egl_config, EGL_ALPHA_SIZE, &alpha))
|
||||
return g_strdup ("Unknown");
|
||||
|
||||
if (epoxy_has_egl_extension (egl_display, "EGL_EXT_pixel_format_float"))
|
||||
{
|
||||
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_COLOR_COMPONENT_TYPE_EXT, &type))
|
||||
type = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
|
||||
}
|
||||
else
|
||||
type = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
|
||||
|
||||
return g_strdup_printf ("R%dG%dB%dA%d%s", red, green, blue, alpha, type == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT ? "" : " float");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*<private>
|
||||
* gdk_display_get_egl_display:
|
||||
* @self: a display
|
||||
*
|
||||
* Retrieves the EGL display connection object for the given GDK display.
|
||||
*
|
||||
* This function returns `NULL` if GL is not supported or GDK is using
|
||||
* a different OpenGL framework than EGL.
|
||||
*
|
||||
* Returns: (nullable): the EGL display object
|
||||
*/
|
||||
gpointer
|
||||
gdk_display_get_egl_display (GdkDisplay *self)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
|
||||
if (!priv->egl_display &&
|
||||
!gdk_display_prepare_gl (self, NULL))
|
||||
return NULL;
|
||||
|
||||
return priv->egl_display;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_display_get_egl_config (GdkDisplay *self)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
|
||||
return priv->egl_config;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_display_get_egl_config_high_depth (GdkDisplay *self)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
|
||||
return priv->egl_config_high_depth;
|
||||
}
|
||||
|
||||
static EGLDisplay
|
||||
gdk_display_create_egl_display (EGLenum platform,
|
||||
gpointer native_display)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
EGLDisplay egl_display = NULL;
|
||||
|
||||
if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base"))
|
||||
{
|
||||
PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay =
|
||||
(void *) eglGetProcAddress ("eglGetPlatformDisplay");
|
||||
|
||||
if (getPlatformDisplay != NULL)
|
||||
egl_display = getPlatformDisplay (platform, native_display, NULL);
|
||||
if (egl_display != NULL)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
|
||||
{
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
|
||||
(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
|
||||
|
||||
if (getPlatformDisplay != NULL)
|
||||
egl_display = getPlatformDisplay (platform, native_display, NULL);
|
||||
if (egl_display != NULL)
|
||||
goto out;
|
||||
}
|
||||
|
||||
egl_display = eglGetDisplay ((EGLNativeDisplayType) native_display);
|
||||
|
||||
out:
|
||||
gdk_profiler_end_mark (start_time, "Create EGL display", NULL);
|
||||
|
||||
return egl_display;
|
||||
}
|
||||
|
||||
#define MAX_EGL_ATTRS 30
|
||||
|
||||
typedef enum {
|
||||
GDK_EGL_CONFIG_PERFECT = (1 << 0),
|
||||
GDK_EGL_CONFIG_HDR = (1 << 1),
|
||||
} GdkEGLConfigCreateFlags;
|
||||
|
||||
static EGLConfig
|
||||
gdk_display_create_egl_config (GdkDisplay *self,
|
||||
GdkEGLConfigCreateFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
EGLint attrs[MAX_EGL_ATTRS];
|
||||
EGLConfig *configs;
|
||||
EGLint count, alloced;
|
||||
EGLConfig best_config;
|
||||
guint best_score;
|
||||
|
||||
int i = 0;
|
||||
|
||||
attrs[i++] = EGL_SURFACE_TYPE;
|
||||
attrs[i++] = EGL_WINDOW_BIT;
|
||||
|
||||
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
|
||||
attrs[i++] = EGL_RGB_BUFFER;
|
||||
|
||||
attrs[i++] = EGL_RED_SIZE;
|
||||
attrs[i++] = (flags & GDK_EGL_CONFIG_HDR) ? 9 : 8;
|
||||
attrs[i++] = EGL_GREEN_SIZE;
|
||||
attrs[i++] = (flags & GDK_EGL_CONFIG_HDR) ? 9 : 8;
|
||||
attrs[i++] = EGL_BLUE_SIZE;
|
||||
attrs[i++] = (flags & GDK_EGL_CONFIG_HDR) ? 9 : 8;
|
||||
attrs[i++] = EGL_ALPHA_SIZE;
|
||||
attrs[i++] = 8;
|
||||
|
||||
if (flags & GDK_EGL_CONFIG_HDR &&
|
||||
self->have_egl_pixel_format_float)
|
||||
{
|
||||
attrs[i++] = EGL_COLOR_COMPONENT_TYPE_EXT;
|
||||
attrs[i++] = EGL_DONT_CARE;
|
||||
}
|
||||
|
||||
attrs[i++] = EGL_NONE;
|
||||
g_assert (i < MAX_EGL_ATTRS);
|
||||
|
||||
if (!eglChooseConfig (priv->egl_display, attrs, NULL, -1, &alloced) || alloced == 0)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("No EGL configuration available"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
configs = g_new (EGLConfig, alloced);
|
||||
if (!eglChooseConfig (priv->egl_display, attrs, configs, alloced, &count))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Failed to get EGL configurations"));
|
||||
return NULL;
|
||||
}
|
||||
g_warn_if_fail (alloced == count);
|
||||
|
||||
best_score = G_MAXUINT;
|
||||
best_config = NULL;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
guint score = GDK_DISPLAY_GET_CLASS (self)->rate_egl_config (self, priv->egl_display, configs[i]);
|
||||
|
||||
if (score < best_score)
|
||||
{
|
||||
best_score = score;
|
||||
best_config = configs[i];
|
||||
}
|
||||
|
||||
if (score == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (configs);
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Create EGL config", NULL);
|
||||
|
||||
if (best_score == G_MAXUINT)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("No EGL configuration with required features found"));
|
||||
return NULL;
|
||||
}
|
||||
else if ((flags & GDK_EGL_CONFIG_PERFECT) && best_score != 0)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("No perfect EGL configuration found"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return best_config;
|
||||
}
|
||||
|
||||
#undef MAX_EGL_ATTRS
|
||||
|
||||
static gboolean
|
||||
gdk_display_check_egl_extensions (EGLDisplay egl_display,
|
||||
const char **extensions,
|
||||
GError **error)
|
||||
{
|
||||
GString *missing = NULL;
|
||||
gsize i, n_missing;
|
||||
|
||||
n_missing = 0;
|
||||
|
||||
for (i = 0; extensions[i] != NULL; i++)
|
||||
{
|
||||
if (!epoxy_has_egl_extension (egl_display, extensions[i]))
|
||||
{
|
||||
if (missing == NULL)
|
||||
{
|
||||
missing = g_string_new (extensions[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append (missing, ", ");
|
||||
g_string_append (missing, extensions[i]);
|
||||
}
|
||||
n_missing++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n_missing)
|
||||
{
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
/* translators: Arguments are the number of missing extensions
|
||||
* followed by a comma-separated list of their names */
|
||||
g_dngettext (GETTEXT_PACKAGE,
|
||||
"EGL implementation is missing extension %2$s",
|
||||
"EGL implementation is missing %d extensions: %s",
|
||||
n_missing),
|
||||
(int) n_missing, missing->str);
|
||||
|
||||
g_string_free (missing, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_display_init_egl (GdkDisplay *self,
|
||||
int platform,
|
||||
gpointer native_display,
|
||||
gboolean allow_any,
|
||||
GError **error)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
G_GNUC_UNUSED gint64 start_time2;
|
||||
int major, minor;
|
||||
|
||||
if (!gdk_gl_backend_can_be_used (GDK_GL_EGL, error))
|
||||
return FALSE;
|
||||
|
||||
if (!epoxy_has_egl ())
|
||||
{
|
||||
gboolean sandboxed = gdk_running_in_sandbox ();
|
||||
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
sandboxed ? _("libEGL not available in this sandbox")
|
||||
: _("libEGL not available"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->egl_display = gdk_display_create_egl_display (platform, native_display);
|
||||
|
||||
if (priv->egl_display == NULL)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Failed to create EGL display"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
start_time2 = GDK_PROFILER_CURRENT_TIME;
|
||||
if (!eglInitialize (priv->egl_display, &major, &minor))
|
||||
{
|
||||
priv->egl_display = NULL;
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Could not initialize EGL display"));
|
||||
return FALSE;
|
||||
}
|
||||
gdk_profiler_end_mark (start_time2, "eglInitialize", NULL);
|
||||
|
||||
if (major < GDK_EGL_MIN_VERSION_MAJOR ||
|
||||
(major == GDK_EGL_MIN_VERSION_MAJOR && minor < GDK_EGL_MIN_VERSION_MINOR))
|
||||
{
|
||||
g_clear_pointer (&priv->egl_display, eglTerminate);
|
||||
g_set_error (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("EGL version %d.%d is too old. GTK requires %d.%d"),
|
||||
major, minor, GDK_EGL_MIN_VERSION_MAJOR, GDK_EGL_MIN_VERSION_MINOR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gdk_display_check_egl_extensions (priv->egl_display,
|
||||
(const char *[]) {
|
||||
"EGL_KHR_create_context",
|
||||
"EGL_KHR_surfaceless_context",
|
||||
NULL
|
||||
},
|
||||
error))
|
||||
{
|
||||
g_clear_pointer (&priv->egl_display, eglTerminate);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->egl_config = gdk_display_create_egl_config (self,
|
||||
allow_any ? 0 : GDK_EGL_CONFIG_PERFECT,
|
||||
error);
|
||||
if (priv->egl_config == NULL)
|
||||
{
|
||||
g_clear_pointer (&priv->egl_display, eglTerminate);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->have_egl_buffer_age =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_buffer_age");
|
||||
self->have_egl_swap_buffers_with_damage =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_swap_buffers_with_damage");
|
||||
self->have_egl_no_config_context =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
|
||||
self->have_egl_pixel_format_float =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_pixel_format_float");
|
||||
|
||||
if (self->have_egl_no_config_context)
|
||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||
GDK_EGL_CONFIG_HDR,
|
||||
error);
|
||||
if (priv->egl_config_high_depth == NULL)
|
||||
priv->egl_config_high_depth = priv->egl_config;
|
||||
|
||||
GDK_DISPLAY_NOTE (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);
|
||||
g_message ("EGL API version %d.%d found\n"
|
||||
" - Vendor: %s\n"
|
||||
" - Version: %s\n"
|
||||
" - Client APIs: %s\n"
|
||||
" - Extensions:\n"
|
||||
"\t%s\n"
|
||||
" - Selected fbconfig: %s\n"
|
||||
" high depth: %s",
|
||||
major, minor,
|
||||
eglQueryString (priv->egl_display, EGL_VENDOR),
|
||||
eglQueryString (priv->egl_display, EGL_VERSION),
|
||||
eglQueryString (priv->egl_display, EGL_CLIENT_APIS),
|
||||
ext, std_cfg,
|
||||
priv->egl_config_high_depth == priv->egl_config ? "none" : hd_cfg);
|
||||
g_free (hd_cfg);
|
||||
g_free (std_cfg);
|
||||
g_free (ext);
|
||||
});
|
||||
|
||||
gdk_profiler_end_mark (start_time, "init EGL", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
GdkDebugFlags
|
||||
gdk_display_get_debug_flags (GdkDisplay *display)
|
||||
{
|
||||
|
@@ -71,9 +71,6 @@ gboolean gdk_display_supports_input_shapes (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
gboolean gdk_display_prepare_gl (GdkDisplay *self,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
GdkGLContext *gdk_display_create_gl_context(GdkDisplay *self,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay *gdk_display_get_default (void);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "gdkconfig.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
|
@@ -92,8 +92,6 @@ struct _GdkDisplay
|
||||
guint double_click_time; /* Maximum time between clicks in msecs */
|
||||
guint double_click_distance; /* Maximum distance between clicks in pixels */
|
||||
|
||||
GList *seats;
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
VkInstance vk_instance;
|
||||
VkDebugReportCallbackEXT vk_debug_callback;
|
||||
@@ -105,11 +103,7 @@ struct _GdkDisplay
|
||||
guint vulkan_refcount;
|
||||
#endif /* GDK_RENDERING_VULKAN */
|
||||
|
||||
/* egl info */
|
||||
guint have_egl_buffer_age : 1;
|
||||
guint have_egl_swap_buffers_with_damage : 1;
|
||||
guint have_egl_no_config_context : 1;
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
GList *seats;
|
||||
};
|
||||
|
||||
struct _GdkDisplayClass
|
||||
@@ -146,15 +140,10 @@ struct _GdkDisplayClass
|
||||
|
||||
GdkKeymap * (*get_keymap) (GdkDisplay *display);
|
||||
|
||||
GdkGLContext * (* init_gl) (GdkDisplay *display,
|
||||
GdkGLContext * (*init_gl) (GdkDisplay *display,
|
||||
GError **error);
|
||||
/* Returns the distance from a perfect score EGL config.
|
||||
* GDK chooses the one with the *LOWEST* score */
|
||||
guint (* rate_egl_config) (GdkDisplay *display,
|
||||
gpointer egl_display,
|
||||
gpointer egl_config);
|
||||
|
||||
GdkSeat * (*get_default_seat) (GdkDisplay *display);
|
||||
GdkSeat * (*get_default_seat) (GdkDisplay *display);
|
||||
|
||||
GListModel * (*get_monitors) (GdkDisplay *self);
|
||||
GdkMonitor * (*get_monitor_at_surface) (GdkDisplay *display,
|
||||
@@ -219,16 +208,6 @@ GdkSurface * gdk_display_create_surface (GdkDisplay *display
|
||||
|
||||
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);
|
||||
|
||||
gboolean gdk_display_init_egl (GdkDisplay *display,
|
||||
int /*EGLenum*/ platform,
|
||||
gpointer native_display,
|
||||
gboolean allow_any,
|
||||
GError **error);
|
||||
gpointer gdk_display_get_egl_display (GdkDisplay *display);
|
||||
gpointer gdk_display_get_egl_config (GdkDisplay *display);
|
||||
gpointer gdk_display_get_egl_config_high_depth
|
||||
(GdkDisplay *display);
|
||||
|
||||
void gdk_display_set_rgba (GdkDisplay *display,
|
||||
gboolean rgba);
|
||||
void gdk_display_set_composited (GdkDisplay *display,
|
||||
|
@@ -29,10 +29,9 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -22,10 +22,9 @@
|
||||
|
||||
#include "gdkdrawcontextprivate.h"
|
||||
|
||||
#include "gdkdebug.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
|
||||
/**
|
||||
* GdkDrawContext:
|
||||
@@ -276,8 +275,7 @@ gdk_draw_context_get_surface (GdkDrawContext *context)
|
||||
|
||||
/**
|
||||
* gdk_draw_context_begin_frame:
|
||||
* @context: the `GdkDrawContext` used to draw the frame. The context must
|
||||
* have a surface.
|
||||
* @context: the `GdkDrawContext` used to draw the frame
|
||||
* @region: minimum region that should be drawn
|
||||
*
|
||||
* Indicates that you are beginning the process of redrawing @region
|
||||
@@ -312,41 +310,8 @@ gdk_draw_context_begin_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);
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
gdk_draw_context_begin_frame_full (context, FALSE, region);
|
||||
}
|
||||
|
||||
/*
|
||||
* @prefers_high_depth: %TRUE to request a higher bit depth
|
||||
*
|
||||
* If high depth is preferred, GDK will see about providing a rendering target
|
||||
* that supports higher bit depth than 8 bits per channel. Typically this means
|
||||
* a target supporting 16bit floating point pixels, but that is not guaranteed.
|
||||
*
|
||||
* This is only a request and if the GDK backend does not support HDR rendering
|
||||
* or does not consider it worthwhile, it may choose to not honor the request.
|
||||
* It may also choose to provide high depth even if it was not requested.
|
||||
* Typically the steps undertaken by a backend are:
|
||||
* 1. Check if high depth is supported by this drawing backend.
|
||||
* 2. Check if the compositor supports high depth.
|
||||
* 3. Check if the compositor prefers regular bit depth. This is usually the case
|
||||
* when the attached monitors do not support high depth content or when the
|
||||
* system is resource constrained.
|
||||
* In either of those cases, the context will usually choose to not honor the request.
|
||||
*
|
||||
* The rendering code must be able to deal with content in any bit depth, no matter
|
||||
* the preference. The prefers_high_depth argument is only a hint and GDK is free
|
||||
* to choose.
|
||||
*/
|
||||
void
|
||||
gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
gboolean prefers_high_depth,
|
||||
const cairo_region_t *region)
|
||||
{
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (priv->surface))
|
||||
return;
|
||||
|
||||
@@ -368,13 +333,10 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
return;
|
||||
}
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (priv->display, HIGH_DEPTH))
|
||||
prefers_high_depth = TRUE;
|
||||
|
||||
priv->frame_region = cairo_region_copy (region);
|
||||
priv->surface->paint_context = g_object_ref (context);
|
||||
|
||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, prefers_high_depth, priv->frame_region);
|
||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, priv->frame_region);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSPROF
|
||||
@@ -415,7 +377,6 @@ gdk_draw_context_end_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;
|
||||
|
@@ -41,7 +41,6 @@ struct _GdkDrawContextClass
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* begin_frame) (GdkDrawContext *context,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *update_area);
|
||||
void (* end_frame) (GdkDrawContext *context,
|
||||
cairo_region_t *painted);
|
||||
@@ -50,9 +49,6 @@ struct _GdkDrawContextClass
|
||||
|
||||
void gdk_draw_context_surface_resized (GdkDrawContext *context);
|
||||
|
||||
void gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
gboolean prefers_high_depth,
|
||||
const cairo_region_t *region);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */
|
||||
|
@@ -46,9 +46,9 @@
|
||||
#include "gdkcontentserializer.h"
|
||||
#include "gdkcursor.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkpipeiostreamprivate.h"
|
||||
#include "gdksurface.h"
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
|
336
gdk/gdkenums.h
336
gdk/gdkenums.h
@@ -1,336 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_ENUMS_H__
|
||||
#define __GDK_ENUMS_H__
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Currently, these are the same values numerically as in the
|
||||
* X protocol. If you change that, gdksurface-x11.c/gdk_surface_set_geometry_hints()
|
||||
* will need fixing.
|
||||
*/
|
||||
/**
|
||||
* GdkGravity:
|
||||
* @GDK_GRAVITY_NORTH_WEST: the reference point is at the top left corner.
|
||||
* @GDK_GRAVITY_NORTH: the reference point is in the middle of the top edge.
|
||||
* @GDK_GRAVITY_NORTH_EAST: the reference point is at the top right corner.
|
||||
* @GDK_GRAVITY_WEST: the reference point is at the middle of the left edge.
|
||||
* @GDK_GRAVITY_CENTER: the reference point is at the center of the surface.
|
||||
* @GDK_GRAVITY_EAST: the reference point is at the middle of the right edge.
|
||||
* @GDK_GRAVITY_SOUTH_WEST: the reference point is at the lower left corner.
|
||||
* @GDK_GRAVITY_SOUTH: the reference point is at the middle of the lower edge.
|
||||
* @GDK_GRAVITY_SOUTH_EAST: the reference point is at the lower right corner.
|
||||
* @GDK_GRAVITY_STATIC: the reference point is at the top left corner of the
|
||||
* surface itself, ignoring window manager decorations.
|
||||
*
|
||||
* Defines the reference point of a surface and is used in `GdkPopupLayout`.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_GRAVITY_NORTH_WEST = 1,
|
||||
GDK_GRAVITY_NORTH,
|
||||
GDK_GRAVITY_NORTH_EAST,
|
||||
GDK_GRAVITY_WEST,
|
||||
GDK_GRAVITY_CENTER,
|
||||
GDK_GRAVITY_EAST,
|
||||
GDK_GRAVITY_SOUTH_WEST,
|
||||
GDK_GRAVITY_SOUTH,
|
||||
GDK_GRAVITY_SOUTH_EAST,
|
||||
GDK_GRAVITY_STATIC
|
||||
} GdkGravity;
|
||||
|
||||
/* Types of modifiers.
|
||||
*/
|
||||
/**
|
||||
* GdkModifierType:
|
||||
* @GDK_SHIFT_MASK: the Shift key.
|
||||
* @GDK_LOCK_MASK: a Lock key (depending on the modifier mapping of the
|
||||
* X server this may either be CapsLock or ShiftLock).
|
||||
* @GDK_CONTROL_MASK: the Control key.
|
||||
* @GDK_ALT_MASK: the fourth modifier key (it depends on the modifier
|
||||
* mapping of the X server which key is interpreted as this modifier, but
|
||||
* normally it is the Alt key).
|
||||
* @GDK_BUTTON1_MASK: the first mouse button.
|
||||
* @GDK_BUTTON2_MASK: the second mouse button.
|
||||
* @GDK_BUTTON3_MASK: the third mouse button.
|
||||
* @GDK_BUTTON4_MASK: the fourth mouse button.
|
||||
* @GDK_BUTTON5_MASK: the fifth mouse button.
|
||||
* @GDK_SUPER_MASK: the Super modifier
|
||||
* @GDK_HYPER_MASK: the Hyper modifier
|
||||
* @GDK_META_MASK: the Meta modifier
|
||||
*
|
||||
* Flags to indicate the state of modifier keys and mouse buttons
|
||||
* in events.
|
||||
*
|
||||
* Typical modifier keys are Shift, Control, Meta, Super, Hyper, Alt, Compose,
|
||||
* Apple, CapsLock or ShiftLock.
|
||||
*
|
||||
* Note that GDK may add internal values to events which include values outside
|
||||
* of this enumeration. Your code should preserve and ignore them. You can use
|
||||
* %GDK_MODIFIER_MASK to remove all private values.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_SHIFT_MASK = 1 << 0,
|
||||
GDK_LOCK_MASK = 1 << 1,
|
||||
GDK_CONTROL_MASK = 1 << 2,
|
||||
GDK_ALT_MASK = 1 << 3,
|
||||
|
||||
GDK_BUTTON1_MASK = 1 << 8,
|
||||
GDK_BUTTON2_MASK = 1 << 9,
|
||||
GDK_BUTTON3_MASK = 1 << 10,
|
||||
GDK_BUTTON4_MASK = 1 << 11,
|
||||
GDK_BUTTON5_MASK = 1 << 12,
|
||||
|
||||
GDK_SUPER_MASK = 1 << 26,
|
||||
GDK_HYPER_MASK = 1 << 27,
|
||||
GDK_META_MASK = 1 << 28,
|
||||
} GdkModifierType;
|
||||
|
||||
|
||||
/**
|
||||
* GDK_MODIFIER_MASK:
|
||||
*
|
||||
* A mask covering all entries in `GdkModifierType`.
|
||||
*/
|
||||
#define GDK_MODIFIER_MASK (GDK_SHIFT_MASK|GDK_LOCK_MASK|GDK_CONTROL_MASK| \
|
||||
GDK_ALT_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK| \
|
||||
GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK| \
|
||||
GDK_BUTTON4_MASK|GDK_BUTTON5_MASK)
|
||||
|
||||
|
||||
/**
|
||||
* GdkGLError:
|
||||
* @GDK_GL_ERROR_NOT_AVAILABLE: OpenGL support is not available
|
||||
* @GDK_GL_ERROR_UNSUPPORTED_FORMAT: The requested visual format is not supported
|
||||
* @GDK_GL_ERROR_UNSUPPORTED_PROFILE: The requested profile is not supported
|
||||
* @GDK_GL_ERROR_COMPILATION_FAILED: The shader compilation failed
|
||||
* @GDK_GL_ERROR_LINK_FAILED: The shader linking failed
|
||||
*
|
||||
* Error enumeration for `GdkGLContext`.
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
GDK_GL_ERROR_LINK_FAILED
|
||||
} GdkGLError;
|
||||
|
||||
/**
|
||||
* GdkVulkanError:
|
||||
* @GDK_VULKAN_ERROR_UNSUPPORTED: Vulkan is not supported on this backend or has not been
|
||||
* compiled in.
|
||||
* @GDK_VULKAN_ERROR_NOT_AVAILABLE: Vulkan support is not available on this Surface
|
||||
*
|
||||
* Error enumeration for `GdkVulkanContext`.
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_VULKAN_ERROR_UNSUPPORTED,
|
||||
GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
||||
} GdkVulkanError;
|
||||
|
||||
/**
|
||||
* GdkAxisUse:
|
||||
* @GDK_AXIS_IGNORE: the axis is ignored.
|
||||
* @GDK_AXIS_X: the axis is used as the x axis.
|
||||
* @GDK_AXIS_Y: the axis is used as the y axis.
|
||||
* @GDK_AXIS_DELTA_X: the axis is used as the scroll x delta
|
||||
* @GDK_AXIS_DELTA_Y: the axis is used as the scroll y delta
|
||||
* @GDK_AXIS_PRESSURE: the axis is used for pressure information.
|
||||
* @GDK_AXIS_XTILT: the axis is used for x tilt information.
|
||||
* @GDK_AXIS_YTILT: the axis is used for y tilt information.
|
||||
* @GDK_AXIS_WHEEL: the axis is used for wheel information.
|
||||
* @GDK_AXIS_DISTANCE: the axis is used for pen/tablet distance information
|
||||
* @GDK_AXIS_ROTATION: the axis is used for pen rotation information
|
||||
* @GDK_AXIS_SLIDER: the axis is used for pen slider information
|
||||
* @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
|
||||
*
|
||||
* Defines how device axes are interpreted by GTK.
|
||||
*
|
||||
* Note that the X and Y axes are not really needed; pointer devices
|
||||
* report their location via the x/y members of events regardless. Whether
|
||||
* X and Y are present as axes depends on the GDK backend.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_AXIS_IGNORE,
|
||||
GDK_AXIS_X,
|
||||
GDK_AXIS_Y,
|
||||
GDK_AXIS_DELTA_X,
|
||||
GDK_AXIS_DELTA_Y,
|
||||
GDK_AXIS_PRESSURE,
|
||||
GDK_AXIS_XTILT,
|
||||
GDK_AXIS_YTILT,
|
||||
GDK_AXIS_WHEEL,
|
||||
GDK_AXIS_DISTANCE,
|
||||
GDK_AXIS_ROTATION,
|
||||
GDK_AXIS_SLIDER,
|
||||
GDK_AXIS_LAST
|
||||
} GdkAxisUse;
|
||||
|
||||
/**
|
||||
* GdkAxisFlags:
|
||||
* @GDK_AXIS_FLAG_X: X axis is present
|
||||
* @GDK_AXIS_FLAG_Y: Y axis is present
|
||||
* @GDK_AXIS_FLAG_DELTA_X: Scroll X delta axis is present
|
||||
* @GDK_AXIS_FLAG_DELTA_Y: Scroll Y delta axis is present
|
||||
* @GDK_AXIS_FLAG_PRESSURE: Pressure axis is present
|
||||
* @GDK_AXIS_FLAG_XTILT: X tilt axis is present
|
||||
* @GDK_AXIS_FLAG_YTILT: Y tilt axis is present
|
||||
* @GDK_AXIS_FLAG_WHEEL: Wheel axis is present
|
||||
* @GDK_AXIS_FLAG_DISTANCE: Distance axis is present
|
||||
* @GDK_AXIS_FLAG_ROTATION: Z-axis rotation is present
|
||||
* @GDK_AXIS_FLAG_SLIDER: Slider axis is present
|
||||
*
|
||||
* Flags describing the current capabilities of a device/tool.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_AXIS_FLAG_X = 1 << GDK_AXIS_X,
|
||||
GDK_AXIS_FLAG_Y = 1 << GDK_AXIS_Y,
|
||||
GDK_AXIS_FLAG_DELTA_X = 1 << GDK_AXIS_DELTA_X,
|
||||
GDK_AXIS_FLAG_DELTA_Y = 1 << GDK_AXIS_DELTA_Y,
|
||||
GDK_AXIS_FLAG_PRESSURE = 1 << GDK_AXIS_PRESSURE,
|
||||
GDK_AXIS_FLAG_XTILT = 1 << GDK_AXIS_XTILT,
|
||||
GDK_AXIS_FLAG_YTILT = 1 << GDK_AXIS_YTILT,
|
||||
GDK_AXIS_FLAG_WHEEL = 1 << GDK_AXIS_WHEEL,
|
||||
GDK_AXIS_FLAG_DISTANCE = 1 << GDK_AXIS_DISTANCE,
|
||||
GDK_AXIS_FLAG_ROTATION = 1 << GDK_AXIS_ROTATION,
|
||||
GDK_AXIS_FLAG_SLIDER = 1 << GDK_AXIS_SLIDER,
|
||||
} GdkAxisFlags;
|
||||
|
||||
/**
|
||||
* GdkDragAction:
|
||||
* @GDK_ACTION_COPY: Copy the data.
|
||||
* @GDK_ACTION_MOVE: Move the data, i.e. first copy it, then delete
|
||||
* it from the source using the DELETE target of the X selection protocol.
|
||||
* @GDK_ACTION_LINK: Add a link to the data. Note that this is only
|
||||
* useful if source and destination agree on what it means, and is not
|
||||
* supported on all platforms.
|
||||
* @GDK_ACTION_ASK: Ask the user what to do with the data.
|
||||
*
|
||||
* Used in `GdkDrop` and `GdkDrag` to indicate the actions that the
|
||||
* destination can and should do with the dropped data.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_ACTION_COPY = 1 << 0,
|
||||
GDK_ACTION_MOVE = 1 << 1,
|
||||
GDK_ACTION_LINK = 1 << 2,
|
||||
GDK_ACTION_ASK = 1 << 3
|
||||
} GdkDragAction;
|
||||
|
||||
/**
|
||||
* GDK_ACTION_ALL:
|
||||
*
|
||||
* Defines all possible DND actions.
|
||||
*
|
||||
* This can be used in [method@Gdk.Drop.status] messages when any drop
|
||||
* can be accepted or a more specific drop method is not yet known.
|
||||
*/
|
||||
#define GDK_ACTION_ALL (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)
|
||||
|
||||
/**
|
||||
* GdkMemoryFormat:
|
||||
* @GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: 4 bytes; for blue, green, red, alpha.
|
||||
* The color values are premultiplied with the alpha value.
|
||||
* @GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: 4 bytes; for alpha, red, green, blue.
|
||||
* 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_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_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
|
||||
* @GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: 4 guint16 values; for red, green,
|
||||
* blue, alpha. The color values are premultiplied with the alpha value.
|
||||
* Since: 4.6
|
||||
* @GDK_MEMORY_R16G16B16A16: 4 guint16 values; for red, green, blue, alpha.
|
||||
* Since: 4.6
|
||||
* @GDK_MEMORY_R16G16B16_FLOAT: 3 half-float values; for red, green, blue.
|
||||
* The data is opaque. Since: 4.6
|
||||
* @GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: 4 half-float values; for
|
||||
* red, green, blue and alpha. The color values are premultiplied with
|
||||
* the alpha value. Since: 4.6
|
||||
* @GDK_MEMORY_R16G16B16A16_FLOAT: 4 half-float values; for red, green,
|
||||
* blue and alpha. Since: 4.6
|
||||
* @GDK_MEMORY_B32G32R32_FLOAT: 3 float values; for blue, green, red.
|
||||
* The data is opaque. Since: 4.6
|
||||
* @GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: 4 float values; for
|
||||
* red, green, blue and alpha. The color values are premultiplied with
|
||||
* the alpha value. Since: 4.6
|
||||
* @GDK_MEMORY_R32G32B32A32_FLOAT: 4 float values; for red, green, blue and
|
||||
* alpha. Since: 4.6
|
||||
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
|
||||
* more formats get added, so do not rely on its concrete integer.
|
||||
*
|
||||
* `GdkMemoryFormat` describes formats that image data can have in memory.
|
||||
*
|
||||
* It describes formats by listing the contents of the memory passed to it.
|
||||
* So GDK_MEMORY_A8R8G8B8 will be 1 byte (8 bits) of alpha, followed by a
|
||||
* byte each of red, green and blue. It is not endian-dependent, so
|
||||
* CAIRO_FORMAT_ARGB32 is represented by different `GdkMemoryFormats`
|
||||
* on architectures with different endiannesses.
|
||||
*
|
||||
* Its naming is modelled after
|
||||
* [VkFormat](https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkFormat)
|
||||
* for details).
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
|
||||
GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
GDK_MEMORY_B8G8R8A8,
|
||||
GDK_MEMORY_A8R8G8B8,
|
||||
GDK_MEMORY_R8G8B8A8,
|
||||
GDK_MEMORY_A8B8G8R8,
|
||||
GDK_MEMORY_R8G8B8,
|
||||
GDK_MEMORY_B8G8R8,
|
||||
GDK_MEMORY_R16G16B16,
|
||||
GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
|
||||
GDK_MEMORY_R16G16B16A16,
|
||||
GDK_MEMORY_R16G16B16_FLOAT,
|
||||
GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
|
||||
GDK_MEMORY_R16G16B16A16_FLOAT,
|
||||
GDK_MEMORY_R32G32B32_FLOAT,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT,
|
||||
|
||||
GDK_MEMORY_N_FORMATS
|
||||
} GdkMemoryFormat;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_ENUMS_H__ */
|
@@ -24,13 +24,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkintl.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkdropprivate.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
@@ -29,12 +29,11 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkframeclockprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
/**
|
||||
* GdkFrameClock:
|
||||
|
@@ -26,8 +26,9 @@
|
||||
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
|
||||
#include "gdkdebug.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkframeclockprivate.h"
|
||||
#include "gdk.h"
|
||||
#include "gdk-private.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
|
||||
|
271
gdk/gdkgl.c
271
gdk/gdkgl.c
@@ -18,14 +18,273 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcairo.h"
|
||||
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *
|
||||
get_shader_type_name (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_VERTEX_SHADER:
|
||||
return "vertex";
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return "geometry";
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return "fragment";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
create_shader (int type,
|
||||
const char *code)
|
||||
{
|
||||
guint shader;
|
||||
int status;
|
||||
|
||||
shader = glCreateShader (type);
|
||||
glShaderSource (shader, 1, &code, 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", get_shader_type_name (type), buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteShader (shader);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
static void
|
||||
make_program (GdkGLContextProgram *program,
|
||||
const char *vertex_shader_path,
|
||||
const char *fragment_shader_path)
|
||||
{
|
||||
guint vertex_shader, fragment_shader;
|
||||
GBytes *source;
|
||||
int status;
|
||||
|
||||
source = g_resources_lookup_data (vertex_shader_path, 0, NULL);
|
||||
g_assert (source != NULL);
|
||||
vertex_shader = create_shader (GL_VERTEX_SHADER, g_bytes_get_data (source, NULL));
|
||||
g_bytes_unref (source);
|
||||
if (vertex_shader == 0)
|
||||
return;
|
||||
|
||||
source = g_resources_lookup_data (fragment_shader_path, 0, NULL);
|
||||
g_assert (source != NULL);
|
||||
fragment_shader = create_shader (GL_FRAGMENT_SHADER, g_bytes_get_data (source, NULL));
|
||||
g_bytes_unref (source);
|
||||
if (fragment_shader == 0)
|
||||
{
|
||||
glDeleteShader (vertex_shader);
|
||||
return;
|
||||
}
|
||||
|
||||
program->program = glCreateProgram ();
|
||||
glAttachShader (program->program, vertex_shader);
|
||||
glAttachShader (program->program, fragment_shader);
|
||||
|
||||
glLinkProgram (program->program);
|
||||
|
||||
glDetachShader (program->program, vertex_shader);
|
||||
glDetachShader (program->program, fragment_shader);
|
||||
|
||||
glDeleteShader (vertex_shader);
|
||||
glDeleteShader (fragment_shader);
|
||||
|
||||
glGetProgramiv (program->program, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
int log_len;
|
||||
char *buffer;
|
||||
|
||||
glGetProgramiv (program->program, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc (log_len + 1);
|
||||
glGetProgramInfoLog (program->program, log_len, NULL, buffer);
|
||||
g_warning ("Linker failure: %s\n", buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program->program);
|
||||
}
|
||||
|
||||
program->position_location = glGetAttribLocation (program->program, "position");
|
||||
program->uv_location = glGetAttribLocation (program->program, "uv");
|
||||
program->map_location = glGetUniformLocation (program->program, "map");
|
||||
program->flip_location = glGetUniformLocation (program->program, "flipColors");
|
||||
}
|
||||
|
||||
static void
|
||||
bind_vao (GdkGLContextPaintData *paint_data)
|
||||
{
|
||||
if (paint_data->vertex_array_object == 0)
|
||||
{
|
||||
glGenVertexArrays (1, &paint_data->vertex_array_object);
|
||||
/* ATM we only use one VAO, so always bind it */
|
||||
glBindVertexArray (paint_data->vertex_array_object);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
use_texture_gles_program (GdkGLContextPaintData *paint_data)
|
||||
{
|
||||
if (paint_data->texture_2d_quad_program.program == 0)
|
||||
make_program (&paint_data->texture_2d_quad_program,
|
||||
"/org/gtk/libgdk/glsl/gles2-texture.vs.glsl",
|
||||
"/org/gtk/libgdk/glsl/gles2-texture.fs.glsl");
|
||||
|
||||
if (paint_data->current_program != &paint_data->texture_2d_quad_program)
|
||||
{
|
||||
paint_data->current_program = &paint_data->texture_2d_quad_program;
|
||||
glUseProgram (paint_data->current_program->program);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
use_texture_2d_program (GdkGLContextPaintData *paint_data)
|
||||
{
|
||||
const char *vertex_shader_path = paint_data->is_legacy
|
||||
? "/org/gtk/libgdk/glsl/gl2-texture-2d.vs.glsl"
|
||||
: "/org/gtk/libgdk/glsl/gl3-texture-2d.vs.glsl";
|
||||
|
||||
const char *fragment_shader_path = paint_data->is_legacy
|
||||
? "/org/gtk/libgdk/glsl/gl2-texture-2d.fs.glsl"
|
||||
: "/org/gtk/libgdk/glsl/gl3-texture-2d.fs.glsl";
|
||||
|
||||
if (paint_data->texture_2d_quad_program.program == 0)
|
||||
make_program (&paint_data->texture_2d_quad_program, vertex_shader_path, fragment_shader_path);
|
||||
|
||||
if (paint_data->current_program != &paint_data->texture_2d_quad_program)
|
||||
{
|
||||
paint_data->current_program = &paint_data->texture_2d_quad_program;
|
||||
glUseProgram (paint_data->current_program->program);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
use_texture_rect_program (GdkGLContextPaintData *paint_data)
|
||||
{
|
||||
const char *vertex_shader_path = paint_data->is_legacy
|
||||
? "/org/gtk/libgdk/glsl/gl2-texture-rect.vs.glsl"
|
||||
: "/org/gtk/libgdk/glsl/gl3-texture-rect.vs.glsl";
|
||||
|
||||
const char *fragment_shader_path = paint_data->is_legacy
|
||||
? "/org/gtk/libgdk/glsl/gl2-texture-rect.fs.glsl"
|
||||
: "/org/gtk/libgdk/glsl/gl3-texture-rect.vs.glsl";
|
||||
|
||||
if (paint_data->texture_rect_quad_program.program == 0)
|
||||
make_program (&paint_data->texture_rect_quad_program, vertex_shader_path, fragment_shader_path);
|
||||
|
||||
if (paint_data->current_program != &paint_data->texture_rect_quad_program)
|
||||
{
|
||||
paint_data->current_program = &paint_data->texture_rect_quad_program;
|
||||
glUseProgram (paint_data->current_program->program);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_texture_quads (GdkGLContext *paint_context,
|
||||
guint texture_target,
|
||||
int n_quads,
|
||||
GdkTexturedQuad *quads,
|
||||
gboolean flip_colors)
|
||||
{
|
||||
GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
|
||||
GdkGLContextProgram *program;
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (paint_context);
|
||||
int surface_scale = gdk_surface_get_scale_factor (surface);
|
||||
float w = gdk_surface_get_width (surface) * surface_scale;
|
||||
float h = gdk_surface_get_height (surface) * surface_scale;
|
||||
int i;
|
||||
float *vertex_buffer_data;
|
||||
|
||||
bind_vao (paint_data);
|
||||
|
||||
if (paint_data->tmp_vertex_buffer == 0)
|
||||
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
|
||||
|
||||
if (paint_data->use_es)
|
||||
use_texture_gles_program (paint_data);
|
||||
else
|
||||
{
|
||||
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
|
||||
use_texture_rect_program (paint_data);
|
||||
else
|
||||
use_texture_2d_program (paint_data);
|
||||
}
|
||||
|
||||
program = paint_data->current_program;
|
||||
|
||||
/* Use texture unit 0 */
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glUniform1i(program->map_location, 0);
|
||||
|
||||
/* Flip 'R' and 'B' colors on GLES, if necessary */
|
||||
if (gdk_gl_context_get_use_es (paint_context))
|
||||
glUniform1i (program->flip_location, flip_colors ? 1 : 0);
|
||||
|
||||
glEnableVertexAttribArray (program->position_location);
|
||||
glEnableVertexAttribArray (program->uv_location);
|
||||
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_vertex_buffer);
|
||||
|
||||
glVertexAttribPointer (program->position_location, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, NULL);
|
||||
glVertexAttribPointer (program->uv_location, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void *) (sizeof(float) * 2));
|
||||
|
||||
#define VERTEX_SIZE 4
|
||||
|
||||
#define QUAD_N_VERTICES 6
|
||||
|
||||
#define QUAD_SIZE (VERTEX_SIZE * QUAD_N_VERTICES)
|
||||
|
||||
vertex_buffer_data = g_new (float, n_quads * QUAD_SIZE);
|
||||
|
||||
for (i = 0; i < n_quads; i++)
|
||||
{
|
||||
GdkTexturedQuad *quad = &quads[i];
|
||||
float vertex_data[] = {
|
||||
(quad->x1 * 2) / w - 1, (quad->y1 * 2) / h - 1, quad->u1, quad->v1,
|
||||
(quad->x1 * 2) / w - 1, (quad->y2 * 2) / h - 1, quad->u1, quad->v2,
|
||||
(quad->x2 * 2) / w - 1, (quad->y1 * 2) / h - 1, quad->u2, quad->v1,
|
||||
|
||||
(quad->x2 * 2) / w - 1, (quad->y2 * 2) / h - 1, quad->u2, quad->v2,
|
||||
(quad->x1 * 2) / w - 1, (quad->y2 * 2) / h - 1, quad->u1, quad->v2,
|
||||
(quad->x2 * 2) / w - 1, (quad->y1 * 2) / h - 1, quad->u2, quad->v1,
|
||||
};
|
||||
|
||||
float *vertex = &vertex_buffer_data[i * QUAD_SIZE];
|
||||
memcpy (vertex, vertex_data, sizeof(vertex_data));
|
||||
}
|
||||
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof(float) * n_quads * QUAD_SIZE, vertex_buffer_data, GL_STREAM_DRAW);
|
||||
glDrawArrays (GL_TRIANGLES, 0, n_quads * QUAD_N_VERTICES);
|
||||
|
||||
g_free (vertex_buffer_data);
|
||||
|
||||
glDisableVertexAttribArray (program->position_location);
|
||||
glDisableVertexAttribArray (program->uv_location);
|
||||
}
|
||||
|
||||
/* x,y,width,height describes a rectangle in the gl render buffer
|
||||
coordinate space, and its top left corner is drawn at the current
|
||||
position according to the cairo translation. */
|
||||
@@ -82,6 +341,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
cairo_surface_t *image;
|
||||
guint framebuffer;
|
||||
int alpha_size = 0;
|
||||
GdkGLContextPaintData *paint_data;
|
||||
int major, minor, version;
|
||||
gboolean es_use_bgra = FALSE;
|
||||
|
||||
@@ -95,8 +355,10 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
es_use_bgra = gdk_gl_context_use_es_bgra (paint_context);
|
||||
|
||||
gdk_gl_context_make_current (paint_context);
|
||||
paint_data = gdk_gl_context_get_paint_data (paint_context);
|
||||
|
||||
glGenFramebuffers (1, &framebuffer);
|
||||
if (paint_data->tmp_framebuffer == 0)
|
||||
glGenFramebuffers (1, &paint_data->tmp_framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
{
|
||||
@@ -135,6 +397,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
cairo_surface_set_device_scale (image, buffer_scale, buffer_scale);
|
||||
|
||||
framebuffer = paint_data->tmp_framebuffer;
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
@@ -165,8 +428,6 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, 0);
|
||||
|
||||
glDeleteFramebuffers (1, &framebuffer);
|
||||
|
||||
cairo_surface_mark_dirty (image);
|
||||
|
||||
cairo_set_source_surface (cr, image, 0, 0);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,20 +30,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GdkGLAPI:
|
||||
* @GDK_GL_API_GL: The OpenGL API
|
||||
* @GDK_GL_API_GLES: The OpenGL ES API
|
||||
*
|
||||
* The list of the different APIs that GdkGLContext can potentially support.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
typedef enum { /*< underscore_name=GDK_GL_API >*/
|
||||
GDK_GL_API_GL = 1 << 0,
|
||||
GDK_GL_API_GLES = 1 << 1
|
||||
} GdkGLAPI;
|
||||
|
||||
#define GDK_TYPE_GL_CONTEXT (gdk_gl_context_get_type ())
|
||||
#define GDK_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContext))
|
||||
#define GDK_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_GL_CONTEXT))
|
||||
@@ -90,14 +76,7 @@ void gdk_gl_context_set_forward_compatible (GdkGLContext *
|
||||
gboolean compatible);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_gl_context_get_forward_compatible (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
void gdk_gl_context_set_allowed_apis (GdkGLContext *self,
|
||||
GdkGLAPI apis);
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
GdkGLAPI gdk_gl_context_get_allowed_apis (GdkGLContext *self);
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
GdkGLAPI gdk_gl_context_get_api (GdkGLContext *self);
|
||||
GDK_DEPRECATED_IN_4_6_FOR(gdk_gl_context_set_allowed_apis)
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_gl_context_set_use_es (GdkGLContext *context,
|
||||
int use_es);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "gdkglcontext.h"
|
||||
#include "gdkdrawcontextprivate.h"
|
||||
#include "gdkmemorytexture.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -33,14 +34,6 @@ G_BEGIN_DECLS
|
||||
#define GDK_EGL_MIN_VERSION_MAJOR (1)
|
||||
#define GDK_EGL_MIN_VERSION_MINOR (4)
|
||||
|
||||
typedef enum {
|
||||
GDK_GL_NONE = 0,
|
||||
GDK_GL_EGL,
|
||||
GDK_GL_GLX,
|
||||
GDK_GL_WGL,
|
||||
GDK_GL_CGL
|
||||
} GdkGLBackend;
|
||||
|
||||
#define GDK_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
|
||||
#define GDK_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT))
|
||||
#define GDK_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
|
||||
@@ -59,9 +52,7 @@ struct _GdkGLContextClass
|
||||
{
|
||||
GdkDrawContextClass parent_class;
|
||||
|
||||
GdkGLBackend backend_type;
|
||||
|
||||
GdkGLAPI (* realize) (GdkGLContext *context,
|
||||
gboolean (* realize) (GdkGLContext *context,
|
||||
GError **error);
|
||||
|
||||
gboolean (* make_current) (GdkGLContext *context,
|
||||
@@ -95,23 +86,20 @@ typedef struct {
|
||||
guint use_es : 1;
|
||||
} GdkGLContextPaintData;
|
||||
|
||||
gboolean gdk_gl_backend_can_be_used (GdkGLBackend backend_type,
|
||||
GError **error);
|
||||
void gdk_gl_backend_use (GdkGLBackend backend_type);
|
||||
GdkGLContext * gdk_gl_context_new_for_surface (GdkSurface *surface);
|
||||
|
||||
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
|
||||
GdkSurface *surface);
|
||||
|
||||
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||
GdkGLAPI api,
|
||||
GError **error);
|
||||
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
gboolean is_legacy);
|
||||
|
||||
gboolean gdk_gl_context_check_version (GdkGLContext *context,
|
||||
int required_major,
|
||||
int required_minor);
|
||||
|
||||
void gdk_gl_context_upload_texture (GdkGLContext *context,
|
||||
const guchar *data,
|
||||
int width,
|
||||
int height,
|
||||
int stride,
|
||||
GdkMemoryFormat data_format,
|
||||
guint texture_target);
|
||||
GdkGLContextPaintData * gdk_gl_context_get_paint_data (GdkGLContext *context);
|
||||
gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context);
|
||||
gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context);
|
||||
void gdk_gl_context_push_debug_group (GdkGLContext *context,
|
||||
const char *message);
|
||||
@@ -133,6 +121,18 @@ gboolean gdk_gl_context_has_debug (GdkGLContext
|
||||
|
||||
gboolean gdk_gl_context_use_es_bgra (GdkGLContext *context);
|
||||
|
||||
typedef struct {
|
||||
float x1, y1, x2, y2;
|
||||
float u1, v1, u2, v2;
|
||||
} GdkTexturedQuad;
|
||||
|
||||
void gdk_gl_texture_quads (GdkGLContext *context,
|
||||
guint texture_target,
|
||||
int n_quads,
|
||||
GdkTexturedQuad *quads,
|
||||
gboolean flip_colors);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_GL_CONTEXT_PRIVATE_H__ */
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdktypes.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include "gdkgltextureprivate.h"
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
|
||||
@@ -109,132 +108,215 @@ gdk_gl_texture_run (GdkGLTexture *self,
|
||||
while (g_atomic_int_get (&invoke.spinlock) == 0);
|
||||
}
|
||||
|
||||
typedef struct _Download Download;
|
||||
|
||||
struct _Download
|
||||
{
|
||||
GdkMemoryFormat format;
|
||||
guchar *data;
|
||||
gsize stride;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gdk_gl_texture_find_format (gboolean use_es,
|
||||
GLint gl_format,
|
||||
GLint gl_type,
|
||||
GdkMemoryFormat *out_format)
|
||||
{
|
||||
GdkMemoryFormat format;
|
||||
|
||||
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
||||
{
|
||||
GLenum q_internal_format, q_format, q_type;
|
||||
|
||||
if (!gdk_memory_format_gl_format (format, use_es, &q_internal_format, &q_format, &q_type))
|
||||
continue;
|
||||
|
||||
if (q_format != gl_format || q_type != gl_type)
|
||||
continue;
|
||||
|
||||
*out_format = format;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_gl_texture_do_download (gpointer texture_,
|
||||
gpointer download_)
|
||||
gdk_gl_texture_get_tex_image (GdkGLTexture *self,
|
||||
GLenum gl_format,
|
||||
GLenum gl_type,
|
||||
GLvoid *data)
|
||||
{
|
||||
gsize expected_stride;
|
||||
GdkGLTexture *self = texture_;
|
||||
GdkTexture *texture = texture_;
|
||||
Download *download = download_;
|
||||
GLenum gl_internal_format, gl_format, gl_type;
|
||||
|
||||
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
|
||||
|
||||
if (download->stride == expected_stride &&
|
||||
!gdk_gl_context_get_use_es (self->context) &&
|
||||
gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type))
|
||||
if (gdk_gl_context_get_use_es (self->context))
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
download->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkMemoryFormat actual_format;
|
||||
GLint gl_read_format, gl_read_type;
|
||||
GdkTexture *texture = GDK_TEXTURE (self);
|
||||
GLuint fbo;
|
||||
|
||||
glGenFramebuffers (1, &fbo);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
|
||||
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (self->context), gl_read_format, gl_read_type, &actual_format))
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
|
||||
if (download->format == actual_format &&
|
||||
(download->stride == expected_stride))
|
||||
{
|
||||
glReadPixels (0, 0,
|
||||
texture->width, texture->height,
|
||||
gl_read_format,
|
||||
gl_read_type,
|
||||
download->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
gsize actual_bpp = gdk_memory_format_bytes_per_pixel (actual_format);
|
||||
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
|
||||
|
||||
glReadPixels (0, 0,
|
||||
texture->width, texture->height,
|
||||
gl_read_format,
|
||||
gl_read_type,
|
||||
pixels);
|
||||
|
||||
gdk_memory_convert (download->data,
|
||||
download->stride,
|
||||
download->format,
|
||||
pixels,
|
||||
texture->width * actual_bpp,
|
||||
actual_format,
|
||||
texture->width,
|
||||
texture->height);
|
||||
|
||||
g_free (pixels);
|
||||
}
|
||||
glReadPixels (0, 0,
|
||||
texture->width, texture->height,
|
||||
gl_format,
|
||||
gl_type,
|
||||
data);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, 0);
|
||||
glDeleteFramebuffers (1, &fbo);
|
||||
}
|
||||
else
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
data);
|
||||
}
|
||||
}
|
||||
static void
|
||||
gdk_gl_texture_do_download_texture (gpointer texture_,
|
||||
gpointer result_)
|
||||
{
|
||||
GdkTexture *texture = texture_;
|
||||
GdkTexture **result = result_;
|
||||
GdkMemoryFormat format;
|
||||
GLint internal_format, gl_format, gl_type;
|
||||
guchar *data;
|
||||
gsize stride;
|
||||
GBytes *bytes;
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
||||
|
||||
switch (internal_format)
|
||||
{
|
||||
case GL_RGB8:
|
||||
format = GDK_MEMORY_R8G8B8;
|
||||
gl_format = GL_RGB;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case GL_RGBA8:
|
||||
format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case GL_RGB16:
|
||||
format = GDK_MEMORY_R16G16B16;
|
||||
gl_format = GL_RGB;
|
||||
gl_type = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
case GL_RGBA16:
|
||||
format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
case GL_RGB16F:
|
||||
format = GDK_MEMORY_R16G16B16_FLOAT;
|
||||
gl_format = GL_RGB;
|
||||
gl_type = GL_HALF_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_RGBA16F:
|
||||
format = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_HALF_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_RGB32F:
|
||||
format = GDK_MEMORY_R32G32B32_FLOAT;
|
||||
gl_format = GL_RGB;
|
||||
gl_type = GL_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_RGBA32F:
|
||||
format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_FLOAT;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format);
|
||||
/* fallback to the dumbest possible format
|
||||
* so that even age old GLES can do it */
|
||||
format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
|
||||
stride = gdk_memory_format_bytes_per_pixel (format) * texture->width;
|
||||
data = g_malloc (stride * texture->height);
|
||||
|
||||
gdk_gl_texture_get_tex_image (texture_,
|
||||
gl_format,
|
||||
gl_type,
|
||||
data);
|
||||
|
||||
bytes = g_bytes_new_take (data, stride * texture->height);
|
||||
*result = gdk_memory_texture_new (texture->width,
|
||||
texture->height,
|
||||
format,
|
||||
bytes,
|
||||
stride);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
gdk_gl_texture_download_texture (GdkTexture *texture)
|
||||
{
|
||||
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
|
||||
GdkTexture *result;
|
||||
|
||||
if (self->saved)
|
||||
return g_object_ref (self->saved);
|
||||
|
||||
gdk_gl_texture_run (self, gdk_gl_texture_do_download_texture, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_download (GdkTexture *texture,
|
||||
GdkMemoryFormat format,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
gdk_gl_texture_do_download (gpointer texture,
|
||||
gpointer data)
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_BGRA,
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
GL_UNSIGNED_BYTE,
|
||||
#else
|
||||
#error "Unknown byte order for gdk_gl_texture_download()"
|
||||
#endif
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_download (GdkTexture *texture,
|
||||
guchar *data,
|
||||
gsize stride)
|
||||
{
|
||||
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
|
||||
Download download;
|
||||
|
||||
if (self->saved)
|
||||
{
|
||||
gdk_texture_do_download (self->saved, format, data, stride);
|
||||
gdk_texture_download (self->saved, data, stride);
|
||||
return;
|
||||
}
|
||||
|
||||
download.format = format;
|
||||
download.data = data;
|
||||
download.stride = stride;
|
||||
if (gdk_gl_context_get_use_es (self->context) ||
|
||||
stride != texture->width * 4)
|
||||
{
|
||||
GDK_TEXTURE_CLASS (gdk_gl_texture_parent_class)->download (texture, data, stride);
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_gl_texture_run (self, gdk_gl_texture_do_download, &download);
|
||||
gdk_gl_texture_run (self, gdk_gl_texture_do_download, data);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_do_download_float (gpointer texture,
|
||||
gpointer data)
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_FLOAT,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_download_float (GdkTexture *texture,
|
||||
float *data,
|
||||
gsize stride)
|
||||
{
|
||||
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
|
||||
|
||||
if (self->saved)
|
||||
{
|
||||
gdk_texture_download_float (self->saved, data, stride);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gdk_gl_context_get_use_es (self->context) ||
|
||||
stride != texture->width * 4)
|
||||
{
|
||||
GDK_TEXTURE_CLASS (gdk_gl_texture_parent_class)->download_float (texture, data, stride);
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_gl_texture_run (self, gdk_gl_texture_do_download_float, data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -243,8 +325,9 @@ gdk_gl_texture_class_init (GdkGLTextureClass *klass)
|
||||
GdkTextureClass *texture_class = GDK_TEXTURE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
texture_class->download_texture = gdk_gl_texture_download_texture;
|
||||
texture_class->download = gdk_gl_texture_download;
|
||||
|
||||
texture_class->download_float = gdk_gl_texture_download_float;
|
||||
gobject_class->dispose = gdk_gl_texture_dispose;
|
||||
}
|
||||
|
||||
@@ -278,14 +361,10 @@ gdk_gl_texture_get_id (GdkGLTexture *self)
|
||||
void
|
||||
gdk_gl_texture_release (GdkGLTexture *self)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE (self));
|
||||
g_return_if_fail (self->saved == NULL);
|
||||
|
||||
texture = GDK_TEXTURE (self);
|
||||
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
|
||||
gdk_texture_get_format (texture)));
|
||||
self->saved = gdk_texture_download_texture (GDK_TEXTURE (self));
|
||||
|
||||
if (self->destroy)
|
||||
{
|
||||
@@ -298,72 +377,6 @@ gdk_gl_texture_release (GdkGLTexture *self)
|
||||
self->id = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
{
|
||||
GdkTexture *texture = GDK_TEXTURE (self);
|
||||
GLint active_texture;
|
||||
GLint internal_format;
|
||||
|
||||
if (self->context != gdk_gl_context_get_current ())
|
||||
{
|
||||
/* Somebody else is GL-ing here, abort! */
|
||||
texture->format = GDK_MEMORY_DEFAULT;
|
||||
return;
|
||||
}
|
||||
|
||||
/* We need to be careful about modifying the GL context, as this is not
|
||||
* expected during construction */
|
||||
glGetIntegerv (GL_TEXTURE_BINDING_2D, &active_texture);
|
||||
glBindTexture (GL_TEXTURE_2D, self->id);
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
||||
|
||||
switch (internal_format)
|
||||
{
|
||||
case GL_RGB8:
|
||||
texture->format = GDK_MEMORY_R8G8B8;
|
||||
break;
|
||||
|
||||
case GL_RGBA8:
|
||||
texture->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case GL_RGB16:
|
||||
texture->format = GDK_MEMORY_R16G16B16;
|
||||
break;
|
||||
|
||||
case GL_RGBA16:
|
||||
texture->format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case GL_RGB16F:
|
||||
texture->format = GDK_MEMORY_R16G16B16_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_RGBA16F:
|
||||
texture->format = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case GL_RGB32F:
|
||||
texture->format = GDK_MEMORY_R32G32B32_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_RGBA32F:
|
||||
texture->format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format);
|
||||
/* fallback to the dumbest possible format
|
||||
* so that even age old GLES can do it */
|
||||
texture->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
break;
|
||||
}
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, active_texture);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_new:
|
||||
* @context: a `GdkGLContext`
|
||||
@@ -407,8 +420,6 @@ gdk_gl_texture_new (GdkGLContext *context,
|
||||
self->destroy = destroy;
|
||||
self->data = data;
|
||||
|
||||
gdk_gl_texture_determine_format (self);
|
||||
|
||||
return GDK_TEXTURE (self);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#ifndef __GTK_HSLA_PRIVATE_H__
|
||||
#define __GTK_HSLA_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdkrgba.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
43
gdk/gdkinternals.h
Normal file
43
gdk/gdkinternals.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
/* Uninstalled header defining types and functions internal to GDK */
|
||||
|
||||
#ifndef __GDK_INTERNALS_H__
|
||||
#define __GDK_INTERNALS_H__
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkseatprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkcairoprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkdebug.h"
|
||||
|
||||
#endif /* __GDK_INTERNALS_H__ */
|
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
/* Key handling not part of the keymap */
|
||||
|
||||
|
@@ -20,8 +20,6 @@
|
||||
|
||||
#include "gdkkeys.h"
|
||||
|
||||
#include "gdkenums.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_KEYMAP (gdk_keymap_get_type ())
|
||||
|
@@ -1,497 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2021 Benjamin Otte
|
||||
*
|
||||
* 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.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
|
||||
#include "gsk/gl/fp16private.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
typedef struct _GdkMemoryFormatDescription GdkMemoryFormatDescription;
|
||||
|
||||
#define TYPED_FUNCS(name, T, R, G, B, A, bpp, scale) \
|
||||
static void \
|
||||
name ## _to_float (float *dest, \
|
||||
const guchar *src_data, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *src = (T *) (src_data + i * bpp); \
|
||||
dest[0] = (float) src[R] / scale; \
|
||||
dest[1] = (float) src[G] / scale; \
|
||||
dest[2] = (float) src[B] / scale; \
|
||||
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
||||
dest += 4; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
name ## _from_float (guchar *dest_data, \
|
||||
const float *src, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *dest = (T *) (dest_data + i * bpp); \
|
||||
dest[R] = CLAMP (src[0] * scale + 0.5, 0, scale); \
|
||||
dest[G] = CLAMP (src[1] * scale + 0.5, 0, scale); \
|
||||
dest[B] = CLAMP (src[2] * scale + 0.5, 0, scale); \
|
||||
if (A >= 0) dest[A] = CLAMP (src[3] * scale + 0.5, 0, scale); \
|
||||
src += 4; \
|
||||
} \
|
||||
}
|
||||
|
||||
TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255)
|
||||
TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255)
|
||||
TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255)
|
||||
TYPED_FUNCS (b8g8r8a8, guchar, 2, 1, 0, 3, 4, 255)
|
||||
TYPED_FUNCS (a8r8g8b8, guchar, 1, 2, 3, 0, 4, 255)
|
||||
TYPED_FUNCS (r8g8b8a8, guchar, 0, 1, 2, 3, 4, 255)
|
||||
TYPED_FUNCS (a8b8g8r8, guchar, 3, 2, 1, 0, 4, 255)
|
||||
TYPED_FUNCS (r8g8b8, guchar, 0, 1, 2, -1, 3, 255)
|
||||
TYPED_FUNCS (b8g8r8, guchar, 2, 1, 0, -1, 3, 255)
|
||||
TYPED_FUNCS (r16g16b16, guint16, 0, 1, 2, -1, 6, 65535)
|
||||
TYPED_FUNCS (r16g16b16a16, guint16, 0, 1, 2, 3, 8, 65535)
|
||||
|
||||
static void
|
||||
r16g16b16_float_to_float (float *dest,
|
||||
const guchar *src_data,
|
||||
gsize n)
|
||||
{
|
||||
guint16 *src = (guint16 *) src_data;
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
half_to_float (src, dest, 3);
|
||||
dest[3] = 1.0;
|
||||
dest += 4;
|
||||
src += 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
r16g16b16_float_from_float (guchar *dest_data,
|
||||
const float *src,
|
||||
gsize n)
|
||||
{
|
||||
guint16 *dest = (guint16 *) dest_data;
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
float_to_half (src, dest, 3);
|
||||
dest += 3;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
r16g16b16a16_float_to_float (float *dest,
|
||||
const guchar *src,
|
||||
gsize n)
|
||||
{
|
||||
half_to_float ((const guint16 *) src, dest, 4 * n);
|
||||
}
|
||||
|
||||
static void
|
||||
r16g16b16a16_float_from_float (guchar *dest,
|
||||
const float *src,
|
||||
gsize n)
|
||||
{
|
||||
float_to_half (src, (guint16 *) dest, 4 * n);
|
||||
}
|
||||
|
||||
static void
|
||||
r32g32b32_float_to_float (float *dest,
|
||||
const guchar *src_data,
|
||||
gsize n)
|
||||
{
|
||||
float *src = (float *) src_data;
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
dest[3] = 1.0;
|
||||
dest += 4;
|
||||
src += 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
r32g32b32_float_from_float (guchar *dest_data,
|
||||
const float *src,
|
||||
gsize n)
|
||||
{
|
||||
float *dest = (float *) dest_data;
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
dest += 3;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
r32g32b32a32_float_to_float (float *dest,
|
||||
const guchar *src,
|
||||
gsize n)
|
||||
{
|
||||
memcpy (dest, src, sizeof (float) * n * 4);
|
||||
}
|
||||
|
||||
static void
|
||||
r32g32b32a32_float_from_float (guchar *dest,
|
||||
const float *src,
|
||||
gsize n)
|
||||
{
|
||||
memcpy (dest, src, sizeof (float) * n * 4);
|
||||
}
|
||||
|
||||
struct _GdkMemoryFormatDescription
|
||||
{
|
||||
GdkMemoryAlpha alpha;
|
||||
gsize bytes_per_pixel;
|
||||
gsize alignment;
|
||||
gboolean prefers_high_depth;
|
||||
gboolean supports_gles;
|
||||
struct {
|
||||
guint internal_format;
|
||||
guint format;
|
||||
guint type;
|
||||
} gl;
|
||||
/* no premultiplication going on here */
|
||||
void (* to_float) (float *, const guchar*, gsize);
|
||||
void (* from_float) (guchar *, const float *, gsize);
|
||||
};
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
# define GDK_GL_UNSIGNED_BYTE_FLIPPED GL_UNSIGNED_INT_8_8_8_8
|
||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
# define GDK_GL_UNSIGNED_BYTE_FLIPPED GL_UNSIGNED_INT_8_8_8_8_REV
|
||||
#else
|
||||
# error "Define the right GL flags here"
|
||||
#endif
|
||||
|
||||
static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_premultiplied_to_float,
|
||||
b8g8r8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_premultiplied_to_float,
|
||||
a8r8g8b8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_premultiplied_to_float,
|
||||
r8g8b8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_B8G8R8A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_to_float,
|
||||
b8g8r8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8R8G8B8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_to_float,
|
||||
a8r8g8b8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_to_float,
|
||||
r8g8b8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8B8G8R8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8b8g8r8_to_float,
|
||||
a8b8g8r8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
|
||||
r8g8b8_to_float,
|
||||
r8g8b8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_B8G8R8] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
|
||||
b8g8r8_to_float,
|
||||
b8g8r8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
|
||||
r16g16b16_to_float,
|
||||
r16g16b16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
|
||||
r16g16b16_float_to_float,
|
||||
r16g16b16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
12,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT },
|
||||
r32g32b32_float_to_float,
|
||||
r32g32b32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
16,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
16,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
}
|
||||
};
|
||||
|
||||
gsize
|
||||
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].bytes_per_pixel;
|
||||
}
|
||||
|
||||
GdkMemoryAlpha
|
||||
gdk_memory_format_alpha (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].alpha;
|
||||
}
|
||||
|
||||
gsize
|
||||
gdk_memory_format_alignment (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].alignment;
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gdk_memory_format_prefers_high_depth:
|
||||
* @format: a memory format
|
||||
*
|
||||
* Checks if the given format benefits from being rendered
|
||||
* in bit depths higher than 8bits per pixel. See
|
||||
* gsk_render_node_prefers_high_depth() for more information
|
||||
* on this.
|
||||
* Usually this is the case when
|
||||
* gdk_memory_format_bytes_per_pixel() is larger than 4.
|
||||
*
|
||||
* Returns: %TRUE if the format benefits from being
|
||||
* composited in hgiher bit depths.
|
||||
**/
|
||||
gboolean
|
||||
gdk_memory_format_prefers_high_depth (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].prefers_high_depth;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type)
|
||||
{
|
||||
*out_internal_format = memory_formats[format].gl.internal_format;
|
||||
*out_format = memory_formats[format].gl.format;
|
||||
*out_type = memory_formats[format].gl.type;
|
||||
|
||||
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return FALSE;
|
||||
|
||||
if (gles && !memory_formats[format].supports_gles)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
premultiply (float *rgba,
|
||||
gsize n)
|
||||
{
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
rgba[0] *= rgba[3];
|
||||
rgba[1] *= rgba[3];
|
||||
rgba[2] *= rgba[3];
|
||||
rgba += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpremultiply (float *rgba,
|
||||
gsize n)
|
||||
{
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
if (rgba[3] > 1/255.0)
|
||||
{
|
||||
rgba[0] /= rgba[3];
|
||||
rgba[1] /= rgba[3];
|
||||
rgba[2] /= rgba[3];
|
||||
}
|
||||
rgba += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_memory_convert (guchar *dest_data,
|
||||
gsize dest_stride,
|
||||
GdkMemoryFormat dest_format,
|
||||
const guchar *src_data,
|
||||
gsize src_stride,
|
||||
GdkMemoryFormat src_format,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
const GdkMemoryFormatDescription *dest_desc = &memory_formats[dest_format];
|
||||
const GdkMemoryFormatDescription *src_desc = &memory_formats[src_format];
|
||||
float *tmp;
|
||||
gsize y;
|
||||
|
||||
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
|
||||
g_assert (src_format < GDK_MEMORY_N_FORMATS);
|
||||
|
||||
tmp = g_new (float, width * 4);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
src_desc->to_float (tmp, src_data, width);
|
||||
if (src_desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED && dest_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
unpremultiply (tmp, width);
|
||||
else if (src_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT && dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
premultiply (tmp, width);
|
||||
dest_desc->from_float (dest_data, tmp, width);
|
||||
src_data += src_stride;
|
||||
dest_data += dest_stride;
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user