Compare commits
22 Commits
matthiasc/
...
css-variab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5d0f32d8c | ||
|
|
e825fd901f | ||
|
|
e3543f37d3 | ||
|
|
e9bf0322ac | ||
|
|
6d5cb0a083 | ||
|
|
8b5aab459a | ||
|
|
8da3cc10fd | ||
|
|
f48a4e84af | ||
|
|
09c76208a2 | ||
|
|
62b1d21556 | ||
|
|
8fba58eaa9 | ||
|
|
b4890edd64 | ||
|
|
93b9388180 | ||
|
|
76b2609ad5 | ||
|
|
a37a0711ad | ||
|
|
23dbb7122c | ||
|
|
e04ab263f9 | ||
|
|
5e6e808a55 | ||
|
|
6eaf6e2f7d | ||
|
|
e4a4a0f6dd | ||
|
|
f301ea7936 | ||
|
|
a3e9ecd199 |
@@ -117,11 +117,10 @@ release-build:
|
|||||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||||
script:
|
script:
|
||||||
- .gitlab-ci/show-info-linux.sh
|
- .gitlab-ci/show-info-linux.sh
|
||||||
- mkdir _install
|
- export PATH="$HOME/.local/bin:$PATH"
|
||||||
- export PATH="$HOME/.local/bin:${CI_PROJECT_DIR}/_install/bin:$PATH"
|
|
||||||
- .gitlab-ci/install-meson-project.sh --prefix ${CI_PROJECT_DIR}/_install https://gitlab.gnome.org/jadahl/catch.git main
|
|
||||||
- meson subprojects download
|
- meson subprojects download
|
||||||
- meson subprojects update --reset
|
- meson subprojects update --reset
|
||||||
|
- mkdir _install
|
||||||
- meson setup
|
- meson setup
|
||||||
--prefix=${CI_PROJECT_DIR}/_install
|
--prefix=${CI_PROJECT_DIR}/_install
|
||||||
${COMMON_MESON_FLAGS}
|
${COMMON_MESON_FLAGS}
|
||||||
@@ -446,10 +445,9 @@ reference:
|
|||||||
--force-fallback-for=gdk-pixbuf,pango
|
--force-fallback-for=gdk-pixbuf,pango
|
||||||
-Dintrospection=enabled
|
-Dintrospection=enabled
|
||||||
-Ddocumentation=true
|
-Ddocumentation=true
|
||||||
-Dman-pages=true
|
|
||||||
-Dgdk-pixbuf:gtk_doc=true
|
-Dgdk-pixbuf:gtk_doc=true
|
||||||
-Dpango:documentation=true
|
-Dpango:documentation=true
|
||||||
-Dbuild-demos=true
|
-Dbuild-demos=false
|
||||||
-Dbuild-examples=false
|
-Dbuild-examples=false
|
||||||
-Dbuild-tests=false
|
-Dbuild-tests=false
|
||||||
-Dbuild-testsuite=false
|
-Dbuild-testsuite=false
|
||||||
@@ -461,7 +459,6 @@ reference:
|
|||||||
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
|
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
|
||||||
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
|
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
|
||||||
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
|
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
|
||||||
- mv _build/docs/reference/gtk/*.html _reference/gtk4/
|
|
||||||
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
|
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
|
||||||
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
|
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
|
||||||
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/
|
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<-EOF
|
|
||||||
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT
|
|
||||||
|
|
||||||
Check out and install a meson project
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-Dkey=val Option to pass on to meson
|
|
||||||
--prefix Prefix to install to
|
|
||||||
--subdir Build subdirectory instead of whole project
|
|
||||||
--prepare Script to run before build
|
|
||||||
|
|
||||||
-h, --help Display this help
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
TEMP=$(getopt \
|
|
||||||
--name=$(basename $0) \
|
|
||||||
--options='D:h' \
|
|
||||||
--longoptions='prefix:' \
|
|
||||||
--longoptions='subdir:' \
|
|
||||||
--longoptions='prepare:' \
|
|
||||||
--longoptions='help' \
|
|
||||||
-- "$@")
|
|
||||||
|
|
||||||
eval set -- "$TEMP"
|
|
||||||
unset TEMP
|
|
||||||
|
|
||||||
MESON_OPTIONS=()
|
|
||||||
PREFIX=/usr
|
|
||||||
SUBDIR=.
|
|
||||||
PREPARE=:
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
case "$1" in
|
|
||||||
-D)
|
|
||||||
MESON_OPTIONS+=( -D$2 )
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
|
|
||||||
--prefix)
|
|
||||||
PREFIX=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
|
|
||||||
--subdir)
|
|
||||||
SUBDIR=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
|
|
||||||
--prepare)
|
|
||||||
PREPARE=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
|
|
||||||
-h|--help)
|
|
||||||
usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $# -lt 2 ]]; then
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
REPO_URL="$1"
|
|
||||||
COMMIT="$2"
|
|
||||||
|
|
||||||
CHECKOUT_DIR=$(mktemp --directory)
|
|
||||||
trap "rm -rf $CHECKOUT_DIR" EXIT
|
|
||||||
|
|
||||||
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
|
|
||||||
|
|
||||||
pushd "$CHECKOUT_DIR/$SUBDIR"
|
|
||||||
sh -c "$PREPARE"
|
|
||||||
meson setup --prefix "$PREFIX" _build "${MESON_OPTIONS[@]}"
|
|
||||||
meson compile -C _build
|
|
||||||
meson install -C _build
|
|
||||||
popd
|
|
||||||
@@ -100,16 +100,14 @@ development tools appropriate for your operating system, including:
|
|||||||
- Meson
|
- Meson
|
||||||
- Ninja
|
- Ninja
|
||||||
- Gettext (19.7 or newer)
|
- Gettext (19.7 or newer)
|
||||||
- a [C99 compatible compiler][glib-toolchain-reqs]
|
- a [C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
|
||||||
|
|
||||||
Up-to-date instructions about developing GNOME applications and libraries
|
Up-to-date instructions about developing GNOME applications and libraries
|
||||||
can be found on [the GNOME Developer Center](https://developer.gnome.org).
|
can be found on [the GNOME Developer Center](https://developer.gnome.org).
|
||||||
|
|
||||||
The GTK project uses GitLab for code hosting and for tracking issues. More
|
The GTK project uses GitLab for code hosting and for tracking issues. More
|
||||||
information about using GitLab can be found on [the GNOME handbook][handbook].
|
information about using GitLab can be found [on the GNOME
|
||||||
|
wiki](https://wiki.gnome.org/GitLab).
|
||||||
[glib-toolchain-reqs]: https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md
|
|
||||||
[handbook]: https://handbook.gnome.org/infrastructure/gitlab.html
|
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
@@ -133,7 +131,7 @@ GTK will attempt to download and build some of these dependencies if it
|
|||||||
cannot find them on your system.
|
cannot find them on your system.
|
||||||
|
|
||||||
Additionally, you may want to look at projects that create a development
|
Additionally, you may want to look at projects that create a development
|
||||||
environment for you, like [jhbuild](https://gitlab.gnome.org/GNOME/jhbuild)
|
environment for you, like [jhbuild](https://wiki.gnome.org/HowDoI/Jhbuild)
|
||||||
and [gvsbuild](https://github.com/wingtk/gvsbuild).
|
and [gvsbuild](https://github.com/wingtk/gvsbuild).
|
||||||
|
|
||||||
### Getting started
|
### Getting started
|
||||||
|
|||||||
97
NEWS
97
NEWS
@@ -1,92 +1,11 @@
|
|||||||
Overview of Changes in 4.15.4, xx-xx-xxxx
|
Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||||
=========================================
|
|
||||||
|
|
||||||
Overview of Changes in 4.15.3, 29-06-2024
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
* Accessibility:
|
|
||||||
- Only emit notifications when cursor positions change in GtkText
|
|
||||||
- Fix handling of help text properties
|
|
||||||
|
|
||||||
* CSS:
|
|
||||||
- Fix some crashes introduced in recent currentcolor changes
|
|
||||||
|
|
||||||
* DND:
|
|
||||||
- Avoid a critical
|
|
||||||
|
|
||||||
* Documentation:
|
|
||||||
- Fix many oversights and missing docs
|
|
||||||
|
|
||||||
* maxOS:
|
|
||||||
- Add native keyboard shortcuts
|
|
||||||
|
|
||||||
|
|
||||||
Overview of Changes in 4.15.2, 28-06-2024
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
* GtkFileChooserWidget:
|
|
||||||
- Plug some memory leaks
|
|
||||||
- Make Ctrl-Shift-N create a new folder
|
|
||||||
|
|
||||||
* GtkPopover:
|
|
||||||
- Handle resizing and position changes better
|
|
||||||
|
|
||||||
* CSS:
|
|
||||||
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
|
|
||||||
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
|
|
||||||
- Support relative colors (https://www.w3.org/TR/css-color-5/)
|
|
||||||
- Support more colorspaces in color()
|
|
||||||
- Allow percentages for opacity
|
|
||||||
- Handle currentcolor more correctly
|
|
||||||
|
|
||||||
* Accessibility:
|
|
||||||
- Avoid markup when reading labels
|
|
||||||
|
|
||||||
* GSK:
|
|
||||||
- Subset fonts when serializing node trees
|
|
||||||
- Make ngl export render_texture results as dmabufs
|
|
||||||
|
|
||||||
* Wayland:
|
|
||||||
- Use xdg-dialog protocol for attached dialogs
|
|
||||||
|
|
||||||
* Windows:
|
|
||||||
- Build with UNICODE
|
|
||||||
|
|
||||||
* macOS:
|
|
||||||
- Implement fullscreen-on-monitor
|
|
||||||
|
|
||||||
* Documentation:
|
|
||||||
- Widget shortcuts and actions are now described in the docs
|
|
||||||
|
|
||||||
* Debugging:
|
|
||||||
- Add GTK_DEBUG=css for warning about deprecated css syntax
|
|
||||||
|
|
||||||
* Tools:
|
|
||||||
- rendernode-tool: Add an extract command for data urls
|
|
||||||
|
|
||||||
* Deprecations:
|
|
||||||
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
|
|
||||||
|
|
||||||
* Translation updates:
|
|
||||||
Czech
|
|
||||||
Hebrew
|
|
||||||
Serbian
|
|
||||||
|
|
||||||
|
|
||||||
Overview of Changes in 4.15.1, 21-05-2024
|
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
* GtkGraphicsOffload:
|
* GtkGraphicsOffload:
|
||||||
- Don't crash without a child
|
- Don't crash without a child
|
||||||
|
|
||||||
* GtkSpinner:
|
|
||||||
- Don't animate when unmapped
|
|
||||||
|
|
||||||
* CSS:
|
* CSS:
|
||||||
- Support the :root selector
|
- Support the :root selector
|
||||||
- Support variables and custom properties (https://www.w3.org/TR/css-variables-1/)
|
|
||||||
- Implement math functions (https://www.w3.org/TR/css-values-4/)
|
|
||||||
- Support modern syntax and calc in rgb() and hsl()
|
|
||||||
|
|
||||||
* Icontheme:
|
* Icontheme:
|
||||||
- Make symbolic svg loading more efficient
|
- Make symbolic svg loading more efficient
|
||||||
@@ -95,22 +14,19 @@ Overview of Changes in 4.15.1, 21-05-2024
|
|||||||
* Accessibility:
|
* Accessibility:
|
||||||
- Make the gtk-demo sidebar search more accessible
|
- Make the gtk-demo sidebar search more accessible
|
||||||
- Stop emitting focus events
|
- Stop emitting focus events
|
||||||
- Realize child contexts when necessary
|
|
||||||
|
|
||||||
* GDK:
|
* GDK:
|
||||||
- Support XDG_ACTIVATION_TOKEN
|
- Support XDG_ACTIVATION_TOKEN
|
||||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||||
- dmabuf: Use narrow range for YUV
|
- dmabuf: Use narrow range for YUV
|
||||||
- vulkan: Recreate swapchains when necessary or beneficial
|
|
||||||
|
|
||||||
* GSK:
|
* GSK:
|
||||||
- Improve logging for GDK_DEBUG=offload
|
- Improve logging for GDK_DEBUG=offload
|
||||||
- Improve logging for GSK_DEBUG=renderer
|
- Improve logging for GSK_DEBUG=renderer
|
||||||
- gpu: Warn about inefficient texture import
|
- gpu: Warn about inefficient texture import
|
||||||
- gpu: Handle tiny offscreens correctly
|
- gpu: Handle tiny offscreens correctly
|
||||||
- vulkan: Add profiler marks in various places
|
- vulkan: Add profiler marks in various places
|
||||||
- vulkan: Fix a problem with imported dmabufs showing up black
|
- vulkan: Fix a problem with imported dmabufs showing up black
|
||||||
- cairo: Speed up mask nodes, since we use them for symbolic icons
|
|
||||||
|
|
||||||
* Wayland:
|
* Wayland:
|
||||||
- Use wl_compositor version 6
|
- Use wl_compositor version 6
|
||||||
@@ -123,22 +39,13 @@ Overview of Changes in 4.15.1, 21-05-2024
|
|||||||
|
|
||||||
* Debugging:
|
* Debugging:
|
||||||
- Show more texture details in the recorder
|
- Show more texture details in the recorder
|
||||||
- Use GTK_DEBUG=css to see CSS deprecations
|
|
||||||
|
|
||||||
* macOS:
|
* macOS:
|
||||||
- Fix problems with events handed back to the OS
|
- Fix problems with events handed back to the OS
|
||||||
- Respect GDK_DEBUG=default-settings
|
- Respect GDK_DEBUG=default-settings
|
||||||
- Allow applictions to handle Dock > Quit
|
|
||||||
|
|
||||||
* Deprecations:
|
|
||||||
- Use of @name colors in CSS
|
|
||||||
|
|
||||||
* Translation updates:
|
* Translation updates:
|
||||||
Catalan
|
|
||||||
Georgian
|
|
||||||
Hungarian
|
|
||||||
Korean
|
Korean
|
||||||
Portuguese
|
|
||||||
Turkish
|
Turkish
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -39,21 +39,18 @@ Nightly documentation can be found at
|
|||||||
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/
|
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/
|
||||||
|
|
||||||
Nightly flatpaks of our demos can be installed from the
|
Nightly flatpaks of our demos can be installed from the
|
||||||
[GNOME Nightly](https://nightly.gnome.org/) repository:
|
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
|
||||||
|
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
|
||||||
```sh
|
- `flatpak install gnome-nightly org.gtk.Demo4`
|
||||||
flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
|
- `flatpak install gnome-nightly org.gtk.WidgetFactory4`
|
||||||
flatpak install gnome-nightly org.gtk.Demo4
|
- `flatpak install gnome-nightly org.gtk.IconBrowser4`
|
||||||
flatpak install gnome-nightly org.gtk.WidgetFactory4
|
|
||||||
flatpak install gnome-nightly org.gtk.IconBrowser4
|
|
||||||
```
|
|
||||||
|
|
||||||
Building and installing
|
Building and installing
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
In order to build GTK you will need:
|
In order to build GTK you will need:
|
||||||
|
|
||||||
- [a C99 compatible compiler](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md)
|
- [a C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
|
||||||
- [Python 3](https://www.python.org/)
|
- [Python 3](https://www.python.org/)
|
||||||
- [Meson](http://mesonbuild.com)
|
- [Meson](http://mesonbuild.com)
|
||||||
- [Ninja](https://ninja-build.org)
|
- [Ninja](https://ninja-build.org)
|
||||||
|
|||||||
@@ -170,7 +170,6 @@ update_paintable (GtkWidget *widget,
|
|||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_cogs (void)
|
create_cogs (void)
|
||||||
{
|
{
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
GtkWidget *picture;
|
GtkWidget *picture;
|
||||||
static GskGLShader *cog_shader = NULL;
|
static GskGLShader *cog_shader = NULL;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
@@ -183,7 +182,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|||||||
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
|
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
|
||||||
|
|
||||||
return picture;
|
return picture;
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
#include "gtkshadertoy.h"
|
#include "gtkshadertoy.h"
|
||||||
#include "gskshaderpaintable.h"
|
#include "gskshaderpaintable.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static GtkWidget *demo_window = NULL;
|
static GtkWidget *demo_window = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -362,5 +360,3 @@ do_gltransition (GtkWidget *do_widget)
|
|||||||
|
|
||||||
return demo_window;
|
return demo_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gskshaderpaintable.h"
|
#include "gskshaderpaintable.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GskShaderPaintable:
|
* GskShaderPaintable:
|
||||||
*
|
*
|
||||||
@@ -334,5 +332,3 @@ gsk_shader_paintable_update_time (GskShaderPaintable *self,
|
|||||||
|
|
||||||
g_bytes_unref (args);
|
g_bytes_unref (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <gsk/gsk.h>
|
#include <gsk/gsk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
|
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
|
||||||
@@ -43,5 +41,3 @@ void gsk_shader_paintable_update_time (GskShaderPaintable *self
|
|||||||
int time_idx,
|
int time_idx,
|
||||||
gint64 frame_time);
|
gint64 frame_time);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "gtkshaderbin.h"
|
#include "gtkshaderbin.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GskGLShader *shader;
|
GskGLShader *shader;
|
||||||
GtkStateFlags state;
|
GtkStateFlags state;
|
||||||
@@ -264,5 +262,3 @@ gtk_shader_bin_new (void)
|
|||||||
|
|
||||||
return GTK_WIDGET (self);
|
return GTK_WIDGET (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
|
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
|
||||||
@@ -20,5 +18,3 @@ void gtk_shader_bin_set_child (GtkShaderBin *self,
|
|||||||
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
|
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "gtkshaderstack.h"
|
#include "gtkshaderstack.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
struct _GtkShaderStack
|
struct _GtkShaderStack
|
||||||
{
|
{
|
||||||
GtkWidget parent_instance;
|
GtkWidget parent_instance;
|
||||||
@@ -361,5 +359,3 @@ gtk_shader_stack_set_active (GtkShaderStack *self,
|
|||||||
self->current = MIN (index, self->children->len);
|
self->current = MIN (index, self->children->len);
|
||||||
update_child_visible (self);
|
update_child_visible (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
|
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
|
||||||
@@ -20,5 +18,3 @@ void gtk_shader_stack_set_active (GtkShaderStack *self,
|
|||||||
int index);
|
int index);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ node_editor_application_new (void)
|
|||||||
|
|
||||||
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
|
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
|
||||||
"application-id", "org.gtk.gtk4.NodeEditor",
|
"application-id", "org.gtk.gtk4.NodeEditor",
|
||||||
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE,
|
"flags", G_APPLICATION_HANDLES_OPEN,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
|
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
|
||||||
|
|||||||
@@ -111,11 +111,3 @@ content_images = [
|
|||||||
]
|
]
|
||||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gdk/"
|
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gdk/"
|
||||||
urlmap_file = "urlmap.js"
|
urlmap_file = "urlmap.js"
|
||||||
|
|
||||||
[[object]]
|
|
||||||
name = "DECLARE_INTERNAL_TYPE"
|
|
||||||
hidden = true
|
|
||||||
|
|
||||||
[[object]]
|
|
||||||
pattern = "KEY_*"
|
|
||||||
check_ignore = true
|
|
||||||
|
|||||||
@@ -29,18 +29,6 @@ if get_option('documentation')
|
|||||||
install_dir: docs_dir,
|
install_dir: docs_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
test('doc-check-gdk',
|
|
||||||
gidocgen,
|
|
||||||
args: [
|
|
||||||
'check',
|
|
||||||
'--config', gdk4_toml,
|
|
||||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
|
||||||
gdk_gir[0],
|
|
||||||
],
|
|
||||||
depends: gdk_gir[0],
|
|
||||||
suite: ['docs'],
|
|
||||||
)
|
|
||||||
|
|
||||||
if x11_enabled
|
if x11_enabled
|
||||||
gdk4x11_toml = configure_file(
|
gdk4x11_toml = configure_file(
|
||||||
input: 'gdk4-x11.toml.in',
|
input: 'gdk4-x11.toml.in',
|
||||||
@@ -99,17 +87,5 @@ if get_option('documentation')
|
|||||||
install: true,
|
install: true,
|
||||||
install_dir: docs_dir,
|
install_dir: docs_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
test('doc-check-gdk-wayland',
|
|
||||||
gidocgen,
|
|
||||||
args: [
|
|
||||||
'check',
|
|
||||||
'--config', gdk4wayland_toml,
|
|
||||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
|
||||||
gdk_wayland_gir[0],
|
|
||||||
],
|
|
||||||
depends: gdk_wayland_gir[0],
|
|
||||||
suite: ['docs'],
|
|
||||||
)
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -66,7 +66,3 @@ content_images = [
|
|||||||
]
|
]
|
||||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gsk/"
|
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gsk/"
|
||||||
urlmap_file = "urlmap.js"
|
urlmap_file = "urlmap.js"
|
||||||
|
|
||||||
[[object]]
|
|
||||||
name = "INCLUDE_WARNING"
|
|
||||||
hidden = true
|
|
||||||
|
|||||||
@@ -30,16 +30,4 @@ if get_option('documentation')
|
|||||||
install: true,
|
install: true,
|
||||||
install_dir: docs_dir,
|
install_dir: docs_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
test('doc-check-gsk',
|
|
||||||
gidocgen,
|
|
||||||
args: [
|
|
||||||
'check',
|
|
||||||
'--config', gsk4_toml,
|
|
||||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
|
||||||
gsk_gir[0],
|
|
||||||
],
|
|
||||||
depends: gsk_gir[0],
|
|
||||||
suite: ['docs'],
|
|
||||||
)
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ Other libraries are maintained separately.
|
|||||||
file formats. It is available [here](ttps://download.gnome.org/sources/gdk-pixbuf/).
|
file formats. It is available [here](ttps://download.gnome.org/sources/gdk-pixbuf/).
|
||||||
- [Pango](http://www.pango.org) is a library for internationalized
|
- [Pango](http://www.pango.org) is a library for internationalized
|
||||||
text handling. It is available [here](https://download.gnome.org/sources/pango/).
|
text handling. It is available [here](https://download.gnome.org/sources/pango/).
|
||||||
- [GObject Introspection](https://gitlab.gnome.org/GNOME/gobject-introspection)
|
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection)
|
||||||
is a framework for making introspection data available to language
|
is a framework for making introspection data available to language
|
||||||
bindings. It is available [here](https://download.gnome.org/sources/gobject-introspection/).
|
bindings. It is available [here](https://download.gnome.org/sources/gobject-introspection/).
|
||||||
- The [GNU libiconv](https://www.gnu.org/software/libiconv/) library
|
- The [GNU libiconv](https://www.gnu.org/software/libiconv/) library
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ spec.
|
|||||||
The following units are supported for basic datatypes:
|
The following units are supported for basic datatypes:
|
||||||
|
|
||||||
Length
|
Length
|
||||||
: px, pt, em, ex, rem, pc, in, cm, mm
|
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
|
||||||
|
|
||||||
Percentage
|
Percentage
|
||||||
: %
|
: %, calc()
|
||||||
|
|
||||||
Angle
|
Angle
|
||||||
: deg, rad, grad, turn
|
: deg, grad, turn, calc()
|
||||||
|
|
||||||
Time
|
Time
|
||||||
: s, ms
|
: s, ms, calc()
|
||||||
|
|
||||||
Length values with the em or ex units are resolved using the font
|
Length values with the em or ex units are resolved using the font
|
||||||
size value, unless they occur in setting the font-size itself, in
|
size value, unless they occur in setting the font-size itself, in
|
||||||
@@ -33,15 +33,11 @@ which case they are resolved using the inherited font size value.
|
|||||||
The rem unit is resolved using the initial font size value, which is
|
The rem unit is resolved using the initial font size value, which is
|
||||||
not quite the same as the CSS definition of rem.
|
not quite the same as the CSS definition of rem.
|
||||||
|
|
||||||
Length values using physical units (pt, pc, in, cm, mm) are translated
|
The calc() notation adds considerable expressive power. There are limits
|
||||||
to px using the dpi value specified by the -gtk-dpi property, which is
|
on what types can be combined in such an expression (e.g. it does not make
|
||||||
different from the CSS definition, which uses a fixed dpi of 96.
|
sense to add a number and a time). For the full details, see the
|
||||||
|
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
|
||||||
The calc() notation adds considerable expressive power to all of these
|
spec.
|
||||||
datatypes. There are limits on what types can be combined in such an
|
|
||||||
expression (e.g. it does not make sense to add a number and a time).
|
|
||||||
For the full details, see the
|
|
||||||
[CSS Values and Units](https://www.w3.org/TR/css-values-4/) spec.
|
|
||||||
|
|
||||||
A common pattern among shorthand properties (called 'four sides') is one
|
A common pattern among shorthand properties (called 'four sides') is one
|
||||||
where one to four values can be specified, to determine a value for each
|
where one to four values can be specified, to determine a value for each
|
||||||
@@ -86,54 +82,36 @@ color: var(--prop, green);
|
|||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
|
|
||||||
### CSS Colors
|
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||||
|
|
||||||
Colors can be expressed in numerous ways in CSS (see the
|
|
||||||
[Color Module](https://www.w3.org/TR/css-color-5/). GTK supports
|
|
||||||
many (but not all) of these.
|
|
||||||
|
|
||||||
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
|
|
||||||
syntax, and calc() can be used as well in color expressions. hwb(), oklab(),
|
|
||||||
oklch(), color(), color-mix() and relative colors are supported as well.
|
|
||||||
|
|
||||||
### Non-CSS Colors
|
|
||||||
|
|
||||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
|
||||||
|
|
||||||
These extensions are deprecated and should be replaced by the equivalent
|
|
||||||
standard CSS notions.
|
|
||||||
|
|
||||||
The first is a reference to a color defined via a @define-color rule in CSS.
|
The first is a reference to a color defined via a @define-color rule in CSS.
|
||||||
The syntax for @define-color rules is as follows:
|
The syntax for @define-color rules is as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
@define-color name color
|
@define-color Name Color
|
||||||
```
|
```
|
||||||
|
|
||||||
To refer to the color defined by a @define-color rule, prefix the name with @.
|
To refer to the color defined by a @define-color rule, prefix the name with @.
|
||||||
|
|
||||||
The standard CSS mechanisms that should be used instead of @define-color are
|
|
||||||
custom properties, :root and var().
|
|
||||||
|
|
||||||
GTK also supports color expressions, which allow colors to be transformed to
|
GTK also supports color expressions, which allow colors to be transformed to
|
||||||
new ones. Color expressions can be nested, providing a rich language to
|
new ones. Color expressions can be nested, providing a rich language to
|
||||||
define colors. Color expressions resemble functions, taking 1 or more colors
|
define colors. Color expressions resemble functions, taking 1 or more colors
|
||||||
and in some cases a number as arguments.
|
and in some cases a number as arguments.
|
||||||
|
|
||||||
`lighter(color)`
|
`lighter(Color)`
|
||||||
: produces a brighter variant of `color`.
|
: produces a brighter variant of Color
|
||||||
|
|
||||||
`darker(color)`
|
`darker(Color)`
|
||||||
: produces a darker variant of `color`.
|
: produces a darker variant of Color
|
||||||
|
|
||||||
`shade(color, number)`
|
`shade(Color, Number)`
|
||||||
: changes the lightness of `color`. The `number` ranges from 0 for black to 2 for white.
|
: changes the lightness of Color. The number ranges from 0 for black to 2 for white.
|
||||||
|
|
||||||
`alpha(color, number)`
|
`alpha(Color, Number)`
|
||||||
: multiplies the alpha value of `color` by `number` (between 0 and 1).
|
: replaces the alpha value of color with number (between 0 and 1)
|
||||||
|
|
||||||
`mix(color1, color2, number)`
|
`mix(Color1, Color2, Number)`
|
||||||
: interpolates between the two colors.
|
: interpolates between the two colors
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
|
||||||
@@ -141,7 +119,7 @@ GTK extends the CSS syntax for images and also uses it for specifying icons.
|
|||||||
To load a themed icon, use
|
To load a themed icon, use
|
||||||
|
|
||||||
```
|
```
|
||||||
-gtk-icontheme(name)
|
-gtk-icontheme(Name)
|
||||||
```
|
```
|
||||||
|
|
||||||
The specified icon name is used to look up a themed icon, while taking into
|
The specified icon name is used to look up a themed icon, while taking into
|
||||||
@@ -177,7 +155,7 @@ images can specify normal and hi-resolution variants. From CSS, this can be
|
|||||||
done with
|
done with
|
||||||
|
|
||||||
```
|
```
|
||||||
-gtk-scaled(image1, image2)
|
-gtk-scaled(Image1, Image2)
|
||||||
```
|
```
|
||||||
|
|
||||||
## GTK CSS Properties
|
## GTK CSS Properties
|
||||||
|
|||||||
@@ -99,15 +99,16 @@ reaches the requested phase. However, in practice most things
|
|||||||
happen at higher levels:
|
happen at higher levels:
|
||||||
|
|
||||||
- If you are doing an animation, you can use
|
- If you are doing an animation, you can use
|
||||||
[method@Gtk.Widget.add_tick_callback] which will cause a regular
|
gtk_widget_add_tick_callback() which will cause a regular
|
||||||
beating of the clock with a callback in the Update phase
|
beating of the clock with a callback in the Update phase
|
||||||
until you stop the tick.
|
until you stop the tick.
|
||||||
- If some state changes that causes the size of your widget to
|
- If some state changes that causes the size of your widget to
|
||||||
change you call [method@Gtk.Widget.queue_resize] which will request
|
change you call gtk_widget_queue_resize() which will request
|
||||||
a Layout phase and mark your widget as needing relayout.
|
a Layout phase and mark your widget as needing relayout.
|
||||||
- If some state changes so you need to redraw your widget you
|
- If some state changes so you need to redraw some area of
|
||||||
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
|
your widget you use the normal gtk_widget_queue_draw()
|
||||||
your widget.
|
set of functions. These will request a Paint phase and
|
||||||
|
mark the region as needing redraw.
|
||||||
|
|
||||||
There are also a lot of implicit triggers of these from the
|
There are also a lot of implicit triggers of these from the
|
||||||
CSS layer (which does animations, resizes and repaints as needed).
|
CSS layer (which does animations, resizes and repaints as needed).
|
||||||
|
|||||||
@@ -245,6 +245,9 @@ to connect the "clicked" signal with [method@Gtk.Window.destroy], then the funct
|
|||||||
would be called on `button` (which would not go well, since the function expects
|
would be called on `button` (which would not go well, since the function expects
|
||||||
a `GtkWindow` as argument).
|
a `GtkWindow` as argument).
|
||||||
|
|
||||||
|
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
|
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
|
section will elaborate further on how to add several [class@Gtk.Widget]s to your
|
||||||
GTK application.
|
GTK application.
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ SYNOPSIS
|
|||||||
|
|
|
|
||||||
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
|
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
|
||||||
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
|
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
|
||||||
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
|
|
||||||
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
|
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
|
||||||
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
|
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
|
||||||
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
|
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
|
||||||
@@ -100,15 +99,3 @@ exit code is 1. If the images are identical, it is 0.
|
|||||||
``--quiet``
|
``--quiet``
|
||||||
|
|
||||||
Don't write results to stdout.
|
Don't write results to stdout.
|
||||||
|
|
||||||
|
|
||||||
Extract
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
The ``extract`` command saves all the data urls found in a node file to a given
|
|
||||||
directory. The file names for the extracted files are derived from the mimetype
|
|
||||||
of the url.
|
|
||||||
|
|
||||||
``--dir=DIRECTORY``
|
|
||||||
|
|
||||||
Save extracted files in ``DIRECTORY`` (defaults to the current directory).
|
|
||||||
|
|||||||
@@ -77,13 +77,11 @@ content_files = [
|
|||||||
"section-tree-widget.md",
|
"section-tree-widget.md",
|
||||||
"migrating-2to4.md",
|
"migrating-2to4.md",
|
||||||
"migrating-3to4.md",
|
"migrating-3to4.md",
|
||||||
"migrating-4to5.md",
|
|
||||||
"broadway.md",
|
"broadway.md",
|
||||||
"osx.md",
|
"osx.md",
|
||||||
"wayland.md",
|
"wayland.md",
|
||||||
"windows.md",
|
"windows.md",
|
||||||
"x11.md",
|
"x11.md",
|
||||||
"tools.md",
|
|
||||||
"visual_index.md",
|
"visual_index.md",
|
||||||
]
|
]
|
||||||
content_images = [
|
content_images = [
|
||||||
@@ -251,12 +249,3 @@ content_images = [
|
|||||||
]
|
]
|
||||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/"
|
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/"
|
||||||
urlmap_file = "urlmap.js"
|
urlmap_file = "urlmap.js"
|
||||||
|
|
||||||
[[object]]
|
|
||||||
name = "StyleProvider"
|
|
||||||
[[object.signal]]
|
|
||||||
name = "gtk-private-changed"
|
|
||||||
hidden = true
|
|
||||||
|
|
||||||
[check]
|
|
||||||
skip_deprecated = true
|
|
||||||
|
|||||||
@@ -140,11 +140,6 @@ capture phase, and key bindings locally, during the target phase.
|
|||||||
Under the hood, all shortcuts are represented as instances of `GtkShortcut`,
|
Under the hood, all shortcuts are represented as instances of `GtkShortcut`,
|
||||||
and they are managed by `GtkShortcutController`.
|
and they are managed by `GtkShortcutController`.
|
||||||
|
|
||||||
Note that GTK does not do anything to map the primary shortcut modifier
|
|
||||||
to <kbd>Command</kbd> on macOS. If you want to let your application to follow
|
|
||||||
macOS user experience conventions, you must create macOS-specific keyboard shortcuts.
|
|
||||||
The <kbd>Command</kbd> is named `Meta` (`GDK_META_MASK`) in GTK.
|
|
||||||
|
|
||||||
## Text input
|
## Text input
|
||||||
|
|
||||||
When actual text input is needed (i.e. not just keyboard shortcuts),
|
When actual text input is needed (i.e. not just keyboard shortcuts),
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ expand_content_md_files = [
|
|||||||
'running.md',
|
'running.md',
|
||||||
'migrating-2to4.md',
|
'migrating-2to4.md',
|
||||||
'migrating-3to4.md',
|
'migrating-3to4.md',
|
||||||
'migrating-4to5.md',
|
|
||||||
'actions.md',
|
'actions.md',
|
||||||
'input-handling.md',
|
'input-handling.md',
|
||||||
'drawing-model.md',
|
'drawing-model.md',
|
||||||
@@ -26,8 +25,7 @@ expand_content_md_files = [
|
|||||||
'section-tree-widget.md',
|
'section-tree-widget.md',
|
||||||
'section-list-widget.md',
|
'section-list-widget.md',
|
||||||
'question_index.md',
|
'question_index.md',
|
||||||
'visual_index.md',
|
'visual_index.md'
|
||||||
'tools.md',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
gtk_images = []
|
gtk_images = []
|
||||||
@@ -62,51 +60,39 @@ if get_option('documentation')
|
|||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: docs_dir,
|
install_dir: docs_dir,
|
||||||
install_tag: 'doc',
|
|
||||||
)
|
|
||||||
|
|
||||||
test('doc-check-gtk',
|
|
||||||
gidocgen,
|
|
||||||
args: [
|
|
||||||
'check',
|
|
||||||
'--config', gtk4_toml,
|
|
||||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
|
||||||
gtk_gir[0],
|
|
||||||
],
|
|
||||||
depends: gtk_gir[0],
|
|
||||||
suite: ['docs'],
|
|
||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
|
rst2man = find_program('rst2man', 'rst2man.py', required: false)
|
||||||
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
|
if get_option('man-pages') and not rst2man.found()
|
||||||
|
error('No rst2man found, but man pages were explicitly enabled')
|
||||||
|
endif
|
||||||
|
|
||||||
rst_files = [
|
if get_option('man-pages') and rst2man.found()
|
||||||
[ 'gtk4-broadwayd', '1' ],
|
rst_files = [
|
||||||
[ 'gtk4-builder-tool', '1' ],
|
[ 'gtk4-broadwayd', '1' ],
|
||||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
[ 'gtk4-builder-tool', '1' ],
|
||||||
[ 'gtk4-launch', '1', ],
|
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||||
[ 'gtk4-query-settings', '1', ],
|
[ 'gtk4-launch', '1', ],
|
||||||
[ 'gtk4-rendernode-tool', '1' ],
|
[ 'gtk4-query-settings', '1', ],
|
||||||
[ 'gtk4-update-icon-cache', '1', ],
|
[ 'gtk4-rendernode-tool', '1' ],
|
||||||
[ 'gtk4-path-tool', '1', ],
|
[ 'gtk4-update-icon-cache', '1', ],
|
||||||
]
|
[ 'gtk4-path-tool', '1', ],
|
||||||
|
|
||||||
if get_option('build-demos')
|
|
||||||
rst_files += [
|
|
||||||
[ 'gtk4-demo', '1', ],
|
|
||||||
[ 'gtk4-demo-application', '1', ],
|
|
||||||
[ 'gtk4-widget-factory', '1', ],
|
|
||||||
[ 'gtk4-icon-browser', '1', ],
|
|
||||||
[ 'gtk4-node-editor', '1', ],
|
|
||||||
]
|
]
|
||||||
endif
|
|
||||||
|
|
||||||
rst2x_flags = [
|
if get_option('build-demos')
|
||||||
'--syntax-highlight=none',
|
rst_files += [
|
||||||
]
|
[ 'gtk4-demo', '1', ],
|
||||||
|
[ 'gtk4-demo-application', '1', ],
|
||||||
|
[ 'gtk4-widget-factory', '1', ],
|
||||||
|
[ 'gtk4-icon-browser', '1', ],
|
||||||
|
[ 'gtk4-node-editor', '1', ],
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
if get_option('man-pages')
|
rst2man_flags = [
|
||||||
|
'--syntax-highlight=none',
|
||||||
|
]
|
||||||
|
|
||||||
foreach rst: rst_files
|
foreach rst: rst_files
|
||||||
man_name = rst[0]
|
man_name = rst[0]
|
||||||
@@ -117,34 +103,12 @@ if get_option('man-pages')
|
|||||||
output: '@0@.@1@'.format(man_name, man_section),
|
output: '@0@.@1@'.format(man_name, man_section),
|
||||||
command: [
|
command: [
|
||||||
rst2man,
|
rst2man,
|
||||||
rst2x_flags,
|
rst2man_flags,
|
||||||
'@INPUT@',
|
'@INPUT@',
|
||||||
],
|
],
|
||||||
capture: true,
|
capture: true,
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
|
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
|
||||||
install_tag: 'doc',
|
|
||||||
)
|
|
||||||
endforeach
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get_option('documentation')
|
|
||||||
|
|
||||||
foreach rst: rst_files
|
|
||||||
man_name = rst[0]
|
|
||||||
|
|
||||||
custom_target(
|
|
||||||
input: '@0@.rst'.format(man_name),
|
|
||||||
output: '@0@.html'.format(man_name),
|
|
||||||
command: [
|
|
||||||
rst2html5,
|
|
||||||
rst2x_flags,
|
|
||||||
'@INPUT@',
|
|
||||||
],
|
|
||||||
capture: true,
|
|
||||||
install: true,
|
|
||||||
install_dir: docs_dir / 'gtk4',
|
|
||||||
install_tag: 'doc',
|
|
||||||
)
|
)
|
||||||
endforeach
|
endforeach
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -451,11 +451,11 @@ hint about how modifiers are expected to be used. It also promoted
|
|||||||
the use of `<Primary>` instead of `<Control>` to specify accelerators that
|
the use of `<Primary>` instead of `<Control>` to specify accelerators that
|
||||||
adapt to platform conventions.
|
adapt to platform conventions.
|
||||||
|
|
||||||
In GTK 4, the meaning of modifiers has been fixed, and applications are
|
In GTK 4, the meaning of modifiers has been fixed, and backends are
|
||||||
expected to map the platform conventions to the existing modifiers.
|
expected to map the platform conventions to the existing modifiers.
|
||||||
The expected use of modifiers in GTK 4 is:
|
The expected use of modifiers in GTK 4 is:
|
||||||
|
|
||||||
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
|
`GDK_CONTROL_MASK`
|
||||||
: Primary accelerators
|
: Primary accelerators
|
||||||
|
|
||||||
`GDK_ALT_MASK`
|
`GDK_ALT_MASK`
|
||||||
@@ -464,7 +464,7 @@ The expected use of modifiers in GTK 4 is:
|
|||||||
`GDK_SHIFT_MASK`
|
`GDK_SHIFT_MASK`
|
||||||
: Extending selections
|
: Extending selections
|
||||||
|
|
||||||
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
|
`GDK_CONTROL_MASK`
|
||||||
: Modifying selections
|
: Modifying selections
|
||||||
|
|
||||||
`GDK_CONTROL_MASK|GDK_ALT_MASK`
|
`GDK_CONTROL_MASK|GDK_ALT_MASK`
|
||||||
@@ -473,15 +473,9 @@ The expected use of modifiers in GTK 4 is:
|
|||||||
Consequently, `GdkModifierIntent` and related APIs have been removed,
|
Consequently, `GdkModifierIntent` and related APIs have been removed,
|
||||||
and `<Control>` is preferred over `<Primary>` in accelerators.
|
and `<Control>` is preferred over `<Primary>` in accelerators.
|
||||||
|
|
||||||
In GTK 3 on macOS, the `<Primary>` modifier mapped to the <kbd>Command</kbd> key.
|
|
||||||
In GTK 4, this is no longer the case: `<Primary>` is synonymous to `<Control>`.
|
|
||||||
If you want to make your application to feel native on macOS,
|
|
||||||
you need to add accelerators for macOS that use the `<Meta>` modifier.
|
|
||||||
|
|
||||||
A related change is that GTK 4 no longer supports the use of archaic
|
A related change is that GTK 4 no longer supports the use of archaic
|
||||||
X11 'real' modifiers with the names Mod1,..., Mod5, and `GDK_MOD1_MASK`
|
X11 'real' modifiers with the names Mod1,..., Mod5, and `GDK_MOD1_MASK`
|
||||||
has been renamed to `GDK_ALT_MASK` and `GDK_MOD2_MASK` has been renamed to
|
has been renamed to `GDK_ALT_MASK`.
|
||||||
`GDK_META_MASK`.
|
|
||||||
|
|
||||||
### Replace `GtkClipboard` with `GdkClipboard`
|
### Replace `GtkClipboard` with `GdkClipboard`
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ use a GtkLabel.
|
|||||||
If you have a need for custom drawing that fits into the current
|
If you have a need for custom drawing that fits into the current
|
||||||
(dark or light) theme, e.g. for rendering a graph, you can still
|
(dark or light) theme, e.g. for rendering a graph, you can still
|
||||||
get the current style foreground color, using
|
get the current style foreground color, using
|
||||||
[method@Gtk.Widget.get_color].
|
[method@Gtk.Widget.get_style_color].
|
||||||
|
|
||||||
## Local stylesheets are going away
|
## Local stylesheets are going away
|
||||||
|
|
||||||
@@ -73,103 +73,6 @@ GTK 5 will no longer provide this functionality. The recommendations
|
|||||||
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
|
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
|
||||||
and rely on style classes to make your CSS apply only where desired.
|
and rely on style classes to make your CSS apply only where desired.
|
||||||
|
|
||||||
## Non-standard CSS extensions are going away
|
|
||||||
|
|
||||||
GTK's CSS machinery has a some non-standard extensions around colors:
|
|
||||||
named colors with \@define-color and color functions: lighter(), darker(),
|
|
||||||
shade(), alpha(), mix().
|
|
||||||
|
|
||||||
GTK now implements equivalent functionality from the CSS specs.
|
|
||||||
|
|
||||||
### \@define-color is going away
|
|
||||||
|
|
||||||
\@define-color should be replaced by custom properties in the :root scope.
|
|
||||||
|
|
||||||
Instead of
|
|
||||||
|
|
||||||
```
|
|
||||||
@define-color fg_color #2e3436
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
box {
|
|
||||||
color: @fg_color;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
use
|
|
||||||
|
|
||||||
```
|
|
||||||
:root {
|
|
||||||
--fg-color: #2e3436;
|
|
||||||
}
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
box {
|
|
||||||
color: var(--fg-color);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information about custom CSS properties and variables, see the
|
|
||||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1/)
|
|
||||||
spec.
|
|
||||||
|
|
||||||
### Color expressions are going away
|
|
||||||
|
|
||||||
The color functions can all be replaced by combinations of calc() and color-mix().
|
|
||||||
|
|
||||||
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
|
|
||||||
thus can be handled the same way as shade in the examples below.
|
|
||||||
|
|
||||||
Replace
|
|
||||||
|
|
||||||
```
|
|
||||||
a {
|
|
||||||
color: mix(red, green, 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
b {
|
|
||||||
color: alpha(green, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
c {
|
|
||||||
color: shade(red, 1.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
d {
|
|
||||||
color: shade(red, 0.7);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
with
|
|
||||||
|
|
||||||
```
|
|
||||||
a {
|
|
||||||
color: color-mix(in srgb, red, green 80%);
|
|
||||||
}
|
|
||||||
|
|
||||||
b {
|
|
||||||
color: rgb(from green, r g b / calc(alpha * 0.6));
|
|
||||||
}
|
|
||||||
|
|
||||||
c {
|
|
||||||
color: hsl(from red, h calc(s * 1.3) calc(l * 1.3));
|
|
||||||
}
|
|
||||||
|
|
||||||
d {
|
|
||||||
color: hsl(from red, h calc(s * 0.7) calc(l * 0.7));
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Variations of these replacements are possible.
|
|
||||||
|
|
||||||
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
|
|
||||||
colorspaces, but using OKLAB instead might yield slightly better results.
|
|
||||||
|
|
||||||
For more information about color-mix(), see the
|
|
||||||
[CSS Color](https://drafts.csswg.org/css-color-5) spec.
|
|
||||||
|
|
||||||
## Chooser interfaces are going away
|
## Chooser interfaces are going away
|
||||||
|
|
||||||
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
|
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ on top of the Quartz API.
|
|||||||
Currently, the macOS port does not use any additional commandline options
|
Currently, the macOS port does not use any additional commandline options
|
||||||
or environment variables.
|
or environment variables.
|
||||||
|
|
||||||
For up-to-date information on building, installation, and bundling, see the
|
For up-to-date information about the current status of this port, see the
|
||||||
[GTK website](https://www.gtk.org/docs/installations/macos).
|
[project page](https://wiki.gnome.org/Projects/GTK/OSX).
|
||||||
|
|||||||
@@ -64,6 +64,6 @@ GTK is divided into three parts:
|
|||||||
[cairo]: https://www.cairographics.org/manual/
|
[cairo]: https://www.cairographics.org/manual/
|
||||||
[opengl]: https://www.opengl.org/about/
|
[opengl]: https://www.opengl.org/about/
|
||||||
[vulkan]: https://www.vulkan.org/
|
[vulkan]: https://www.vulkan.org/
|
||||||
[pango]: https://docs.gtk.org/Pango/
|
[pango]: https://docs.gtk.org/pango/
|
||||||
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
|
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
|
||||||
[graphene]: https://ebassi.github.io/graphene/
|
[graphene]: https://ebassi.github.io/graphene/
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ Slug: gtk-running
|
|||||||
|
|
||||||
GTK inspects a number of environment variables in addition to
|
GTK inspects a number of environment variables in addition to
|
||||||
standard variables like `LANG`, `PATH`, `HOME` or `DISPLAY`; mostly
|
standard variables like `LANG`, `PATH`, `HOME` or `DISPLAY`; mostly
|
||||||
to determine paths to look for certain files. The
|
to determine paths to look for certain files. The [X11](#x11-envar),
|
||||||
[X11](https://docs.gtk.org/gtk4/x11.html#x11-specific-environment-variables),
|
[Wayland](#wayland-envar), [Windows](#win32-envar) and
|
||||||
[Wayland](https://docs.gtk.org/gtk4/wayland.html#wayland-specific-environment-variables),
|
[Broadway](#broadway-envar) GDK backends use some additional
|
||||||
[Windows](https://docs.gtk.org/gtk4/windows.html#windows-specific-environment-variables) and
|
environment variables.
|
||||||
[Broadway](https://docs.gtk.org/gtk4/broadway.html#broadway-specific-environment-variables)
|
|
||||||
GDK backends use some additional environment variables.
|
|
||||||
|
|
||||||
Note that environment variables are generally used for debugging
|
Note that environment variables are generally used for debugging
|
||||||
purposes. They are not guaranteed to be API stable, and should not
|
purposes. They are not guaranteed to be API stable, and should not
|
||||||
@@ -292,8 +290,8 @@ are only available when GTK has been configured with `-Ddebug=true`.
|
|||||||
`fallback`
|
`fallback`
|
||||||
: Information about fallback usage in renderers
|
: Information about fallback usage in renderers
|
||||||
|
|
||||||
`cache`
|
`glyphcache`
|
||||||
: Information about caching
|
: Information about glyph caching
|
||||||
|
|
||||||
`verbose`
|
`verbose`
|
||||||
: Print verbose output while rendering
|
: Print verbose output while rendering
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
Title: Tools and Demos
|
|
||||||
|
|
||||||
GTK ships with a number of tools and demos that come with their own
|
|
||||||
documentation in the form of man pages.
|
|
||||||
|
|
||||||
- [gtk4-broadwayd](gtk4-broadwayd.html)
|
|
||||||
- [gtk4-builder-tool](gtk4-builder-tool.html)
|
|
||||||
- [gtk4-demo](gtk4-demo.html)
|
|
||||||
- [gtk4-demo-application](gtk4-demo-application.html)
|
|
||||||
- [gtk4-encode-symbolic-svg](gtk4-encode-symbolic-svg.html)
|
|
||||||
- [gtk4-icon-browser](gtk4-icon-browser.html)
|
|
||||||
- [gtk4-launch](gtk4-launch.html)
|
|
||||||
- [gtk4-node-editor](gtk4-node-editor.html)
|
|
||||||
- [gtk4-path-tool](gtk4-path-tool.html)
|
|
||||||
- [gtk4-query-settings](gtk4-query-settings.html)
|
|
||||||
- [gtk4-rendernode-tool](gtk4-rendernode-tool.html)
|
|
||||||
- [gtk4-update-icon-cache](gtk4-update-icon-cache.html)
|
|
||||||
- [gtk4-widget-factory](gtk4-widget-factory.html)
|
|
||||||
@@ -43,7 +43,7 @@ X11 details, in particular the ICCCM and the Extended Window Manager
|
|||||||
Hints specifications. [freedesktop.org](http://www.freedesktop.org/standards/)
|
Hints specifications. [freedesktop.org](http://www.freedesktop.org/standards/)
|
||||||
has links to many relevant specifications.
|
has links to many relevant specifications.
|
||||||
|
|
||||||
The GDK manual covers [using Xlib in a GTK program](https://docs.gtk.org/gdk4/x11.html).
|
The GDK manual covers [using Xlib in a GTK program](#gdk-X-Window-System-Interaction).
|
||||||
|
|
||||||
### Server, client, window manager
|
### Server, client, window manager
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,9 @@ gdk_broadway_cairo_context_dispose (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
|
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
|
||||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
||||||
@@ -61,9 +59,6 @@ gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -33,11 +33,9 @@ gdk_broadway_draw_context_dispose (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
|
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
|
||||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
||||||
@@ -54,9 +52,6 @@ gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
|
|
||||||
self->nodes = g_array_new (FALSE, FALSE, sizeof(guint32));
|
self->nodes = g_array_new (FALSE, FALSE, sizeof(guint32));
|
||||||
self->node_textures = g_ptr_array_new_with_free_func (g_object_unref);
|
self->node_textures = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
|||||||
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
|
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
|
||||||
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
|
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
|
||||||
|
|
||||||
{ "linear", GDK_DEBUG_LINEAR, "Enable linear rendering" },
|
|
||||||
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
|
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
|
||||||
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
|
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
|
||||||
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
|
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include <gdk/gdkcairo.h>
|
#include <gdk/gdkcairo.h>
|
||||||
#include <gdk/gdkcairocontext.h>
|
#include <gdk/gdkcairocontext.h>
|
||||||
#include <gdk/gdkclipboard.h>
|
#include <gdk/gdkclipboard.h>
|
||||||
#include <gdk/gdkcolorstate.h>
|
|
||||||
#include <gdk/gdkconfig.h>
|
#include <gdk/gdkconfig.h>
|
||||||
#include <gdk/gdkcontentdeserializer.h>
|
#include <gdk/gdkcontentdeserializer.h>
|
||||||
#include <gdk/gdkcontentformats.h>
|
#include <gdk/gdkcontentformats.h>
|
||||||
|
|||||||
@@ -41,10 +41,8 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||||
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
|
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
|
||||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
|
|
||||||
#else
|
#else
|
||||||
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
|
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
|
||||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* make this readable */
|
/* make this readable */
|
||||||
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
|
|||||||
gdk_array(reserve) (GdkArray *self,
|
gdk_array(reserve) (GdkArray *self,
|
||||||
gsize n)
|
gsize n)
|
||||||
{
|
{
|
||||||
gsize new_capacity, size, capacity;
|
gsize new_size, size;
|
||||||
|
|
||||||
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
|
if (n <= gdk_array(get_capacity) (self))
|
||||||
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
|
return;
|
||||||
|
|
||||||
capacity = gdk_array(get_capacity) (self);
|
|
||||||
if (n <= capacity)
|
|
||||||
return;
|
|
||||||
|
|
||||||
size = gdk_array(get_size) (self);
|
size = gdk_array(get_size) (self);
|
||||||
/* capacity * 2 can overflow, that's why we MAX() */
|
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
|
||||||
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
|
|
||||||
|
|
||||||
#ifdef GDK_ARRAY_PREALLOC
|
#ifdef GDK_ARRAY_PREALLOC
|
||||||
if (self->start == self->preallocated)
|
if (self->start == self->preallocated)
|
||||||
{
|
{
|
||||||
self->start = g_new (_T_, new_capacity);
|
self->start = g_new (_T_, new_size);
|
||||||
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
|
|||||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||||
if (self->start == NULL)
|
if (self->start == NULL)
|
||||||
{
|
{
|
||||||
self->start = g_new (_T_, new_capacity);
|
self->start = g_new (_T_, new_size);
|
||||||
*self->start = *(_T_[1]) { 0 };
|
*self->start = *(_T_[1]) { 0 };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
self->start = g_renew (_T_, self->start, new_capacity);
|
self->start = g_renew (_T_, self->start, new_size);
|
||||||
|
|
||||||
self->end = self->start + size;
|
self->end = self->start + size;
|
||||||
self->end_allocation = self->start + new_capacity;
|
self->end_allocation = self->start + new_size;
|
||||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||||
self->end_allocation--;
|
self->end_allocation--;
|
||||||
#endif
|
#endif
|
||||||
@@ -319,7 +312,6 @@ gdk_array(get) (const GdkArray *self,
|
|||||||
#undef gdk_array_paste
|
#undef gdk_array_paste
|
||||||
#undef gdk_array
|
#undef gdk_array
|
||||||
#undef GDK_ARRAY_REAL_SIZE
|
#undef GDK_ARRAY_REAL_SIZE
|
||||||
#undef GDK_ARRAY_MAX_SIZE
|
|
||||||
|
|
||||||
#undef GDK_ARRAY_BY_VALUE
|
#undef GDK_ARRAY_BY_VALUE
|
||||||
#undef GDK_ARRAY_ELEMENT_TYPE
|
#undef GDK_ARRAY_ELEMENT_TYPE
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
|
|
||||||
#include "gdkmemoryformatprivate.h"
|
|
||||||
#include "gdkmemorytexture.h"
|
|
||||||
|
|
||||||
#include <cairo.h>
|
|
||||||
#include <graphene.h>
|
|
||||||
|
|
||||||
static inline cairo_format_t
|
|
||||||
gdk_cairo_format_for_depth (GdkMemoryDepth depth)
|
|
||||||
{
|
|
||||||
switch (depth)
|
|
||||||
{
|
|
||||||
case GDK_MEMORY_NONE:
|
|
||||||
case GDK_MEMORY_U8:
|
|
||||||
return CAIRO_FORMAT_ARGB32;
|
|
||||||
|
|
||||||
case GDK_MEMORY_U8_SRGB:
|
|
||||||
case GDK_MEMORY_U16:
|
|
||||||
case GDK_MEMORY_FLOAT16:
|
|
||||||
case GDK_MEMORY_FLOAT32:
|
|
||||||
return CAIRO_FORMAT_RGBA128F;
|
|
||||||
|
|
||||||
case GDK_N_DEPTHS:
|
|
||||||
default:
|
|
||||||
g_return_val_if_reached (CAIRO_FORMAT_ARGB32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GdkMemoryDepth
|
|
||||||
gdk_cairo_depth_for_format (cairo_format_t format)
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case CAIRO_FORMAT_ARGB32:
|
|
||||||
case CAIRO_FORMAT_RGB24:
|
|
||||||
case CAIRO_FORMAT_RGB16_565:
|
|
||||||
case CAIRO_FORMAT_A1:
|
|
||||||
case CAIRO_FORMAT_A8:
|
|
||||||
return GDK_MEMORY_U8;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB30:
|
|
||||||
return GDK_MEMORY_U16;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB96F:
|
|
||||||
case CAIRO_FORMAT_RGBA128F:
|
|
||||||
return GDK_MEMORY_FLOAT32;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_INVALID:
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return GDK_MEMORY_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkMemoryFormat
|
|
||||||
gdk_cairo_format_to_memory_format (cairo_format_t format)
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case CAIRO_FORMAT_ARGB32:
|
|
||||||
return GDK_MEMORY_DEFAULT;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB24:
|
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
||||||
return GDK_MEMORY_B8G8R8X8;
|
|
||||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
|
||||||
return GDK_MEMORY_X8R8G8B8;
|
|
||||||
#else
|
|
||||||
#error "Unknown byte order for Cairo format"
|
|
||||||
#endif
|
|
||||||
case CAIRO_FORMAT_A8:
|
|
||||||
return GDK_MEMORY_A8;
|
|
||||||
case CAIRO_FORMAT_RGB96F:
|
|
||||||
return GDK_MEMORY_R32G32B32_FLOAT;
|
|
||||||
case CAIRO_FORMAT_RGBA128F:
|
|
||||||
return GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB16_565:
|
|
||||||
case CAIRO_FORMAT_RGB30:
|
|
||||||
case CAIRO_FORMAT_INVALID:
|
|
||||||
case CAIRO_FORMAT_A1:
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return GDK_MEMORY_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
gdk_cairo_set_source_rgba_ccs (cairo_t *cr,
|
|
||||||
GdkColorState *ccs,
|
|
||||||
const GdkRGBA *rgba)
|
|
||||||
{
|
|
||||||
float color[4];
|
|
||||||
|
|
||||||
gdk_color_state_from_rgba (ccs, rgba, color);
|
|
||||||
cairo_set_source_rgba (cr, color[0], color[1], color[2], color[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
gdk_cairo_pattern_add_color_stop_rgba_ccs (cairo_pattern_t *pattern,
|
|
||||||
GdkColorState *ccs,
|
|
||||||
double offset,
|
|
||||||
const GdkRGBA *rgba)
|
|
||||||
{
|
|
||||||
float color[4];
|
|
||||||
|
|
||||||
gdk_color_state_from_rgba (ccs, rgba, color);
|
|
||||||
cairo_pattern_add_color_stop_rgba (pattern, offset, color[0], color[1], color[2], color[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
gdk_cairo_rect (cairo_t *cr,
|
|
||||||
const graphene_rect_t *rect)
|
|
||||||
{
|
|
||||||
cairo_rectangle (cr,
|
|
||||||
rect->origin.x, rect->origin.y,
|
|
||||||
rect->size.width, rect->size.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
gdk_cairo_surface_convert_color_state (cairo_surface_t *surface,
|
|
||||||
GdkColorState *source,
|
|
||||||
GdkColorState *target)
|
|
||||||
{
|
|
||||||
cairo_surface_t *image_surface;
|
|
||||||
|
|
||||||
if (gdk_color_state_equal (source, target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
image_surface = cairo_surface_map_to_image (surface, NULL);
|
|
||||||
|
|
||||||
gdk_memory_convert_color_state (cairo_image_surface_get_data (image_surface),
|
|
||||||
cairo_image_surface_get_stride (image_surface),
|
|
||||||
gdk_cairo_format_to_memory_format (cairo_image_surface_get_format (image_surface)),
|
|
||||||
source,
|
|
||||||
target,
|
|
||||||
cairo_image_surface_get_width (image_surface),
|
|
||||||
cairo_image_surface_get_height (image_surface));
|
|
||||||
|
|
||||||
cairo_surface_mark_dirty (image_surface);
|
|
||||||
cairo_surface_unmap_image (surface, image_surface);
|
|
||||||
/* https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/487 */
|
|
||||||
cairo_surface_mark_dirty (surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -515,13 +515,15 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
|
|||||||
* @clipboard: a `GdkClipboard`
|
* @clipboard: a `GdkClipboard`
|
||||||
* @io_priority: the I/O priority of the request
|
* @io_priority: the I/O priority of the request
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data:: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously instructs the @clipboard to store its contents remotely.
|
* Asynchronously instructs the @clipboard to store its contents remotely.
|
||||||
*
|
*
|
||||||
* If the clipboard is not local, this function does nothing but report success.
|
* If the clipboard is not local, this function does nothing but report success.
|
||||||
*
|
*
|
||||||
|
* The @callback must call [method@Gdk.Clipboard.store_finish].
|
||||||
|
*
|
||||||
* The purpose of this call is to preserve clipboard contents beyond the
|
* The purpose of this call is to preserve clipboard contents beyond the
|
||||||
* lifetime of an application, so this function is typically called on
|
* lifetime of an application, so this function is typically called on
|
||||||
* exit. Depending on the platform, the functionality may not be available
|
* exit. Depending on the platform, the functionality may not be available
|
||||||
@@ -630,12 +632,15 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
|
|||||||
* @mime_types: (array zero-terminated=1): a %NULL-terminated array of mime types to choose from
|
* @mime_types: (array zero-terminated=1): a %NULL-terminated array of mime types to choose from
|
||||||
* @io_priority: the I/O priority of the request
|
* @io_priority: the I/O priority of the request
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously requests an input stream to read the @clipboard's
|
* Asynchronously requests an input stream to read the @clipboard's
|
||||||
* contents from.
|
* contents from.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must then
|
||||||
|
* call [method@Gdk.Clipboard.read_finish] to get the result of the operation.
|
||||||
|
*
|
||||||
* The clipboard will choose the most suitable mime type from the given list
|
* The clipboard will choose the most suitable mime type from the given list
|
||||||
* to fulfill the request, preferring the ones listed first.
|
* to fulfill the request, preferring the ones listed first.
|
||||||
*/
|
*/
|
||||||
@@ -823,12 +828,15 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
|
|||||||
* @type: a `GType` to read
|
* @type: a `GType` to read
|
||||||
* @io_priority: the I/O priority of the request
|
* @io_priority: the I/O priority of the request
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously request the @clipboard contents converted to the given
|
* Asynchronously request the @clipboard contents converted to the given
|
||||||
* @type.
|
* @type.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must then call
|
||||||
|
* [method@Gdk.Clipboard.read_value_finish] to get the resulting `GValue`.
|
||||||
|
*
|
||||||
* For local clipboard contents that are available in the given `GType`,
|
* For local clipboard contents that are available in the given `GType`,
|
||||||
* the value will be copied directly. Otherwise, GDK will try to use
|
* the value will be copied directly. Otherwise, GDK will try to use
|
||||||
* [func@content_deserialize_async] to convert the clipboard's data.
|
* [func@content_deserialize_async] to convert the clipboard's data.
|
||||||
@@ -882,11 +890,14 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
|
|||||||
* gdk_clipboard_read_texture_async:
|
* gdk_clipboard_read_texture_async:
|
||||||
* @clipboard: a `GdkClipboard`
|
* @clipboard: a `GdkClipboard`
|
||||||
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
|
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must then
|
||||||
|
* call [method@Gdk.Clipboard.read_texture_finish] to get the result.
|
||||||
|
*
|
||||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||||
* need more control over the operation.
|
* need more control over the operation.
|
||||||
@@ -944,11 +955,14 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
|
|||||||
* gdk_clipboard_read_text_async:
|
* gdk_clipboard_read_text_async:
|
||||||
* @clipboard: a `GdkClipboard`
|
* @clipboard: a `GdkClipboard`
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously request the @clipboard contents converted to a string.
|
* Asynchronously request the @clipboard contents converted to a string.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must then
|
||||||
|
* call [method@Gdk.Clipboard.read_text_finish] to get the result.
|
||||||
|
*
|
||||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||||
* need more control over the operation.
|
* need more control over the operation.
|
||||||
|
|||||||
@@ -1,714 +0,0 @@
|
|||||||
/* gdkcolorstate.c
|
|
||||||
*
|
|
||||||
* Copyright 2024 Matthias Clasen
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GdkColorState:
|
|
||||||
*
|
|
||||||
* A `GdkColorState` object provides the information to interpret
|
|
||||||
* colors and pixels in a variety of ways.
|
|
||||||
*
|
|
||||||
* They are also known as
|
|
||||||
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
|
|
||||||
*
|
|
||||||
* Crucially, GTK knows how to convert colors from one color
|
|
||||||
* state to another.
|
|
||||||
*
|
|
||||||
* `GdkColorState objects are immutable and therefore threadsafe.
|
|
||||||
*
|
|
||||||
* Since 4.16
|
|
||||||
*/
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
|
|
||||||
gdk_color_state_ref, gdk_color_state_unref);
|
|
||||||
|
|
||||||
/* {{{ Public API */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_ref:
|
|
||||||
* @self: a `GdkColorState`
|
|
||||||
*
|
|
||||||
* Increase the reference count of @self.
|
|
||||||
*
|
|
||||||
* Returns: the object that was passed in
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
(gdk_color_state_ref) (GdkColorState *self)
|
|
||||||
{
|
|
||||||
return _gdk_color_state_ref (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_unref:
|
|
||||||
* @self:a `GdkColorState`
|
|
||||||
*
|
|
||||||
* Decrease the reference count of @self.
|
|
||||||
*
|
|
||||||
* Unless @self is static, it will be freed
|
|
||||||
* when the reference count reaches zero.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
(gdk_color_state_unref) (GdkColorState *self)
|
|
||||||
{
|
|
||||||
_gdk_color_state_unref (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_srgb:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the sRGB color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_srgb (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_SRGB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_srgb_linear:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the linearized sRGB color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_srgb_linear (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_SRGB_LINEAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_xyz:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the XYZ color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_xyz (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_XYZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_oklab:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the OKLAB color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_oklab (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_OKLAB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_oklch:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the OKLCH color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_oklch (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_OKLCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_rec2020:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the rec2020 color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_rec2020 (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_REC2020;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_get_rec2020_linear:
|
|
||||||
*
|
|
||||||
* Returns the color state object representing the linear rec2020 color space.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_rec2020_linear (void)
|
|
||||||
{
|
|
||||||
return GDK_COLOR_STATE_REC2020_LINEAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_color_state_equal:
|
|
||||||
* @self: a `GdkColorState`
|
|
||||||
* @other: another `GdkColorStatee`
|
|
||||||
*
|
|
||||||
* Compares two `GdkColorStates` for equality.
|
|
||||||
*
|
|
||||||
* Note that this function is not guaranteed to be perfect and two objects
|
|
||||||
* describing the same color state may compare not equal. However, different
|
|
||||||
* color states will never compare equal.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if the two color states compare equal
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
(gdk_color_state_equal) (GdkColorState *self,
|
|
||||||
GdkColorState *other)
|
|
||||||
{
|
|
||||||
return _gdk_color_state_equal (self, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
/* {{{ Default implementation */
|
|
||||||
/* {{{ Vfuncs */
|
|
||||||
static gboolean
|
|
||||||
gdk_default_color_state_equal (GdkColorState *self,
|
|
||||||
GdkColorState *other)
|
|
||||||
{
|
|
||||||
return self == other;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
gdk_default_color_state_get_name (GdkColorState *color_state)
|
|
||||||
{
|
|
||||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
|
||||||
|
|
||||||
return self->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkColorState *
|
|
||||||
gdk_default_color_state_get_no_srgb_tf (GdkColorState *color_state)
|
|
||||||
{
|
|
||||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
|
||||||
|
|
||||||
return self->no_srgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkFloatColorConvert
|
|
||||||
gdk_default_color_state_get_convert_to (GdkColorState *color_state,
|
|
||||||
GdkColorState *target)
|
|
||||||
{
|
|
||||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
|
||||||
|
|
||||||
if (!GDK_IS_DEFAULT_COLOR_STATE (target))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return self->convert_to[GDK_DEFAULT_COLOR_STATE_ID (target)];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
/* {{{ Conversion functions */
|
|
||||||
|
|
||||||
#define COORDINATE_TRANSFORM(name, tf) \
|
|
||||||
static void \
|
|
||||||
name(GdkColorState *self, \
|
|
||||||
float (*values)[4], \
|
|
||||||
gsize n_values) \
|
|
||||||
{ \
|
|
||||||
for (gsize i = 0; i < n_values; i++) \
|
|
||||||
{ \
|
|
||||||
values[i][0] = tf (values[i][0]); \
|
|
||||||
values[i][1] = tf (values[i][1]); \
|
|
||||||
values[i][2] = tf (values[i][2]); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
srgb_oetf (float v)
|
|
||||||
{
|
|
||||||
if (v > 0.0031308f)
|
|
||||||
return 1.055f * powf (v, 1.f / 2.4f) - 0.055f;
|
|
||||||
else
|
|
||||||
return 12.92f * v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
srgb_eotf (float v)
|
|
||||||
{
|
|
||||||
if (v >= 0.04045f)
|
|
||||||
return powf (((v + 0.055f) / (1.f + 0.055f)), 2.4f);
|
|
||||||
else
|
|
||||||
return v / 12.92f;
|
|
||||||
}
|
|
||||||
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_srgb_to_srgb_linear, srgb_eotf)
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_srgb_linear_to_srgb, srgb_oetf)
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
vec3_multiply (const float matrix[3][3],
|
|
||||||
const float vec[3],
|
|
||||||
float res[3])
|
|
||||||
{
|
|
||||||
res[0] = matrix[0][0] * vec[0] + matrix[0][1] * vec[1] + matrix[0][2] * vec[2];
|
|
||||||
res[1] = matrix[1][0] * vec[0] + matrix[1][1] * vec[1] + matrix[1][2] * vec[2];
|
|
||||||
res[2] = matrix[2][0] * vec[0] + matrix[2][1] * vec[1] + matrix[2][2] * vec[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LINEAR_TRANSFORM(name, matrix) \
|
|
||||||
static void \
|
|
||||||
name (GdkColorState *self, \
|
|
||||||
float (*values)[4], \
|
|
||||||
gsize n_values) \
|
|
||||||
{ \
|
|
||||||
for (gsize i = 0; i < n_values; i++) \
|
|
||||||
{ \
|
|
||||||
float res[3]; \
|
|
||||||
\
|
|
||||||
vec3_multiply (matrix, values[i], res); \
|
|
||||||
\
|
|
||||||
values[i][0] = res[0]; \
|
|
||||||
values[i][1] = res[1]; \
|
|
||||||
values[i][2] = res[2]; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
static const float srgb_linear_to_xyz[3][3] = {
|
|
||||||
{ (506752.0 / 1228815.0), (87881.0 / 245763.0), (12673.0 / 70218.0) },
|
|
||||||
{ (87098.0 / 409605.0), (175762.0 / 245763.0), (12673.0 / 175545.0) },
|
|
||||||
{ ( 7918.0 / 409605.0), (87881.0 / 737289.0), (1001167.0 / 1053270.0) },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float xyz_to_srgb_linear[3][3] = {
|
|
||||||
{ (12831.0 / 3959.0), - (329.0 / 214.0), - (1974.0 / 3959.0) },
|
|
||||||
{ - (851781.0 / 878810.0), (1648619.0 / 878810.0), (36519.0 / 878810.0) },
|
|
||||||
{ (705.0 / 12673.0), - (2585.0 / 12673.0), (705.0 / 667.0) },
|
|
||||||
};
|
|
||||||
|
|
||||||
LINEAR_TRANSFORM(gdk_default_xyz_to_srgb_linear, xyz_to_srgb_linear)
|
|
||||||
LINEAR_TRANSFORM(gdk_default_srgb_linear_to_xyz, srgb_linear_to_xyz)
|
|
||||||
|
|
||||||
#define DEG_TO_RAD(x) ((x) * G_PI / 180)
|
|
||||||
#define RAD_TO_DEG(x) ((x) * 180 / G_PI)
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_sincosf (float angle,
|
|
||||||
float *out_s,
|
|
||||||
float *out_c)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SINCOSF
|
|
||||||
sincosf (angle, out_s, out_c);
|
|
||||||
#else
|
|
||||||
*out_s = sinf (angle);
|
|
||||||
*out_c = cosf (angle);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_default_oklab_to_oklch (GdkColorState *self,
|
|
||||||
float (*values)[4],
|
|
||||||
gsize n_values)
|
|
||||||
{
|
|
||||||
for (gsize i = 0; i < n_values; i++)
|
|
||||||
{
|
|
||||||
float a = values[i][1];
|
|
||||||
float b = values[i][2];
|
|
||||||
float C, H;
|
|
||||||
|
|
||||||
C = hypotf (a, b);
|
|
||||||
H = RAD_TO_DEG (atan2 (b, a));
|
|
||||||
H = fmod (H, 360);
|
|
||||||
if (H < 0)
|
|
||||||
H += 360;
|
|
||||||
|
|
||||||
values[i][1] = C;
|
|
||||||
values[i][2] = H;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_default_oklch_to_oklab (GdkColorState *self,
|
|
||||||
float (*values)[4],
|
|
||||||
gsize n_values)
|
|
||||||
{
|
|
||||||
for (gsize i = 0; i < n_values; i++)
|
|
||||||
{
|
|
||||||
float C = values[i][1];
|
|
||||||
float H = values[i][2];
|
|
||||||
float a, b;
|
|
||||||
|
|
||||||
_sincosf (DEG_TO_RAD (H), &b, &a);
|
|
||||||
a *= C;
|
|
||||||
b *= C;
|
|
||||||
|
|
||||||
values[i][1] = a;
|
|
||||||
values[i][2] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const float oklab_to_lms[3][3] = {
|
|
||||||
{ 1, 0.3963377774, 0.2158037573 },
|
|
||||||
{ 1, - 0.1055613458, - 0.0638541728 },
|
|
||||||
{ 1, - 0.0894841775, - 1.2914855480 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float lms_to_srgb_linear[3][3] = {
|
|
||||||
{ 4.0767416621, - 3.3077115913, 0.2309699292 },
|
|
||||||
{ - 1.2684380046, 2.6097574011, - 0.3413193965 },
|
|
||||||
{ - 0.0041960863, - 0.7034186147, 1.7076147010 },
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SUM(a, b, i, j) ((a)[i][0] * (b)[0][j] + (a)[i][1] * (b)[1][j] + (a)[i][2] * (b)[2][j])
|
|
||||||
#define MATMUL(name, a, b) \
|
|
||||||
static const float name[3][3] = { \
|
|
||||||
{ SUM((a),(b),0,0), SUM((a),(b),0,1), SUM((a),(b),0,2) }, \
|
|
||||||
{ SUM((a),(b),1,0), SUM((a),(b),1,1), SUM((a),(b),1,2) }, \
|
|
||||||
{ SUM((a),(b),2,0), SUM((a),(b),2,1), SUM((a),(b),2,2) }, \
|
|
||||||
};
|
|
||||||
|
|
||||||
MATMUL(lms_to_xyz, lms_to_srgb_linear, srgb_linear_to_xyz)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_default_oklab_to_xyz (GdkColorState *self,
|
|
||||||
float (*values)[4],
|
|
||||||
gsize n_values)
|
|
||||||
{
|
|
||||||
for (gsize i = 0; i < n_values; i++)
|
|
||||||
{
|
|
||||||
float lms[3];
|
|
||||||
|
|
||||||
vec3_multiply (oklab_to_lms, values[i], lms);
|
|
||||||
|
|
||||||
lms[0] = powf (lms[0], 3);
|
|
||||||
lms[1] = powf (lms[1], 3);
|
|
||||||
lms[2] = powf (lms[2], 3);
|
|
||||||
|
|
||||||
vec3_multiply (lms_to_xyz, lms, values[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const float srgb_linear_to_lms[3][3] = {
|
|
||||||
{ 0.4122214708, 0.5363325363, 0.0514459929 },
|
|
||||||
{ 0.2119034982, 0.6806995451, 0.1073969566 },
|
|
||||||
{ 0.0883024619, 0.2817188376, 0.6299787005 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float lms_to_oklab[3][3] = {
|
|
||||||
{ 0.2104542553, 0.7936177850, - 0.0040720468 },
|
|
||||||
{ 1.9779984951, - 2.4285922050, 0.4505937099 },
|
|
||||||
{ 0.0259040371, 0.7827717662, - 0.8086757660 },
|
|
||||||
};
|
|
||||||
|
|
||||||
MATMUL(xyz_to_lms, xyz_to_srgb_linear, srgb_linear_to_lms)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_default_xyz_to_oklab (GdkColorState *self,
|
|
||||||
float (*values)[4],
|
|
||||||
gsize n_values)
|
|
||||||
{
|
|
||||||
for (gsize i = 0; i < n_values; i++)
|
|
||||||
{
|
|
||||||
float lms[3];
|
|
||||||
|
|
||||||
vec3_multiply (xyz_to_lms, values[i], lms);
|
|
||||||
|
|
||||||
lms[0] = cbrtf (lms[0]);
|
|
||||||
lms[1] = cbrtf (lms[1]);
|
|
||||||
lms[2] = cbrtf (lms[2]);
|
|
||||||
|
|
||||||
vec3_multiply (lms_to_oklab, lms, values[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
rec2020_eotf (float v)
|
|
||||||
{
|
|
||||||
float alpha = 1.09929682680944;
|
|
||||||
float beta = 0.018053968510807;
|
|
||||||
|
|
||||||
int sign = v < 0 ? -1 : 1;
|
|
||||||
float abs = fabsf (v);
|
|
||||||
|
|
||||||
if (abs < beta * 4.5 )
|
|
||||||
return v/ 4.5;
|
|
||||||
else
|
|
||||||
return sign * powf ((abs + alpha - 1) / alpha, 1.0 / 0.45);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
rec2020_oetf (float v)
|
|
||||||
{
|
|
||||||
float alpha = 1.09929682680944;
|
|
||||||
float beta = 0.018053968510807;
|
|
||||||
int sign = v < 0 ? -1 : 1;
|
|
||||||
float abs = fabsf (v);
|
|
||||||
|
|
||||||
if (abs > beta)
|
|
||||||
return sign * (alpha * powf (abs, 0.45) - (alpha - 1));
|
|
||||||
else
|
|
||||||
return 4.5 * v;
|
|
||||||
}
|
|
||||||
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_rec2020_to_rec2020_linear, rec2020_eotf)
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_rec2020_linear_to_rec2020, rec2020_oetf)
|
|
||||||
|
|
||||||
static const float rec2020_linear_to_xyz[3][3] = {
|
|
||||||
{ (63426534.0 / 99577255.0), (20160776.0 / 139408157.0), (47086771.0 / 278816314.0) },
|
|
||||||
{ (26158966.0 / 99577255.0), (472592308.0 / 697040785.0), (8267143.0 / 139408157.0) },
|
|
||||||
{ ( 0 / 1), (19567812.0 / 697040785.0), (295819943.0 / 278816314.0) },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float xyz_to_rec2020_linear[3][3] = {
|
|
||||||
{ (30757411.0 / 17917100.0), - (6372589.0 / 17917100.0), - (4539589.0 / 17917100.0) },
|
|
||||||
{ - (19765991.0 / 29648200.0), (47925759.0 / 29648200.0), (467509.0 / 29648200.0) },
|
|
||||||
{ (792561.0 / 44930125.0), - (1921689.0 / 44930125.0), (42328811.0 / 44930125.0) },
|
|
||||||
};
|
|
||||||
|
|
||||||
LINEAR_TRANSFORM(gdk_default_rec2020_linear_to_xyz, rec2020_linear_to_xyz)
|
|
||||||
LINEAR_TRANSFORM(gdk_default_xyz_to_rec2020_linear, xyz_to_rec2020_linear)
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
rec2100_pq_eotf (float v)
|
|
||||||
{
|
|
||||||
float ninv = (1 << 14) / 2610.0;
|
|
||||||
float minv = (1 << 5) / 2523.0;
|
|
||||||
float c1 = 3424.0 / (1 << 12);
|
|
||||||
float c2 = 2413.0 / (1 << 7);
|
|
||||||
float c3 = 2392.0 / (1 << 7);
|
|
||||||
|
|
||||||
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
|
|
||||||
|
|
||||||
return x * 10000 / 203.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
rec2100_pq_oetf (float v)
|
|
||||||
{
|
|
||||||
float x = v * 203.0 / 10000.0;
|
|
||||||
float n = 2610.0 / (1 << 14);
|
|
||||||
float m = 2523.0 / (1 << 5);
|
|
||||||
float c1 = 3424.0 / (1 << 12);
|
|
||||||
float c2 = 2413.0 / (1 << 7);
|
|
||||||
float c3 = 2392.0 / (1 << 7);
|
|
||||||
|
|
||||||
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
|
|
||||||
}
|
|
||||||
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_rec2100_pq_to_rec2100_linear, rec2100_pq_eotf)
|
|
||||||
COORDINATE_TRANSFORM(gdk_default_rec2100_linear_to_rec2100_pq, rec2100_pq_oetf)
|
|
||||||
|
|
||||||
|
|
||||||
#define CONCAT(name, f1, f2) \
|
|
||||||
static void \
|
|
||||||
name (GdkColorState *self, \
|
|
||||||
float (*values)[4], \
|
|
||||||
gsize n_values) \
|
|
||||||
{ \
|
|
||||||
f1 (self, values, n_values); \
|
|
||||||
f2 (self, values, n_values); \
|
|
||||||
}
|
|
||||||
|
|
||||||
CONCAT(gdk_default_xyz_to_srgb, gdk_default_xyz_to_srgb_linear, gdk_default_srgb_linear_to_srgb);
|
|
||||||
CONCAT(gdk_default_srgb_to_xyz, gdk_default_srgb_to_srgb_linear, gdk_default_srgb_linear_to_xyz);
|
|
||||||
CONCAT(gdk_default_oklch_to_xyz, gdk_default_oklch_to_oklab, gdk_default_oklab_to_xyz);
|
|
||||||
CONCAT(gdk_default_xyz_to_oklch, gdk_default_xyz_to_oklab, gdk_default_oklab_to_oklch);
|
|
||||||
CONCAT(gdk_default_rec2020_to_xyz, gdk_default_rec2020_to_rec2020_linear, gdk_default_rec2020_linear_to_xyz);
|
|
||||||
CONCAT(gdk_default_xyz_to_rec2020, gdk_default_xyz_to_rec2020_linear, gdk_default_rec2020_linear_to_rec2020);
|
|
||||||
CONCAT(gdk_default_rec2100_pq_to_xyz, gdk_default_rec2100_pq_to_rec2100_linear, gdk_default_rec2020_linear_to_xyz);
|
|
||||||
CONCAT(gdk_default_xyz_to_rec2100_pq, gdk_default_xyz_to_rec2020_linear, gdk_default_rec2100_linear_to_rec2100_pq);
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
static const
|
|
||||||
GdkColorStateClass GDK_DEFAULT_COLOR_STATE_CLASS = {
|
|
||||||
.free = NULL, /* crash here if this ever happens */
|
|
||||||
.equal = gdk_default_color_state_equal,
|
|
||||||
.get_name = gdk_default_color_state_get_name,
|
|
||||||
.get_no_srgb_tf = gdk_default_color_state_get_no_srgb_tf,
|
|
||||||
.get_convert_to = gdk_default_color_state_get_convert_to,
|
|
||||||
};
|
|
||||||
|
|
||||||
GdkDefaultColorState gdk_default_color_states[] = {
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_U8_SRGB,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "srgb",
|
|
||||||
.no_srgb = GDK_COLOR_STATE_SRGB_LINEAR,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_srgb_linear,
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_srgb_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_U8,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "srgb-linear",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_srgb_linear_to_srgb,
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_srgb_linear_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_XYZ,
|
|
||||||
},
|
|
||||||
.name = "xyz",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_xyz_to_srgb,
|
|
||||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_xyz_to_srgb_linear,
|
|
||||||
[GDK_COLOR_STATE_ID_OKLAB] = gdk_default_xyz_to_oklab,
|
|
||||||
[GDK_COLOR_STATE_ID_OKLCH] = gdk_default_xyz_to_oklch,
|
|
||||||
[GDK_COLOR_STATE_ID_REC2020] = gdk_default_xyz_to_rec2020,
|
|
||||||
[GDK_COLOR_STATE_ID_REC2020_LINEAR] = gdk_default_xyz_to_rec2020_linear,
|
|
||||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_xyz_to_rec2100_pq,
|
|
||||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_xyz_to_rec2020_linear,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_OKLAB] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "oklab",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_oklab_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_OKLCH] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "oklch",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_oklch_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_REC2020] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_REC2020_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "rec2020",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_rec2020_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_REC2020_LINEAR] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_REC2020_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "rec2020-linear",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_rec2020_linear_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "rec2100-pq",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_rec2100_pq_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = {
|
|
||||||
.parent = {
|
|
||||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
|
||||||
.ref_count = 0,
|
|
||||||
.depth = GDK_MEMORY_FLOAT16,
|
|
||||||
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
|
|
||||||
},
|
|
||||||
.name = "rec2100-linear",
|
|
||||||
.no_srgb = NULL,
|
|
||||||
.convert_to = {
|
|
||||||
[GDK_COLOR_STATE_ID_XYZ] = gdk_default_rec2020_linear_to_xyz,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
/* {{{ Private API */
|
|
||||||
|
|
||||||
const char *
|
|
||||||
gdk_color_state_get_name (GdkColorState *self)
|
|
||||||
{
|
|
||||||
return self->klass->get_name (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* gdk_color_state_get_no_srgb_tf:
|
|
||||||
* @self: a colorstate
|
|
||||||
*
|
|
||||||
* This function checks if the colorstate uses an sRGB transfer function
|
|
||||||
* as final operation. In that case, it is suitable for use with GL_SRGB
|
|
||||||
* (and the Vulkan equivalents).
|
|
||||||
*
|
|
||||||
* If it is suitable, the colorstate without the transfer function is
|
|
||||||
* returned. Otherwise, this function returns NULL.
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): the colorstate without sRGB transfer function.
|
|
||||||
**/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_color_state_get_no_srgb_tf (GdkColorState *self)
|
|
||||||
{
|
|
||||||
if (!GDK_DEBUG_CHECK (LINEAR))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return self->klass->get_no_srgb_tf (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* vim:set foldmethod=marker expandtab: */
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/* gdkcolorstate.h
|
|
||||||
*
|
|
||||||
* Copyright 2024 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
|
||||||
#error "Only <gdk/gdk.h> can be included directly."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <gdk/gdktypes.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GType gdk_color_state_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_ref (GdkColorState *self);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
void gdk_color_state_unref (GdkColorState *self);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_srgb (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_srgb_linear (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_xyz (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_oklab (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_oklch (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_rec2020 (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_rec2020_linear (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_rec2100_pq (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_color_state_get_rec2100_linear (void);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
gboolean gdk_color_state_equal (GdkColorState *self,
|
|
||||||
GdkColorState *other);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "gdkcolorstate.h"
|
|
||||||
|
|
||||||
#include "gdkdebugprivate.h"
|
|
||||||
#include "gdkmemoryformatprivate.h"
|
|
||||||
#include "gdkrgba.h"
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GDK_COLOR_STATE_ID_SRGB,
|
|
||||||
GDK_COLOR_STATE_ID_SRGB_LINEAR,
|
|
||||||
GDK_COLOR_STATE_ID_XYZ,
|
|
||||||
GDK_COLOR_STATE_ID_OKLAB,
|
|
||||||
GDK_COLOR_STATE_ID_OKLCH,
|
|
||||||
GDK_COLOR_STATE_ID_REC2020,
|
|
||||||
GDK_COLOR_STATE_ID_REC2020_LINEAR,
|
|
||||||
GDK_COLOR_STATE_ID_REC2100_PQ,
|
|
||||||
GDK_COLOR_STATE_ID_REC2100_LINEAR,
|
|
||||||
|
|
||||||
GDK_COLOR_STATE_N_IDS
|
|
||||||
} GdkColorStateId;
|
|
||||||
|
|
||||||
typedef struct _GdkColorStateClass GdkColorStateClass;
|
|
||||||
|
|
||||||
struct _GdkColorState
|
|
||||||
{
|
|
||||||
const GdkColorStateClass *klass;
|
|
||||||
gatomicrefcount ref_count;
|
|
||||||
|
|
||||||
GdkMemoryDepth depth;
|
|
||||||
GdkColorState *rendering_color_state;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (* GdkFloatColorConvert)(GdkColorState *self,
|
|
||||||
float (*values)[4],
|
|
||||||
gsize n_values);
|
|
||||||
|
|
||||||
struct _GdkColorStateClass
|
|
||||||
{
|
|
||||||
void (* free) (GdkColorState *self);
|
|
||||||
gboolean (* equal) (GdkColorState *self,
|
|
||||||
GdkColorState *other);
|
|
||||||
const char * (* get_name) (GdkColorState *self);
|
|
||||||
GdkColorState * (* get_no_srgb_tf) (GdkColorState *self);
|
|
||||||
GdkFloatColorConvert (* get_convert_to) (GdkColorState *self,
|
|
||||||
GdkColorState *target);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _GdkDefaultColorState GdkDefaultColorState;
|
|
||||||
|
|
||||||
struct _GdkDefaultColorState
|
|
||||||
{
|
|
||||||
GdkColorState parent;
|
|
||||||
|
|
||||||
const char *name;
|
|
||||||
GdkColorState *no_srgb;
|
|
||||||
GdkFloatColorConvert convert_to[GDK_COLOR_STATE_N_IDS];
|
|
||||||
};
|
|
||||||
|
|
||||||
extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
|
|
||||||
|
|
||||||
#define GDK_COLOR_STATE_SRGB ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
|
|
||||||
#define GDK_COLOR_STATE_SRGB_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
|
|
||||||
#define GDK_COLOR_STATE_XYZ ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_XYZ])
|
|
||||||
#define GDK_COLOR_STATE_OKLAB ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_OKLAB])
|
|
||||||
#define GDK_COLOR_STATE_OKLCH ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_OKLCH])
|
|
||||||
#define GDK_COLOR_STATE_REC2020 ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2020])
|
|
||||||
#define GDK_COLOR_STATE_REC2020_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2020_LINEAR])
|
|
||||||
#define GDK_COLOR_STATE_REC2100_PQ ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_PQ])
|
|
||||||
#define GDK_COLOR_STATE_REC2100_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_LINEAR])
|
|
||||||
|
|
||||||
#define GDK_IS_DEFAULT_COLOR_STATE(c) ((GdkDefaultColorState *) (c) >= &gdk_default_color_states[0] && \
|
|
||||||
(GdkDefaultColorState *) (c) < &gdk_default_color_states[GDK_COLOR_STATE_N_IDS])
|
|
||||||
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (((GdkDefaultColorState *) c) - gdk_default_color_states))
|
|
||||||
|
|
||||||
const char * gdk_color_state_get_name (GdkColorState *color_state);
|
|
||||||
GdkColorState * gdk_color_state_get_no_srgb_tf (GdkColorState *self);
|
|
||||||
|
|
||||||
static inline GdkColorState *
|
|
||||||
gdk_color_state_get_rendering_color_state (GdkColorState *self)
|
|
||||||
{
|
|
||||||
if (!GDK_DEBUG_CHECK (LINEAR))
|
|
||||||
return self;
|
|
||||||
|
|
||||||
return self->rendering_color_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GdkMemoryDepth
|
|
||||||
gdk_color_state_get_depth (GdkColorState *self)
|
|
||||||
{
|
|
||||||
if (!GDK_DEBUG_CHECK (LINEAR) && self->depth == GDK_MEMORY_U8_SRGB)
|
|
||||||
return GDK_MEMORY_U8;
|
|
||||||
|
|
||||||
return self->depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GdkColorState *
|
|
||||||
gdk_color_state_get_by_id (GdkColorStateId id)
|
|
||||||
{
|
|
||||||
return (GdkColorState *) &gdk_default_color_states[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
|
|
||||||
static inline GdkColorState *
|
|
||||||
_gdk_color_state_ref (GdkColorState *self)
|
|
||||||
{
|
|
||||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
|
||||||
return self;
|
|
||||||
|
|
||||||
g_atomic_ref_count_inc (&self->ref_count);
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
|
|
||||||
static inline void
|
|
||||||
_gdk_color_state_unref (GdkColorState *self)
|
|
||||||
{
|
|
||||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_atomic_ref_count_dec (&self->ref_count))
|
|
||||||
self->klass->free (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
|
|
||||||
static inline gboolean
|
|
||||||
_gdk_color_state_equal (GdkColorState *self,
|
|
||||||
GdkColorState *other)
|
|
||||||
{
|
|
||||||
if (self == other)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (self->klass != other->klass)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return self->klass->equal (self, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GdkFloatColorConvert
|
|
||||||
gdk_color_state_get_convert_to (GdkColorState *self,
|
|
||||||
GdkColorState *target)
|
|
||||||
{
|
|
||||||
return self->klass->get_convert_to (self, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
gdk_color_state_from_rgba (GdkColorState *self,
|
|
||||||
const GdkRGBA *rgba,
|
|
||||||
float out_color[4])
|
|
||||||
{
|
|
||||||
GdkFloatColorConvert convert_to;
|
|
||||||
|
|
||||||
out_color[0] = rgba->red;
|
|
||||||
out_color[1] = rgba->green;
|
|
||||||
out_color[2] = rgba->blue;
|
|
||||||
out_color[3] = rgba->alpha;
|
|
||||||
|
|
||||||
if (gdk_color_state_equal (GDK_COLOR_STATE_SRGB, self))
|
|
||||||
return;
|
|
||||||
|
|
||||||
convert_to = gdk_color_state_get_convert_to (GDK_COLOR_STATE_SRGB, self);
|
|
||||||
convert_to (GDK_COLOR_STATE_SRGB, (float(*)[4]) out_color, 1);
|
|
||||||
}
|
|
||||||
@@ -533,13 +533,16 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
|
|||||||
* @type: the GType to deserialize from
|
* @type: the GType to deserialize from
|
||||||
* @io_priority: the I/O priority of the operation
|
* @io_priority: the I/O priority of the operation
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the operation is done
|
* @callback: (scope async): callback to call when the operation is done
|
||||||
* @user_data: data to pass to the callback function
|
* @user_data: (closure): data to pass to the callback function
|
||||||
*
|
*
|
||||||
* Read content from the given input stream and deserialize it, asynchronously.
|
* Read content from the given input stream and deserialize it, asynchronously.
|
||||||
*
|
*
|
||||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||||
* indicate a higher priority.
|
* indicate a higher priority.
|
||||||
|
*
|
||||||
|
* When the operation is finished, @callback will be called. You must then
|
||||||
|
* call [func@Gdk.content_deserialize_finish] to get the result of the operation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gdk_content_deserialize_async (GInputStream *stream,
|
gdk_content_deserialize_async (GInputStream *stream,
|
||||||
|
|||||||
@@ -273,12 +273,16 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
|
|||||||
* @stream: the `GOutputStream` to write to
|
* @stream: the `GOutputStream` to write to
|
||||||
* @io_priority: I/O priority of the request.
|
* @io_priority: I/O priority of the request.
|
||||||
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously writes the contents of @provider to @stream in the given
|
* Asynchronously writes the contents of @provider to @stream in the given
|
||||||
* @mime_type.
|
* @mime_type.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must then call
|
||||||
|
* [method@Gdk.ContentProvider.write_mime_type_finish] to get the result
|
||||||
|
* of the operation.
|
||||||
|
*
|
||||||
* The given mime type does not need to be listed in the formats returned by
|
* The given mime type does not need to be listed in the formats returned by
|
||||||
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
|
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
|
||||||
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
|
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
|
||||||
|
|||||||
@@ -539,13 +539,16 @@ serialize_not_found (GdkContentSerializer *serializer)
|
|||||||
* @value: the content to serialize
|
* @value: the content to serialize
|
||||||
* @io_priority: the I/O priority of the operation
|
* @io_priority: the I/O priority of the operation
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure): callback to call when the operation is done
|
* @callback: (scope async): callback to call when the operation is done
|
||||||
* @user_data: data to pass to the callback function
|
* @user_data: (closure): data to pass to the callback function
|
||||||
*
|
*
|
||||||
* Serialize content and write it to the given output stream, asynchronously.
|
* Serialize content and write it to the given output stream, asynchronously.
|
||||||
*
|
*
|
||||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||||
* indicate a higher priority.
|
* indicate a higher priority.
|
||||||
|
*
|
||||||
|
* When the operation is finished, @callback will be called. You must then
|
||||||
|
* call [func@Gdk.content_serialize_finish] to get the result of the operation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gdk_content_serialize_async (GOutputStream *stream,
|
gdk_content_serialize_async (GOutputStream *stream,
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ GdkCursor* gdk_cursor_new_from_name (const char *name,
|
|||||||
GdkCursor *fallback);
|
GdkCursor *fallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkCursorGetTextureCallback:
|
* GdkCursorGetTestureCallback:
|
||||||
* @cursor: the `GdkCursor`
|
* @cursor: the `GdkCursor`
|
||||||
* @cursor_size: the nominal cursor size, in application pixels
|
* @cursor_size: the nominal cursor size, in application pixels
|
||||||
* @scale: the device scale
|
* @scale: the device scale
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ typedef enum {
|
|||||||
GDK_DEBUG_OFFLOAD = 1 << 12,
|
GDK_DEBUG_OFFLOAD = 1 << 12,
|
||||||
|
|
||||||
/* flags below are influencing behavior */
|
/* flags below are influencing behavior */
|
||||||
GDK_DEBUG_LINEAR = 1 << 13,
|
|
||||||
GDK_DEBUG_PORTALS = 1 << 14,
|
GDK_DEBUG_PORTALS = 1 << 14,
|
||||||
GDK_DEBUG_NO_PORTALS = 1 << 15,
|
GDK_DEBUG_NO_PORTALS = 1 << 15,
|
||||||
GDK_DEBUG_GL_DISABLE = 1 << 16,
|
GDK_DEBUG_GL_DISABLE = 1 << 16,
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "gdkdihedralprivate.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
gdk_dihedral_get_mat2 (GdkDihedral transform,
|
|
||||||
float *xx,
|
|
||||||
float *xy,
|
|
||||||
float *yx,
|
|
||||||
float *yy)
|
|
||||||
{
|
|
||||||
const float mat[8][2][2] = {
|
|
||||||
[GDK_DIHEDRAL_NORMAL] = {
|
|
||||||
{ 1.0, 0.0 },
|
|
||||||
{ 0.0, 1.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_90] = {
|
|
||||||
{ 0.0, 1.0 },
|
|
||||||
{ -1.0, 0.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_180] = {
|
|
||||||
{ -1.0, 0.0 },
|
|
||||||
{ 0.0, -1.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_270] = {
|
|
||||||
{ 0.0, -1.0 },
|
|
||||||
{ 1.0, 0.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_FLIPPED] = {
|
|
||||||
{ -1.0, 0.0 },
|
|
||||||
{ 0.0, 1.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_FLIPPED_90] = {
|
|
||||||
{ 0.0, -1.0 },
|
|
||||||
{ -1.0, 0.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_FLIPPED_180] = {
|
|
||||||
{ 1.0, 0.0 },
|
|
||||||
{ 0.0, -1.0 }
|
|
||||||
},
|
|
||||||
[GDK_DIHEDRAL_FLIPPED_270] = {
|
|
||||||
{ 0.0, 1.0 },
|
|
||||||
{ 1.0, 0.0 }
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
*xx = mat[transform][0][0];
|
|
||||||
*xy = mat[transform][1][0];
|
|
||||||
*yx = mat[transform][0][1];
|
|
||||||
*yy = mat[transform][1][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkDihedral
|
|
||||||
gdk_dihedral_combine (GdkDihedral first,
|
|
||||||
GdkDihedral second)
|
|
||||||
{
|
|
||||||
return ((first & 4) ^ (second & 4)) |
|
|
||||||
((((first & 3) * (((second & 4) >> 1) + 1)) + second) & 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkDihedral
|
|
||||||
gdk_dihedral_invert (GdkDihedral self)
|
|
||||||
{
|
|
||||||
return ((4 - self) * (((self & 4) >> 1) + 1) & 3) | (self & 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gdk_dihedral_swaps_xy (GdkDihedral self)
|
|
||||||
{
|
|
||||||
return (self & 1) ? TRUE : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
gdk_dihedral_get_name (GdkDihedral self)
|
|
||||||
{
|
|
||||||
const char *name[] = {
|
|
||||||
"normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270"
|
|
||||||
};
|
|
||||||
|
|
||||||
return name[self];
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/* GDK - The GIMP Drawing Kit
|
|
||||||
* Copyright (C) 2024 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GDK_DIHEDRAL_NORMAL,
|
|
||||||
GDK_DIHEDRAL_90,
|
|
||||||
GDK_DIHEDRAL_180,
|
|
||||||
GDK_DIHEDRAL_270,
|
|
||||||
GDK_DIHEDRAL_FLIPPED,
|
|
||||||
GDK_DIHEDRAL_FLIPPED_90,
|
|
||||||
GDK_DIHEDRAL_FLIPPED_180,
|
|
||||||
GDK_DIHEDRAL_FLIPPED_270,
|
|
||||||
} GdkDihedral;
|
|
||||||
|
|
||||||
void gdk_dihedral_get_mat2 (GdkDihedral transform,
|
|
||||||
float *xx,
|
|
||||||
float *xy,
|
|
||||||
float *yx,
|
|
||||||
float *yy);
|
|
||||||
|
|
||||||
GdkDihedral gdk_dihedral_combine (GdkDihedral first,
|
|
||||||
GdkDihedral second);
|
|
||||||
GdkDihedral gdk_dihedral_invert (GdkDihedral self);
|
|
||||||
gboolean gdk_dihedral_swaps_xy (GdkDihedral self);
|
|
||||||
|
|
||||||
const char * gdk_dihedral_get_name (GdkDihedral self);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
@@ -1570,27 +1570,19 @@ describe_egl_config (EGLDisplay egl_display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
gdk_display_get_egl_config (GdkDisplay *self,
|
gdk_display_get_egl_config (GdkDisplay *self)
|
||||||
GdkMemoryDepth depth)
|
|
||||||
{
|
{
|
||||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||||
|
|
||||||
switch (depth)
|
return priv->egl_config;
|
||||||
{
|
}
|
||||||
case GDK_MEMORY_NONE:
|
|
||||||
case GDK_MEMORY_U8:
|
|
||||||
case GDK_MEMORY_U8_SRGB:
|
|
||||||
return priv->egl_config;
|
|
||||||
|
|
||||||
case GDK_MEMORY_U16:
|
gpointer
|
||||||
case GDK_MEMORY_FLOAT16:
|
gdk_display_get_egl_config_high_depth (GdkDisplay *self)
|
||||||
case GDK_MEMORY_FLOAT32:
|
{
|
||||||
return priv->egl_config_high_depth;
|
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||||
|
|
||||||
case GDK_N_DEPTHS:
|
return priv->egl_config_high_depth;
|
||||||
default:
|
|
||||||
g_return_val_if_reached (priv->egl_config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGLDisplay
|
static EGLDisplay
|
||||||
@@ -1882,8 +1874,6 @@ gdk_display_init_egl (GdkDisplay *self,
|
|||||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
|
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
|
||||||
self->have_egl_dma_buf_export =
|
self->have_egl_dma_buf_export =
|
||||||
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
|
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
|
||||||
self->have_egl_gl_colorspace =
|
|
||||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
|
|
||||||
|
|
||||||
if (self->have_egl_no_config_context)
|
if (self->have_egl_no_config_context)
|
||||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||||
|
|||||||
@@ -18,16 +18,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gdkdisplay.h"
|
#include "gdkdisplay.h"
|
||||||
|
#include "gdksurface.h"
|
||||||
#include "gdkcursor.h"
|
#include "gdkcursor.h"
|
||||||
#include "gdkdebugprivate.h"
|
|
||||||
#include "gdkdeviceprivate.h"
|
|
||||||
#include "gdkdmabufdownloaderprivate.h"
|
|
||||||
#include "gdkdmabufprivate.h"
|
|
||||||
#include "gdkkeysprivate.h"
|
|
||||||
#include "gdkmemoryformatprivate.h"
|
|
||||||
#include "gdkmonitor.h"
|
#include "gdkmonitor.h"
|
||||||
|
#include "gdkdebugprivate.h"
|
||||||
#include "gdksurfaceprivate.h"
|
#include "gdksurfaceprivate.h"
|
||||||
|
#include "gdkkeysprivate.h"
|
||||||
|
#include "gdkdeviceprivate.h"
|
||||||
|
#include "gdkdmabufprivate.h"
|
||||||
|
#include "gdkdmabufdownloaderprivate.h"
|
||||||
|
|
||||||
#ifdef GDK_RENDERING_VULKAN
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
@@ -131,7 +130,6 @@ struct _GdkDisplay
|
|||||||
guint have_egl_pixel_format_float : 1;
|
guint have_egl_pixel_format_float : 1;
|
||||||
guint have_egl_dma_buf_import : 1;
|
guint have_egl_dma_buf_import : 1;
|
||||||
guint have_egl_dma_buf_export : 1;
|
guint have_egl_dma_buf_export : 1;
|
||||||
guint have_egl_gl_colorspace : 1;
|
|
||||||
|
|
||||||
GdkDmabufFormats *dmabuf_formats;
|
GdkDmabufFormats *dmabuf_formats;
|
||||||
GdkDmabufDownloader *dmabuf_downloaders[4];
|
GdkDmabufDownloader *dmabuf_downloaders[4];
|
||||||
@@ -249,8 +247,9 @@ gboolean gdk_display_init_egl (GdkDisplay *display
|
|||||||
gboolean allow_any,
|
gboolean allow_any,
|
||||||
GError **error);
|
GError **error);
|
||||||
gpointer gdk_display_get_egl_display (GdkDisplay *display);
|
gpointer gdk_display_get_egl_display (GdkDisplay *display);
|
||||||
gpointer gdk_display_get_egl_config (GdkDisplay *display,
|
gpointer gdk_display_get_egl_config (GdkDisplay *display);
|
||||||
GdkMemoryDepth depth);
|
gpointer gdk_display_get_egl_config_high_depth
|
||||||
|
(GdkDisplay *display);
|
||||||
|
|
||||||
void gdk_display_set_rgba (GdkDisplay *display,
|
void gdk_display_set_rgba (GdkDisplay *display,
|
||||||
gboolean rgba);
|
gboolean rgba);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ download_memcpy (guchar *dst_data,
|
|||||||
bpp = gdk_memory_format_bytes_per_pixel (dst_format);
|
bpp = gdk_memory_format_bytes_per_pixel (dst_format);
|
||||||
src_stride = dmabuf->planes[0].stride;
|
src_stride = dmabuf->planes[0].stride;
|
||||||
src_data = src_datas[0] + dmabuf->planes[0].offset;
|
src_data = src_datas[0] + dmabuf->planes[0].offset;
|
||||||
g_return_if_fail (sizes[0] >= dmabuf->planes[0].offset + gdk_memory_format_min_buffer_size (dst_format, dst_stride, width, height));
|
g_return_if_fail (sizes[0] >= dmabuf->planes[0].offset + (height - 1) * dst_stride + width * bpp);
|
||||||
|
|
||||||
if (dst_stride == src_stride)
|
if (dst_stride == src_stride)
|
||||||
memcpy (dst_data, src_data, (height - 1) * dst_stride + width * bpp);
|
memcpy (dst_data, src_data, (height - 1) * dst_stride + width * bpp);
|
||||||
@@ -2372,20 +2372,3 @@ gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_DMABUF */
|
#endif /* HAVE_DMABUF */
|
||||||
|
|
||||||
void
|
|
||||||
gdk_dmabuf_close_fds (GdkDmabuf *dmabuf)
|
|
||||||
{
|
|
||||||
guint i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < dmabuf->n_planes; i++)
|
|
||||||
{
|
|
||||||
for (j = 0; j < i; j++)
|
|
||||||
{
|
|
||||||
if (dmabuf->planes[i].fd == dmabuf->planes[j].fd)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == j)
|
|
||||||
g_close (dmabuf->planes[i].fd, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ struct _GdkDmabuf
|
|||||||
} planes[GDK_DMABUF_MAX_PLANES];
|
} planes[GDK_DMABUF_MAX_PLANES];
|
||||||
};
|
};
|
||||||
|
|
||||||
void gdk_dmabuf_close_fds (GdkDmabuf *dmabuf);
|
|
||||||
|
|
||||||
#ifdef HAVE_DMABUF
|
#ifdef HAVE_DMABUF
|
||||||
|
|
||||||
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
|
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
|
||||||
@@ -32,6 +30,7 @@ void gdk_dmabuf_download_mmap (GdkTexture
|
|||||||
guchar *data,
|
guchar *data,
|
||||||
gsize stride);
|
gsize stride);
|
||||||
|
|
||||||
|
|
||||||
int gdk_dmabuf_ioctl (int fd,
|
int gdk_dmabuf_ioctl (int fd,
|
||||||
unsigned long request,
|
unsigned long request,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "gdkdmabuftextureprivate.h"
|
#include "gdkdmabuftextureprivate.h"
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
#include "gdkdmabufdownloaderprivate.h"
|
#include "gdkdmabufdownloaderprivate.h"
|
||||||
#include "gdkdmabufformatsbuilderprivate.h"
|
#include "gdkdmabufformatsbuilderprivate.h"
|
||||||
@@ -63,13 +62,6 @@ struct _GdkDmabufTextureClass
|
|||||||
GdkTextureClass parent_class;
|
GdkTextureClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_dmabuf_error_quark:
|
|
||||||
*
|
|
||||||
* Registers an error quark for [class@Gdk.DmabufTexture] errors.
|
|
||||||
*
|
|
||||||
* Returns: the error quark
|
|
||||||
**/
|
|
||||||
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
|
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
|
||||||
|
|
||||||
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
|
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
|
||||||
@@ -201,7 +193,6 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
|||||||
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
|
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
|
||||||
"width", width,
|
"width", width,
|
||||||
"height", height,
|
"height", height,
|
||||||
"color-state", GDK_COLOR_STATE_SRGB,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_set_object (&self->display, display);
|
g_set_object (&self->display, display);
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ struct _GdkDrawContextPrivate {
|
|||||||
GdkSurface *surface;
|
GdkSurface *surface;
|
||||||
|
|
||||||
cairo_region_t *frame_region;
|
cairo_region_t *frame_region;
|
||||||
GdkColorState *color_state;
|
|
||||||
GdkMemoryDepth depth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -203,12 +201,8 @@ static guint pixels_counter;
|
|||||||
static void
|
static void
|
||||||
gdk_draw_context_init (GdkDrawContext *self)
|
gdk_draw_context_init (GdkDrawContext *self)
|
||||||
{
|
{
|
||||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (self);
|
|
||||||
|
|
||||||
if (pixels_counter == 0)
|
if (pixels_counter == 0)
|
||||||
pixels_counter = gdk_profiler_define_int_counter ("frame pixels", "Pixels drawn per frame");
|
pixels_counter = gdk_profiler_define_int_counter ("frame pixels", "Pixels drawn per frame");
|
||||||
|
|
||||||
priv->depth = GDK_N_DEPTHS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -384,15 +378,7 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
|||||||
priv->frame_region = cairo_region_copy (region);
|
priv->frame_region = cairo_region_copy (region);
|
||||||
priv->surface->paint_context = g_object_ref (context);
|
priv->surface->paint_context = g_object_ref (context);
|
||||||
|
|
||||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context,
|
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, depth, priv->frame_region);
|
||||||
depth,
|
|
||||||
priv->frame_region,
|
|
||||||
&priv->color_state,
|
|
||||||
&priv->depth);
|
|
||||||
|
|
||||||
/* the callback is meant to set them */
|
|
||||||
g_assert (priv->color_state != NULL);
|
|
||||||
g_assert (priv->depth < GDK_N_DEPTHS);
|
|
||||||
|
|
||||||
cairo_region_intersect_rectangle (priv->frame_region,
|
cairo_region_intersect_rectangle (priv->frame_region,
|
||||||
&(cairo_rectangle_int_t) {
|
&(cairo_rectangle_int_t) {
|
||||||
@@ -463,10 +449,8 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
|
|||||||
|
|
||||||
gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region));
|
gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region));
|
||||||
|
|
||||||
g_clear_pointer (&priv->color_state, gdk_color_state_unref);
|
|
||||||
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
|
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
|
||||||
g_clear_object (&priv->surface->paint_context);
|
g_clear_object (&priv->surface->paint_context);
|
||||||
priv->depth = GDK_N_DEPTHS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -494,38 +478,6 @@ gdk_draw_context_get_frame_region (GdkDrawContext *context)
|
|||||||
return priv->frame_region;
|
return priv->frame_region;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* gdk_draw_context_get_color_state:
|
|
||||||
* @self: a `GdkDrawContext`
|
|
||||||
*
|
|
||||||
* Gets the target color state while rendering. If no rendering is going on, %NULL is returned.
|
|
||||||
*
|
|
||||||
* Returns: (transfer none) (nullable): the target color state
|
|
||||||
**/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_draw_context_get_color_state (GdkDrawContext *self)
|
|
||||||
{
|
|
||||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (self);
|
|
||||||
|
|
||||||
return priv->color_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* gdk_draw_context_get_depth:
|
|
||||||
* @self: a `GdkDrawContext`
|
|
||||||
*
|
|
||||||
* Gets the target depth while rendering. If no rendering is going on, the return value is undefined.
|
|
||||||
*
|
|
||||||
* Returns: the target depth
|
|
||||||
**/
|
|
||||||
GdkMemoryDepth
|
|
||||||
gdk_draw_context_get_depth (GdkDrawContext *self)
|
|
||||||
{
|
|
||||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (self);
|
|
||||||
|
|
||||||
return priv->depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_draw_context_empty_frame (GdkDrawContext *context)
|
gdk_draw_context_empty_frame (GdkDrawContext *context)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "gdkdrawcontext.h"
|
#include "gdkdrawcontext.h"
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
#include "gdkmemoryformatprivate.h"
|
#include "gdkmemoryformatprivate.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@@ -44,9 +43,7 @@ struct _GdkDrawContextClass
|
|||||||
|
|
||||||
void (* begin_frame) (GdkDrawContext *context,
|
void (* begin_frame) (GdkDrawContext *context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *update_area,
|
cairo_region_t *update_area);
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth);
|
|
||||||
void (* end_frame) (GdkDrawContext *context,
|
void (* end_frame) (GdkDrawContext *context,
|
||||||
cairo_region_t *painted);
|
cairo_region_t *painted);
|
||||||
void (* empty_frame) (GdkDrawContext *context);
|
void (* empty_frame) (GdkDrawContext *context);
|
||||||
@@ -61,9 +58,6 @@ void gdk_draw_context_begin_frame_full (GdkDrawContext
|
|||||||
|
|
||||||
void gdk_draw_context_empty_frame (GdkDrawContext *context);
|
void gdk_draw_context_empty_frame (GdkDrawContext *context);
|
||||||
|
|
||||||
GdkColorState * gdk_draw_context_get_color_state (GdkDrawContext *self);
|
|
||||||
GdkMemoryDepth gdk_draw_context_get_depth (GdkDrawContext *self);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@@ -651,9 +651,9 @@ gdk_drop_read_internal (GdkDrop *self,
|
|||||||
* pointer to an array of mime types
|
* pointer to an array of mime types
|
||||||
* @io_priority: the I/O priority for the read operation
|
* @io_priority: the I/O priority for the read operation
|
||||||
* @cancellable: (nullable): optional `GCancellable` object
|
* @cancellable: (nullable): optional `GCancellable` object
|
||||||
* @callback: (scope async) (closure user_data): a `GAsyncReadyCallback` to call when
|
* @callback: (scope async): a `GAsyncReadyCallback` to call when
|
||||||
* the request is satisfied
|
* the request is satisfied
|
||||||
* @user_data: the data to pass to @callback
|
* @user_data: (closure): the data to pass to @callback
|
||||||
*
|
*
|
||||||
* Asynchronously read the dropped data from a `GdkDrop`
|
* Asynchronously read the dropped data from a `GdkDrop`
|
||||||
* in a format that complies with one of the mime types.
|
* in a format that complies with one of the mime types.
|
||||||
@@ -843,12 +843,16 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
|||||||
* @type: a `GType` to read
|
* @type: a `GType` to read
|
||||||
* @io_priority: the I/O priority of the request.
|
* @io_priority: the I/O priority of the request.
|
||||||
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
||||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
* @callback: (scope async): callback to call when the request is satisfied
|
||||||
* @user_data: the data to pass to callback function
|
* @user_data: (closure): the data to pass to callback function
|
||||||
*
|
*
|
||||||
* Asynchronously request the drag operation's contents converted
|
* Asynchronously request the drag operation's contents converted
|
||||||
* to the given @type.
|
* to the given @type.
|
||||||
*
|
*
|
||||||
|
* When the operation is finished @callback will be called. You must
|
||||||
|
* then call [method@Gdk.Drop.read_value_finish] to get the resulting
|
||||||
|
* `GValue`.
|
||||||
|
*
|
||||||
* For local drag-and-drop operations that are available in the given
|
* For local drag-and-drop operations that are available in the given
|
||||||
* `GType`, the value will be copied directly. Otherwise, GDK will
|
* `GType`, the value will be copied directly. Otherwise, GDK will
|
||||||
* try to use [func@Gdk.content_deserialize_async] to convert the data.
|
* try to use [func@Gdk.content_deserialize_async] to convert the data.
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ typedef enum
|
|||||||
* @GDK_BUTTON3_MASK: the third mouse button.
|
* @GDK_BUTTON3_MASK: the third mouse button.
|
||||||
* @GDK_BUTTON4_MASK: the fourth mouse button.
|
* @GDK_BUTTON4_MASK: the fourth mouse button.
|
||||||
* @GDK_BUTTON5_MASK: the fifth mouse button.
|
* @GDK_BUTTON5_MASK: the fifth mouse button.
|
||||||
* @GDK_SUPER_MASK: the Super modifier.
|
* @GDK_SUPER_MASK: the Super modifier
|
||||||
* @GDK_HYPER_MASK: the Hyper modifier.
|
* @GDK_HYPER_MASK: the Hyper modifier
|
||||||
* @GDK_META_MASK: the Meta modifier. Maps to Command on macOS.
|
* @GDK_META_MASK: the Meta modifier
|
||||||
*
|
*
|
||||||
* Flags to indicate the state of modifier keys and mouse buttons
|
* Flags to indicate the state of modifier keys and mouse buttons
|
||||||
* in events.
|
* in events.
|
||||||
|
|||||||
@@ -1371,8 +1371,6 @@ gdk_event_get_modifier_state (GdkEvent *event)
|
|||||||
* Extract the event surface relative x/y coordinates from an event.
|
* Extract the event surface relative x/y coordinates from an event.
|
||||||
*
|
*
|
||||||
* This position is in [surface coordinates](coordinates.html).
|
* This position is in [surface coordinates](coordinates.html).
|
||||||
*
|
|
||||||
* Returns: whether the positions were set
|
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gdk_event_get_position (GdkEvent *event,
|
gdk_event_get_position (GdkEvent *event,
|
||||||
|
|||||||
@@ -152,13 +152,6 @@ enum {
|
|||||||
|
|
||||||
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_gl_error_quark:
|
|
||||||
*
|
|
||||||
* Registers an error quark for [class@Gdk.GLContext] errors.
|
|
||||||
*
|
|
||||||
* Returns: the error quark
|
|
||||||
**/
|
|
||||||
G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
|
G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
|
||||||
@@ -329,7 +322,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
|
|||||||
if (display->have_egl_no_config_context)
|
if (display->have_egl_no_config_context)
|
||||||
egl_config = NULL;
|
egl_config = NULL;
|
||||||
else
|
else
|
||||||
egl_config = gdk_display_get_egl_config (display, GDK_MEMORY_U8);
|
egl_config = gdk_display_get_egl_config (display);
|
||||||
|
|
||||||
if (debug_bit)
|
if (debug_bit)
|
||||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||||
@@ -609,11 +602,9 @@ gdk_gl_context_get_scale (GdkGLContext *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
||||||
G_GNUC_UNUSED GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
G_GNUC_UNUSED GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
@@ -628,16 +619,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
|||||||
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
if (priv->egl_context)
|
if (priv->egl_context)
|
||||||
*out_depth = gdk_surface_ensure_egl_surface (surface, depth);
|
gdk_surface_ensure_egl_surface (surface, depth != GDK_MEMORY_U8);
|
||||||
else
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
if (*out_depth == GDK_MEMORY_U8_SRGB)
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
|
||||||
else
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
#else
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "gdkgltextureprivate.h"
|
#include "gdkgltextureprivate.h"
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
#include "gdkglcontextprivate.h"
|
#include "gdkglcontextprivate.h"
|
||||||
#include "gdkmemoryformatprivate.h"
|
#include "gdkmemoryformatprivate.h"
|
||||||
@@ -152,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
|
|||||||
|
|
||||||
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
||||||
{
|
{
|
||||||
GLint q_internal_format, q_internal_srgb_format;
|
GLint q_internal_format;
|
||||||
GLenum q_format, q_type;
|
GLenum q_format, q_type;
|
||||||
GLint q_swizzle[4];
|
GLint q_swizzle[4];
|
||||||
|
|
||||||
@@ -165,7 +164,6 @@ gdk_gl_texture_find_format (GdkGLContext *context,
|
|||||||
gdk_memory_format_gl_format (format,
|
gdk_memory_format_gl_format (format,
|
||||||
gdk_gl_context_get_use_es (context),
|
gdk_gl_context_get_use_es (context),
|
||||||
&q_internal_format,
|
&q_internal_format,
|
||||||
&q_internal_srgb_format,
|
|
||||||
&q_format,
|
&q_format,
|
||||||
&q_type,
|
&q_type,
|
||||||
q_swizzle);
|
q_swizzle);
|
||||||
@@ -189,7 +187,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
|||||||
GdkMemoryFormat format;
|
GdkMemoryFormat format;
|
||||||
gsize expected_stride;
|
gsize expected_stride;
|
||||||
Download *download = download_;
|
Download *download = download_;
|
||||||
GLint gl_internal_format, gl_internal_srgb_format;
|
GLint gl_internal_format;
|
||||||
GLenum gl_format, gl_type;
|
GLenum gl_format, gl_type;
|
||||||
GLint gl_swizzle[4];
|
GLint gl_swizzle[4];
|
||||||
|
|
||||||
@@ -201,7 +199,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
|||||||
{
|
{
|
||||||
gdk_memory_format_gl_format (format,
|
gdk_memory_format_gl_format (format,
|
||||||
gdk_gl_context_get_use_es (context),
|
gdk_gl_context_get_use_es (context),
|
||||||
&gl_internal_format, &gl_internal_srgb_format,
|
&gl_internal_format,
|
||||||
&gl_format, &gl_type, gl_swizzle);
|
&gl_format, &gl_type, gl_swizzle);
|
||||||
if (download->stride == expected_stride &&
|
if (download->stride == expected_stride &&
|
||||||
download->format == format)
|
download->format == format)
|
||||||
@@ -258,25 +256,25 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format, FALSE));
|
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format));
|
||||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
|
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||||
actual_format = gdk_memory_format_get_straight (actual_format);
|
actual_format = gdk_memory_format_get_straight (actual_format);
|
||||||
|
|
||||||
gdk_memory_format_gl_format (actual_format,
|
gdk_memory_format_gl_format (actual_format,
|
||||||
gdk_gl_context_get_use_es (context),
|
gdk_gl_context_get_use_es (context),
|
||||||
&gl_internal_format, &gl_internal_srgb_format,
|
&gl_internal_format,
|
||||||
&gl_read_format, &gl_read_type, gl_swizzle);
|
&gl_read_format, &gl_read_type, gl_swizzle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format, FALSE));
|
actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format));
|
||||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
|
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||||
actual_format = gdk_memory_format_get_straight (actual_format);
|
actual_format = gdk_memory_format_get_straight (actual_format);
|
||||||
|
|
||||||
gdk_memory_format_gl_format (actual_format,
|
gdk_memory_format_gl_format (actual_format,
|
||||||
gdk_gl_context_get_use_es (context),
|
gdk_gl_context_get_use_es (context),
|
||||||
&gl_internal_format, &gl_internal_srgb_format,
|
&gl_internal_format,
|
||||||
&gl_read_format, &gl_read_type, gl_swizzle);
|
&gl_read_format, &gl_read_type, gl_swizzle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +471,8 @@ gdk_gl_texture_release (GdkGLTexture *self)
|
|||||||
g_return_if_fail (self->saved == NULL);
|
g_return_if_fail (self->saved == NULL);
|
||||||
|
|
||||||
texture = GDK_TEXTURE (self);
|
texture = GDK_TEXTURE (self);
|
||||||
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
|
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
|
||||||
|
gdk_texture_get_format (texture)));
|
||||||
|
|
||||||
drop_gl_resources (self);
|
drop_gl_resources (self);
|
||||||
}
|
}
|
||||||
@@ -489,7 +488,6 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
|
|||||||
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
||||||
"width", gdk_gl_texture_builder_get_width (builder),
|
"width", gdk_gl_texture_builder_get_width (builder),
|
||||||
"height", gdk_gl_texture_builder_get_height (builder),
|
"height", gdk_gl_texture_builder_get_height (builder),
|
||||||
"color-state", GDK_COLOR_STATE_SRGB,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));
|
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));
|
||||||
@@ -684,7 +682,6 @@ gdk_gl_texture_new (GdkGLContext *context,
|
|||||||
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
||||||
"width", width,
|
"width", width,
|
||||||
"height", height,
|
"height", height,
|
||||||
"color-state", GDK_COLOR_STATE_SRGB,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
self->context = g_object_ref (context);
|
self->context = g_object_ref (context);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -37,31 +37,19 @@ typedef enum {
|
|||||||
} GdkMemoryAlpha;
|
} GdkMemoryAlpha;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GDK_MEMORY_NONE,
|
|
||||||
GDK_MEMORY_U8,
|
GDK_MEMORY_U8,
|
||||||
GDK_MEMORY_U8_SRGB,
|
|
||||||
GDK_MEMORY_U16,
|
GDK_MEMORY_U16,
|
||||||
GDK_MEMORY_FLOAT16,
|
GDK_MEMORY_FLOAT16,
|
||||||
GDK_MEMORY_FLOAT32,
|
GDK_MEMORY_FLOAT32
|
||||||
|
|
||||||
GDK_N_DEPTHS
|
|
||||||
} GdkMemoryDepth;
|
} GdkMemoryDepth;
|
||||||
|
|
||||||
#define GDK_MEMORY_DEPTH_BITS 3
|
|
||||||
|
|
||||||
gsize gdk_memory_format_alignment (GdkMemoryFormat format) G_GNUC_CONST;
|
gsize gdk_memory_format_alignment (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
GdkMemoryAlpha gdk_memory_format_alpha (GdkMemoryFormat format) G_GNUC_CONST;
|
GdkMemoryAlpha gdk_memory_format_alpha (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) G_GNUC_CONST;
|
gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
GdkMemoryFormat gdk_memory_format_get_premultiplied (GdkMemoryFormat format) G_GNUC_CONST;
|
GdkMemoryFormat gdk_memory_format_get_premultiplied (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
GdkMemoryFormat gdk_memory_format_get_straight (GdkMemoryFormat format) G_GNUC_CONST;
|
GdkMemoryFormat gdk_memory_format_get_straight (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
const GdkMemoryFormat * gdk_memory_format_get_fallbacks (GdkMemoryFormat format) G_GNUC_CONST;
|
const GdkMemoryFormat * gdk_memory_format_get_fallbacks (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format,
|
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
gboolean srgb) G_GNUC_CONST;
|
|
||||||
gsize gdk_memory_format_min_buffer_size (GdkMemoryFormat format,
|
|
||||||
gsize stride,
|
|
||||||
gsize width,
|
|
||||||
gsize height) G_GNUC_CONST;
|
|
||||||
gboolean gdk_memory_depth_is_srgb (GdkMemoryDepth depth) G_GNUC_CONST;
|
|
||||||
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
||||||
GdkMemoryDepth depth2) G_GNUC_CONST;
|
GdkMemoryDepth depth2) G_GNUC_CONST;
|
||||||
GdkMemoryFormat gdk_memory_depth_get_format (GdkMemoryDepth depth) G_GNUC_CONST;
|
GdkMemoryFormat gdk_memory_depth_get_format (GdkMemoryDepth depth) G_GNUC_CONST;
|
||||||
@@ -69,7 +57,6 @@ GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth
|
|||||||
void gdk_memory_format_gl_format (GdkMemoryFormat format,
|
void gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||||
gboolean gles,
|
gboolean gles,
|
||||||
GLint *out_internal_format,
|
GLint *out_internal_format,
|
||||||
GLint *out_internal_srgb_format,
|
|
||||||
GLenum *out_format,
|
GLenum *out_format,
|
||||||
GLenum *out_type,
|
GLenum *out_type,
|
||||||
GLint out_swizzle[4]);
|
GLint out_swizzle[4]);
|
||||||
@@ -77,20 +64,18 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
|
|||||||
gboolean gles,
|
gboolean gles,
|
||||||
GdkMemoryFormat *out_actual_format,
|
GdkMemoryFormat *out_actual_format,
|
||||||
GLint *out_internal_format,
|
GLint *out_internal_format,
|
||||||
GLint *out_internal_srgb_format,
|
|
||||||
GLenum *out_format,
|
GLenum *out_format,
|
||||||
GLenum *out_type,
|
GLenum *out_type,
|
||||||
GLint out_swizzle[4]);
|
GLint out_swizzle[4]);
|
||||||
#ifdef GDK_RENDERING_VULKAN
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
|
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
|
||||||
VkComponentMapping *out_swizzle);
|
VkComponentMapping *out_swizzle);
|
||||||
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
|
|
||||||
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
|
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
|
||||||
GdkMemoryFormat *out_rgba_format,
|
GdkMemoryFormat *out_rgba_format,
|
||||||
VkComponentMapping *out_swizzle);
|
VkComponentMapping *out_swizzle);
|
||||||
#endif
|
#endif
|
||||||
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
|
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
|
||||||
const char * gdk_memory_format_get_name (GdkMemoryFormat format);
|
|
||||||
|
|
||||||
void gdk_memory_convert (guchar *dest_data,
|
void gdk_memory_convert (guchar *dest_data,
|
||||||
gsize dest_stride,
|
gsize dest_stride,
|
||||||
@@ -100,13 +85,6 @@ void gdk_memory_convert (guchar
|
|||||||
GdkMemoryFormat src_format,
|
GdkMemoryFormat src_format,
|
||||||
gsize width,
|
gsize width,
|
||||||
gsize height);
|
gsize height);
|
||||||
void gdk_memory_convert_color_state (guchar *data,
|
|
||||||
gsize stride,
|
|
||||||
GdkMemoryFormat format,
|
|
||||||
GdkColorState *src_color_state,
|
|
||||||
GdkColorState *dest_color_state,
|
|
||||||
gsize width,
|
|
||||||
gsize height);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
#include "gdkmemorytextureprivate.h"
|
#include "gdkmemorytextureprivate.h"
|
||||||
|
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
#include "gdkmemoryformatprivate.h"
|
#include "gdkmemoryformatprivate.h"
|
||||||
|
#include "gsk/gl/fp16private.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkMemoryTexture:
|
* GdkMemoryTexture:
|
||||||
@@ -152,14 +152,13 @@ gdk_memory_texture_new (int width,
|
|||||||
g_return_val_if_fail (bytes != NULL, NULL);
|
g_return_val_if_fail (bytes != NULL, NULL);
|
||||||
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
||||||
/* needs to be this complex to support subtexture of the bottom right part */
|
/* needs to be this complex to support subtexture of the bottom right part */
|
||||||
g_return_val_if_fail (g_bytes_get_size (bytes) >= gdk_memory_format_min_buffer_size (format, stride, width, height), NULL);
|
g_return_val_if_fail (g_bytes_get_size (bytes) >= stride * (height - 1) + width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
||||||
|
|
||||||
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
|
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
|
||||||
|
|
||||||
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
|
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
|
||||||
"width", width,
|
"width", width,
|
||||||
"height", height,
|
"height", height,
|
||||||
"color-state", GDK_COLOR_STATE_SRGB,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GDK_TEXTURE (self)->format = format;
|
GDK_TEXTURE (self)->format = format;
|
||||||
@@ -177,7 +176,7 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
|||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
GdkTexture *texture, *result;
|
GdkTexture *texture, *result;
|
||||||
gsize offset, size;
|
gsize bpp, offset, size;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_MEMORY_TEXTURE (source), NULL);
|
g_return_val_if_fail (GDK_IS_MEMORY_TEXTURE (source), NULL);
|
||||||
@@ -187,8 +186,9 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
|||||||
g_return_val_if_fail (height > 0 && y + height <= GDK_TEXTURE (source)->height, NULL);
|
g_return_val_if_fail (height > 0 && y + height <= GDK_TEXTURE (source)->height, NULL);
|
||||||
|
|
||||||
texture = GDK_TEXTURE (source);
|
texture = GDK_TEXTURE (source);
|
||||||
offset = y * source->stride + x * gdk_memory_format_bytes_per_pixel (texture->format);
|
bpp = gdk_memory_format_bytes_per_pixel (texture->format);
|
||||||
size = gdk_memory_format_min_buffer_size (texture->format, source->stride, width, height);
|
offset = y * source->stride + x * bpp;
|
||||||
|
size = source->stride * (height - 1) + width * bpp;
|
||||||
bytes = g_bytes_new_from_bytes (source->bytes, offset, size);
|
bytes = g_bytes_new_from_bytes (source->bytes, offset, size);
|
||||||
|
|
||||||
result = gdk_memory_texture_new (width,
|
result = gdk_memory_texture_new (width,
|
||||||
@@ -202,7 +202,8 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GdkMemoryTexture *
|
GdkMemoryTexture *
|
||||||
gdk_memory_texture_from_texture (GdkTexture *texture)
|
gdk_memory_texture_from_texture (GdkTexture *texture,
|
||||||
|
GdkMemoryFormat format)
|
||||||
{
|
{
|
||||||
GdkTexture *result;
|
GdkTexture *result;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
@@ -212,16 +213,21 @@ gdk_memory_texture_from_texture (GdkTexture *texture)
|
|||||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
|
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
|
||||||
|
|
||||||
if (GDK_IS_MEMORY_TEXTURE (texture))
|
if (GDK_IS_MEMORY_TEXTURE (texture))
|
||||||
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
|
{
|
||||||
|
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
|
||||||
|
|
||||||
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
|
if (gdk_texture_get_format (texture) == format)
|
||||||
|
return g_object_ref (memtex);
|
||||||
|
}
|
||||||
|
|
||||||
|
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
|
||||||
data = g_malloc_n (stride, texture->height);
|
data = g_malloc_n (stride, texture->height);
|
||||||
|
|
||||||
gdk_texture_do_download (texture, texture->format, data, stride);
|
gdk_texture_do_download (texture, format, data, stride);
|
||||||
bytes = g_bytes_new_take (data, stride * texture->height);
|
bytes = g_bytes_new_take (data, stride * texture->height);
|
||||||
result = gdk_memory_texture_new (texture->width,
|
result = gdk_memory_texture_new (texture->width,
|
||||||
texture->height,
|
texture->height,
|
||||||
texture->format,
|
format,
|
||||||
bytes,
|
bytes,
|
||||||
stride);
|
stride);
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ G_BEGIN_DECLS
|
|||||||
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
|
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
|
||||||
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
|
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
|
||||||
|
|
||||||
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
|
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
|
||||||
|
GdkMemoryFormat format);
|
||||||
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
|
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ gdk_popup_default_init (GdkPopupInterface *iface)
|
|||||||
*
|
*
|
||||||
* Present @popup after having processed the `GdkPopupLayout` rules.
|
* Present @popup after having processed the `GdkPopupLayout` rules.
|
||||||
*
|
*
|
||||||
* If the popup was previously not showing, it will be shown,
|
* If the popup was previously now showing, it will be showed,
|
||||||
* otherwise it will change position according to @layout.
|
* otherwise it will change position according to @layout.
|
||||||
*
|
*
|
||||||
* After calling this function, the result should be handled in response
|
* After calling this function, the result should be handled in response
|
||||||
|
|||||||
@@ -396,18 +396,10 @@ gboolean
|
|||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
gdk_rgba_to_string (const GdkRGBA *rgba)
|
gdk_rgba_to_string (const GdkRGBA *rgba)
|
||||||
{
|
|
||||||
return g_string_free (gdk_rgba_print (rgba, g_string_new ("")), FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
GString *
|
|
||||||
gdk_rgba_print (const GdkRGBA *rgba,
|
|
||||||
GString *string)
|
|
||||||
{
|
{
|
||||||
if (rgba->alpha > 0.999)
|
if (rgba->alpha > 0.999)
|
||||||
{
|
{
|
||||||
g_string_append_printf (string,
|
return g_strdup_printf ("rgb(%d,%d,%d)",
|
||||||
"rgb(%d,%d,%d)",
|
|
||||||
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
||||||
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
||||||
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
|
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
|
||||||
@@ -418,15 +410,12 @@ gdk_rgba_print (const GdkRGBA *rgba,
|
|||||||
|
|
||||||
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
|
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
|
||||||
|
|
||||||
g_string_append_printf (string,
|
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
|
||||||
"rgba(%d,%d,%d,%s)",
|
|
||||||
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
||||||
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
||||||
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.),
|
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.),
|
||||||
alpha);
|
alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
@@ -72,8 +72,5 @@ _gdk_rgba_equal (gconstpointer p1,
|
|||||||
rgba1->alpha == rgba2->alpha;
|
rgba1->alpha == rgba2->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString * gdk_rgba_print (const GdkRGBA *rgba,
|
|
||||||
GString *string);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
|
|||||||
GdkTexture *texture,
|
GdkTexture *texture,
|
||||||
const graphene_rect_t *source,
|
const graphene_rect_t *source,
|
||||||
const graphene_rect_t *dest,
|
const graphene_rect_t *dest,
|
||||||
GdkDihedral transform,
|
GdkTextureTransform transform,
|
||||||
const graphene_rect_t *background,
|
const graphene_rect_t *background,
|
||||||
gboolean above,
|
gboolean above,
|
||||||
GdkSubsurface *sibling)
|
GdkSubsurface *sibling)
|
||||||
@@ -156,8 +156,8 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
|
|||||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
|
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
|
||||||
g_return_val_if_fail (source != NULL &&
|
g_return_val_if_fail (source != NULL &&
|
||||||
gsk_rect_contains_rect (&GRAPHENE_RECT_INIT (0, 0,
|
gsk_rect_contains_rect (&GRAPHENE_RECT_INIT (0, 0,
|
||||||
gdk_dihedral_swaps_xy (transform) ? gdk_texture_get_height (texture) : gdk_texture_get_width (texture),
|
gdk_texture_get_width (texture),
|
||||||
gdk_dihedral_swaps_xy (transform) ? gdk_texture_get_width (texture) : gdk_texture_get_height (texture)),
|
gdk_texture_get_height (texture)),
|
||||||
source), FALSE);
|
source), FALSE);
|
||||||
g_return_val_if_fail (dest != NULL, FALSE);
|
g_return_val_if_fail (dest != NULL, FALSE);
|
||||||
g_return_val_if_fail (sibling != subsurface, FALSE);
|
g_return_val_if_fail (sibling != subsurface, FALSE);
|
||||||
@@ -320,10 +320,10 @@ gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
|
|||||||
*
|
*
|
||||||
* Returns: the transform
|
* Returns: the transform
|
||||||
*/
|
*/
|
||||||
GdkDihedral
|
GdkTextureTransform
|
||||||
gdk_subsurface_get_transform (GdkSubsurface *subsurface)
|
gdk_subsurface_get_transform (GdkSubsurface *subsurface)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_DIHEDRAL_NORMAL);
|
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_TEXTURE_TRANSFORM_NORMAL);
|
||||||
|
|
||||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface);
|
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gdkenumtypes.h"
|
#include "gdkenumtypes.h"
|
||||||
#include "gdkdihedralprivate.h"
|
|
||||||
#include "gdksurface.h"
|
#include "gdksurface.h"
|
||||||
#include <graphene.h>
|
#include <graphene.h>
|
||||||
|
|
||||||
@@ -48,6 +47,17 @@ struct _GdkSubsurface
|
|||||||
GdkSubsurface *sibling_below;
|
GdkSubsurface *sibling_below;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GDK_TEXTURE_TRANSFORM_NORMAL,
|
||||||
|
GDK_TEXTURE_TRANSFORM_90,
|
||||||
|
GDK_TEXTURE_TRANSFORM_180,
|
||||||
|
GDK_TEXTURE_TRANSFORM_270,
|
||||||
|
GDK_TEXTURE_TRANSFORM_FLIPPED,
|
||||||
|
GDK_TEXTURE_TRANSFORM_FLIPPED_90,
|
||||||
|
GDK_TEXTURE_TRANSFORM_FLIPPED_180,
|
||||||
|
GDK_TEXTURE_TRANSFORM_FLIPPED_270,
|
||||||
|
} GdkTextureTransform;
|
||||||
|
|
||||||
struct _GdkSubsurfaceClass
|
struct _GdkSubsurfaceClass
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
@@ -56,7 +66,7 @@ struct _GdkSubsurfaceClass
|
|||||||
GdkTexture *texture,
|
GdkTexture *texture,
|
||||||
const graphene_rect_t *source,
|
const graphene_rect_t *source,
|
||||||
const graphene_rect_t *dest,
|
const graphene_rect_t *dest,
|
||||||
GdkDihedral transform,
|
GdkTextureTransform transform,
|
||||||
const graphene_rect_t *bg,
|
const graphene_rect_t *bg,
|
||||||
gboolean above,
|
gboolean above,
|
||||||
GdkSubsurface *sibling);
|
GdkSubsurface *sibling);
|
||||||
@@ -66,7 +76,7 @@ struct _GdkSubsurfaceClass
|
|||||||
graphene_rect_t *rect);
|
graphene_rect_t *rect);
|
||||||
void (* get_texture_rect) (GdkSubsurface *subsurface,
|
void (* get_texture_rect) (GdkSubsurface *subsurface,
|
||||||
graphene_rect_t *rect);
|
graphene_rect_t *rect);
|
||||||
GdkDihedral
|
GdkTextureTransform
|
||||||
(* get_transform) (GdkSubsurface *subsurface);
|
(* get_transform) (GdkSubsurface *subsurface);
|
||||||
gboolean (* get_background_rect) (GdkSubsurface *subsurface,
|
gboolean (* get_background_rect) (GdkSubsurface *subsurface,
|
||||||
graphene_rect_t *rect);
|
graphene_rect_t *rect);
|
||||||
@@ -80,7 +90,7 @@ gboolean gdk_subsurface_attach (GdkSubsurface *subsu
|
|||||||
GdkTexture *texture,
|
GdkTexture *texture,
|
||||||
const graphene_rect_t *source,
|
const graphene_rect_t *source,
|
||||||
const graphene_rect_t *dest,
|
const graphene_rect_t *dest,
|
||||||
GdkDihedral transform,
|
GdkTextureTransform transform,
|
||||||
const graphene_rect_t *background,
|
const graphene_rect_t *background,
|
||||||
gboolean above,
|
gboolean above,
|
||||||
GdkSubsurface *sibling);
|
GdkSubsurface *sibling);
|
||||||
@@ -93,7 +103,7 @@ void gdk_subsurface_get_texture_rect (GdkSubsurface *subsu
|
|||||||
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
|
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
|
||||||
GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
|
GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
|
||||||
gboolean above);
|
gboolean above);
|
||||||
GdkDihedral
|
GdkTextureTransform
|
||||||
gdk_subsurface_get_transform (GdkSubsurface *subsurface);
|
gdk_subsurface_get_transform (GdkSubsurface *subsurface);
|
||||||
gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
|
gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
|
||||||
graphene_rect_t *rect);
|
graphene_rect_t *rect);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ struct _GdkSurfacePrivate
|
|||||||
gpointer egl_native_window;
|
gpointer egl_native_window;
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
GdkMemoryDepth egl_surface_depth;
|
gboolean egl_surface_high_depth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gpointer widget;
|
gpointer widget;
|
||||||
@@ -1139,18 +1139,18 @@ gdk_surface_get_egl_surface (GdkSurface *self)
|
|||||||
return priv->egl_surface;
|
return priv->egl_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkMemoryDepth
|
void
|
||||||
gdk_surface_ensure_egl_surface (GdkSurface *self,
|
gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||||
GdkMemoryDepth depth)
|
gboolean high_depth)
|
||||||
{
|
{
|
||||||
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
||||||
GdkDisplay *display = gdk_surface_get_display (self);
|
GdkDisplay *display = gdk_surface_get_display (self);
|
||||||
|
|
||||||
g_return_val_if_fail (priv->egl_native_window != NULL, depth);
|
g_return_if_fail (priv->egl_native_window != NULL);
|
||||||
|
|
||||||
if (priv->egl_surface_depth != depth &&
|
if (priv->egl_surface_high_depth != high_depth &&
|
||||||
priv->egl_surface != NULL &&
|
priv->egl_surface != NULL &&
|
||||||
gdk_display_get_egl_config (display, priv->egl_surface_depth) != gdk_display_get_egl_config (display, depth))
|
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
|
||||||
{
|
{
|
||||||
gdk_gl_context_clear_current_if_surface (self);
|
gdk_gl_context_clear_current_if_surface (self);
|
||||||
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
|
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
|
||||||
@@ -1159,45 +1159,16 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
|
|||||||
|
|
||||||
if (priv->egl_surface == NULL)
|
if (priv->egl_surface == NULL)
|
||||||
{
|
{
|
||||||
EGLint attribs[4];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if (depth == GDK_MEMORY_U8_SRGB && display->have_egl_gl_colorspace)
|
|
||||||
{
|
|
||||||
attribs[i++] = EGL_GL_COLORSPACE_KHR;
|
|
||||||
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
|
|
||||||
self->is_srgb = TRUE;
|
|
||||||
}
|
|
||||||
g_assert (i < G_N_ELEMENTS (attribs));
|
|
||||||
attribs[i++] = EGL_NONE;
|
|
||||||
|
|
||||||
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
||||||
gdk_display_get_egl_config (display, depth),
|
high_depth ? gdk_display_get_egl_config_high_depth (display)
|
||||||
|
: gdk_display_get_egl_config (display),
|
||||||
(EGLNativeWindowType) priv->egl_native_window,
|
(EGLNativeWindowType) priv->egl_native_window,
|
||||||
attribs);
|
NULL);
|
||||||
if (priv->egl_surface == EGL_NO_SURFACE)
|
priv->egl_surface_high_depth = high_depth;
|
||||||
{
|
|
||||||
/* just assume the error is no srgb support and try again without */
|
|
||||||
self->is_srgb = FALSE;
|
|
||||||
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
|
||||||
gdk_display_get_egl_config (display, depth),
|
|
||||||
(EGLNativeWindowType) priv->egl_native_window,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
priv->egl_surface_depth = depth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return priv->egl_surface_depth;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
gdk_surface_get_gl_is_srgb (GdkSurface *self)
|
|
||||||
{
|
|
||||||
return self->is_srgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkGLContext *
|
GdkGLContext *
|
||||||
gdk_surface_get_paint_gl_context (GdkSurface *surface,
|
gdk_surface_get_paint_gl_context (GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
#include "gdkenumtypes.h"
|
#include "gdkenumtypes.h"
|
||||||
#include "gdkmemoryformatprivate.h"
|
|
||||||
#include "gdksurface.h"
|
#include "gdksurface.h"
|
||||||
#include "gdktoplevel.h"
|
#include "gdktoplevel.h"
|
||||||
#include <graphene.h>
|
#include <graphene.h>
|
||||||
@@ -71,7 +70,6 @@ struct _GdkSurface
|
|||||||
guint shortcuts_inhibited : 1;
|
guint shortcuts_inhibited : 1;
|
||||||
guint request_motion : 1;
|
guint request_motion : 1;
|
||||||
guint has_pointer : 1;
|
guint has_pointer : 1;
|
||||||
guint is_srgb : 1;
|
|
||||||
|
|
||||||
guint request_motion_id;
|
guint request_motion_id;
|
||||||
|
|
||||||
@@ -300,12 +298,10 @@ void gdk_surface_set_frame_clock (GdkSurface
|
|||||||
GdkFrameClock *clock);
|
GdkFrameClock *clock);
|
||||||
void gdk_surface_set_egl_native_window (GdkSurface *self,
|
void gdk_surface_set_egl_native_window (GdkSurface *self,
|
||||||
gpointer native_window);
|
gpointer native_window);
|
||||||
GdkMemoryDepth gdk_surface_ensure_egl_surface (GdkSurface *self,
|
void gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||||
GdkMemoryDepth depth);
|
gboolean hdr);
|
||||||
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
|
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
|
||||||
|
|
||||||
gboolean gdk_surface_get_gl_is_srgb (GdkSurface *self);
|
|
||||||
|
|
||||||
void gdk_surface_set_widget (GdkSurface *self,
|
void gdk_surface_set_widget (GdkSurface *self,
|
||||||
gpointer widget);
|
gpointer widget);
|
||||||
gpointer gdk_surface_get_widget (GdkSurface *self);
|
gpointer gdk_surface_get_widget (GdkSurface *self);
|
||||||
@@ -343,6 +339,12 @@ void gdk_surface_queue_state_change (GdkSurface *surface,
|
|||||||
|
|
||||||
void gdk_surface_apply_state_change (GdkSurface *surface);
|
void gdk_surface_apply_state_change (GdkSurface *surface);
|
||||||
|
|
||||||
|
void gdk_surface_emit_size_changed (GdkSurface *surface,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
|
void gdk_surface_request_compute_size (GdkSurface *surface);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gdk_surface_request_motion (GdkSurface *surface);
|
void gdk_surface_request_motion (GdkSurface *surface);
|
||||||
|
|
||||||
|
|||||||
160
gdk/gdktexture.c
160
gdk/gdktexture.c
@@ -40,26 +40,16 @@
|
|||||||
|
|
||||||
#include "gdktextureprivate.h"
|
#include "gdktextureprivate.h"
|
||||||
|
|
||||||
#include "gdkcairoprivate.h"
|
#include <glib/gi18n-lib.h>
|
||||||
#include "gdkcolorstateprivate.h"
|
|
||||||
#include "gdkmemorytextureprivate.h"
|
#include "gdkmemorytextureprivate.h"
|
||||||
#include "gdkpaintable.h"
|
#include "gdkpaintable.h"
|
||||||
#include "gdksnapshot.h"
|
#include "gdksnapshot.h"
|
||||||
#include "gdktexturedownloaderprivate.h"
|
|
||||||
|
|
||||||
#include <glib/gi18n-lib.h>
|
|
||||||
#include <graphene.h>
|
#include <graphene.h>
|
||||||
#include "loaders/gdkpngprivate.h"
|
#include "loaders/gdkpngprivate.h"
|
||||||
#include "loaders/gdktiffprivate.h"
|
#include "loaders/gdktiffprivate.h"
|
||||||
#include "loaders/gdkjpegprivate.h"
|
#include "loaders/gdkjpegprivate.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_texture_error_quark:
|
|
||||||
*
|
|
||||||
* Registers an error quark for [class@Gdk.Texture] errors.
|
|
||||||
*
|
|
||||||
* Returns: the error quark
|
|
||||||
**/
|
|
||||||
G_DEFINE_QUARK (gdk-texture-error-quark, gdk_texture_error)
|
G_DEFINE_QUARK (gdk-texture-error-quark, gdk_texture_error)
|
||||||
|
|
||||||
/* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
|
/* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
|
||||||
@@ -72,7 +62,6 @@ enum {
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_WIDTH,
|
PROP_WIDTH,
|
||||||
PROP_HEIGHT,
|
PROP_HEIGHT,
|
||||||
PROP_COLOR_STATE,
|
|
||||||
|
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
@@ -286,11 +275,6 @@ gdk_texture_set_property (GObject *gobject,
|
|||||||
self->height = g_value_get_int (value);
|
self->height = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_COLOR_STATE:
|
|
||||||
self->color_state = g_value_dup_boxed (value);
|
|
||||||
g_assert (self->color_state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -315,10 +299,6 @@ gdk_texture_get_property (GObject *gobject,
|
|||||||
g_value_set_int (value, self->height);
|
g_value_set_int (value, self->height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_COLOR_STATE:
|
|
||||||
g_value_set_boxed (value, self->color_state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -360,16 +340,6 @@ gdk_texture_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_texture_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
GdkTexture *self = GDK_TEXTURE (object);
|
|
||||||
|
|
||||||
gdk_color_state_unref (self->color_state);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gdk_texture_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_texture_class_init (GdkTextureClass *klass)
|
gdk_texture_class_init (GdkTextureClass *klass)
|
||||||
{
|
{
|
||||||
@@ -380,7 +350,6 @@ gdk_texture_class_init (GdkTextureClass *klass)
|
|||||||
gobject_class->set_property = gdk_texture_set_property;
|
gobject_class->set_property = gdk_texture_set_property;
|
||||||
gobject_class->get_property = gdk_texture_get_property;
|
gobject_class->get_property = gdk_texture_get_property;
|
||||||
gobject_class->dispose = gdk_texture_dispose;
|
gobject_class->dispose = gdk_texture_dispose;
|
||||||
gobject_class->finalize = gdk_texture_finalize;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkTexture:width: (attributes org.gtk.Property.get=gdk_texture_get_width)
|
* GdkTexture:width: (attributes org.gtk.Property.get=gdk_texture_get_width)
|
||||||
@@ -412,70 +381,21 @@ gdk_texture_class_init (GdkTextureClass *klass)
|
|||||||
G_PARAM_STATIC_STRINGS |
|
G_PARAM_STATIC_STRINGS |
|
||||||
G_PARAM_EXPLICIT_NOTIFY);
|
G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
/**
|
|
||||||
* GdkTexture:color-state: (attributes org.gtk.Property.get=gdk_texture_get_color_state)
|
|
||||||
*
|
|
||||||
* The color state of the texture.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
properties[PROP_COLOR_STATE] =
|
|
||||||
g_param_spec_boxed ("color-state", NULL, NULL,
|
|
||||||
GDK_TYPE_COLOR_STATE,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
|
||||||
G_PARAM_STATIC_STRINGS |
|
|
||||||
G_PARAM_EXPLICIT_NOTIFY);
|
|
||||||
|
|
||||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_texture_init (GdkTexture *self)
|
gdk_texture_init (GdkTexture *self)
|
||||||
{
|
{
|
||||||
self->color_state = gdk_color_state_get_srgb ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkMemoryFormat
|
/**
|
||||||
cairo_format_to_memory_format (cairo_format_t format)
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case CAIRO_FORMAT_ARGB32:
|
|
||||||
return GDK_MEMORY_DEFAULT;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB24:
|
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
||||||
return GDK_MEMORY_B8G8R8X8;
|
|
||||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
|
||||||
return GDK_MEMORY_X8R8G8B8;
|
|
||||||
#else
|
|
||||||
#error "Unknown byte order for Cairo format"
|
|
||||||
#endif
|
|
||||||
case CAIRO_FORMAT_A8:
|
|
||||||
return GDK_MEMORY_A8;
|
|
||||||
case CAIRO_FORMAT_RGB96F:
|
|
||||||
return GDK_MEMORY_R32G32B32_FLOAT;
|
|
||||||
case CAIRO_FORMAT_RGBA128F:
|
|
||||||
return GDK_MEMORY_R32G32B32A32_FLOAT;
|
|
||||||
|
|
||||||
case CAIRO_FORMAT_RGB16_565:
|
|
||||||
case CAIRO_FORMAT_RGB30:
|
|
||||||
case CAIRO_FORMAT_INVALID:
|
|
||||||
case CAIRO_FORMAT_A1:
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return GDK_MEMORY_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* gdk_texture_new_for_surface:
|
* gdk_texture_new_for_surface:
|
||||||
* @surface: a cairo image surface
|
* @surface: a cairo image surface
|
||||||
*
|
*
|
||||||
* Creates a new texture object representing the surface.
|
* Creates a new texture object representing the surface.
|
||||||
*
|
*
|
||||||
* The @surface must be an image surface with a format supperted by GTK.
|
* The @surface must be an image surface with format `CAIRO_FORMAT_ARGB32`.
|
||||||
*
|
*
|
||||||
* The newly created texture will acquire a reference on the @surface.
|
* The newly created texture will acquire a reference on the @surface.
|
||||||
*
|
*
|
||||||
@@ -499,7 +419,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
|
|||||||
|
|
||||||
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
|
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
|
||||||
cairo_image_surface_get_height (surface),
|
cairo_image_surface_get_height (surface),
|
||||||
cairo_format_to_memory_format (cairo_image_surface_get_format (surface)),
|
GDK_MEMORY_DEFAULT,
|
||||||
bytes,
|
bytes,
|
||||||
cairo_image_surface_get_stride (surface));
|
cairo_image_surface_get_stride (surface));
|
||||||
|
|
||||||
@@ -800,24 +720,6 @@ gdk_texture_get_height (GdkTexture *texture)
|
|||||||
return texture->height;
|
return texture->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_texture_get_color_state: (attributes org.gtk.Method.get_property=color-state)
|
|
||||||
* @self: a `GdkTexture`
|
|
||||||
*
|
|
||||||
* Returns the color state associated with the texture.
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): the color state of the `GdkTexture`
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GdkColorState *
|
|
||||||
gdk_texture_get_color_state (GdkTexture *self)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GDK_IS_TEXTURE (self), NULL);
|
|
||||||
|
|
||||||
return self->color_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_texture_do_download (GdkTexture *texture,
|
gdk_texture_do_download (GdkTexture *texture,
|
||||||
GdkMemoryFormat format,
|
GdkMemoryFormat format,
|
||||||
@@ -920,46 +822,22 @@ gdk_texture_set_diff (GdkTexture *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
gdk_texture_download_surface (GdkTexture *texture,
|
gdk_texture_download_surface (GdkTexture *texture)
|
||||||
GdkColorState *color_state)
|
|
||||||
{
|
{
|
||||||
GdkMemoryDepth depth;
|
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_status_t surface_status;
|
cairo_status_t surface_status;
|
||||||
cairo_format_t surface_format;
|
|
||||||
GdkTextureDownloader downloader;
|
|
||||||
|
|
||||||
depth = gdk_texture_get_depth (texture);
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
#if 0
|
|
||||||
/* disabled for performance reasons. Enjoy living with some banding. */
|
|
||||||
if (!gdk_color_state_equal (texture->color_state, color_state))
|
|
||||||
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_depth (color_state));
|
|
||||||
#else
|
|
||||||
if (depth == GDK_MEMORY_U8_SRGB)
|
|
||||||
depth = GDK_MEMORY_U8;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
surface_format = gdk_cairo_format_for_depth (depth);
|
|
||||||
surface = cairo_image_surface_create (surface_format,
|
|
||||||
texture->width, texture->height);
|
texture->width, texture->height);
|
||||||
|
|
||||||
surface_status = cairo_surface_status (surface);
|
surface_status = cairo_surface_status (surface);
|
||||||
if (surface_status != CAIRO_STATUS_SUCCESS)
|
if (surface_status != CAIRO_STATUS_SUCCESS)
|
||||||
{
|
g_warning ("%s: surface error: %s", __FUNCTION__,
|
||||||
g_warning ("%s: surface error: %s", __FUNCTION__,
|
cairo_status_to_string (surface_status));
|
||||||
cairo_status_to_string (surface_status));
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdk_texture_downloader_init (&downloader, texture);
|
gdk_texture_download (texture,
|
||||||
gdk_texture_downloader_set_format (&downloader,
|
cairo_image_surface_get_data (surface),
|
||||||
gdk_cairo_format_to_memory_format (surface_format));
|
cairo_image_surface_get_stride (surface));
|
||||||
gdk_texture_downloader_download_into (&downloader,
|
|
||||||
cairo_image_surface_get_data (surface),
|
|
||||||
cairo_image_surface_get_stride (surface));
|
|
||||||
gdk_texture_downloader_finish (&downloader);
|
|
||||||
|
|
||||||
gdk_cairo_surface_convert_color_state (surface, texture->color_state, color_state);
|
|
||||||
cairo_surface_mark_dirty (surface);
|
cairo_surface_mark_dirty (surface);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
@@ -1036,13 +914,6 @@ gdk_texture_get_format (GdkTexture *self)
|
|||||||
return self->format;
|
return self->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkMemoryDepth
|
|
||||||
gdk_texture_get_depth (GdkTexture *self)
|
|
||||||
{
|
|
||||||
return gdk_memory_format_get_depth (self->format,
|
|
||||||
gdk_color_state_get_no_srgb_tf (self->color_state) != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gdk_texture_set_render_data (GdkTexture *self,
|
gdk_texture_set_render_data (GdkTexture *self,
|
||||||
gpointer key,
|
gpointer key,
|
||||||
@@ -1061,14 +932,6 @@ gdk_texture_set_render_data (GdkTexture *self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gdk_texture_steal_render_data (GdkTexture *self)
|
|
||||||
{
|
|
||||||
self->render_key = NULL;
|
|
||||||
self->render_data = NULL;
|
|
||||||
self->render_notify = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_texture_clear_render_data (GdkTexture *self)
|
gdk_texture_clear_render_data (GdkTexture *self)
|
||||||
{
|
{
|
||||||
@@ -1216,4 +1079,3 @@ gdk_texture_save_to_tiff_bytes (GdkTexture *texture)
|
|||||||
|
|
||||||
return gdk_save_tiff (texture);
|
return gdk_save_tiff (texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,9 +83,6 @@ int gdk_texture_get_height (GdkTexture
|
|||||||
GDK_AVAILABLE_IN_4_10
|
GDK_AVAILABLE_IN_4_10
|
||||||
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
|
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GdkColorState * gdk_texture_get_color_state (GdkTexture *self);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gdk_texture_download (GdkTexture *texture,
|
void gdk_texture_download (GdkTexture *texture,
|
||||||
guchar *data,
|
guchar *data,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "gdktexture.h"
|
#include "gdktexture.h"
|
||||||
|
|
||||||
#include "gdkenums.h"
|
#include "gdkenums.h"
|
||||||
#include "gdkmemoryformatprivate.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@@ -26,7 +25,6 @@ struct _GdkTexture
|
|||||||
GdkMemoryFormat format;
|
GdkMemoryFormat format;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
GdkColorState *color_state;
|
|
||||||
|
|
||||||
gpointer render_key;
|
gpointer render_key;
|
||||||
gpointer render_data;
|
gpointer render_data;
|
||||||
@@ -55,10 +53,7 @@ struct _GdkTextureClass {
|
|||||||
gboolean gdk_texture_can_load (GBytes *bytes);
|
gboolean gdk_texture_can_load (GBytes *bytes);
|
||||||
|
|
||||||
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
|
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
|
||||||
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture,
|
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture);
|
||||||
GdkColorState *color_state);
|
|
||||||
|
|
||||||
GdkMemoryDepth gdk_texture_get_depth (GdkTexture *self);
|
|
||||||
|
|
||||||
void gdk_texture_do_download (GdkTexture *texture,
|
void gdk_texture_do_download (GdkTexture *texture,
|
||||||
GdkMemoryFormat format,
|
GdkMemoryFormat format,
|
||||||
@@ -76,7 +71,6 @@ gboolean gdk_texture_set_render_data (GdkTexture
|
|||||||
gpointer key,
|
gpointer key,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
void gdk_texture_steal_render_data (GdkTexture *self);
|
|
||||||
void gdk_texture_clear_render_data (GdkTexture *self);
|
void gdk_texture_clear_render_data (GdkTexture *self);
|
||||||
gpointer gdk_texture_get_render_data (GdkTexture *self,
|
gpointer gdk_texture_get_render_data (GdkTexture *self,
|
||||||
gpointer key);
|
gpointer key);
|
||||||
|
|||||||
@@ -745,10 +745,6 @@ gdk_toplevel_begin_move (GdkToplevel *toplevel,
|
|||||||
* @toplevel: a `GdkToplevel`
|
* @toplevel: a `GdkToplevel`
|
||||||
* @gesture: a `GdkTitlebarGesture`
|
* @gesture: a `GdkTitlebarGesture`
|
||||||
*
|
*
|
||||||
* Performs a title bar gesture.
|
|
||||||
*
|
|
||||||
* Returns: whether the gesture was performed
|
|
||||||
*
|
|
||||||
* Since: 4.4
|
* Since: 4.4
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
@@ -771,6 +767,9 @@ gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
|
|||||||
* This function asynchronously obtains a handle for a toplevel surface
|
* This function asynchronously obtains a handle for a toplevel surface
|
||||||
* that can be passed to other processes.
|
* that can be passed to other processes.
|
||||||
*
|
*
|
||||||
|
* When a handle has been obtained, @callback will be called, and can
|
||||||
|
* receive the handle via [method@Gdk.Toplevel.export_handle_finish].
|
||||||
|
*
|
||||||
* It is an error to call this function on a surface that is already
|
* It is an error to call this function on a surface that is already
|
||||||
* exported.
|
* exported.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -118,12 +118,9 @@ typedef enum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkTitlebarGesture:
|
* GdkTitlebarGesture:
|
||||||
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK: double click gesture
|
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
|
||||||
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK: right click gesture
|
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
|
||||||
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK: middle click gesture
|
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
|
||||||
*
|
|
||||||
* The kind of title bar gesture to emit with
|
|
||||||
* [method@Gdk.Toplevel.titlebar_gesture].
|
|
||||||
*
|
*
|
||||||
* Since: 4.4
|
* Since: 4.4
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ typedef cairo_rectangle_int_t GdkRectangle;
|
|||||||
|
|
||||||
/* Forward declarations of commonly used types */
|
/* Forward declarations of commonly used types */
|
||||||
typedef struct _GdkRGBA GdkRGBA;
|
typedef struct _GdkRGBA GdkRGBA;
|
||||||
typedef struct _GdkColorState GdkColorState;
|
|
||||||
typedef struct _GdkContentFormats GdkContentFormats;
|
typedef struct _GdkContentFormats GdkContentFormats;
|
||||||
typedef struct _GdkContentProvider GdkContentProvider;
|
typedef struct _GdkContentProvider GdkContentProvider;
|
||||||
typedef struct _GdkCursor GdkCursor;
|
typedef struct _GdkCursor GdkCursor;
|
||||||
@@ -100,7 +99,7 @@ typedef struct _GdkVulkanContext GdkVulkanContext;
|
|||||||
typedef struct _GdkDmabufFormats GdkDmabufFormats;
|
typedef struct _GdkDmabufFormats GdkDmabufFormats;
|
||||||
typedef struct _GdkDmabufTexture GdkDmabufTexture;
|
typedef struct _GdkDmabufTexture GdkDmabufTexture;
|
||||||
|
|
||||||
/*<private>
|
/*
|
||||||
* GDK_DECLARE_INTERNAL_TYPE:
|
* GDK_DECLARE_INTERNAL_TYPE:
|
||||||
* @ModuleObjName: The name of the new type, in camel case (like GtkWidget)
|
* @ModuleObjName: The name of the new type, in camel case (like GtkWidget)
|
||||||
* @module_obj_name: The name of the new type in lowercase, with words
|
* @module_obj_name: The name of the new type in lowercase, with words
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include "gdkdmabuftextureprivate.h"
|
#include "gdkdmabuftextureprivate.h"
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
#include "gdkprofilerprivate.h"
|
#include "gdkprofilerprivate.h"
|
||||||
#include "gdkmemorytexture.h"
|
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -72,8 +71,9 @@ struct _GdkVulkanContextPrivate {
|
|||||||
struct {
|
struct {
|
||||||
VkSurfaceFormatKHR vk_format;
|
VkSurfaceFormatKHR vk_format;
|
||||||
GdkMemoryFormat gdk_format;
|
GdkMemoryFormat gdk_format;
|
||||||
} formats[GDK_N_DEPTHS];
|
} formats[4];
|
||||||
GdkMemoryDepth current_depth;
|
GdkMemoryDepth current_format;
|
||||||
|
GdkMemoryFormat offscreen_formats[4];
|
||||||
|
|
||||||
VkSwapchainKHR swapchain;
|
VkSwapchainKHR swapchain;
|
||||||
VkSemaphore draw_semaphore;
|
VkSemaphore draw_semaphore;
|
||||||
@@ -94,13 +94,6 @@ enum {
|
|||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_vulkan_error_quark:
|
|
||||||
*
|
|
||||||
* Registers an error quark for [class@Gdk.VulkanContext] errors.
|
|
||||||
*
|
|
||||||
* Returns: the error quark
|
|
||||||
**/
|
|
||||||
G_DEFINE_QUARK (gdk-vulkan-error-quark, gdk_vulkan_error)
|
G_DEFINE_QUARK (gdk-vulkan-error-quark, gdk_vulkan_error)
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
@@ -473,8 +466,8 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
|||||||
.minImageCount = CLAMP (4,
|
.minImageCount = CLAMP (4,
|
||||||
capabilities.minImageCount,
|
capabilities.minImageCount,
|
||||||
capabilities.maxImageCount ? capabilities.maxImageCount : G_MAXUINT32),
|
capabilities.maxImageCount ? capabilities.maxImageCount : G_MAXUINT32),
|
||||||
.imageFormat = priv->formats[priv->current_depth].vk_format.format,
|
.imageFormat = priv->formats[priv->current_format].vk_format.format,
|
||||||
.imageColorSpace = priv->formats[priv->current_depth].vk_format.colorSpace,
|
.imageColorSpace = priv->formats[priv->current_format].vk_format.colorSpace,
|
||||||
.imageExtent = capabilities.currentExtent,
|
.imageExtent = capabilities.currentExtent,
|
||||||
.imageArrayLayers = 1,
|
.imageArrayLayers = 1,
|
||||||
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||||
@@ -614,8 +607,7 @@ physical_device_check_features (VkPhysicalDevice device)
|
|||||||
features |= GDK_VULKAN_FEATURE_YCBCR;
|
features |= GDK_VULKAN_FEATURE_YCBCR;
|
||||||
|
|
||||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
|
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
|
||||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
|
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
|
||||||
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
|
|
||||||
features |= GDK_VULKAN_FEATURE_DMABUF;
|
features |= GDK_VULKAN_FEATURE_DMABUF;
|
||||||
|
|
||||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
|
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
|
||||||
@@ -634,71 +626,59 @@ physical_device_check_features (VkPhysicalDevice device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||||
VkResult acquire_result;
|
VkResult acquire_result;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (depth != priv->current_depth && depth != GDK_MEMORY_NONE)
|
if (depth != priv->current_format)
|
||||||
{
|
{
|
||||||
if (priv->formats[depth].vk_format.format != priv->formats[priv->current_depth].vk_format.format ||
|
if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
|
||||||
priv->formats[depth].vk_format.colorSpace != priv->formats[priv->current_depth].vk_format.colorSpace)
|
|
||||||
{
|
{
|
||||||
GdkMemoryDepth old_depth = priv->current_depth;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
priv->current_depth = depth;
|
|
||||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||||
{
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
priv->current_depth = old_depth;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
priv->current_format = depth;
|
||||||
}
|
}
|
||||||
for (i = 0; i < priv->n_images; i++)
|
for (i = 0; i < priv->n_images; i++)
|
||||||
{
|
{
|
||||||
cairo_region_union (priv->regions[i], region);
|
cairo_region_union (priv->regions[i], region);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (TRUE)
|
acquire_next_image:
|
||||||
|
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||||
|
priv->swapchain,
|
||||||
|
UINT64_MAX,
|
||||||
|
priv->draw_semaphore,
|
||||||
|
VK_NULL_HANDLE,
|
||||||
|
&priv->draw_index);
|
||||||
|
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
|
||||||
|
(acquire_result == VK_SUBOPTIMAL_KHR))
|
||||||
{
|
{
|
||||||
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
GError *error = NULL;
|
||||||
priv->swapchain,
|
|
||||||
UINT64_MAX,
|
GDK_DEBUG (VULKAN, "Recreating the swapchain");
|
||||||
priv->draw_semaphore,
|
|
||||||
VK_NULL_HANDLE,
|
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||||
&priv->draw_index);
|
|
||||||
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
|
|
||||||
(acquire_result == VK_SUBOPTIMAL_KHR))
|
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
GDK_DEBUG (VULKAN, "Recreating the swapchain");
|
|
||||||
|
|
||||||
if (gdk_vulkan_context_check_swapchain (context, &error))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
goto acquire_next_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_region_union (region, priv->regions[priv->draw_index]);
|
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||||
|
|
||||||
if (priv->current_depth == GDK_MEMORY_U8_SRGB)
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
|
||||||
else
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = priv->current_depth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -836,6 +816,11 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
|||||||
if (!priv->vulkan_ref)
|
if (!priv->vulkan_ref)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
priv->offscreen_formats[GDK_MEMORY_U8] = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||||
|
priv->offscreen_formats[GDK_MEMORY_U16] = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||||
|
priv->offscreen_formats[GDK_MEMORY_FLOAT16] = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||||
|
priv->offscreen_formats[GDK_MEMORY_FLOAT32] = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < G_N_ELEMENTS (priv->formats); i++)
|
for (i = 0; i < G_N_ELEMENTS (priv->formats); i++)
|
||||||
@@ -891,6 +876,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
|||||||
{
|
{
|
||||||
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
||||||
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||||
|
priv->offscreen_formats[GDK_MEMORY_U8] = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -902,22 +888,6 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
|
||||||
if (priv->formats[GDK_MEMORY_U8_SRGB].vk_format.format == VK_FORMAT_UNDEFINED)
|
|
||||||
{
|
|
||||||
priv->formats[GDK_MEMORY_U8_SRGB].vk_format = formats[i];
|
|
||||||
priv->formats[GDK_MEMORY_U8_SRGB].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
|
||||||
if (priv->formats[GDK_MEMORY_U8_SRGB].vk_format.format == VK_FORMAT_UNDEFINED)
|
|
||||||
{
|
|
||||||
priv->formats[GDK_MEMORY_U8_SRGB].vk_format = formats[i];
|
|
||||||
priv->formats[GDK_MEMORY_U8_SRGB].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_FORMAT_R16G16B16A16_UNORM:
|
case VK_FORMAT_R16G16B16A16_UNORM:
|
||||||
priv->formats[GDK_MEMORY_U16].vk_format = formats[i];
|
priv->formats[GDK_MEMORY_U16].vk_format = formats[i];
|
||||||
priv->formats[GDK_MEMORY_U16].gdk_format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
priv->formats[GDK_MEMORY_U16].gdk_format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||||
@@ -961,7 +931,6 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
|||||||
priv->formats[GDK_MEMORY_FLOAT16] = priv->formats[GDK_MEMORY_FLOAT32];
|
priv->formats[GDK_MEMORY_FLOAT16] = priv->formats[GDK_MEMORY_FLOAT32];
|
||||||
if (priv->formats[GDK_MEMORY_U16].vk_format.format == VK_FORMAT_UNDEFINED)
|
if (priv->formats[GDK_MEMORY_U16].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||||
priv->formats[GDK_MEMORY_U16] = priv->formats[GDK_MEMORY_FLOAT32];
|
priv->formats[GDK_MEMORY_U16] = priv->formats[GDK_MEMORY_FLOAT32];
|
||||||
priv->formats[GDK_MEMORY_NONE] = priv->formats[GDK_MEMORY_U8];
|
|
||||||
|
|
||||||
if (!gdk_vulkan_context_check_swapchain (context, error))
|
if (!gdk_vulkan_context_check_swapchain (context, error))
|
||||||
goto out_surface;
|
goto out_surface;
|
||||||
@@ -984,6 +953,15 @@ out_surface:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkMemoryFormat
|
||||||
|
gdk_vulkan_context_get_offscreen_format (GdkVulkanContext *context,
|
||||||
|
GdkMemoryDepth depth)
|
||||||
|
{
|
||||||
|
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||||
|
|
||||||
|
return priv->offscreen_formats[depth];
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_vulkan_context_initable_init (GInitableIface *iface)
|
gdk_vulkan_context_initable_init (GInitableIface *iface)
|
||||||
{
|
{
|
||||||
@@ -1305,18 +1283,9 @@ gdk_vulkan_context_get_image_format (GdkVulkanContext *context)
|
|||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), VK_FORMAT_UNDEFINED);
|
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), VK_FORMAT_UNDEFINED);
|
||||||
|
|
||||||
return priv->formats[priv->current_depth].vk_format.format;
|
return priv->formats[priv->current_format].vk_format.format;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkMemoryFormat
|
|
||||||
gdk_vulkan_context_get_memory_format (GdkVulkanContext *context)
|
|
||||||
{
|
|
||||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), GDK_MEMORY_DEFAULT);
|
|
||||||
|
|
||||||
return priv->formats[priv->current_depth].gdk_format;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* gdk_vulkan_context_get_n_images:
|
* gdk_vulkan_context_get_n_images:
|
||||||
* @context: a `GdkVulkanContext`
|
* @context: a `GdkVulkanContext`
|
||||||
@@ -1548,7 +1517,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
|||||||
|
|
||||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
||||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
|
|
||||||
|
|
||||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
|
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
|
||||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
||||||
@@ -1889,9 +1857,8 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
|||||||
{
|
{
|
||||||
g_free (key);
|
g_free (key);
|
||||||
vkDestroyShaderModule (display->vk_device,
|
vkDestroyShaderModule (display->vk_device,
|
||||||
*((VkShaderModule *)value),
|
value,
|
||||||
NULL);
|
NULL);
|
||||||
g_free (value);
|
|
||||||
}
|
}
|
||||||
g_hash_table_unref (display->vk_shader_modules);
|
g_hash_table_unref (display->vk_shader_modules);
|
||||||
|
|
||||||
@@ -2019,13 +1986,13 @@ VkShaderModule
|
|||||||
gdk_display_get_vk_shader_module (GdkDisplay *self,
|
gdk_display_get_vk_shader_module (GdkDisplay *self,
|
||||||
const char *resource_name)
|
const char *resource_name)
|
||||||
{
|
{
|
||||||
VkShaderModule *shader;
|
VkShaderModule shader;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
|
||||||
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
|
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
|
||||||
if (shader)
|
if (shader)
|
||||||
return *shader;
|
return shader;
|
||||||
|
|
||||||
bytes = g_resources_lookup_data (resource_name, 0, &error);
|
bytes = g_resources_lookup_data (resource_name, 0, &error);
|
||||||
if (bytes == NULL)
|
if (bytes == NULL)
|
||||||
@@ -2035,7 +2002,6 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
|
|||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
shader = g_new0 (VkShaderModule, 1);
|
|
||||||
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
|
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
|
||||||
&(VkShaderModuleCreateInfo) {
|
&(VkShaderModuleCreateInfo) {
|
||||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||||
@@ -2043,20 +2009,18 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
|
|||||||
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
|
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
|
||||||
},
|
},
|
||||||
NULL,
|
NULL,
|
||||||
shader) == VK_SUCCESS)
|
&shader) == VK_SUCCESS)
|
||||||
{
|
{
|
||||||
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
|
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_free (shader);
|
shader = VK_NULL_HANDLE;
|
||||||
|
|
||||||
return VK_NULL_HANDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
return *shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* GDK_RENDERING_VULKAN */
|
#else /* GDK_RENDERING_VULKAN */
|
||||||
|
|||||||
@@ -94,13 +94,15 @@ VkDevice gdk_vulkan_context_get_device (GdkVulk
|
|||||||
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
|
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
|
||||||
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
|
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
|
||||||
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
|
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
|
||||||
GdkMemoryFormat gdk_vulkan_context_get_memory_format (GdkVulkanContext *context);
|
|
||||||
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
|
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
|
||||||
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
|
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
|
||||||
guint id);
|
guint id);
|
||||||
uint32_t gdk_vulkan_context_get_draw_index (GdkVulkanContext *context);
|
uint32_t gdk_vulkan_context_get_draw_index (GdkVulkanContext *context);
|
||||||
VkSemaphore gdk_vulkan_context_get_draw_semaphore (GdkVulkanContext *context);
|
VkSemaphore gdk_vulkan_context_get_draw_semaphore (GdkVulkanContext *context);
|
||||||
|
|
||||||
|
GdkMemoryFormat gdk_vulkan_context_get_offscreen_format (GdkVulkanContext *context,
|
||||||
|
GdkMemoryDepth depth);
|
||||||
|
|
||||||
#else /* !GDK_RENDERING_VULKAN */
|
#else /* !GDK_RENDERING_VULKAN */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -197,11 +197,9 @@ clamp_region_to_surface (cairo_region_t *region,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
_gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
|
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
|
||||||
GdkMacosBuffer *buffer;
|
GdkMacosBuffer *buffer;
|
||||||
@@ -251,9 +249,6 @@ _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
cairo_region_destroy (copy);
|
cairo_region_destroy (copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ void _gdk_macos_display_set_drop (GdkMacosDisp
|
|||||||
GdkDrop *drop);
|
GdkDrop *drop);
|
||||||
void _gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
void _gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
||||||
GdkMacosSurface *surface,
|
GdkMacosSurface *surface,
|
||||||
GdkMonitor *monitor,
|
|
||||||
int *x,
|
int *x,
|
||||||
int *y);
|
int *y);
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "gdk/gdkeventsprivate.h"
|
#include "gdk/gdkeventsprivate.h"
|
||||||
|
|
||||||
|
#define GDK_MOD2_MASK (1 << 4)
|
||||||
#define GRIP_WIDTH 15
|
#define GRIP_WIDTH 15
|
||||||
#define GRIP_HEIGHT 15
|
#define GRIP_HEIGHT 15
|
||||||
#define GDK_LION_RESIZE 5
|
#define GDK_LION_RESIZE 5
|
||||||
@@ -174,7 +175,7 @@ get_keyboard_modifiers_from_ns_flags (NSUInteger nsflags)
|
|||||||
if (nsflags & NSEventModifierFlagOption)
|
if (nsflags & NSEventModifierFlagOption)
|
||||||
modifiers |= GDK_ALT_MASK;
|
modifiers |= GDK_ALT_MASK;
|
||||||
if (nsflags & NSEventModifierFlagCommand)
|
if (nsflags & NSEventModifierFlagCommand)
|
||||||
modifiers |= GDK_META_MASK;
|
modifiers |= GDK_MOD2_MASK;
|
||||||
|
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
@@ -313,6 +314,13 @@ get_group_from_ns_event (NSEvent *nsevent)
|
|||||||
return ([nsevent modifierFlags] & NSEventModifierFlagOption) ? 1 : 0;
|
return ([nsevent modifierFlags] & NSEventModifierFlagOption) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_virtual_modifiers (GdkModifierType *state)
|
||||||
|
{
|
||||||
|
if (*state & GDK_MOD2_MASK)
|
||||||
|
*state |= GDK_META_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
static GdkEvent *
|
static GdkEvent *
|
||||||
fill_key_event (GdkMacosDisplay *display,
|
fill_key_event (GdkMacosDisplay *display,
|
||||||
GdkMacosSurface *surface,
|
GdkMacosSurface *surface,
|
||||||
@@ -359,7 +367,7 @@ fill_key_event (GdkMacosDisplay *display,
|
|||||||
{
|
{
|
||||||
case GDK_KEY_Meta_R:
|
case GDK_KEY_Meta_R:
|
||||||
case GDK_KEY_Meta_L:
|
case GDK_KEY_Meta_L:
|
||||||
mask = GDK_META_MASK;
|
mask = GDK_MOD2_MASK;
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_Shift_R:
|
case GDK_KEY_Shift_R:
|
||||||
case GDK_KEY_Shift_L:
|
case GDK_KEY_Shift_L:
|
||||||
@@ -387,6 +395,7 @@ fill_key_event (GdkMacosDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
state |= _gdk_macos_display_get_current_mouse_modifiers (display);
|
state |= _gdk_macos_display_get_current_mouse_modifiers (display);
|
||||||
|
add_virtual_modifiers (&state);
|
||||||
|
|
||||||
translated.keyval = keyval;
|
translated.keyval = keyval;
|
||||||
translated.consumed = consumed;
|
translated.consumed = consumed;
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ has_surface_at_origin (const GList *surfaces,
|
|||||||
static void
|
static void
|
||||||
_gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
_gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||||
GdkMacosSurface *surface,
|
GdkMacosSurface *surface,
|
||||||
GdkMonitor *selected_monitor,
|
|
||||||
int *x,
|
int *x,
|
||||||
int *y)
|
int *y)
|
||||||
{
|
{
|
||||||
@@ -96,11 +95,7 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
|||||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (surface));
|
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (surface));
|
||||||
|
|
||||||
mouse = [NSEvent mouseLocation];
|
mouse = [NSEvent mouseLocation];
|
||||||
if (!selected_monitor)
|
monitor = _gdk_macos_display_get_monitor_at_display_coords (self, mouse.x, mouse.y);
|
||||||
monitor = _gdk_macos_display_get_monitor_at_display_coords (self, mouse.x, mouse.y);
|
|
||||||
else
|
|
||||||
monitor = selected_monitor;
|
|
||||||
|
|
||||||
gdk_macos_monitor_get_workarea (monitor, &workarea);
|
gdk_macos_monitor_get_workarea (monitor, &workarea);
|
||||||
|
|
||||||
/* First place at top-left of current monitor */
|
/* First place at top-left of current monitor */
|
||||||
@@ -109,7 +104,7 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
|||||||
surface_rect.x = workarea.x + ((workarea.width - surface_rect.width) / 2);
|
surface_rect.x = workarea.x + ((workarea.width - surface_rect.width) / 2);
|
||||||
surface_rect.y = workarea.y + ((workarea.height - surface_rect.height) / 2);
|
surface_rect.y = workarea.y + ((workarea.height - surface_rect.height) / 2);
|
||||||
|
|
||||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (selected_monitor ? selected_monitor : surface->best_monitor), &surface_rect);
|
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (surface->best_monitor), &surface_rect);
|
||||||
|
|
||||||
*x = surface_rect.x;
|
*x = surface_rect.x;
|
||||||
*y = surface_rect.y;
|
*y = surface_rect.y;
|
||||||
@@ -143,7 +138,6 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
|||||||
void
|
void
|
||||||
_gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
_gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
||||||
GdkMacosSurface *surface,
|
GdkMacosSurface *surface,
|
||||||
GdkMonitor *monitor,
|
|
||||||
int *x,
|
int *x,
|
||||||
int *y)
|
int *y)
|
||||||
{
|
{
|
||||||
@@ -157,5 +151,5 @@ _gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
|||||||
if (transient_for != NULL)
|
if (transient_for != NULL)
|
||||||
_gdk_macos_display_position_toplevel_with_parent (self, surface, GDK_MACOS_SURFACE (transient_for), x, y);
|
_gdk_macos_display_position_toplevel_with_parent (self, surface, GDK_MACOS_SURFACE (transient_for), x, y);
|
||||||
else
|
else
|
||||||
_gdk_macos_display_position_toplevel (self, surface, monitor, x, y);
|
_gdk_macos_display_position_toplevel (self, surface, x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ _gdk_macos_drag_surface_constructed (GObject *object)
|
|||||||
defer:NO
|
defer:NO
|
||||||
screen:screen];
|
screen:screen];
|
||||||
|
|
||||||
_gdk_macos_surface_set_native (self, window);
|
|
||||||
|
|
||||||
[window setOpaque:NO];
|
[window setOpaque:NO];
|
||||||
[window setBackgroundColor:[NSColor clearColor]];
|
[window setBackgroundColor:[NSColor clearColor]];
|
||||||
[window setDecorated:NO];
|
[window setDecorated:NO];
|
||||||
|
|
||||||
|
_gdk_macos_surface_set_native (self, window);
|
||||||
|
|
||||||
frame_clock = _gdk_frame_clock_idle_new ();
|
frame_clock = _gdk_frame_clock_idle_new ();
|
||||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||||
g_object_unref (frame_clock);
|
g_object_unref (frame_clock);
|
||||||
|
|||||||
@@ -478,11 +478,9 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
||||||
GdkMacosBuffer *buffer;
|
GdkMacosBuffer *buffer;
|
||||||
@@ -500,7 +498,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
|||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
gdk_macos_gl_context_allocate (self);
|
gdk_macos_gl_context_allocate (self);
|
||||||
|
|
||||||
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, depth, region, out_color_state, out_depth);
|
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, depth, region);
|
||||||
|
|
||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
|||||||
GdkRectangle bounds;
|
GdkRectangle bounds;
|
||||||
GdkRectangle final_rect;
|
GdkRectangle final_rect;
|
||||||
int x, y;
|
int x, y;
|
||||||
int shadow_left, shadow_right, shadow_top, shadow_bottom;
|
|
||||||
|
|
||||||
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
|
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
|
||||||
g_assert (layout != NULL);
|
g_assert (layout != NULL);
|
||||||
@@ -69,19 +68,10 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
|||||||
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
||||||
gdk_macos_monitor_get_workarea (monitor, &bounds);
|
gdk_macos_monitor_get_workarea (monitor, &bounds);
|
||||||
|
|
||||||
gdk_popup_layout_get_shadow_width (layout,
|
|
||||||
&shadow_left,
|
|
||||||
&shadow_right,
|
|
||||||
&shadow_top,
|
|
||||||
&shadow_bottom);
|
|
||||||
|
|
||||||
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
|
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
shadow_left,
|
0, 0, 0, 0, /* shadow-left/right/top/bottom */
|
||||||
shadow_right,
|
|
||||||
shadow_top,
|
|
||||||
shadow_bottom,
|
|
||||||
monitor,
|
monitor,
|
||||||
&bounds,
|
&bounds,
|
||||||
self->layout,
|
self->layout,
|
||||||
@@ -316,14 +306,14 @@ _gdk_macos_popup_surface_constructed (GObject *object)
|
|||||||
defer:NO
|
defer:NO
|
||||||
screen:screen];
|
screen:screen];
|
||||||
|
|
||||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
|
||||||
|
|
||||||
[window setOpaque:NO];
|
[window setOpaque:NO];
|
||||||
[window setBackgroundColor:[NSColor clearColor]];
|
[window setBackgroundColor:[NSColor clearColor]];
|
||||||
[window setDecorated:NO];
|
[window setDecorated:NO];
|
||||||
[window setExcludedFromWindowsMenu:YES];
|
[window setExcludedFromWindowsMenu:YES];
|
||||||
[window setLevel:NSPopUpMenuWindowLevel];
|
[window setLevel:NSPopUpMenuWindowLevel];
|
||||||
|
|
||||||
|
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||||
|
|
||||||
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
|
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
|
||||||
|
|
||||||
GDK_END_MACOS_ALLOC_POOL;
|
GDK_END_MACOS_ALLOC_POOL;
|
||||||
|
|||||||
@@ -261,30 +261,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
|||||||
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
|
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
|
||||||
{
|
{
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
_gdk_macos_toplevel_surface_fullscreen (self);
|
||||||
GdkMonitor *fullscreen_monitor =
|
|
||||||
gdk_toplevel_layout_get_fullscreen_monitor (layout);
|
|
||||||
|
|
||||||
if (fullscreen_monitor)
|
|
||||||
{
|
|
||||||
int x = 0, y = 0;
|
|
||||||
|
|
||||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (display),
|
|
||||||
GDK_MACOS_SURFACE (self),
|
|
||||||
fullscreen_monitor,
|
|
||||||
&x, &y);
|
|
||||||
|
|
||||||
GDK_DEBUG (MISC, "Moving toplevel \"%s\" to %d,%d",
|
|
||||||
GDK_MACOS_SURFACE (self)->title ?
|
|
||||||
GDK_MACOS_SURFACE (self)->title :
|
|
||||||
"untitled",
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (self), x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
_gdk_macos_toplevel_surface_fullscreen (self);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
_gdk_macos_toplevel_surface_unfullscreen (self);
|
_gdk_macos_toplevel_surface_unfullscreen (self);
|
||||||
}
|
}
|
||||||
@@ -297,7 +274,6 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
|||||||
|
|
||||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (display),
|
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (display),
|
||||||
GDK_MACOS_SURFACE (self),
|
GDK_MACOS_SURFACE (self),
|
||||||
gdk_toplevel_layout_get_fullscreen_monitor (layout),
|
|
||||||
&x, &y);
|
&x, &y);
|
||||||
|
|
||||||
GDK_DEBUG (MISC, "Placing new toplevel \"%s\" at %d,%d",
|
GDK_DEBUG (MISC, "Placing new toplevel \"%s\" at %d,%d",
|
||||||
@@ -615,11 +591,11 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
|
|||||||
defer:NO
|
defer:NO
|
||||||
screen:screen];
|
screen:screen];
|
||||||
|
|
||||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
|
||||||
|
|
||||||
/* Allow NSWindow to go fullscreen */
|
/* Allow NSWindow to go fullscreen */
|
||||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
|
|
||||||
|
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||||
|
|
||||||
frame_clock = _gdk_frame_clock_idle_new ();
|
frame_clock = _gdk_frame_clock_idle_new ();
|
||||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||||
g_object_unref (frame_clock);
|
g_object_unref (frame_clock);
|
||||||
@@ -681,7 +657,6 @@ _gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self)
|
|||||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (surface->display),
|
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (surface->display),
|
||||||
GDK_MACOS_SURFACE (surface),
|
GDK_MACOS_SURFACE (surface),
|
||||||
NULL,
|
|
||||||
&x, &y);
|
&x, &y);
|
||||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (surface), x, y);
|
_gdk_macos_surface_move (GDK_MACOS_SURFACE (surface), x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ gdk_public_sources = files([
|
|||||||
'gdkcairo.c',
|
'gdkcairo.c',
|
||||||
'gdkcairocontext.c',
|
'gdkcairocontext.c',
|
||||||
'gdkclipboard.c',
|
'gdkclipboard.c',
|
||||||
'gdkcolorstate.c',
|
|
||||||
'gdkcontentdeserializer.c',
|
'gdkcontentdeserializer.c',
|
||||||
'gdkcontentformats.c',
|
'gdkcontentformats.c',
|
||||||
'gdkcontentprovider.c',
|
'gdkcontentprovider.c',
|
||||||
@@ -16,7 +15,6 @@ gdk_public_sources = files([
|
|||||||
'gdkdevice.c',
|
'gdkdevice.c',
|
||||||
'gdkdevicepad.c',
|
'gdkdevicepad.c',
|
||||||
'gdkdevicetool.c',
|
'gdkdevicetool.c',
|
||||||
'gdkdihedral.c',
|
|
||||||
'gdkdisplay.c',
|
'gdkdisplay.c',
|
||||||
'gdkdisplaymanager.c',
|
'gdkdisplaymanager.c',
|
||||||
'gdkdmabuf.c',
|
'gdkdmabuf.c',
|
||||||
@@ -77,7 +75,6 @@ gdk_public_headers = files([
|
|||||||
'gdkcairo.h',
|
'gdkcairo.h',
|
||||||
'gdkcairocontext.h',
|
'gdkcairocontext.h',
|
||||||
'gdkclipboard.h',
|
'gdkclipboard.h',
|
||||||
'gdkcolorstate.h',
|
|
||||||
'gdkcontentdeserializer.h',
|
'gdkcontentdeserializer.h',
|
||||||
'gdkcontentformats.h',
|
'gdkcontentformats.h',
|
||||||
'gdkcontentprovider.h',
|
'gdkcontentprovider.h',
|
||||||
@@ -131,8 +128,8 @@ install_headers(gdk_deprecated_headers, subdir: 'gtk-4.0/gdk/deprecated')
|
|||||||
gdk_sources = gdk_public_sources + gdk_deprecated_sources
|
gdk_sources = gdk_public_sources + gdk_deprecated_sources
|
||||||
|
|
||||||
gdk_private_h_sources = files([
|
gdk_private_h_sources = files([
|
||||||
'gdkdevicetoolprivate.h',
|
|
||||||
'gdkeventsprivate.h',
|
'gdkeventsprivate.h',
|
||||||
|
'gdkdevicetoolprivate.h',
|
||||||
'gdkhslaprivate.h',
|
'gdkhslaprivate.h',
|
||||||
'gdkmonitorprivate.h',
|
'gdkmonitorprivate.h',
|
||||||
'gdkseatdefaultprivate.h',
|
'gdkseatdefaultprivate.h',
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_MEMFD_CREATE
|
#ifdef HAVE_MEMFD_CREATE
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@@ -70,10 +69,13 @@ create_tmpfile_cloexec(char *tmpname)
|
|||||||
|
|
||||||
#ifdef HAVE_MKOSTEMP
|
#ifdef HAVE_MKOSTEMP
|
||||||
fd = mkostemp(tmpname, O_CLOEXEC);
|
fd = mkostemp(tmpname, O_CLOEXEC);
|
||||||
|
if (fd >= 0)
|
||||||
|
unlink(tmpname);
|
||||||
#else
|
#else
|
||||||
fd = mkstemp(tmpname);
|
fd = mkstemp(tmpname);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
fd = set_cloexec_or_close(fd);
|
fd = set_cloexec_or_close(fd);
|
||||||
|
unlink(tmpname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -113,7 +115,7 @@ os_create_anonymous_file(off_t size)
|
|||||||
{
|
{
|
||||||
static const char template[] = "/wayland-cursor-shared-XXXXXX";
|
static const char template[] = "/wayland-cursor-shared-XXXXXX";
|
||||||
const char *path;
|
const char *path;
|
||||||
char *name = NULL;
|
char *name;
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -132,12 +134,11 @@ os_create_anonymous_file(off_t size)
|
|||||||
{
|
{
|
||||||
path = getenv("XDG_RUNTIME_DIR");
|
path = getenv("XDG_RUNTIME_DIR");
|
||||||
if (!path) {
|
if (!path) {
|
||||||
g_warning ("os_create_anonymous_file(): XDG_RUNTIME_DIR is not set");
|
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = alloca(strlen(path) + sizeof(template));
|
name = malloc(strlen(path) + sizeof(template));
|
||||||
if (!name)
|
if (!name)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -146,29 +147,26 @@ os_create_anonymous_file(off_t size)
|
|||||||
|
|
||||||
fd = create_tmpfile_cloexec(name);
|
fd = create_tmpfile_cloexec(name);
|
||||||
|
|
||||||
if (fd < 0) {
|
free(name);
|
||||||
g_warning ("os_create_anonymous_file(): create_tmpfile_cloexec(\"%s\") failed", name);
|
|
||||||
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_POSIX_FALLOCATE
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
ret = posix_fallocate(fd, 0, size);
|
ret = posix_fallocate(fd, 0, size);
|
||||||
if (ret == 0) {
|
if (ret != 0) {
|
||||||
goto allocated;
|
close(fd);
|
||||||
}
|
errno = ret;
|
||||||
#endif
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
ret = ftruncate(fd, size);
|
ret = ftruncate(fd, size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
g_warning ("os_create_anonymous_file(): ftruncate() failed");
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
allocated:
|
|
||||||
if (fd >= 0 && name)
|
|
||||||
unlink (name);
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,24 +54,18 @@ shm_pool_create(struct wl_shm *shm, int size)
|
|||||||
struct shm_pool *pool;
|
struct shm_pool *pool;
|
||||||
|
|
||||||
pool = malloc(sizeof *pool);
|
pool = malloc(sizeof *pool);
|
||||||
if (!pool) {
|
if (!pool)
|
||||||
g_warning ("malloc() failed");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
pool->fd = os_create_anonymous_file (size);
|
pool->fd = os_create_anonymous_file (size);
|
||||||
if (pool->fd < 0) {
|
if (pool->fd < 0)
|
||||||
g_warning ("os_create_anonymous_file() failed");
|
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
|
||||||
|
|
||||||
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
pool->fd, 0);
|
pool->fd, 0);
|
||||||
|
|
||||||
if (pool->data == MAP_FAILED) {
|
if (pool->data == MAP_FAILED)
|
||||||
g_warning ("mmap() failed: %s", strerror (errno));
|
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
|
||||||
|
|
||||||
pool->pool = wl_shm_create_pool(shm, pool->fd, size);
|
pool->pool = wl_shm_create_pool(shm, pool->fd, size);
|
||||||
pool->size = size;
|
pool->size = size;
|
||||||
@@ -355,10 +349,8 @@ wl_cursor_theme_create(const char *path, int size, struct wl_shm *shm)
|
|||||||
struct wl_cursor_theme *theme;
|
struct wl_cursor_theme *theme;
|
||||||
|
|
||||||
theme = malloc(sizeof *theme);
|
theme = malloc(sizeof *theme);
|
||||||
if (!theme) {
|
if (!theme)
|
||||||
g_warning ("malloc() failed");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
theme->path = strdup (path);
|
theme->path = strdup (path);
|
||||||
theme->size = size;
|
theme->size = size;
|
||||||
@@ -367,7 +359,6 @@ wl_cursor_theme_create(const char *path, int size, struct wl_shm *shm)
|
|||||||
|
|
||||||
theme->pool = shm_pool_create(shm, size * size * 4);
|
theme->pool = shm_pool_create(shm, size * size * 4);
|
||||||
if (!theme->pool) {
|
if (!theme->pool) {
|
||||||
g_warning ("shm_pool_create() failed");
|
|
||||||
free (theme->path);
|
free (theme->path);
|
||||||
free (theme);
|
free (theme);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -144,11 +144,9 @@ gdk_wayland_cairo_context_create_surface (GdkWaylandCairoContext *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
|
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
|
||||||
const cairo_region_t *surface_region;
|
const cairo_region_t *surface_region;
|
||||||
@@ -175,9 +173,6 @@ gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
gdk_cairo_region (cr, region);
|
gdk_cairo_region (cr, region);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -165,29 +165,25 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
double *scale)
|
double *scale)
|
||||||
{
|
{
|
||||||
GdkTexture *texture;
|
GdkTexture *texture;
|
||||||
|
int desired_scale_factor;
|
||||||
|
|
||||||
|
desired_scale_factor = (int) ceil (desired_scale);
|
||||||
|
|
||||||
if (gdk_cursor_get_name (cursor))
|
if (gdk_cursor_get_name (cursor))
|
||||||
{
|
{
|
||||||
struct wl_cursor *c;
|
struct wl_cursor *c;
|
||||||
int scale_factor;
|
|
||||||
|
|
||||||
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
|
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
|
||||||
{
|
goto none;
|
||||||
*hotspot_x = *hotspot_y = 0;
|
|
||||||
*width = *height = 0;
|
|
||||||
*scale = 1;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
scale_factor = (int) ceil (desired_scale);
|
|
||||||
|
|
||||||
c = gdk_wayland_cursor_load_for_name (display,
|
c = gdk_wayland_cursor_load_for_name (display,
|
||||||
display->cursor_theme,
|
_gdk_wayland_display_get_cursor_theme (display),
|
||||||
scale_factor,
|
desired_scale_factor,
|
||||||
gdk_cursor_get_name (cursor));
|
gdk_cursor_get_name (cursor));
|
||||||
if (c && c->image_count > 0)
|
if (c && c->image_count > 0)
|
||||||
{
|
{
|
||||||
struct wl_cursor_image *image;
|
struct wl_cursor_image *image;
|
||||||
|
int cursor_scale;
|
||||||
|
|
||||||
if (image_index >= c->image_count)
|
if (image_index >= c->image_count)
|
||||||
{
|
{
|
||||||
@@ -199,23 +195,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
|
|
||||||
image = c->images[image_index];
|
image = c->images[image_index];
|
||||||
|
|
||||||
*width = display->cursor_theme_size;
|
cursor_scale = desired_scale_factor;
|
||||||
*height = display->cursor_theme_size;
|
if ((image->width % cursor_scale != 0) ||
|
||||||
*scale = image->width / (double) *width;
|
(image->height % cursor_scale != 0))
|
||||||
*hotspot_x = image->hotspot_x / scale_factor;
|
|
||||||
*hotspot_y = image->hotspot_y / scale_factor;
|
|
||||||
|
|
||||||
if (*scale != scale_factor && !use_viewporter)
|
|
||||||
{
|
{
|
||||||
g_warning (G_STRLOC " cursor image size (%d) not an integer "
|
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
|
||||||
"multiple of theme size (%d)", image->width, *width);
|
"multiple of scale (%d)", image->width, image->height,
|
||||||
*width = image->width;
|
cursor_scale);
|
||||||
*height = image->height;
|
cursor_scale = 1;
|
||||||
*hotspot_x = image->hotspot_x;
|
|
||||||
*hotspot_y = image->hotspot_y;
|
|
||||||
*scale = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*hotspot_x = image->hotspot_x / cursor_scale;
|
||||||
|
*hotspot_y = image->hotspot_y / cursor_scale;
|
||||||
|
|
||||||
|
*width = image->width / cursor_scale;
|
||||||
|
*height = image->height / cursor_scale;
|
||||||
|
*scale = cursor_scale;
|
||||||
|
|
||||||
return wl_cursor_image_get_buffer (image);
|
return wl_cursor_image_get_buffer (image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,7 +257,7 @@ from_texture:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!use_viewporter)
|
if (!use_viewporter)
|
||||||
*scale = ceil (desired_scale);
|
*scale = desired_scale_factor;
|
||||||
else
|
else
|
||||||
*scale = desired_scale;
|
*scale = desired_scale;
|
||||||
|
|
||||||
@@ -298,23 +294,28 @@ from_texture:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gdk_cursor_get_fallback (cursor))
|
if (gdk_cursor_get_fallback (cursor))
|
||||||
{
|
return _gdk_wayland_cursor_get_buffer (display,
|
||||||
return _gdk_wayland_cursor_get_buffer (display,
|
gdk_cursor_get_fallback (cursor),
|
||||||
gdk_cursor_get_fallback (cursor),
|
desired_scale,
|
||||||
desired_scale,
|
use_viewporter,
|
||||||
use_viewporter,
|
image_index,
|
||||||
image_index,
|
hotspot_x, hotspot_y,
|
||||||
hotspot_x, hotspot_y,
|
width, height,
|
||||||
width, height,
|
scale);
|
||||||
scale);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
|
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
|
||||||
goto from_texture;
|
goto from_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert_not_reached ();
|
none:
|
||||||
|
*hotspot_x = 0;
|
||||||
|
*hotspot_y = 0;
|
||||||
|
*width = 0;
|
||||||
|
*height = 0;
|
||||||
|
*scale = 1;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#include "gdkvulkancontext-wayland.h"
|
#include "gdkvulkancontext-wayland.h"
|
||||||
#include "gdkwaylandmonitor.h"
|
#include "gdkwaylandmonitor.h"
|
||||||
#include "gdkprofilerprivate.h"
|
#include "gdkprofilerprivate.h"
|
||||||
#include "gdkdihedralprivate.h"
|
|
||||||
#include "gdktoplevel-wayland-private.h"
|
#include "gdktoplevel-wayland-private.h"
|
||||||
#include <wayland/pointer-gestures-unstable-v1-client-protocol.h>
|
#include <wayland/pointer-gestures-unstable-v1-client-protocol.h>
|
||||||
#include "tablet-unstable-v2-client-protocol.h"
|
#include "tablet-unstable-v2-client-protocol.h"
|
||||||
@@ -98,7 +97,6 @@
|
|||||||
#define OUTPUT_VERSION_WITH_DONE 2
|
#define OUTPUT_VERSION_WITH_DONE 2
|
||||||
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
|
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
|
||||||
#define OUTPUT_VERSION 3
|
#define OUTPUT_VERSION 3
|
||||||
#define XDG_WM_DIALOG_VERSION 1
|
|
||||||
|
|
||||||
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
|
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
|
||||||
#define XDG_WM_BASE_VERSION 6
|
#define XDG_WM_BASE_VERSION 6
|
||||||
@@ -384,13 +382,6 @@ gdk_registry_handle_global (void *data,
|
|||||||
{
|
{
|
||||||
display_wayland->zxdg_shell_v6_id = id;
|
display_wayland->zxdg_shell_v6_id = id;
|
||||||
}
|
}
|
||||||
else if (strcmp (interface, "xdg_wm_dialog_v1") == 0)
|
|
||||||
{
|
|
||||||
display_wayland->xdg_wm_dialog =
|
|
||||||
wl_registry_bind (display_wayland->wl_registry, id,
|
|
||||||
&xdg_wm_dialog_v1_interface,
|
|
||||||
MIN (version, XDG_WM_DIALOG_VERSION));
|
|
||||||
}
|
|
||||||
else if (strcmp (interface, "gtk_shell1") == 0)
|
else if (strcmp (interface, "gtk_shell1") == 0)
|
||||||
{
|
{
|
||||||
display_wayland->gtk_shell =
|
display_wayland->gtk_shell =
|
||||||
@@ -2308,6 +2299,30 @@ subpixel_to_string (int layout)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
transform_to_string (int transform)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct { int transform; const char *name; } transforms[] = {
|
||||||
|
{ WL_OUTPUT_TRANSFORM_NORMAL, "normal" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_90, "90" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_180, "180" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_270, "270" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_FLIPPED, "flipped" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_FLIPPED_90, "flipped 90" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_FLIPPED_180, "flipped 180" },
|
||||||
|
{ WL_OUTPUT_TRANSFORM_FLIPPED_270, "flipped 270" },
|
||||||
|
{ 0xffffffff, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; transforms[i].name; i++)
|
||||||
|
{
|
||||||
|
if (transforms[i].transform == transform)
|
||||||
|
return transforms[i].name;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_scale (GdkDisplay *display)
|
update_scale (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
@@ -2538,7 +2553,7 @@ output_handle_geometry (void *data,
|
|||||||
physical_width, physical_height,
|
physical_width, physical_height,
|
||||||
subpixel_to_string (subpixel),
|
subpixel_to_string (subpixel),
|
||||||
make, model,
|
make, model,
|
||||||
gdk_dihedral_get_name ((GdkDihedral) transform));
|
transform_to_string (transform));
|
||||||
|
|
||||||
monitor->output_geometry.x = x;
|
monitor->output_geometry.x = x;
|
||||||
monitor->output_geometry.y = y;
|
monitor->output_geometry.y = y;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include <gdk/wayland/viewporter-client-protocol.h>
|
#include <gdk/wayland/viewporter-client-protocol.h>
|
||||||
#include <gdk/wayland/presentation-time-client-protocol.h>
|
#include <gdk/wayland/presentation-time-client-protocol.h>
|
||||||
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
|
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
|
||||||
#include <gdk/wayland/xdg-dialog-v1-client-protocol.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gdk/gdkkeys.h>
|
#include <gdk/gdkkeys.h>
|
||||||
@@ -103,7 +102,6 @@ struct _GdkWaylandDisplay
|
|||||||
DmabufFormatsInfo *dmabuf_formats_info;
|
DmabufFormatsInfo *dmabuf_formats_info;
|
||||||
struct xdg_wm_base *xdg_wm_base;
|
struct xdg_wm_base *xdg_wm_base;
|
||||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||||
struct xdg_wm_dialog_v1 *xdg_wm_dialog;
|
|
||||||
struct gtk_shell1 *gtk_shell;
|
struct gtk_shell1 *gtk_shell;
|
||||||
struct wl_data_device_manager *data_device_manager;
|
struct wl_data_device_manager *data_device_manager;
|
||||||
struct wl_subcompositor *subcompositor;
|
struct wl_subcompositor *subcompositor;
|
||||||
|
|||||||
@@ -47,15 +47,13 @@
|
|||||||
G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
|
G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
|
gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
|
||||||
GdkMemoryDepth depth,
|
GdkMemoryDepth depth,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region)
|
||||||
GdkColorState **out_color_state,
|
|
||||||
GdkMemoryDepth *out_depth)
|
|
||||||
{
|
{
|
||||||
gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context));
|
gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context));
|
||||||
|
|
||||||
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, depth, region, out_color_state, out_depth);
|
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, depth, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -3866,25 +3866,9 @@ pointer_surface_leave (void *data,
|
|||||||
pointer_surface_update_scale (device);
|
pointer_surface_update_scale (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
pointer_surface_preferred_buffer_scale (void *data,
|
|
||||||
struct wl_surface *wl_surface,
|
|
||||||
int32_t factor)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pointer_surface_preferred_buffer_transform (void *data,
|
|
||||||
struct wl_surface *wl_surface,
|
|
||||||
uint32_t transform)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct wl_surface_listener pointer_surface_listener = {
|
static const struct wl_surface_listener pointer_surface_listener = {
|
||||||
pointer_surface_enter,
|
pointer_surface_enter,
|
||||||
pointer_surface_leave,
|
pointer_surface_leave
|
||||||
pointer_surface_preferred_buffer_scale,
|
|
||||||
pointer_surface_preferred_buffer_transform,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
#include "gdksurface-wayland-private.h"
|
#include "gdksurface-wayland-private.h"
|
||||||
#include "gdksubsurfaceprivate.h"
|
#include "gdksubsurfaceprivate.h"
|
||||||
#include "gdkdebugprivate.h"
|
#include "gdkdebugprivate.h"
|
||||||
#include "gdkglcontextprivate.h"
|
|
||||||
#include "gdkgltextureprivate.h"
|
|
||||||
#include "gsk/gskrectprivate.h"
|
#include "gsk/gskrectprivate.h"
|
||||||
|
|
||||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||||
@@ -145,19 +143,18 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct wl_buffer *
|
static struct wl_buffer *
|
||||||
get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
||||||
const GdkDmabuf *dmabuf,
|
GdkTexture *texture)
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
const struct wl_buffer_listener *listener,
|
|
||||||
void * data)
|
|
||||||
{
|
{
|
||||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
||||||
|
const GdkDmabuf *dmabuf;
|
||||||
struct zwp_linux_buffer_params_v1 *params;
|
struct zwp_linux_buffer_params_v1 *params;
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
CreateBufferData cd = { NULL, FALSE };
|
CreateBufferData cd = { NULL, FALSE };
|
||||||
struct wl_event_queue *event_queue;
|
struct wl_event_queue *event_queue;
|
||||||
|
|
||||||
|
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
|
||||||
|
|
||||||
params = zwp_linux_dmabuf_v1_create_params (display->linux_dmabuf);
|
params = zwp_linux_dmabuf_v1_create_params (display->linux_dmabuf);
|
||||||
|
|
||||||
for (gsize i = 0; i < dmabuf->n_planes; i++)
|
for (gsize i = 0; i < dmabuf->n_planes; i++)
|
||||||
@@ -176,8 +173,8 @@ get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
|||||||
zwp_linux_buffer_params_v1_add_listener (params, ¶ms_listener, &cd);
|
zwp_linux_buffer_params_v1_add_listener (params, ¶ms_listener, &cd);
|
||||||
|
|
||||||
zwp_linux_buffer_params_v1_create (params,
|
zwp_linux_buffer_params_v1_create (params,
|
||||||
width,
|
gdk_texture_get_width (texture),
|
||||||
height,
|
gdk_texture_get_height (texture),
|
||||||
dmabuf->fourcc,
|
dmabuf->fourcc,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
@@ -192,82 +189,12 @@ get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
|||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
wl_proxy_set_queue ((struct wl_proxy *) buffer, NULL);
|
wl_proxy_set_queue ((struct wl_proxy *) buffer, NULL);
|
||||||
wl_buffer_add_listener (buffer, listener, data);
|
wl_buffer_add_listener (buffer, &dmabuf_buffer_listener, g_object_ref (texture));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
listener->release (data, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wl_buffer *
|
|
||||||
get_dmabuf_texture_wl_buffer (GdkWaylandSubsurface *self,
|
|
||||||
GdkTexture *texture)
|
|
||||||
{
|
|
||||||
return get_dmabuf_wl_buffer (self,
|
|
||||||
gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture)),
|
|
||||||
gdk_texture_get_width (texture),
|
|
||||||
gdk_texture_get_height (texture),
|
|
||||||
&dmabuf_buffer_listener,
|
|
||||||
g_object_ref (texture));
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
GdkTexture *texture;
|
|
||||||
GdkDmabuf dmabuf;
|
|
||||||
} GLBufferData;
|
|
||||||
|
|
||||||
static void
|
|
||||||
gl_buffer_release (void *data,
|
|
||||||
struct wl_buffer *buffer)
|
|
||||||
{
|
|
||||||
GLBufferData *gldata = data;
|
|
||||||
|
|
||||||
g_object_unref (gldata->texture);
|
|
||||||
gdk_dmabuf_close_fds (&gldata->dmabuf);
|
|
||||||
g_free (gldata);
|
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
wl_buffer_destroy (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct wl_buffer_listener gl_buffer_listener = {
|
|
||||||
gl_buffer_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct wl_buffer *
|
|
||||||
get_gl_texture_wl_buffer (GdkWaylandSubsurface *self,
|
|
||||||
GdkTexture *texture)
|
|
||||||
{
|
|
||||||
GdkDisplay *display = gdk_surface_get_display (GDK_SUBSURFACE (self)->parent);
|
|
||||||
GdkGLTexture *gltexture = GDK_GL_TEXTURE (texture);
|
|
||||||
GdkGLContext *glcontext;
|
|
||||||
GLBufferData gldata;
|
|
||||||
|
|
||||||
glcontext = gdk_display_get_gl_context (display);
|
|
||||||
if (!gdk_gl_context_is_shared (glcontext, gdk_gl_texture_get_context (gltexture)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Can we avoid this when a right context is current already? */
|
|
||||||
gdk_gl_context_make_current (glcontext);
|
|
||||||
|
|
||||||
if (!gdk_gl_context_export_dmabuf (glcontext,
|
|
||||||
gdk_gl_texture_get_id (gltexture),
|
|
||||||
&gldata.dmabuf))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
gldata.texture = g_object_ref (texture);
|
|
||||||
|
|
||||||
return get_dmabuf_wl_buffer (self,
|
|
||||||
&gldata.dmabuf,
|
|
||||||
gdk_texture_get_width (texture),
|
|
||||||
gdk_texture_get_height (texture),
|
|
||||||
&gl_buffer_listener,
|
|
||||||
g_memdup (&gldata, sizeof (gldata)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct wl_buffer *
|
static struct wl_buffer *
|
||||||
get_wl_buffer (GdkWaylandSubsurface *self,
|
get_wl_buffer (GdkWaylandSubsurface *self,
|
||||||
GdkTexture *texture)
|
GdkTexture *texture)
|
||||||
@@ -276,9 +203,7 @@ get_wl_buffer (GdkWaylandSubsurface *self,
|
|||||||
struct wl_buffer *buffer = NULL;
|
struct wl_buffer *buffer = NULL;
|
||||||
|
|
||||||
if (GDK_IS_DMABUF_TEXTURE (texture))
|
if (GDK_IS_DMABUF_TEXTURE (texture))
|
||||||
buffer = get_dmabuf_texture_wl_buffer (self, texture);
|
buffer = get_dmabuf_wl_buffer (self, texture);
|
||||||
else if (GDK_IS_GL_TEXTURE (texture))
|
|
||||||
buffer = get_gl_texture_wl_buffer (self, texture);
|
|
||||||
|
|
||||||
if (GDK_DISPLAY_DEBUG_CHECK (display, FORCE_OFFLOAD))
|
if (GDK_DISPLAY_DEBUG_CHECK (display, FORCE_OFFLOAD))
|
||||||
{
|
{
|
||||||
@@ -317,26 +242,17 @@ get_sp_buffer (GdkWaylandSubsurface *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline enum wl_output_transform
|
static inline enum wl_output_transform
|
||||||
gdk_texture_transform_to_wl (GdkDihedral transform)
|
gdk_texture_transform_to_wl (GdkTextureTransform transform)
|
||||||
{
|
{
|
||||||
return (enum wl_output_transform) transform;
|
return (enum wl_output_transform) transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GdkDihedral
|
static inline GdkTextureTransform
|
||||||
wl_output_transform_to_gdk (enum wl_output_transform transform)
|
wl_output_transform_to_gdk (enum wl_output_transform transform)
|
||||||
{
|
{
|
||||||
return (GdkDihedral) transform;
|
return (GdkTextureTransform) transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_NORMAL == (int) GDK_DIHEDRAL_NORMAL);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_90 == (int) GDK_DIHEDRAL_90);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_180 == (int) GDK_DIHEDRAL_180);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_270 == (int) GDK_DIHEDRAL_270);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_FLIPPED == (int) GDK_DIHEDRAL_FLIPPED);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_FLIPPED_90 == (int) GDK_DIHEDRAL_FLIPPED_90);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_FLIPPED_180 == (int) GDK_DIHEDRAL_FLIPPED_180);
|
|
||||||
G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_FLIPPED_270 == (int) GDK_DIHEDRAL_FLIPPED_270);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_bg_surface (GdkWaylandSubsurface *self)
|
ensure_bg_surface (GdkWaylandSubsurface *self)
|
||||||
{
|
{
|
||||||
@@ -388,7 +304,7 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
GdkTexture *texture,
|
GdkTexture *texture,
|
||||||
const graphene_rect_t *source,
|
const graphene_rect_t *source,
|
||||||
const graphene_rect_t *dest,
|
const graphene_rect_t *dest,
|
||||||
GdkDihedral transform,
|
GdkTextureTransform transform,
|
||||||
const graphene_rect_t *background,
|
const graphene_rect_t *background,
|
||||||
gboolean above,
|
gboolean above,
|
||||||
GdkSubsurface *sibling)
|
GdkSubsurface *sibling)
|
||||||
@@ -526,6 +442,16 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
device_rect.size.width, device_rect.size.height,
|
device_rect.size.width, device_rect.size.height,
|
||||||
scale);
|
scale);
|
||||||
}
|
}
|
||||||
|
else if (!GDK_IS_DMABUF_TEXTURE (texture) &&
|
||||||
|
!GDK_DISPLAY_DEBUG_CHECK (gdk_surface_get_display (sub->parent), FORCE_OFFLOAD))
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
|
"[%p] 🗙 %s (%dx%d) is not a GdkDmabufTexture",
|
||||||
|
self,
|
||||||
|
G_OBJECT_TYPE_NAME (texture),
|
||||||
|
gdk_texture_get_width (texture),
|
||||||
|
gdk_texture_get_height (texture));
|
||||||
|
}
|
||||||
else if (!will_be_above &&
|
else if (!will_be_above &&
|
||||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE &&
|
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE &&
|
||||||
!has_background)
|
!has_background)
|
||||||
@@ -568,28 +494,22 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"[%p] %s Attaching %s (%dx%d) at %d %d %d %d%s%s%s",
|
"[%p] %s Attaching texture (%dx%d) at %d %d %d %d",
|
||||||
self,
|
self,
|
||||||
G_OBJECT_TYPE_NAME (texture),
|
|
||||||
will_be_above
|
will_be_above
|
||||||
? (has_background ? "▲" : "△")
|
? (has_background ? "▲" : "△")
|
||||||
: (has_background ? "▼" : "▽"),
|
: (has_background ? "▼" : "▽"),
|
||||||
gdk_texture_get_width (texture),
|
gdk_texture_get_width (texture),
|
||||||
gdk_texture_get_height (texture),
|
gdk_texture_get_height (texture),
|
||||||
self->dest.x, self->dest.y,
|
self->dest.x, self->dest.y,
|
||||||
self->dest.width, self->dest.height,
|
self->dest.width, self->dest.height);
|
||||||
transform != GDK_DIHEDRAL_NORMAL ? " (" : "",
|
|
||||||
transform != GDK_DIHEDRAL_NORMAL ? gdk_dihedral_get_name (transform) : "",
|
|
||||||
transform != GDK_DIHEDRAL_NORMAL ? " )" : ""
|
|
||||||
);
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"[%p] 🗙 Failed to create wl_buffer for %s",
|
"[%p] 🗙 Failed to create wl_buffer",
|
||||||
self,
|
self);
|
||||||
G_OBJECT_TYPE_NAME (texture));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -795,7 +715,7 @@ gdk_wayland_subsurface_get_source_rect (GdkSubsurface *sub,
|
|||||||
rect->size.height = self->source.size.height;
|
rect->size.height = self->source.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkDihedral
|
static GdkTextureTransform
|
||||||
gdk_wayland_subsurface_get_transform (GdkSubsurface *sub)
|
gdk_wayland_subsurface_get_transform (GdkSubsurface *sub)
|
||||||
{
|
{
|
||||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||||
|
|||||||
@@ -893,10 +893,13 @@ surface_preferred_buffer_transform (void *data,
|
|||||||
uint32_t transform)
|
uint32_t transform)
|
||||||
{
|
{
|
||||||
GdkSurface *surface = GDK_SURFACE (data);
|
GdkSurface *surface = GDK_SURFACE (data);
|
||||||
|
const char *transform_name[] = {
|
||||||
|
"normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270"
|
||||||
|
};
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||||
"preferred buffer transform, surface %p transform %s",
|
"preferred buffer transform, surface %p transform %s",
|
||||||
surface, gdk_dihedral_get_name ((GdkDihedral) transform));
|
surface, transform_name[transform]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_surface_listener surface_listener = {
|
static const struct wl_surface_listener surface_listener = {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user