Compare commits

..

22 Commits

Author SHA1 Message Date
Matthias Clasen
e5d0f32d8c css: Improve error reporting for variables
Emit errors for all the variables that were being expanded
if an error occurs while parsing a property value at compute time.

Include the variables that are being expanded in the error message.
2024-05-09 23:13:53 -04:00
Matthias Clasen
e825fd901f css parser: Keep variables for tokenizers
Add a function that gets the names of the variables that the
parser is currently in the process of expanding. This will
be used for error reporting.
2024-05-09 23:13:53 -04:00
Matthias Clasen
e3543f37d3 css parser: Inline the tokenizer array
This is in preparation of associating more data with the token streams.
2024-05-09 23:13:53 -04:00
Matthias Clasen
e9bf0322ac css provider: Set bytes on sections
Pass the bytes we're parsing to the sections, and keep a pointer
to them around, so we can compare them in the has_section
implementation.

This commit also corrects some of the location information that
we add into the section for variables to be more accurate.
2024-05-09 23:13:53 -04:00
Matthias Clasen
6d5cb0a083 css parser: Add gtk_css_parser_get_bytes
Gets the bytes that the parser is operating on.
2024-05-09 23:13:53 -04:00
Matthias Clasen
8b5aab459a css provider: Set sections on all variable values
We were doing it in one case, but forgetting it in another.
These sections are necessary to report meaningful error locations
when parsing property values at compute time.
2024-05-09 23:13:53 -04:00
Matthias Clasen
8da3cc10fd style cascade: Propagate errors
When we compute values, the provider we use ends up being the
style cascade. If we hit a parser error when parsing variable-bearing
property values at compute time, we emit the error on that provider.

By making the cascade propagate the error back to the proper css
provider that contains the section in question, we get it reported
back to the css editor in the inspector.
2024-05-09 23:13:53 -04:00
Matthias Clasen
f48a4e84af style provider: Add a has_section api
Add gtk_style_provider_has_section and implement it for
GtkCssProvider. This will be used later to direct error
emissions to the right provider.
2024-05-09 23:13:53 -04:00
Matthias Clasen
09c76208a2 css parser: Add bytes to sections
We will use this later to link sections back to the providers
they come from.
2024-05-09 23:13:53 -04:00
Matthias Clasen
62b1d21556 css parser: Add gtk_css_parser_skip_whitespace
Does what it says.
2024-05-09 23:13:53 -04:00
Matthias Clasen
8fba58eaa9 css: Don't accept junk
Check that there is no junk at the end of the property value
when parsing variable-bearing properties at compute time.
2024-05-09 23:13:52 -04:00
Alice Mikhaylenko
b4890edd64 inspector: Sort GTK CSS properties between standard and custom ones 2024-05-08 19:03:45 +04:00
Alice Mikhaylenko
93b9388180 inspector: Show custom properties for css nodes 2024-05-08 19:03:45 +04:00
Alice Mikhaylenko
76b2609ad5 testsuite: Add css variables tests 2024-05-08 19:03:44 +04:00
Alice Mikhaylenko
a37a0711ad csskeyframes: Support variables 2024-05-08 19:03:44 +04:00
Alice Mikhaylenko
23dbb7122c cssanimation: Recompute values while playing
This will be necessary for supporting variables in animations.

For this we need to pass all the gtk_css_value_compute() parameters into
GtkCssAnimatedStyle: parent style and provider.
2024-05-08 19:03:44 +04:00
Alice Mikhaylenko
e04ab263f9 cssstaticstyle: Split property lists into a separate header
We'll need to use them in GtkCssAnimatedStyle too.
2024-05-08 19:03:44 +04:00
Alice Mikhaylenko
5e6e808a55 cssvalue: Pass an extra GtkCssVariableSet to compute()
We'll need this to support variables in @keyframes, since styles will
need to combine their own variables and the ones from the keyframes.

See the next commit, this one is split out to avoid a huge diff.
2024-05-08 19:03:44 +04:00
Alice Mikhaylenko
6eaf6e2f7d Implement basic support for CSS variables 2024-05-08 19:03:43 +04:00
Alice Mikhaylenko
e4a4a0f6dd cssvalue: Add contains_variables()
We'll need this to know which values to recompute for animations.

It will be used in the next commit, it's separate to avoid the diff
being too large.
2024-05-08 19:00:40 +04:00
Alice Mikhaylenko
f301ea7936 csstokenizer: Add save() and restore()
We'll need that to check if property values contain variables.
2024-05-08 19:00:40 +04:00
Alice Mikhaylenko
a3e9ecd199 cssprovider: Copy bytes when loading
We'll need to keep accessing them later to compute values with variables,
so we can't avoid this anymore.
2024-05-08 19:00:40 +04:00
417 changed files with 5443 additions and 16592 deletions

View File

@@ -459,7 +459,6 @@ reference:
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
- 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/PangoCairo/ _reference/PangoCairo/
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/

View File

@@ -35,11 +35,7 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-python-gobject \
mingw-w64-$MSYS2_ARCH-shaderc \
mingw-w64-$MSYS2_ARCH-vulkan \
mingw-w64-$MSYS2_ARCH-vulkan-headers \
mingw-w64-$MSYS2_ARCH-libpng \
mingw-w64-$MSYS2_ARCH-libjpeg-turbo \
mingw-w64-$MSYS2_ARCH-libtiff \
mingw-w64-$MSYS2_ARCH-lcms2
mingw-w64-$MSYS2_ARCH-vulkan-headers
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"

59
NEWS
View File

@@ -1,54 +1,11 @@
Overview of Changes in 4.15.2, xx-xx-xxxx
=========================================
* GtkFileChooserWidget:
- Plug some memory leaks
- Make Ctrl-Shift-N create a new folder
* 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/)
* Accessibility:
- Avoid markup when reading labels
* GSK:
- Subset fonts when serializing node trees
* Wayland:
- Use xdg-dialog protocol for attached dialogs
* Windows:
- Build with UNICODE
* Debugging:
- Add GTK_DEBUG=css for warning about deprecated css syntax
* Tools:
- nodeparser: Add an extract command for data urls
* Deprecations:
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
* Translation updates:
Hebrew
Overview of Changes in 4.15.1, 21-05-2024
Overview of Changes in 4.15.1, xx-xx-xxxx
=========================================
* GtkGraphicsOffload:
- Don't crash without a child
* GtkSpinner:
- Don't animate when unmapped
* CSS:
- 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:
- Make symbolic svg loading more efficient
@@ -57,22 +14,19 @@ Overview of Changes in 4.15.1, 21-05-2024
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
- Realize child contexts when necessary
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
- vulkan: Recreate swapchains when necessary or beneficial
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
- cairo: Speed up mask nodes, since we use them for symbolic icons
* Wayland:
- Use wl_compositor version 6
@@ -85,22 +39,13 @@ Overview of Changes in 4.15.1, 21-05-2024
* Debugging:
- Show more texture details in the recorder
- Use GTK_DEBUG=css to see CSS deprecations
* macOS:
- Fix problems with events handed back to the OS
- Respect GDK_DEBUG=default-settings
- Allow applictions to handle Dock > Quit
* Deprecations:
- Use of @name colors in CSS
* Translation updates:
Catalan
Georgian
Hungarian
Korean
Portuguese
Turkish

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

View File

@@ -1,86 +0,0 @@
/* Color Spaces
*
* Demonstrates support for color spaces.
*
* The test images used here are taken from http://displaycal.net/icc-color-management-test/
* and are licensed under the Creative Commons BY-SA 4.0 International License
*/
#include <gtk/gtk.h>
static GtkWidget *jpeg;
static GtkWidget *png;
static GtkWidget *tiff;
static GtkWidget *noprofile;
static GtkWidget *test1;
static GtkWidget *test2;
static void
on_changed (GtkCheckButton *button,
gpointer user_data)
{
GdkTexture *texture;
const char *extension = NULL;
char *path;
if (!gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
return;
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (jpeg)))
extension = ".jpg";
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (png)))
extension = ".png";
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (tiff)))
extension = ".tif";
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (noprofile)))
extension = "-expected-result-no-cm.png";
path = g_strconcat ("/colorspaces/sRGB_Gray", extension, NULL);
texture = gdk_texture_new_from_resource (path);
gtk_picture_set_paintable (GTK_PICTURE (test1), GDK_PAINTABLE (texture));
g_object_unref (texture);
path = g_strconcat ("/colorspaces/ICC-Rendering-Intent-Test", extension, NULL);
texture = gdk_texture_new_from_resource (path);
gtk_picture_set_paintable (GTK_PICTURE (test2), GDK_PAINTABLE (texture));
g_object_unref (texture);
}
GtkWidget*
do_colorspaces (GtkWidget *do_widget)
{
static GtkWidget *window;
if (!window)
{
GtkBuilder *builder;
GtkBuilderScope *scope;
scope = gtk_builder_cscope_new ();
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope),
"on_changed", G_CALLBACK (on_changed));
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/colorspaces/colorspaces.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
jpeg = GTK_WIDGET (gtk_builder_get_object (builder, "jpeg"));
png = GTK_WIDGET (gtk_builder_get_object (builder, "png"));
tiff = GTK_WIDGET (gtk_builder_get_object (builder, "tiff"));
noprofile = GTK_WIDGET (gtk_builder_get_object (builder, "noprofile"));
test1 = GTK_WIDGET (gtk_builder_get_object (builder, "test1"));
test2 = GTK_WIDGET (gtk_builder_get_object (builder, "test2"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -1,94 +0,0 @@
<interface>
<object class="GtkWindow" id="window">
<property name="default-width">660</property>
<property name="default-height">660</property>
<property name="resizable">false</property>
<property name="title">Color Profiles</property>
<child>
<object class="GtkScrolledWindow">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<child>
<object class="GtkBox">
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">File format:</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="jpeg">
<property name="label">JPEG</property>
<property name="active">1</property>
<signal name="notify::active" handler="on_changed"/>
</object>
</child>
<child>
<object class="GtkCheckButton" id="png">
<property name="label">PNG</property>
<property name="group">jpeg</property>
<signal name="notify::active" handler="on_changed"/>
</object>
</child>
<child>
<object class="GtkCheckButton" id="tiff">
<property name="label">TIFF</property>
<property name="group">png</property>
<signal name="notify::active" handler="on_changed"/>
</object>
</child>
<child>
<object class="GtkCheckButton" id="noprofile">
<property name="label">No profile</property>
<property name="group">tiff</property>
<signal name="notify::active" handler="on_changed"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Test 1: Matrix-based profile</property>
<style>
<class name="title-3"/>
</style>
</object>
</child>
<child>
<object class="GtkPicture" id="test1">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="can-shrink">1</property>
<property name="keep-aspect-ratio">1</property>
<property name="file">resource:///colorprofiles/sRGB_Gray.jpg</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Test 2: Lookup table-based profile</property>
<style>
<class name="title-3"/>
</style>
</object>
</child>
<child>
<object class="GtkPicture" id="test2">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="can-shrink">1</property>
<property name="keep-aspect-ratio">1</property>
<property name="file">resource:///colorprofiles/ICC-Rendering-Intent-Test.jpg</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -19,17 +19,6 @@
<file>demoimage.c</file>
<file>demoimage.h</file>
</gresource>
<gresource prefix="/colorspaces">
<file>colorspaces.ui</file>
<file>sRGB_Gray.jpg</file>
<file>sRGB_Gray.png</file>
<file>sRGB_Gray.tif</file>
<file>sRGB_Gray-expected-result-no-cm.png</file>
<file>ICC-Rendering-Intent-Test.png</file>
<file>ICC-Rendering-Intent-Test.jpg</file>
<file>ICC-Rendering-Intent-Test.tif</file>
<file>ICC-Rendering-Intent-Test-expected-result-no-cm.png</file>
</gresource>
<gresource prefix="/constraints_builder">
<file>constraints_builder.ui</file>
</gresource>
@@ -276,7 +265,6 @@
<file>assistant.c</file>
<file>builder.c</file>
<file>clipboard.c</file>
<file>colorspaces.c</file>
<file>combobox.c</file>
<file>constraints.c</file>
<file>constraints_interactive.c</file>

View File

@@ -5,7 +5,6 @@ demos = files([
'assistant.c',
'builder.c',
'clipboard.c',
'colorspaces.c',
'combobox.c',
'constraints.c',
'constraints_interactive.c',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

View File

@@ -117,15 +117,6 @@ should be aware that the allowed values are meant to be used on 3D transformatio
so their naming might appear awkward. However, it is always possible to use the
matrix3d() production to specify all 16 values individually.
### color-state
| property | syntax | default | printed |
| ----------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| color-state | `<ident>|<url>` | srgb | always |
Creates a node like `gsk_color_state_node_new()` with the given properties.
### conic-gradient
| property | syntax | default | printed |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

View File

@@ -6,10 +6,3 @@
.toolbar {
-gtk-icon-style: symbolic;
}
.gtk-gradient-color {
background: linear-gradient(to right, lime, red);
}
.gtk-gradient-monochrome {
background: linear-gradient(to right, black, white);
}

View File

@@ -117,9 +117,5 @@
<file>portland-rose.jpg</file>
<file>nyc.jpg</file>
<file>beach.jpg</file>
<file>linear-gradient-color.png</file>
<file>linear-gradient-monochrome.png</file>
<file>srgb-gradient-color.png</file>
<file>srgb-gradient-monochrome.png</file>
</gresource>
</gresources>

View File

@@ -1344,173 +1344,13 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkGrid">
<property name="hexpand">0</property>
<property name="row-spacing">6</property>
<property name="column-spacing">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="row-homogeneous">1</property>
<property name="valign">start</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">color</property>
<style>
<class name="caption-heading"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">sRGB</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/srgb-gradient-color.png</property>
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">0</property>
<property name="hexpand">1</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">GTK</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="width-request">128</property>
<property name="keep-aspect-ratio">0</property>
<style>
<class name="gtk-gradient-color"/>
</style>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">linear</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/linear-gradient-color.png</property>
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">0</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">monochrome</property>
<style>
<class name="caption-heading"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">4</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">sRGB</property>
<layout>
<property name="column">0</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/srgb-gradient-monochrome.png</property>
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">0</property>
<property name="hexpand">1</property>
<layout>
<property name="column">1</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">GTK</property>
<layout>
<property name="column">0</property>
<property name="row">6</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="width-request">128</property>
<property name="keep-aspect-ratio">0</property>
<style>
<class name="gtk-gradient-monochrome"/>
</style>
<layout>
<property name="column">1</property>
<property name="row">6</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">linear</property>
<layout>
<property name="column">0</property>
<property name="row">7</property>
</layout>
</object>
</child>
<child>
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/linear-gradient-monochrome.png</property>
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">0</property>
<layout>
<property name="column">1</property>
<property name="row">7</property>
</layout>
</object>
</child>
<object class="GtkBox" id="box8">
<property name="orientation">1</property>
</object>
</property>
<property name="tab">
<object class="GtkLabel" id="label8">
<property name="label" translatable="1">Gradients</property>
<property name="label" translatable="1">page 1</property>
</object>
</property>
</object>

View File

@@ -15,16 +15,16 @@ spec.
The following units are supported for basic datatypes:
Length
: px, pt, em, ex, rem, pc, in, cm, mm
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
Percentage
: %
: %, calc()
Angle
: deg, rad, grad, turn
: deg, grad, turn, calc()
Time
: s, ms
: s, ms, calc()
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
@@ -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
not quite the same as the CSS definition of rem.
Length values using physical units (pt, pc, in, cm, mm) are translated
to px using the dpi value specified by the -gtk-dpi property, which is
different from the CSS definition, which uses a fixed dpi of 96.
The calc() notation adds considerable expressive power to all of these
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.
The calc() notation adds considerable expressive power. 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
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
spec.
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
@@ -86,54 +82,36 @@ color: var(--prop, green);
## Colors
### CSS 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.
GTK extends the CSS syntax with several additional ways to specify colors.
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:
```
@define-color name color
@define-color Name Color
```
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
new ones. Color expressions can be nested, providing a rich language to
define colors. Color expressions resemble functions, taking 1 or more colors
and in some cases a number as arguments.
`lighter(color)`
: produces a brighter variant of `color`.
`lighter(Color)`
: produces a brighter variant of Color
`darker(color)`
: produces a darker variant of `color`.
`darker(Color)`
: produces a darker variant of Color
`shade(color, number)`
: changes the lightness of `color`. The `number` ranges from 0 for black to 2 for white.
`shade(Color, Number)`
: changes the lightness of Color. The number ranges from 0 for black to 2 for white.
`alpha(color, number)`
: multiplies the alpha value of `color` by `number` (between 0 and 1).
`alpha(Color, Number)`
: replaces the alpha value of color with number (between 0 and 1)
`mix(color1, color2, number)`
: interpolates between the two colors.
`mix(Color1, Color2, Number)`
: interpolates between the two colors
## 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
```
-gtk-icontheme(name)
-gtk-icontheme(Name)
```
The specified icon name is used to look up a themed icon, while taking into
@@ -170,14 +148,14 @@ and the
syntax makes this available. -gtk-recolor requires a url as first argument.
The remaining arguments specify the color palette to use. If the palette is
not explicitly specified, the current value of the -gtk-icon-palette property
is used.
is used.
GTK supports scaled rendering on hi-resolution displays. This works best if
images can specify normal and hi-resolution variants. From CSS, this can be
done with
```
-gtk-scaled(image1, image2)
-gtk-scaled(Image1, Image2)
```
## GTK CSS Properties

View File

@@ -18,7 +18,6 @@ SYNOPSIS
|
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
@@ -100,15 +99,3 @@ exit code is 1. If the images are identical, it is 0.
``--quiet``
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).

View File

@@ -77,13 +77,11 @@ content_files = [
"section-tree-widget.md",
"migrating-2to4.md",
"migrating-3to4.md",
"migrating-4to5.md",
"broadway.md",
"osx.md",
"wayland.md",
"windows.md",
"x11.md",
"tools.md",
"visual_index.md",
]
content_images = [

View File

@@ -14,7 +14,6 @@ expand_content_md_files = [
'running.md',
'migrating-2to4.md',
'migrating-3to4.md',
'migrating-4to5.md',
'actions.md',
'input-handling.md',
'drawing-model.md',
@@ -26,8 +25,7 @@ expand_content_md_files = [
'section-tree-widget.md',
'section-list-widget.md',
'question_index.md',
'visual_index.md',
'tools.md',
'visual_index.md'
]
gtk_images = []
@@ -62,39 +60,39 @@ if get_option('documentation')
build_by_default: true,
install: true,
install_dir: docs_dir,
install_tag: 'doc',
)
endif
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-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', ],
]
rst2man = find_program('rst2man', 'rst2man.py', required: false)
if get_option('man-pages') and not rst2man.found()
error('No rst2man found, but man pages were explicitly enabled')
endif
rst2x_flags = [
'--syntax-highlight=none',
]
if get_option('man-pages') and rst2man.found()
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-path-tool', '1', ],
]
if get_option('man-pages')
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
rst2man_flags = [
'--syntax-highlight=none',
]
foreach rst: rst_files
man_name = rst[0]
@@ -105,34 +103,12 @@ if get_option('man-pages')
output: '@0@.@1@'.format(man_name, man_section),
command: [
rst2man,
rst2x_flags,
rst2man_flags,
'@INPUT@',
],
capture: true,
install: true,
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
endif

View File

@@ -58,7 +58,7 @@ use a GtkLabel.
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
get the current style foreground color, using
[method@Gtk.Widget.get_color].
[method@Gtk.Widget.get_style_color].
## 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())
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
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser

View File

@@ -64,6 +64,6 @@ GTK is divided into three parts:
[cairo]: https://www.cairographics.org/manual/
[opengl]: https://www.opengl.org/about/
[vulkan]: https://www.vulkan.org/
[pango]: https://docs.gtk.org/Pango/
[pango]: https://docs.gtk.org/pango/
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
[graphene]: https://ebassi.github.io/graphene/

View File

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

View File

@@ -46,10 +46,9 @@ gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
width = gdk_surface_get_width (surface);
height = gdk_surface_get_height (surface);
scale = gdk_surface_get_scale_factor (surface);
self->paint_surface = gdk_surface_create_similar_surface (surface,
CAIRO_CONTENT_COLOR_ALPHA,
width * scale, height *scale);
self->paint_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
width * scale, height * scale);
cairo_surface_set_device_scale (self->paint_surface, scale, scale);
repaint_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
cairo_region_union (region, repaint_region);

View File

@@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
@@ -138,7 +138,6 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible" },
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)" },
{ "dmabuf-disable", GDK_DEBUG_DMABUF_DISABLE, "Disable dmabuf support" },
{ "srgb", GDK_DEBUG_SRGB, "Force sRRGB rendering and turn off color profiles" },
};

View File

@@ -30,7 +30,6 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.h>

View File

@@ -41,10 +41,8 @@ G_BEGIN_DECLS
#ifdef GDK_ARRAY_NULL_TERMINATED
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
#else
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
#endif
/* make this readable */
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
gsize new_capacity, size, capacity;
gsize new_size, size;
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
capacity = gdk_array(get_capacity) (self);
if (n <= capacity)
return;
if (n <= gdk_array(get_capacity) (self))
return;
size = gdk_array(get_size) (self);
/* capacity * 2 can overflow, that's why we MAX() */
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
#ifdef GDK_ARRAY_PREALLOC
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));
}
else
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
#ifdef GDK_ARRAY_NULL_TERMINATED
if (self->start == NULL)
{
self->start = g_new (_T_, new_capacity);
self->start = g_new (_T_, new_size);
*self->start = *(_T_[1]) { 0 };
}
else
#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_allocation = self->start + new_capacity;
self->end_allocation = self->start + new_size;
#ifdef GDK_ARRAY_NULL_TERMINATED
self->end_allocation--;
#endif
@@ -319,7 +312,6 @@ gdk_array(get) (const GdkArray *self,
#undef gdk_array_paste
#undef gdk_array
#undef GDK_ARRAY_REAL_SIZE
#undef GDK_ARRAY_MAX_SIZE
#undef GDK_ARRAY_BY_VALUE
#undef GDK_ARRAY_ELEMENT_TYPE

View File

@@ -21,9 +21,6 @@
#include "gdkrgba.h"
#include "gdktexture.h"
#include "gdkcolorstate.h"
#include "gdkcolorprivate.h"
#include "gdkmemoryformatprivate.h"
#include <math.h>
@@ -38,20 +35,14 @@ void
gdk_cairo_set_source_rgba (cairo_t *cr,
const GdkRGBA *rgba)
{
GdkColor color;
const float *components;
g_return_if_fail (cr != NULL);
g_return_if_fail (rgba != NULL);
gdk_color_convert_rgba (&color, gdk_cairo_get_color_state (cr), rgba);
components = gdk_color_get_components (&color);
cairo_set_source_rgba (cr,
components[0],
components[1],
components[2],
gdk_color_get_alpha (&color));
gdk_color_finish (&color);
rgba->red,
rgba->green,
rgba->blue,
rgba->alpha);
}
/**
@@ -312,98 +303,3 @@ gdk_cairo_region_create_from_surface (cairo_surface_t *surface)
return region;
}
static cairo_user_data_key_t color_state_key;
/**
* gdk_cairo_surface_set_color_state:
* @surface: a surface
* @color_state: the color state to attach to the surface
*
* Attaches a `GdkColorState` to the Cairo surface.
*
* This is just auxiliary data for use by GTK, no Cairo functions
* do interact with this information.
*
* Note that all Cairo compositing operations are assumed to happen
* in a linear RGB color state, so if you want to use the surface
* as a target for rendering in a color managed way, you should use
* such a color state.
*
* The default color state is assumed to be sRGB, which is not
* linear.
*
* Since: 4.16
*/
void
gdk_cairo_surface_set_color_state (cairo_surface_t *surface,
GdkColorState *color_state)
{
g_return_if_fail (surface != NULL);
g_return_if_fail (GDK_IS_COLOR_STATE (color_state));
cairo_surface_set_user_data (surface,
&color_state_key,
g_object_ref (color_state),
g_object_unref);
}
/**
* gdk_cairo_surface_get_color_state:
* @surface: a surface
*
* Gets the color state GTK assumes for the surface.
*
* See [method@Gdk.CairoSurface.set_color_state] for details.
*
* Returns: (transfer none): the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_cairo_surface_get_color_state (cairo_surface_t *surface)
{
GdkColorState *color_state;
g_return_val_if_fail (surface != NULL, gdk_color_state_get_srgb ());
color_state = cairo_surface_get_user_data (surface, &color_state_key);
if (color_state == NULL)
color_state = gdk_color_state_get_srgb ();
return color_state;
}
/**
* gdk_cairo_get_color_state:
* @cr: a cairo context
*
* Gets the color state GTK assumes for the cairo context.
*
* Returns: (transfer none): the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_cairo_get_color_state (cairo_t *cr)
{
GdkColorState *color_state;
cairo_surface_t *surface;
g_return_val_if_fail (cr != NULL, gdk_color_state_get_srgb ());
surface = cairo_get_group_target (cr);
color_state = cairo_surface_get_user_data (surface, &color_state_key);
if (color_state != NULL)
return color_state;
/* theoretically, we should walk the whole group stack, but I don't
* think Cairo lets us do that
*/
surface = cairo_get_target (cr);
color_state = cairo_surface_get_user_data (surface, &color_state_key);
if (color_state != NULL)
return color_state;
return gdk_color_state_get_srgb ();
}

View File

@@ -44,15 +44,9 @@ void gdk_cairo_region (cairo_t *cr,
const cairo_region_t *region);
GDK_AVAILABLE_IN_ALL
cairo_region_t * gdk_cairo_region_create_from_surface (cairo_surface_t *surface);
GDK_AVAILABLE_IN_4_16
void gdk_cairo_surface_set_color_state (cairo_surface_t *surface,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_cairo_surface_get_color_state (cairo_surface_t *surface);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_cairo_get_color_state (cairo_t *cr);
cairo_region_t *
gdk_cairo_region_create_from_surface
(cairo_surface_t *surface);
GDK_DEPRECATED_IN_4_6_FOR(gdk_gl_texture_new)
void gdk_cairo_draw_from_gl (cairo_t *cr,

View File

@@ -522,6 +522,8 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
*
* 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
* lifetime of an application, so this function is typically called on
* exit. Depending on the platform, the functionality may not be available
@@ -636,6 +638,9 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
* Asynchronously requests an input stream to read the @clipboard's
* 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
* to fulfill the request, preferring the ones listed first.
*/
@@ -829,6 +834,9 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
* Asynchronously request the @clipboard contents converted to the given
* @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`,
* the value will be copied directly. Otherwise, GDK will try to use
* [func@content_deserialize_async] to convert the clipboard's data.
@@ -887,6 +895,9 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
*
* 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].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.
@@ -949,6 +960,9 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
*
* 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].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.

View File

@@ -1,104 +0,0 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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 "gdkcolorprivate.h"
#include "gdkcolorstateprivate.h"
#include <lcms2.h>
void
gdk_color_convert (GdkColor *self,
GdkColorState *color_state,
const GdkColor *other)
{
GdkColorStateTransform *tf;
gdk_color_init (self, color_state, other->alpha, NULL);
tf = gdk_color_state_get_transform (gdk_color_state_get_srgb (), color_state, FALSE);
gdk_color_state_transform (tf,
(float *) gdk_color_get_components (other),
(float *) gdk_color_get_components (self),
1);
}
void
gdk_color_convert_rgba (GdkColor *self,
GdkColorState *color_state,
const GdkRGBA *rgba)
{
GdkColorStateTransform *tf;
gdk_color_init (self, color_state, rgba->alpha, NULL);
tf = gdk_color_state_get_transform (gdk_color_state_get_srgb (), color_state, FALSE);
gdk_color_state_transform (tf,
(float[3]) { rgba->red, rgba->green, rgba->blue },
(float *) gdk_color_get_components (self),
1);
gdk_color_state_transform_free (tf);
}
void
gdk_color_mix (GdkColor *self,
GdkColorState *color_state,
const GdkColor *src1,
const GdkColor *src2,
double progress)
{
if (src1->color_state != color_state)
{
GdkColor tmp;
gdk_color_convert (&tmp, color_state, src1);
gdk_color_mix (self, color_state, &tmp, src2, progress);
}
else if (src2->color_state != color_state)
{
GdkColor tmp;
gdk_color_convert (&tmp, color_state, src2);
gdk_color_mix (self, color_state, src1, &tmp, progress);
}
else
{
gsize i;
const float *s1, *s2;
float *d;
gdk_color_init (self,
color_state,
src1->alpha * (1.0 - progress) + src2->alpha * progress,
NULL);
d = (float *) gdk_color_get_components (self);
s1 = gdk_color_get_components (src1);
s2 = gdk_color_get_components (src2);
if (self->alpha == 0)
{
for (i = 0; i < 3; i++)
d[i] = s1[i] * (1.0 - progress) + s2[i] * progress;
}
else
{
for (i = 0; i < 3; i++)
d[i] = (s1[i] * src1->alpha * (1.0 - progress) + s2[i] * src2->alpha * progress) / self->alpha;
}
}
}

View File

@@ -1,61 +0,0 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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 <gdk/gdkcolorstate.h>
#include <gdk/gdkrgba.h>
typedef struct _GdkColor GdkColor;
struct _GdkColor
{
GdkColorState *color_state;
float alpha;
float values[3];
};
G_STATIC_ASSERT (sizeof (GdkColor) % sizeof (gpointer) == 0);
static inline void gdk_color_init (GdkColor *self,
GdkColorState *color_state,
float alpha,
float components[3]);
static inline void gdk_color_init_from_rgba (GdkColor *self,
const GdkRGBA *rgba);
static inline void gdk_color_finish (GdkColor *self);
void gdk_color_convert (GdkColor *self,
GdkColorState *color_state,
const GdkColor *other);
void gdk_color_convert_rgba (GdkColor *self,
GdkColorState *color_state,
const GdkRGBA *rgba);
void gdk_color_mix (GdkColor *self,
GdkColorState *color_state,
const GdkColor *src1,
const GdkColor *src2,
double progress);
static inline GdkColorState * gdk_color_get_color_state (const GdkColor *self);
static inline float gdk_color_get_alpha (const GdkColor *self);
static inline const float * gdk_color_get_components (const GdkColor *self);
#include "gdkcolorprivateimpl.h"
G_END_DECLS

View File

@@ -1,63 +0,0 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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/>.
*/
static inline void
gdk_color_init (GdkColor *self,
GdkColorState *color_state,
float alpha,
float components[3])
{
self->color_state = g_object_ref (color_state);
self->alpha = alpha;
if (components)
memcpy (self->values, components, sizeof (float) * 3);
}
static inline void
gdk_color_init_from_rgba (GdkColor *self,
const GdkRGBA *rgba)
{
gdk_color_init (self,
gdk_color_state_get_srgb (),
rgba->alpha,
(float[3]) { rgba->red, rgba->green, rgba->blue });
}
static inline void
gdk_color_finish (GdkColor *self)
{
g_object_unref (self->color_state);
}
static inline GdkColorState *
gdk_color_get_color_state (const GdkColor *self)
{
return self->color_state;
}
static inline float
gdk_color_get_alpha (const GdkColor *self)
{
return self->alpha;
}
static inline const float *
gdk_color_get_components (const GdkColor *self)
{
return self->values;
}

View File

@@ -1,405 +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 <glib/gi18n-lib.h>
#include "gdknamedcolorstateprivate.h"
#include "gdklcmscolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
G_DEFINE_TYPE (GdkColorState, gdk_color_state, G_TYPE_OBJECT)
static void
gdk_color_state_init (GdkColorState *self)
{
}
static GBytes *
gdk_color_state_default_save_to_icc_profile (GdkColorState *self,
GError **error)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("This color state does not support ICC profiles"));
return NULL;
}
static gboolean
gdk_color_state_default_equal (GdkColorState *self,
GdkColorState *other)
{
return self == other;
}
static const char *
gdk_color_state_default_get_name (GdkColorState *self)
{
return "color state";
}
static GdkMemoryDepth
gdk_color_state_default_get_min_depth (GdkColorState *self)
{
return GDK_MEMORY_U8;
}
static void
gdk_color_state_class_init (GdkColorStateClass *class)
{
class->save_to_icc_profile = gdk_color_state_default_save_to_icc_profile;
class->equal = gdk_color_state_default_equal;
class->get_name = gdk_color_state_default_get_name;
class->get_min_depth = gdk_color_state_default_get_min_depth;
}
/**
* gdk_color_state_equal:
* @cs1: a `GdkColorState`
* @cs2: 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 state will never compare equal.
*
* Returns: %TRUE if the two color states compare equal
*
* Since: 4.16
*/
gboolean
gdk_color_state_equal (GdkColorState *cs1,
GdkColorState *cs2)
{
if (cs1 == cs2)
return TRUE;
if (GDK_COLOR_STATE_GET_CLASS (cs1) != GDK_COLOR_STATE_GET_CLASS (cs2))
return FALSE;
return GDK_COLOR_STATE_GET_CLASS (cs1)->equal (cs1, cs2);
}
/**
* gdk_color_state_is_linear:
* @self: a `GdkColorState`
*
* Returns whether the color state is linear.
*
* Returns: `TRUE` if the color state is linear
* Since: 4.16
*/
gboolean
gdk_color_state_is_linear (GdkColorState *self)
{
g_return_val_if_fail (GDK_IS_COLOR_STATE (self), FALSE);
return self == gdk_color_state_get_srgb_linear ();
}
/**
* gdk_color_state_save_to_icc_profile:
* @self: a `GdkColorState`
* @error: Return location for an error
*
* Saves the color state to an
* [ICC profile](https://en.wikipedia.org/wiki/ICC_profile).
*
* Some color state cannot be represented as ICC profiles. In
* that case, an error will be set and %NULL will be returned.
*
* Returns: (nullable): A new `GBytes` containing the ICC profile
*
* Since: 4.16
*/
GBytes *
gdk_color_state_save_to_icc_profile (GdkColorState *self,
GError **error)
{
g_return_val_if_fail (GDK_IS_COLOR_STATE (self), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
return GDK_COLOR_STATE_GET_CLASS (self)->save_to_icc_profile (self, error);
}
GdkMemoryDepth
gdk_color_state_get_min_depth (GdkColorState *self)
{
return GDK_COLOR_STATE_GET_CLASS (self)->get_min_depth (self);
}
const char *
gdk_color_state_get_name (GdkColorState *self)
{
return GDK_COLOR_STATE_GET_CLASS (self)->get_name (self);
}
typedef void (* StepFunc) (float s0, float s1, float s2,
float *d0, float *d1, float *d2);
struct _GdkColorStateTransform
{
cmsHTRANSFORM transform;
int n_funcs;
StepFunc funcs[10];
gboolean cms_first;
gboolean copy_alpha;
};
static void
transform_list_append (GdkColorStateTransform *tf,
StepFunc func)
{
g_assert (tf->n_funcs < G_N_ELEMENTS (tf->funcs));
tf->funcs[tf->n_funcs] = func;
tf->n_funcs++;
}
static struct {
GdkColorStateId n1, n2;
StepFunc func;
} functions[] = {
{ GDK_COLOR_STATE_HWB, GDK_COLOR_STATE_SRGB, gtk_hwb_to_rgb },
{ GDK_COLOR_STATE_SRGB, GDK_COLOR_STATE_HWB, gtk_rgb_to_hwb },
{ GDK_COLOR_STATE_HSL, GDK_COLOR_STATE_SRGB, gtk_hsl_to_rgb },
{ GDK_COLOR_STATE_SRGB, GDK_COLOR_STATE_HSL, gtk_rgb_to_hsl },
{ GDK_COLOR_STATE_SRGB_LINEAR, GDK_COLOR_STATE_SRGB, gtk_rgb_to_linear_srgb },
{ GDK_COLOR_STATE_SRGB, GDK_COLOR_STATE_SRGB_LINEAR, gtk_linear_srgb_to_rgb },
{ GDK_COLOR_STATE_SRGB_LINEAR, GDK_COLOR_STATE_OKLAB, gtk_linear_srgb_to_oklab },
{ GDK_COLOR_STATE_OKLAB, GDK_COLOR_STATE_SRGB_LINEAR, gtk_oklab_to_linear_srgb },
{ GDK_COLOR_STATE_OKLAB, GDK_COLOR_STATE_OKLCH, gtk_oklab_to_oklch },
{ GDK_COLOR_STATE_OKLCH, GDK_COLOR_STATE_OKLAB, gtk_oklch_to_oklab },
};
static gpointer
find_function (int i, int j)
{
for (int k = 0; k < G_N_ELEMENTS (functions); k++)
{
if (functions[k].n1 == i && functions[k].n2 == j)
return functions[k].func;
}
return NULL;
}
static GdkColorStateId line1[] = { GDK_COLOR_STATE_SRGB,
GDK_COLOR_STATE_SRGB_LINEAR,
GDK_COLOR_STATE_OKLAB,
GDK_COLOR_STATE_OKLCH };
static GdkColorStateId line2[] = { GDK_COLOR_STATE_HSL,
GDK_COLOR_STATE_SRGB,
GDK_COLOR_STATE_HWB};
static void
collect_functions (GdkColorStateTransform *tf,
GdkColorStateId line[],
int si,
int di)
{
int inc = di < si ? -1 : 1;
int i0, i;
i0 = i = si;
do
{
i += inc;
transform_list_append (tf, find_function (line[i0], line[i]));
i0 = i;
}
while (i != di);
}
static void
get_transform_list (GdkColorStateTransform *tf,
GdkColorState *from,
GdkColorState *to)
{
GdkColorStateId sn, dn;
int si, di, sii, dii;
sn = gdk_named_color_state_get_id (from);
dn = gdk_named_color_state_get_id (to);
for (int i = 0; i < G_N_ELEMENTS (line1); i++)
{
if (line1[i] == sn)
si = i;
if (line1[i] == dn)
di = i;
}
if (si > -1 && di > -1)
{
collect_functions (tf, line1, si, di);
return;
}
for (int i = 0; i < G_N_ELEMENTS (line2); i++)
{
if (line2[i] == sn)
sii = i;
if (line2[i] == dn)
dii = i;
}
if (sii > -1 && dii > -1)
{
collect_functions (tf, line2, sii, dii);
return;
}
if (si > -1 && dii > -1)
{
collect_functions (tf, line1, si, 0);
collect_functions (tf, line2, 1, dii);
return;
}
if (sii > -1 && di > -1)
{
collect_functions (tf, line2, sii, 1);
collect_functions (tf, line2, 0, di);
return;
}
}
GdkColorStateTransform *
gdk_color_state_get_transform (GdkColorState *from,
GdkColorState *to,
gboolean copy_alpha)
{
GdkColorStateTransform *tf;
tf = g_new0 (GdkColorStateTransform, 1);
if (gdk_color_state_equal (from, to))
{
}
else if (GDK_IS_LCMS_COLOR_STATE (from) &&
GDK_IS_LCMS_COLOR_STATE (to))
{
tf->transform = cmsCreateTransform (gdk_lcms_color_state_get_lcms_profile (from),
TYPE_RGBA_FLT,
gdk_lcms_color_state_get_lcms_profile (to),
TYPE_RGBA_FLT,
INTENT_PERCEPTUAL,
copy_alpha ? cmsFLAGS_COPY_ALPHA : 0);
}
else if (GDK_IS_NAMED_COLOR_STATE (from) &&
GDK_IS_NAMED_COLOR_STATE (to))
{
get_transform_list (tf, from, to);
}
else if (GDK_IS_NAMED_COLOR_STATE (from) &&
GDK_IS_LCMS_COLOR_STATE (to))
{
cmsHPROFILE profile;
get_transform_list (tf, from, gdk_color_state_get_srgb ());
profile = cmsCreate_sRGBProfile ();
tf->transform = cmsCreateTransform (profile,
TYPE_RGBA_FLT,
gdk_lcms_color_state_get_lcms_profile (to),
TYPE_RGBA_FLT,
INTENT_PERCEPTUAL,
copy_alpha ? cmsFLAGS_COPY_ALPHA : 0);
cmsCloseProfile (profile);
tf->cms_first = FALSE;
}
else if (GDK_IS_LCMS_COLOR_STATE (from) &&
GDK_IS_NAMED_COLOR_STATE (to))
{
cmsHPROFILE profile;
profile = cmsCreate_sRGBProfile ();
tf->transform = cmsCreateTransform (gdk_lcms_color_state_get_lcms_profile (from),
TYPE_RGBA_FLT,
profile,
TYPE_RGBA_FLT,
INTENT_PERCEPTUAL,
copy_alpha ? cmsFLAGS_COPY_ALPHA : 0);
cmsCloseProfile (profile);
get_transform_list (tf, gdk_color_state_get_srgb (), to);
tf->cms_first = TRUE;
}
tf->copy_alpha = copy_alpha;
return tf;
}
void
gdk_color_state_transform_free (GdkColorStateTransform *tf)
{
if (tf->transform)
cmsDeleteTransform (tf->transform);
g_free (tf);
}
void
gdk_color_state_transform (GdkColorStateTransform *tf,
const float *src,
float *dst,
int width)
{
if (tf->copy_alpha)
memcpy (dst, src, sizeof (float) * 4 * width);
else
{
for (int i = 0; i < width * 4; i += 4)
{
dst[i] = src[i];
dst[i + 1] = src[i + 1];
dst[i + 2] = src[i + 2];
}
}
if (tf->cms_first && tf->transform)
cmsDoTransform (tf->transform, dst, dst, width);
if (tf->n_funcs)
{
for (int i = 0; i < width * 4; i += 4)
{
float s0 = dst[i];
float s1 = dst[i + 1];
float s2 = dst[i + 2];
for (int k = 0; k < tf->n_funcs; k++)
tf->funcs[k] (s0, s1, s2, &s0, &s1, &s2);
dst[i] = s0;
dst[i + 1] = s1;
dst[i + 2] = s2;
}
}
if (!tf->cms_first && tf->transform)
cmsDoTransform (tf->transform, dst, dst, width);
}

View File

@@ -1,68 +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
GDK_DECLARE_INTERNAL_TYPE (GdkColorState, gdk_color_state, GDK, COLOR_STATE, GObject)
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_hsl (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_hwb (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_new_from_icc_profile (GBytes *icc_profile,
GError **error);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *cs1,
GdkColorState *cs2);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_is_linear (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
GBytes * gdk_color_state_save_to_icc_profile (GdkColorState *self,
GError **error);
G_END_DECLS

View File

@@ -1,40 +0,0 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkmemoryformatprivate.h"
struct _GdkColorState
{
GObject parent_instance;
};
struct _GdkColorStateClass
{
GObjectClass parent_class;
GBytes * (* save_to_icc_profile) (GdkColorState *self,
GError **error);
gboolean (* equal) (GdkColorState *self,
GdkColorState *other);
const char * (* get_name) (GdkColorState *self);
GdkMemoryDepth (* get_min_depth) (GdkColorState *self);
};
const char * gdk_color_state_get_name (GdkColorState *color_state);
GdkMemoryDepth gdk_color_state_get_min_depth (GdkColorState *color_state);
typedef struct _GdkColorStateTransform GdkColorStateTransform;
GdkColorStateTransform * gdk_color_state_get_transform (GdkColorState *from,
GdkColorState *to,
gboolean copy_alpha);
void gdk_color_state_transform_free (GdkColorStateTransform *tf);
void gdk_color_state_transform (GdkColorStateTransform *tf,
const float *src,
float *dst,
int width);

View File

@@ -540,6 +540,9 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
*
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
* 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
gdk_content_deserialize_async (GInputStream *stream,

View File

@@ -279,6 +279,10 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
* Asynchronously writes the contents of @provider to @stream in the given
* @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
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.

View File

@@ -546,6 +546,9 @@ serialize_not_found (GdkContentSerializer *serializer)
*
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
* 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
gdk_content_serialize_async (GOutputStream *stream,

View File

@@ -52,7 +52,7 @@ GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor *fallback);
/**
* GdkCursorGetTextureCallback:
* GdkCursorGetTestureCallback:
* @cursor: the `GdkCursor`
* @cursor_size: the nominal cursor size, in application pixels
* @scale: the device scale

View File

@@ -40,7 +40,6 @@ typedef enum {
GDK_DEBUG_OFFLOAD = 1 << 12,
/* flags below are influencing behavior */
GDK_DEBUG_SRGB = 1 << 13,
GDK_DEBUG_PORTALS = 1 << 14,
GDK_DEBUG_NO_PORTALS = 1 << 15,
GDK_DEBUG_GL_DISABLE = 1 << 16,

View File

@@ -24,7 +24,6 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkcolorstate.h"
#ifdef HAVE_DMABUF
#include <sys/mman.h>
@@ -2063,15 +2062,12 @@ out:
void
gdk_dmabuf_download_mmap (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GdkMemoryFormat src_format = gdk_texture_get_format (texture);
GdkColorState *src_color_state = gdk_texture_get_color_state (texture);
if (format == src_format &&
gdk_color_state_equal (color_state, src_color_state))
if (format == src_format)
gdk_dmabuf_do_download_mmap (texture, data, stride);
else
{
@@ -2087,10 +2083,8 @@ gdk_dmabuf_download_mmap (GdkTexture *texture,
gdk_dmabuf_do_download_mmap (texture, src_data, src_stride);
gdk_memory_convert (data, stride,
format, color_state,
src_data, src_stride,
src_format, src_color_state,
gdk_memory_convert (data, stride, format,
src_data, src_stride, src_format,
width, height);
g_free (src_data);

View File

@@ -35,7 +35,6 @@ void
gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -44,6 +43,6 @@ gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
g_return_if_fail (GDK_IS_DMABUF_DOWNLOADER (self));
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
iface->download (self, texture, format, color_state, data, stride);
iface->download (self, texture, format, data, stride);
}

View File

@@ -20,7 +20,6 @@ struct _GdkDmabufDownloaderInterface
void (* download) (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
};
@@ -32,7 +31,6 @@ gboolean gdk_dmabuf_downloader_supports (GdkDmabufDownlo
void gdk_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);

View File

@@ -27,7 +27,6 @@ struct _GdkDmabuf
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
void gdk_dmabuf_download_mmap (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);

View File

@@ -62,13 +62,6 @@ struct _GdkDmabufTextureClass
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_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
@@ -96,7 +89,6 @@ struct _Download
{
GdkDmabufTexture *texture;
GdkMemoryFormat format;
GdkColorState *color_state;
guchar *data;
gsize stride;
volatile int spinlock;
@@ -110,7 +102,6 @@ gdk_dmabuf_texture_invoke_callback (gpointer data)
gdk_dmabuf_downloader_download (download->texture->downloader,
download->texture,
download->format,
download->color_state,
download->data,
download->stride);
@@ -122,17 +113,16 @@ gdk_dmabuf_texture_invoke_callback (gpointer data)
static void
gdk_dmabuf_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (texture);
Download download = { self, format, color_state, data, stride, 0 };
Download download = { self, format, data, stride, 0 };
if (self->downloader == NULL)
{
#ifdef HAVE_DMABUF
gdk_dmabuf_download_mmap (texture, format, color_state, data, stride);
gdk_dmabuf_download_mmap (texture, format, data, stride);
#endif
return;
}
@@ -203,7 +193,6 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
"width", width,
"height", height,
"color-state", gdk_dmabuf_texture_builder_get_color_state (builder),
NULL);
g_set_object (&self->display, display);

View File

@@ -24,7 +24,6 @@
#include "gdkdebugprivate.h"
#include "gdkdisplay.h"
#include "gdkenumtypes.h"
#include "gdkcolorstate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkdmabuftexturebuilderprivate.h"
@@ -42,8 +41,6 @@ struct _GdkDmabufTextureBuilder
GdkDmabuf dmabuf;
GdkColorState *color_state;
GdkTexture *update_texture;
cairo_region_t *update_region;
};
@@ -127,7 +124,6 @@ enum
PROP_MODIFIER,
PROP_PREMULTIPLIED,
PROP_N_PLANES,
PROP_COLOR_STATE,
PROP_UPDATE_REGION,
PROP_UPDATE_TEXTURE,
@@ -145,7 +141,6 @@ gdk_dmabuf_texture_builder_dispose (GObject *object)
g_clear_object (&self->update_texture);
g_clear_pointer (&self->update_region, cairo_region_destroy);
g_clear_object (&self->color_state);
G_OBJECT_CLASS (gdk_dmabuf_texture_builder_parent_class)->dispose (object);
}
@@ -188,10 +183,6 @@ gdk_dmabuf_texture_builder_get_property (GObject *object,
g_value_set_uint (value, self->dmabuf.n_planes);
break;
case PROP_COLOR_STATE:
g_value_set_object (value, self->color_state);
break;
case PROP_UPDATE_REGION:
g_value_set_boxed (value, self->update_region);
break;
@@ -244,10 +235,6 @@ gdk_dmabuf_texture_builder_set_property (GObject *object,
gdk_dmabuf_texture_builder_set_n_planes (self, g_value_get_uint (value));
break;
case PROP_COLOR_STATE:
gdk_dmabuf_texture_builder_set_color_state (self, g_value_get_object (value));
break;
case PROP_UPDATE_REGION:
gdk_dmabuf_texture_builder_set_update_region (self, g_value_get_boxed (value));
break;
@@ -360,18 +347,6 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
1, GDK_DMABUF_MAX_PLANES, 1,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_color_state org.gtk.Property.set=gdk_dmabuf_texture_builder_set_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_object ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_region org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_region)
*
@@ -408,8 +383,6 @@ gdk_dmabuf_texture_builder_init (GdkDmabufTextureBuilder *self)
for (int i = 0; i < GDK_DMABUF_MAX_PLANES; i++)
self->dmabuf.planes[i].fd = -1;
self->color_state = g_object_ref (gdk_color_state_get_srgb ());
}
/**
@@ -870,44 +843,6 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
self->dmabuf.planes[plane].offset = offset;
}
/**
* gdk_dmabuf_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self)
{
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), NULL);
return self->color_state;
}
/**
* gdk_dmabuf_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
* @self: a `GdkDmabufTextureBuilder`
* @color_state: a `GdkColorState`
*
* Sets the color state for the texture.
*
* Since: 4.16
*/
void
gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
GdkColorState *color_state)
{
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
g_return_if_fail (GDK_IS_COLOR_STATE (color_state));
if (g_set_object (&self->color_state, color_state))
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
}
/**
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
* @self: a `GdkDmabufTextureBuilder`

View File

@@ -100,12 +100,6 @@ void gdk_dmabuf_texture_builder_set_offset (GdkDmabufT
unsigned int plane,
unsigned int offset);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self);
GDK_AVAILABLE_IN_4_16
void gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_14
GdkTexture * gdk_dmabuf_texture_builder_get_update_texture (GdkDmabufTextureBuilder *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_14

View File

@@ -134,7 +134,7 @@ gdk_drop_read_local_async (GdkDrop *self,
g_object_get (priv->drag, "content", &content, NULL);
content_formats = gdk_content_provider_ref_formats (content);
g_object_unref (content);
g_object_unref (content);
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
@@ -784,7 +784,7 @@ gdk_drop_read_value_internal (GdkDrop *self,
GdkContentFormats *formats;
GValue *value;
GTask *task;
g_return_if_fail (priv->state != GDK_DROP_STATE_FINISHED);
task = g_task_new (self, cancellable, callback, user_data);
@@ -849,6 +849,10 @@ gdk_drop_read_value_internal (GdkDrop *self,
* Asynchronously request the drag operation's contents converted
* 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
* `GType`, the value will be copied directly. Otherwise, GDK will
* try to use [func@Gdk.content_deserialize_async] to convert the data.

View File

@@ -1371,8 +1371,6 @@ gdk_event_get_modifier_state (GdkEvent *event)
* Extract the event surface relative x/y coordinates from an event.
*
* This position is in [surface coordinates](coordinates.html).
*
* Returns: whether the positions were set
*/
gboolean
gdk_event_get_position (GdkEvent *event,

View File

@@ -152,13 +152,6 @@ enum {
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_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)

View File

@@ -24,7 +24,6 @@
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkcolorstate.h"
#include <epoxy/gl.h>
@@ -137,7 +136,6 @@ typedef struct _Download Download;
struct _Download
{
GdkMemoryFormat format;
GdkColorState *color_state;
guchar *data;
gsize stride;
};
@@ -187,15 +185,13 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
{
GdkTexture *texture = GDK_TEXTURE (self);
GdkMemoryFormat format;
GdkColorState *color_state;
gsize expected_stride;
Download *download = download_;
GLint gl_internal_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
format = gdk_texture_get_format (texture);
color_state = gdk_texture_get_color_state (texture);
format = gdk_texture_get_format (texture),
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
if (!gdk_gl_context_get_use_es (context) &&
@@ -229,11 +225,9 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_convert (download->data,
download->stride,
download->format,
download->color_state,
pixels,
stride,
format,
color_state,
texture->width,
texture->height);
@@ -383,11 +377,9 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_convert (download->data,
download->stride,
download->format,
download->color_state,
pixels,
stride,
actual_format,
color_state,
texture->width,
texture->height);
@@ -401,7 +393,6 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
static void
gdk_gl_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -410,12 +401,11 @@ gdk_gl_texture_download (GdkTexture *texture,
if (self->saved)
{
gdk_texture_do_download (self->saved, format, color_state, data, stride);
gdk_texture_do_download (self->saved, format, data, stride);
return;
}
download.format = format;
download.color_state = color_state;
download.data = data;
download.stride = stride;
@@ -481,7 +471,8 @@ gdk_gl_texture_release (GdkGLTexture *self)
g_return_if_fail (self->saved == NULL);
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);
}
@@ -497,7 +488,6 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
self = g_object_new (GDK_TYPE_GL_TEXTURE,
"width", gdk_gl_texture_builder_get_width (builder),
"height", gdk_gl_texture_builder_get_height (builder),
"color-state", gdk_gl_texture_builder_get_color_state (builder),
NULL);
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));

View File

@@ -23,7 +23,6 @@
#include "gdkenumtypes.h"
#include "gdkglcontext.h"
#include "gdkcolorstate.h"
#include "gdkgltextureprivate.h"
#include <cairo-gobject.h>
@@ -39,7 +38,6 @@ struct _GdkGLTextureBuilder
GdkMemoryFormat format;
gboolean has_mipmap;
gpointer sync;
GdkColorState *color_state;
GdkTexture *update_texture;
cairo_region_t *update_region;
@@ -77,7 +75,6 @@ enum
PROP_HEIGHT,
PROP_ID,
PROP_SYNC,
PROP_COLOR_STATE,
PROP_UPDATE_REGION,
PROP_UPDATE_TEXTURE,
PROP_WIDTH,
@@ -98,7 +95,6 @@ gdk_gl_texture_builder_dispose (GObject *object)
g_clear_object (&self->update_texture);
g_clear_pointer (&self->update_region, cairo_region_destroy);
g_clear_object (&self->color_state);
G_OBJECT_CLASS (gdk_gl_texture_builder_parent_class)->dispose (object);
}
@@ -137,10 +133,6 @@ gdk_gl_texture_builder_get_property (GObject *object,
g_value_set_pointer (value, self->sync);
break;
case PROP_COLOR_STATE:
g_value_set_object (value, self->color_state);
break;
case PROP_UPDATE_REGION:
g_value_set_boxed (value, self->update_region);
break;
@@ -193,10 +185,6 @@ gdk_gl_texture_builder_set_property (GObject *object,
gdk_gl_texture_builder_set_sync (self, g_value_get_pointer (value));
break;
case PROP_COLOR_STATE:
gdk_gl_texture_builder_set_color_state (self, g_value_get_object (value));
break;
case PROP_UPDATE_REGION:
gdk_gl_texture_builder_set_update_region (self, g_value_get_boxed (value));
break;
@@ -298,18 +286,6 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
g_param_spec_pointer ("sync", NULL, NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_color_state org.gtk.Property.set=gdk_gl_texture_builder_set_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_object ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_region org.gtk.Property.set=gdk_gl_texture_builder_set_update_region)
*
@@ -353,7 +329,6 @@ static void
gdk_gl_texture_builder_init (GdkGLTextureBuilder *self)
{
self->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
self->color_state = g_object_ref (gdk_color_state_get_srgb ());
}
/**
@@ -641,44 +616,6 @@ gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SYNC]);
}
/**
* gdk_gl_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @self: a `GdkGLTextureBuilder`
*
* Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self)
{
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
return self->color_state;
}
/**
* gdk_gl_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
* @self: a `GdkGLTextureBuilder`
* @color_state: a `GdkColorState`
*
* Sets the color state for the texture.
*
* Since: 4.16
*/
void
gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
GdkColorState *color_state)
{
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
g_return_if_fail (GDK_IS_COLOR_STATE (color_state));
if (g_set_object (&self->color_state, color_state))
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
}
/**
* gdk_gl_texture_builder_get_format: (attributes org.gtk.Method.get_property=format)
* @self: a `GdkGLTextureBuilder`

View File

@@ -76,12 +76,6 @@ GDK_AVAILABLE_IN_4_12
void gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
gpointer sync);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self);
GDK_AVAILABLE_IN_4_16
void gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_12
GdkTexture * gdk_gl_texture_builder_get_update_texture (GdkGLTextureBuilder *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_12

View File

@@ -1,255 +0,0 @@
/* gdklcmscolorstate.c
*
* Copyright 2021 (c) Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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 "gdklcmscolorstateprivate.h"
#include <glib/gi18n-lib.h>
struct _GdkLcmsColorState
{
GdkColorState parent_instance;
cmsHPROFILE lcms_profile;
};
struct _GdkLcmsColorStateClass
{
GdkColorStateClass parent_class;
};
G_DEFINE_TYPE (GdkLcmsColorState, gdk_lcms_color_state, GDK_TYPE_COLOR_STATE)
static GBytes *
gdk_lcms_color_state_save_to_icc_profile (GdkColorState *state,
GError **error)
{
GdkLcmsColorState *self = GDK_LCMS_COLOR_STATE (state);
cmsUInt32Number size;
guchar *data;
size = 0;
if (!cmsSaveProfileToMem (self->lcms_profile, NULL, &size))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Could not prepare ICC profile"));
return NULL;
}
data = g_malloc (size);
if (!cmsSaveProfileToMem (self->lcms_profile, data, &size))
{
g_free (data);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Failed to save ICC profile"));
return NULL;
}
return g_bytes_new_take (data, size);
}
static gboolean
gdk_lcms_color_state_equal (GdkColorState *cs1,
GdkColorState *cs2)
{
GBytes *icc1, *icc2;
gboolean res;
icc1 = gdk_color_state_save_to_icc_profile (cs1, NULL);
icc2 = gdk_color_state_save_to_icc_profile (cs2, NULL);
res = g_bytes_equal (icc1, icc2);
g_bytes_unref (icc1);
g_bytes_unref (icc2);
return res;
}
static void
gdk_lcms_color_state_dispose (GObject *object)
{
GdkLcmsColorState *self = GDK_LCMS_COLOR_STATE (object);
g_clear_pointer (&self->lcms_profile, cmsCloseProfile);
G_OBJECT_CLASS (gdk_lcms_color_state_parent_class)->dispose (object);
}
static const char *
gdk_lcms_color_state_get_name (GdkColorState *self)
{
static char buffer[48];
g_snprintf (buffer, sizeof (buffer), "lcms color state %p", self);
return buffer;
}
static void
gdk_lcms_color_state_class_init (GdkLcmsColorStateClass *klass)
{
GdkColorStateClass *color_state_class = GDK_COLOR_STATE_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gdk_lcms_color_state_dispose;
color_state_class->save_to_icc_profile = gdk_lcms_color_state_save_to_icc_profile;
color_state_class->equal = gdk_lcms_color_state_equal;
color_state_class->get_name = gdk_lcms_color_state_get_name;
}
static void
gdk_lcms_color_state_init (GdkLcmsColorState *self)
{
}
GdkColorState *
gdk_lcms_color_state_new_from_lcms_profile (cmsHPROFILE lcms_profile)
{
GdkLcmsColorState *result;
result = g_object_new (GDK_TYPE_LCMS_COLOR_STATE, NULL);
result->lcms_profile = lcms_profile;
return GDK_COLOR_STATE (result);
}
/**
* gdk_color_state_new_from_icc_profile:
* @icc_profile: The ICC profiles given as a `GBytes`
* @error: Return location for an error
*
* Creates a new color state for the given ICC profile data.
*
* if the profile is not valid, %NULL is returned and an error
* is raised.
*
* Returns: a new `GdkColorState` or %NULL on error
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_new_from_icc_profile (GBytes *icc_profile,
GError **error)
{
cmsHPROFILE lcms_profile;
const guchar *data;
gsize size;
g_return_val_if_fail (icc_profile != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
data = g_bytes_get_data (icc_profile, &size);
lcms_profile = cmsOpenProfileFromMem (data, size);
if (lcms_profile == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Failed to load ICC profile"));
return NULL;
}
return gdk_lcms_color_state_new_from_lcms_profile (lcms_profile);
}
cmsHPROFILE
gdk_lcms_color_state_get_lcms_profile (GdkColorState *self)
{
g_return_val_if_fail (GDK_IS_LCMS_COLOR_STATE (self), NULL);
return GDK_LCMS_COLOR_STATE (self)->lcms_profile;
}
typedef struct _GdkColorTransformCache GdkColorTransformCache;
struct _GdkColorTransformCache
{
GdkColorState *source;
guint source_type;
GdkColorState *dest;
guint dest_type;
};
static void
gdk_color_transform_cache_free (gpointer data)
{
g_free (data);
}
static guint
gdk_color_transform_cache_hash (gconstpointer data)
{
const GdkColorTransformCache *cache = data;
return g_direct_hash (cache->source) ^
(g_direct_hash (cache->dest) >> 2) ^
((cache->source_type << 16) | (cache->source_type >> 16)) ^
cache->dest_type;
}
static gboolean
gdk_color_transform_cache_equal (gconstpointer data1,
gconstpointer data2)
{
const GdkColorTransformCache *cache1 = data1;
const GdkColorTransformCache *cache2 = data2;
return cache1->source == cache2->source &&
cache1->source_type == cache2->source_type &&
cache1->dest == cache2->dest &&
cache1->dest_type == cache2->dest_type;
}
cmsHTRANSFORM *
gdk_lcms_color_state_lookup_transform (GdkColorState *source,
guint source_type,
GdkColorState *dest,
guint dest_type)
{
GdkColorTransformCache *entry;
static GHashTable *cache = NULL;
cmsHTRANSFORM *transform;
if (cache == NULL)
cache = g_hash_table_new_full (gdk_color_transform_cache_hash,
gdk_color_transform_cache_equal,
gdk_color_transform_cache_free,
cmsDeleteTransform);
transform = g_hash_table_lookup (cache,
&(GdkColorTransformCache) {
source, source_type,
dest, dest_type
});
if (G_UNLIKELY (transform == NULL && source && dest))
{
transform = cmsCreateTransform (gdk_lcms_color_state_get_lcms_profile (source),
source_type,
gdk_lcms_color_state_get_lcms_profile (dest),
dest_type,
INTENT_PERCEPTUAL,
cmsFLAGS_COPY_ALPHA);
entry = g_new (GdkColorTransformCache, 1);
*entry = (GdkColorTransformCache) {
source, source_type,
dest, dest_type
};
g_hash_table_insert (cache, entry, transform);
}
return transform;
}

View File

@@ -1,38 +0,0 @@
/* gdklcmscolorstate.h
*
* Copyright 2021 (c) Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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 "gdkcolorstateprivate.h"
#include <lcms2.h>
G_BEGIN_DECLS
#define GDK_TYPE_LCMS_COLOR_STATE (gdk_lcms_color_state_get_type ())
GDK_DECLARE_INTERNAL_TYPE (GdkLcmsColorState, gdk_lcms_color_state, GDK, LCMS_COLOR_STATE, GdkColorState)
GdkColorState * gdk_lcms_color_state_new_from_lcms_profile (cmsHPROFILE lcms_profile);
cmsHPROFILE gdk_lcms_color_state_get_lcms_profile (GdkColorState *color_state);
cmsHTRANSFORM * gdk_lcms_color_state_lookup_transform (GdkColorState *source,
guint source_type,
GdkColorState *dest,
guint dest_type);
G_END_DECLS

View File

@@ -23,9 +23,8 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkcolorstateprivate.h"
#include "gsk/gl/fp16private.h"
#include "gtk/gtkcolorutilsprivate.h"
#include <epoxy/gl.h>
@@ -1695,17 +1694,14 @@ void
gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryFormat dest_format,
GdkColorState *dest_color_state,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
GdkColorState *src_color_state,
gsize width,
gsize height)
{
const GdkMemoryFormatDescription *dest_desc = &memory_formats[dest_format];
const GdkMemoryFormatDescription *src_desc = &memory_formats[src_format];
GdkColorStateTransform *transform;
float *tmp;
gsize y;
void (*func) (guchar *, const guchar *, gsize) = NULL;
@@ -1713,8 +1709,7 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
if (gdk_color_state_equal (src_color_state, dest_color_state) &&
src_format == dest_format)
if (src_format == dest_format)
{
gsize bytes_per_row = src_desc->bytes_per_pixel * width;
@@ -1734,9 +1729,7 @@ gdk_memory_convert (guchar *dest_data,
return;
}
if (!gdk_color_state_equal (src_color_state, dest_color_state))
func = NULL;
else if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8a8_to_b8g8r8a8_premultiplied;
@@ -1784,31 +1777,15 @@ gdk_memory_convert (guchar *dest_data,
return;
}
if (!gdk_color_state_equal (src_color_state, dest_color_state))
transform = gdk_color_state_get_transform (src_color_state, dest_color_state, TRUE);
else
transform = NULL;
tmp = g_new (float, width * 4);
for (y = 0; y < height; y++)
{
src_desc->to_float (tmp, src_data, width);
if (transform)
{
if (src_desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED)
unpremultiply (tmp, width);
gdk_color_state_transform (transform, tmp, tmp, width);
if (dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
}
else
{
if (src_desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED && dest_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT)
unpremultiply (tmp, width);
else if (src_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT && dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
}
if (src_desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED && dest_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT)
unpremultiply (tmp, width);
else if (src_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT && dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
dest_desc->from_float (dest_data, tmp, width);
src_data += src_stride;
dest_data += dest_stride;

View File

@@ -80,11 +80,9 @@ guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryFormat dest_format,
GdkColorState *dest_color_state,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
GdkColorState *src_color_state,
gsize width,
gsize height);

View File

@@ -22,7 +22,6 @@
#include "gdkmemorytextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkcolorstate.h"
#include "gsk/gl/fp16private.h"
/**
@@ -59,7 +58,6 @@ gdk_memory_texture_dispose (GObject *object)
static void
gdk_memory_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -67,11 +65,9 @@ gdk_memory_texture_download (GdkTexture *texture,
gdk_memory_convert (data, stride,
format,
color_state,
(guchar *) g_bytes_get_data (self->bytes, NULL),
self->stride,
texture->format,
texture->color_state,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
}
@@ -135,7 +131,7 @@ gdk_memory_sanitize (GBytes *bytes,
* @bytes: the `GBytes` containing the pixel data
* @stride: rowstride for the data
*
* Creates a new texture for a blob of sRGB image data.
* Creates a new texture for a blob of image data.
*
* The `GBytes` must contain @stride × @height pixels
* in the given format.
@@ -148,43 +144,11 @@ gdk_memory_texture_new (int width,
GdkMemoryFormat format,
GBytes *bytes,
gsize stride)
{
return gdk_memory_texture_new_with_color_state (width, height, format,
gdk_color_state_get_srgb (),
bytes, stride);
}
/**
* gdk_memory_texture_new_with_color_state:
* @width: the width of the texture
* @height: the height of the texture
* @format: the format of the data
* @color_state: a `GdkColorSpace`
* @bytes: the `GBytes` containing the pixel data
* @stride: rowstride for the data
*
* Creates a new texture for a blob of image data with a given color state.
*
* The `GBytes` must contain @stride x @height pixels
* in the given format.
*
* Returns: A newly-created `GdkTexture`
*
* Since: 4.16
*/
GdkTexture *
gdk_memory_texture_new_with_color_state (int width,
int height,
GdkMemoryFormat format,
GdkColorState *color_state,
GBytes *bytes,
gsize stride)
{
GdkMemoryTexture *self;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (GDK_IS_COLOR_STATE (color_state), NULL);
g_return_val_if_fail (bytes != NULL, 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 */
@@ -195,7 +159,6 @@ gdk_memory_texture_new_with_color_state (int width,
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
"width", width,
"height", height,
"color-state", color_state,
NULL);
GDK_TEXTURE (self)->format = format;
@@ -228,19 +191,19 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
size = source->stride * (height - 1) + width * bpp;
bytes = g_bytes_new_from_bytes (source->bytes, offset, size);
result = gdk_memory_texture_new_with_color_state (width,
height,
texture->format,
texture->color_state,
bytes,
source->stride);
result = gdk_memory_texture_new (width,
height,
texture->format,
bytes,
source->stride);
g_bytes_unref (bytes);
return result;
}
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture)
gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
{
GdkTexture *result;
GBytes *bytes;
@@ -250,19 +213,23 @@ gdk_memory_texture_from_texture (GdkTexture *texture)
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
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);
gdk_texture_do_download (texture, texture->format, texture->color_state, data, stride);
gdk_texture_do_download (texture, format, data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new_with_color_state (texture->width,
texture->height,
texture->format,
texture->color_state,
bytes,
stride);
result = gdk_memory_texture_new (texture->width,
texture->height,
format,
bytes,
stride);
g_bytes_unref (bytes);
return GDK_MEMORY_TEXTURE (result);

View File

@@ -68,14 +68,6 @@ GdkTexture * gdk_memory_texture_new (int
GBytes *bytes,
gsize stride);
GDK_AVAILABLE_IN_4_16
GdkTexture * gdk_memory_texture_new_with_color_state (int width,
int height,
GdkMemoryFormat format,
GdkColorState *color_state,
GBytes *bytes,
gsize stride);
G_END_DECLS

View File

@@ -28,7 +28,8 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#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,
int x,
int y,

View File

@@ -1,282 +0,0 @@
/* gdknamedcolorstate.c
*
* Copyright 2024 (c) 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 "gdknamedcolorstateprivate.h"
#include <glib/gi18n-lib.h>
struct _GdkNamedColorState
{
GdkColorState parent_instance;
GdkColorStateId id;
};
struct _GdkNamedColorStateClass
{
GdkColorStateClass parent_class;
};
G_DEFINE_TYPE (GdkNamedColorState, gdk_named_color_state, GDK_TYPE_COLOR_STATE)
static gboolean
gdk_named_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
return ((GdkNamedColorState *) self)->id == ((GdkNamedColorState *) other)->id;
}
static GdkMemoryDepth
gdk_named_color_state_get_min_depth (GdkColorState *self)
{
switch (((GdkNamedColorState *) self)->id)
{
case GDK_COLOR_STATE_SRGB_LINEAR:
case GDK_COLOR_STATE_OKLAB:
case GDK_COLOR_STATE_OKLCH:
return GDK_MEMORY_U16;
case GDK_COLOR_STATE_SRGB:
case GDK_COLOR_STATE_HSL:
case GDK_COLOR_STATE_HWB:
return GDK_MEMORY_U8;
default:
g_assert_not_reached ();
}
}
static const char *
gdk_named_color_state_get_name (GdkColorState *self)
{
const char *names[] = {
"srgb", "srgb-linear", "hsl", "hwb", "oklab", "oklch"
};
return names[((GdkNamedColorState *) self)->id];
}
static void
gdk_named_color_state_dispose (GObject *object)
{
g_assert_not_reached ();
G_OBJECT_CLASS (gdk_named_color_state_parent_class)->dispose (object);
}
static void
gdk_named_color_state_class_init (GdkNamedColorStateClass *klass)
{
GdkColorStateClass *color_state_class = GDK_COLOR_STATE_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gdk_named_color_state_dispose;
color_state_class->equal = gdk_named_color_state_equal;
color_state_class->get_min_depth = gdk_named_color_state_get_min_depth;
color_state_class->get_name = gdk_named_color_state_get_name;
}
static void
gdk_named_color_state_init (GdkNamedColorState *self)
{
}
static GdkColorState *
gdk_named_color_state_new (GdkColorStateId id)
{
GdkNamedColorState *self;
self = g_object_new (GDK_TYPE_NAMED_COLOR_STATE, NULL);
self->id = id;
return (GdkColorState *) self;
}
/**
* gdk_color_state_get_srgb:
*
* Returns the object representing the sRGB color state.
*
* If you don't know anything about color states but need one for
* use with some function, this one is most likely the right one.
*
* Returns: (transfer none): the object for the sRGB color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb (void)
{
static GdkColorState *srgb_color_state;
if (g_once_init_enter (&srgb_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_SRGB);
g_assert (color_state);
g_once_init_leave (&srgb_color_state, color_state);
}
return srgb_color_state;
}
/**
* gdk_color_state_get_srgb_linear:
*
* Returns the object representing the linear sRGB color state.
*
* Returns: (transfer none): the object for the linear sRGB color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
static GdkColorState *srgb_linear_color_state;
if (g_once_init_enter (&srgb_linear_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_SRGB);
g_assert (color_state);
g_once_init_leave (&srgb_linear_color_state, color_state);
}
return srgb_linear_color_state;
}
/**
* gdk_color_state_get_hsl:
*
* Returns the object representing the HSL color state.
*
* Returns: (transfer none): the object for the HSL color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_hsl (void)
{
static GdkColorState *hsl_color_state;
if (g_once_init_enter (&hsl_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_HSL);
g_assert (color_state);
g_once_init_leave (&hsl_color_state, color_state);
}
return hsl_color_state;
}
/**
* gdk_color_state_get_hwb:
*
* Returns the object representing the HWB color state.
*
* Returns: (transfer none): the object for the HWB color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_hwb (void)
{
static GdkColorState *hwb_color_state;
if (g_once_init_enter (&hwb_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_HWB);
g_assert (color_state);
g_once_init_leave (&hwb_color_state, color_state);
}
return hwb_color_state;
}
/**
* gdk_color_state_get_oklab:
*
* Returns the object representing the OKLAB color state.
*
* Returns: (transfer none): the object for the OKLAB color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_oklab (void)
{
static GdkColorState *oklab_color_state;
if (g_once_init_enter (&oklab_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_OKLAB);
g_assert (color_state);
g_once_init_leave (&oklab_color_state, color_state);
}
return oklab_color_state;
}
/**
* gdk_color_state_get_oklcb:
*
* Returns the object representing the OKLCH color state.
*
* Returns: (transfer none): the object for the OKLCH color state.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_oklch (void)
{
static GdkColorState *oklch_color_state;
if (g_once_init_enter (&oklch_color_state))
{
GdkColorState *color_state;
color_state = gdk_named_color_state_new (GDK_COLOR_STATE_OKLCH);
g_assert (color_state);
g_once_init_leave (&oklch_color_state, color_state);
}
return oklch_color_state;
}
GdkColorStateId
gdk_named_color_state_get_id (GdkColorState *self)
{
return ((GdkNamedColorState *) self)->id;
}

View File

@@ -1,40 +0,0 @@
/* gdknamedscolorstate.h
*
* Copyright 2024 (c) 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/>.
*/
#pragma once
#include "gdkcolorstateprivate.h"
G_BEGIN_DECLS
#define GDK_TYPE_NAMED_COLOR_STATE (gdk_named_color_state_get_type ())
typedef enum {
GDK_COLOR_STATE_SRGB,
GDK_COLOR_STATE_SRGB_LINEAR,
GDK_COLOR_STATE_HSL,
GDK_COLOR_STATE_HWB,
GDK_COLOR_STATE_OKLAB,
GDK_COLOR_STATE_OKLCH,
} GdkColorStateId;
GDK_DECLARE_INTERNAL_TYPE (GdkNamedColorState, gdk_named_color_state, GDK, NAMED_COLOR_STATE, GdkColorState)
GdkColorStateId gdk_named_color_state_get_id (GdkColorState *self);
G_END_DECLS

View File

@@ -396,18 +396,10 @@ gboolean
*/
char *
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)
{
g_string_append_printf (string,
"rgb(%d,%d,%d)",
return g_strdup_printf ("rgb(%d,%d,%d)",
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->green, 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_string_append_printf (string,
"rgba(%d,%d,%d,%s)",
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.),
alpha);
}
return string;
}
static gboolean

View File

@@ -72,8 +72,5 @@ _gdk_rgba_equal (gconstpointer p1,
rgba1->alpha == rgba2->alpha;
}
GString * gdk_rgba_print (const GdkRGBA *rgba,
GString *string);
G_END_DECLS

View File

@@ -30,8 +30,6 @@
#include "gdksurface.h"
#include "gdkprivate.h"
#include "gdkcolorstate.h"
#include "gdkcairo.h"
#include "gdkcontentprovider.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h"
@@ -46,7 +44,6 @@
#include "gdktoplevelprivate.h"
#include "gdkvulkancontext.h"
#include "gdksubsurfaceprivate.h"
#include "gdkcolorstate.h"
#include <math.h>
@@ -92,7 +89,6 @@ enum {
enum {
PROP_0,
PROP_COLOR_STATE,
PROP_CURSOR,
PROP_DISPLAY,
PROP_FRAME_CLOCK,
@@ -488,8 +484,6 @@ gdk_surface_init (GdkSurface *surface)
surface->alpha = 255;
surface->color_state = g_object_ref (gdk_color_state_get_srgb ());
surface->device_cursor = g_hash_table_new_full (NULL, NULL,
NULL, g_object_unref);
@@ -534,25 +528,6 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
klass->get_scale = gdk_surface_real_get_scale;
klass->create_subsurface = gdk_surface_real_create_subsurface;
/**
* GdkSurface:color-state: (attributes org.gtk.Property.get=gdk_surface_get_color_state)
*
* The preferred color state for rendering to the surface
*
* This color state is negotiated between GTK and the compositor.
*
* The color state may change as the surface gets moved around - for example
* to different monitors or when the compositor gets reconfigured. As long as
* the surface isn't shown, the color space may not represent the actual color
* state that is going to be used.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_object ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* GdkSurface:cursor: (attributes org.gtk.Property.get=gdk_surface_get_cursor org.gtk.Property.set=gdk_surface_set_cursor)
*
@@ -811,10 +786,6 @@ gdk_surface_set_property (GObject *object,
switch (prop_id)
{
case PROP_COLOR_STATE:
gdk_surface_set_color_state (surface, g_value_get_object (value));
break;
case PROP_CURSOR:
gdk_surface_set_cursor (surface, g_value_get_object (value));
break;
@@ -848,10 +819,6 @@ gdk_surface_get_property (GObject *object,
switch (prop_id)
{
case PROP_COLOR_STATE:
g_value_set_object (value, gdk_surface_get_color_state (surface));
break;
case PROP_CURSOR:
g_value_set_object (value, gdk_surface_get_cursor (surface));
break;
@@ -2363,7 +2330,6 @@ gdk_surface_create_similar_surface (GdkSurface *surface,
content == CAIRO_CONTENT_ALPHA ? CAIRO_FORMAT_A8 : CAIRO_FORMAT_ARGB32,
width * scale, height * scale);
cairo_surface_set_device_scale (similar_surface, scale, scale);
gdk_cairo_surface_set_color_state (similar_surface, gdk_surface_get_color_state (surface));
return similar_surface;
}
@@ -3110,37 +3076,3 @@ gdk_surface_get_subsurface (GdkSurface *surface,
{
return g_ptr_array_index (surface->subsurfaces, idx);
}
void
gdk_surface_set_color_state (GdkSurface *surface,
GdkColorState *color_state)
{
/* This way we support unsetting, too */
if (G_UNLIKELY (gdk_display_get_debug_flags (surface->display) & GDK_DEBUG_SRGB))
color_state = gdk_color_state_get_srgb ();
if (gdk_color_state_equal (surface->color_state, color_state))
return;
g_set_object (&surface->color_state, color_state);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_COLOR_STATE]);
}
/**
* gdk_surface_get_color_state:
* @self: a `GdkSurface`
*
* Returns the preferred color state for rendering to the given @surface.
*
* Returns: (transfer none): The color state of @surface
*
* Since: 4.16
*/
GdkColorState *
gdk_surface_get_color_state (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), gdk_color_state_get_srgb ());
return surface->color_state;
}

View File

@@ -139,9 +139,6 @@ GdkVulkanContext *
gdk_surface_create_vulkan_context(GdkSurface *surface,
GError **error);
GDK_AVAILABLE_IN_4_16
GdkColorState *gdk_surface_get_color_state (GdkSurface *surface);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GdkSurface, g_object_unref)
G_END_DECLS

View File

@@ -105,8 +105,6 @@ struct _GdkSurface
*/
GdkSubsurface *subsurfaces_above;
GdkSubsurface *subsurfaces_below;
GdkColorState *color_state;
};
struct _GdkSurfaceClass
@@ -357,7 +355,4 @@ gsize gdk_surface_get_n_subsurfaces (GdkSurface *surface);
GdkSubsurface * gdk_surface_get_subsurface (GdkSurface *surface,
gsize idx);
void gdk_surface_set_color_state (GdkSurface *surface,
GdkColorState *color_state);
G_END_DECLS

View File

@@ -44,21 +44,12 @@
#include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h"
#include "gdksnapshot.h"
#include "gdkcolorstate.h"
#include "gdkcairo.h"
#include <graphene.h>
#include "loaders/gdkpngprivate.h"
#include "loaders/gdktiffprivate.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)
/* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
@@ -71,7 +62,6 @@ enum {
PROP_0,
PROP_WIDTH,
PROP_HEIGHT,
PROP_COLOR_STATE,
N_PROPS
};
@@ -261,7 +251,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkTexture, gdk_texture, G_TYPE_OBJECT,
static void
gdk_texture_default_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -286,10 +275,6 @@ gdk_texture_set_property (GObject *gobject,
self->height = g_value_get_int (value);
break;
case PROP_COLOR_STATE:
g_set_object (&self->color_state, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -314,10 +299,6 @@ gdk_texture_get_property (GObject *gobject,
g_value_set_int (value, self->height);
break;
case PROP_COLOR_STATE:
g_value_set_object (value, self->color_state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -356,8 +337,6 @@ gdk_texture_dispose (GObject *object)
gdk_texture_clear_render_data (self);
g_clear_object (&self->color_state);
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
}
@@ -402,28 +381,12 @@ gdk_texture_class_init (GdkTextureClass *klass)
G_PARAM_STATIC_STRINGS |
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_object ("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);
}
static void
gdk_texture_init (GdkTexture *self)
{
self->color_state = g_object_ref (gdk_color_state_get_srgb ());
}
/**
@@ -454,42 +417,17 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
(GDestroyNotify) cairo_surface_destroy,
cairo_surface_reference (surface));
texture = gdk_memory_texture_new_with_color_state (cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface),
GDK_MEMORY_DEFAULT,
gdk_cairo_surface_get_color_state (surface),
bytes,
cairo_image_surface_get_stride (surface));
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface),
GDK_MEMORY_DEFAULT,
bytes,
cairo_image_surface_get_stride (surface));
g_bytes_unref (bytes);
return texture;
}
static GdkColorState *
gdk_color_state_from_pixbuf (GdkPixbuf *pixbuf)
{
const char *icc_profile_base64;
GdkColorState *color_state = NULL;
icc_profile_base64 = gdk_pixbuf_get_option (pixbuf, "icc-profile");
if (icc_profile_base64)
{
guchar *icc_data;
gsize icc_len;
GBytes *bytes;
icc_data = g_base64_decode (icc_profile_base64, &icc_len);
bytes = g_bytes_new_take (icc_data, icc_len);
color_state = gdk_color_state_new_from_icc_profile (bytes, NULL);
g_bytes_unref (bytes);
}
if (!color_state)
color_state = g_object_ref (gdk_color_state_get_srgb ());
return color_state;
}
/**
* gdk_texture_new_for_pixbuf:
* @pixbuf: a `GdkPixbuf`
@@ -507,31 +445,24 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
{
GdkTexture *texture;
GBytes *bytes;
GdkColorState *color_state;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
color_state = gdk_color_state_from_pixbuf (pixbuf);
bytes = g_bytes_new_with_free_func (gdk_pixbuf_get_pixels (pixbuf),
gdk_pixbuf_get_height (pixbuf)
* (gsize) gdk_pixbuf_get_rowstride (pixbuf),
g_object_unref,
g_object_ref (pixbuf));
texture = gdk_memory_texture_new_with_color_state (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf)
? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE,
color_state,
bytes,
gdk_pixbuf_get_rowstride (pixbuf));
texture = gdk_memory_texture_new (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf)
? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE,
bytes,
gdk_pixbuf_get_rowstride (pixbuf));
g_bytes_unref (bytes);
g_object_unref (color_state);
return texture;
}
@@ -789,32 +720,13 @@ gdk_texture_get_height (GdkTexture *texture)
return texture->height;
}
/**
* gdk_texture_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @texture: a `GdkTexture`
*
* Returns the color state associsated with @texture.
*
* Returns: (transfer none): the color state of the `GdkTexture`
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_get_color_state (GdkTexture *texture)
{
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
return texture->color_state;
}
void
gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, color_state, data, stride);
GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, data, stride);
}
static gboolean
@@ -910,8 +822,7 @@ gdk_texture_set_diff (GdkTexture *self,
}
cairo_surface_t *
gdk_texture_download_surface (GdkTexture *texture,
GdkColorState *color_state)
gdk_texture_download_surface (GdkTexture *texture)
{
cairo_surface_t *surface;
cairo_status_t surface_status;
@@ -923,13 +834,10 @@ gdk_texture_download_surface (GdkTexture *texture,
if (surface_status != CAIRO_STATUS_SUCCESS)
g_warning ("%s: surface error: %s", __FUNCTION__,
cairo_status_to_string (surface_status));
else
gdk_texture_do_download (texture,
GDK_MEMORY_DEFAULT,
color_state,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
gdk_texture_download (texture,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
cairo_surface_mark_dirty (surface);
return surface;
@@ -976,7 +884,6 @@ gdk_texture_download (GdkTexture *texture,
gdk_texture_do_download (texture,
GDK_MEMORY_DEFAULT,
gdk_color_state_get_srgb (),
data,
stride);
}

View File

@@ -83,9 +83,6 @@ int gdk_texture_get_height (GdkTexture
GDK_AVAILABLE_IN_4_10
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
void gdk_texture_download (GdkTexture *texture,
guchar *data,

View File

@@ -39,7 +39,6 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
#include "gdkcolorstate.h"
G_DEFINE_BOXED_TYPE (GdkTextureDownloader, gdk_texture_downloader,
gdk_texture_downloader_copy,
@@ -52,14 +51,12 @@ gdk_texture_downloader_init (GdkTextureDownloader *self,
{
self->texture = g_object_ref (texture);
self->format = GDK_MEMORY_DEFAULT;
self->color_state = g_object_ref (gdk_color_state_get_srgb ());
}
void
gdk_texture_downloader_finish (GdkTextureDownloader *self)
{
g_object_unref (self->texture);
g_object_unref (self->color_state);
}
/**
@@ -106,7 +103,6 @@ gdk_texture_downloader_copy (const GdkTextureDownloader *self)
copy = gdk_texture_downloader_new (self->texture);
gdk_texture_downloader_set_format (copy, self->format);
gdk_texture_downloader_set_color_state (copy, self->color_state);
return copy;
}
@@ -125,8 +121,6 @@ gdk_texture_downloader_free (GdkTextureDownloader *self)
g_return_if_fail (self != NULL);
gdk_texture_downloader_finish (self);
g_clear_object (&self->color_state);
g_free (self);
}
@@ -205,38 +199,6 @@ gdk_texture_downloader_get_format (const GdkTextureDownloader *self)
return self->format;
}
/**
* gdk_texture_downloader_set_color_state:
* @self: a texture downloader
* @color_state: the color state to use
*
* Sets the color state that the data will be converted to.
*
* Since: 4.16
*/
void
gdk_texture_downloader_set_color_state (GdkTextureDownloader *self,
GdkColorState *color_state)
{
g_set_object (&self->color_state, color_state);
}
/**
* gdk_texture_downloader_get_color_state:
* @self: a texture downloader
*
* Gets the color state that the data will be converted to.
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_downloader_get_color_state (const GdkTextureDownloader *self)
{
return self->color_state;
}
/**
* gdk_texture_downloader_download_into:
* @self: a texture downloader
@@ -257,7 +219,7 @@ gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (self->texture) * gdk_memory_format_bytes_per_pixel (self->format));
gdk_texture_do_download (self->texture, self->format, self->color_state, data, stride);
gdk_texture_do_download (self->texture, self->format, data, stride);
}
/**
@@ -288,8 +250,7 @@ gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
g_return_val_if_fail (out_stride != NULL, NULL);
if (GDK_IS_MEMORY_TEXTURE (self->texture) &&
gdk_texture_get_format (self->texture) == self->format &&
gdk_color_state_equal (self->texture->color_state, self->color_state))
gdk_texture_get_format (self->texture) == self->format)
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (self->texture);
@@ -299,7 +260,7 @@ gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
stride = self->texture->width * gdk_memory_format_bytes_per_pixel (self->format);
data = g_malloc_n (stride, self->texture->height);
gdk_texture_do_download (self->texture, self->format, self->color_state, data, stride);
gdk_texture_do_download (self->texture, self->format, data, stride);
*out_stride = stride;
return g_bytes_new_take (data, stride * self->texture->height);

View File

@@ -49,12 +49,6 @@ void gdk_texture_downloader_set_format (GdkTextureDownl
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_downloader_get_format (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_16
void gdk_texture_downloader_set_color_state (GdkTextureDownloader *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_texture_downloader_get_color_state (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_download_into (const GdkTextureDownloader *self,

View File

@@ -28,7 +28,6 @@ struct _GdkTextureDownloader
/*< private >*/
GdkTexture *texture;
GdkMemoryFormat format;
GdkColorState *color_state;
};
void gdk_texture_downloader_init (GdkTextureDownloader *self,

View File

@@ -26,8 +26,6 @@ struct _GdkTexture
int width;
int height;
GdkColorState *color_state;
gpointer render_key;
gpointer render_data;
GDestroyNotify render_notify;
@@ -48,7 +46,6 @@ struct _GdkTextureClass {
/* mandatory: Download in the given format into data */
void (* download) (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
};
@@ -56,12 +53,10 @@ struct _GdkTextureClass {
gboolean gdk_texture_can_load (GBytes *bytes);
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture,
GdkColorState *color_state);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture);
void gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
void gdk_texture_diff (GdkTexture *self,

View File

@@ -767,6 +767,9 @@ gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
* This function asynchronously obtains a handle for a toplevel surface
* 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
* exported.
*

View File

@@ -118,12 +118,9 @@ typedef enum
/**
* GdkTitlebarGesture:
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK: double click gesture
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK: right click gesture
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK: middle click gesture
*
* The kind of title bar gesture to emit with
* [method@Gdk.Toplevel.titlebar_gesture].
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
*
* Since: 4.4
*/

View File

@@ -74,7 +74,6 @@ typedef cairo_rectangle_int_t GdkRectangle;
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
typedef struct _GdkColorState GdkColorState;
typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;

View File

@@ -94,13 +94,6 @@ enum {
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)
static guint signals[LAST_SIGNAL] = { 0 };
@@ -614,8 +607,7 @@ physical_device_check_features (VkPhysicalDevice device)
features |= GDK_VULKAN_FEATURE_YCBCR;
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_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
features |= GDK_VULKAN_FEATURE_DMABUF;
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
@@ -1525,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_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_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
@@ -1866,9 +1857,8 @@ gdk_display_unref_vulkan (GdkDisplay *display)
{
g_free (key);
vkDestroyShaderModule (display->vk_device,
*((VkShaderModule *)value),
value,
NULL);
g_free (value);
}
g_hash_table_unref (display->vk_shader_modules);
@@ -1996,13 +1986,13 @@ VkShaderModule
gdk_display_get_vk_shader_module (GdkDisplay *self,
const char *resource_name)
{
VkShaderModule *shader;
VkShaderModule shader;
GError *error = NULL;
GBytes *bytes;
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
if (shader)
return *shader;
return shader;
bytes = g_resources_lookup_data (resource_name, 0, &error);
if (bytes == NULL)
@@ -2012,7 +2002,6 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
return VK_NULL_HANDLE;
}
shader = g_new0 (VkShaderModule, 1);
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
&(VkShaderModuleCreateInfo) {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
@@ -2020,20 +2009,18 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
},
NULL,
shader) == VK_SUCCESS)
&shader) == VK_SUCCESS)
{
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
}
else
{
g_free (shader);
return VK_NULL_HANDLE;
shader = VK_NULL_HANDLE;
}
g_bytes_unref (bytes);
return *shader;
return shader;
}
#else /* GDK_RENDERING_VULKAN */

View File

@@ -24,8 +24,6 @@
#include <glib/gi18n-lib.h>
#include "gdktexture.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkcolorstate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkprofilerprivate.h"
@@ -145,12 +143,9 @@ gdk_load_jpeg (GBytes *input_bytes,
guint width, height, stride;
unsigned char *data = NULL;
unsigned char *row[1];
JOCTET *icc_data;
unsigned int icc_len;
GBytes *bytes;
GdkTexture *texture;
GdkMemoryFormat format;
GdkColorState *color_state;
G_GNUC_UNUSED guint64 before = GDK_PROFILER_CURRENT_TIME;
info.err = jpeg_std_error (&jerr.pub);
@@ -174,9 +169,6 @@ gdk_load_jpeg (GBytes *input_bytes,
g_bytes_get_data (input_bytes, NULL),
g_bytes_get_size (input_bytes));
/* save color space */
jpeg_save_markers (&info, JPEG_APP0 + 2, 0xFFFF);
jpeg_read_header (&info, TRUE);
jpeg_start_decompress (&info);
@@ -234,35 +226,19 @@ gdk_load_jpeg (GBytes *input_bytes,
g_assert_not_reached ();
}
if (jpeg_read_icc_profile (&info, &icc_data, &icc_len))
{
GBytes *icc_bytes = g_bytes_new_with_free_func (icc_data, icc_len, free, icc_data);
color_state = gdk_color_state_new_from_icc_profile (icc_bytes, error);
g_bytes_unref (icc_bytes);
}
else
color_state = g_object_ref (gdk_color_state_get_srgb ());
jpeg_finish_decompress (&info);
jpeg_destroy_decompress (&info);
bytes = g_bytes_new_take (data, stride * height);
if (color_state)
{
texture = gdk_memory_texture_new_with_color_state (width, height,
format,
color_state,
bytes, stride);
}
else
texture = NULL;
texture = gdk_memory_texture_new (width, height,
format,
bytes, stride);
g_clear_object (&color_state);
g_bytes_unref (bytes);
gdk_profiler_end_mark (before, "Load jpeg", NULL);
return texture;
}
@@ -281,12 +257,9 @@ gdk_save_jpeg (GdkTexture *texture)
gsize texstride;
guchar *row;
int width, height;
GdkColorState *color_state;
GBytes *bytes;
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
color_state = gdk_texture_get_color_state (texture);
info.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = fatal_error_handler;
@@ -325,15 +298,6 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_start_compress (&info, TRUE);
bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
if (bytes)
{
jpeg_write_icc_profile (&info,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
}
while (info.next_scanline < info.image_height)
{
row = (guchar *) texdata + info.next_scanline * texstride;

View File

@@ -20,15 +20,11 @@
#include "gdkpngprivate.h"
#include <glib/gi18n-lib.h>
#include "gdkcolorstateprivate.h"
#include "gdklcmscolorstateprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gsk/gl/fp16private.h"
#include <lcms2.h>
#include <png.h>
#include <stdio.h>
@@ -130,105 +126,6 @@ png_simple_warning_callback (png_structp png,
{
}
/* }}} */
/* {{{ Color profile handling */
static GdkColorState *
gdk_png_get_color_state (png_struct *png,
png_info *info)
{
GdkColorState *color_state;
guchar *icc_data;
png_uint_32 icc_len;
char *name;
double gamma;
cmsCIExyY whitepoint;
cmsCIExyYTRIPLE primaries;
cmsToneCurve *curve;
cmsHPROFILE lcms_profile;
int intent;
if (png_get_sRGB (png, info, &intent))
return g_object_ref (gdk_color_state_get_srgb ());
if (png_get_iCCP (png, info, &name, NULL, &icc_data, &icc_len))
{
GBytes *bytes = g_bytes_new (icc_data, icc_len);
color_state = gdk_color_state_new_from_icc_profile (bytes, NULL);
g_bytes_unref (bytes);
if (color_state)
return color_state;
}
/* If neither of those is valid, the result is sRGB */
if (!png_get_valid (png, info, PNG_INFO_gAMA) &&
!png_get_valid (png, info, PNG_INFO_cHRM))
return g_object_ref (gdk_color_state_get_srgb ());
if (!png_get_gAMA (png, info, &gamma))
gamma = 2.4;
if (!png_get_cHRM (png, info,
&whitepoint.x, &whitepoint.y,
&primaries.Red.x, &primaries.Red.y,
&primaries.Green.x, &primaries.Green.y,
&primaries.Blue.x, &primaries.Blue.y))
{
if (gamma == 2.4)
return g_object_ref (gdk_color_state_get_srgb ());
whitepoint = (cmsCIExyY) { 0.3127, 0.3290, 1.0 };
primaries = (cmsCIExyYTRIPLE) {
{ 0.6400, 0.3300, 1.0 },
{ 0.3000, 0.6000, 1.0 },
{ 0.1500, 0.0600, 1.0 }
};
}
else
{
primaries.Red.Y = 1.0;
primaries.Green.Y = 1.0;
primaries.Blue.Y = 1.0;
}
curve = cmsBuildGamma (NULL, 1.0 / gamma);
lcms_profile = cmsCreateRGBProfile (&whitepoint,
&primaries,
(cmsToneCurve*[3]) { curve, curve, curve });
color_state = gdk_lcms_color_state_new_from_lcms_profile (lcms_profile);
/* FIXME: errors? */
if (color_state == NULL)
color_state = g_object_ref (gdk_color_state_get_srgb ());
cmsFreeToneCurve (curve);
return color_state;
}
static void
gdk_png_set_color_state (png_struct *png,
png_info *info,
GdkColorState *color_state)
{
/* FIXME: allow deconstructing RGB profiles into gAMA and cHRM
* instead of falling back to iCCP
*/
if (color_state == gdk_color_state_get_srgb ())
{
png_set_sRGB_gAMA_and_cHRM (png, info, /* FIXME */ PNG_sRGB_INTENT_PERCEPTUAL);
}
else
{
GBytes *bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
png_set_iCCP (png, info,
"ICC profile",
0,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
}
}
/* }}} */
/* {{{ Public API */
@@ -250,7 +147,6 @@ gdk_load_png (GBytes *bytes,
guchar *buffer = NULL;
guchar **row_pointers = NULL;
GBytes *out_bytes;
GdkColorState *color_state;
GdkTexture *texture;
int bpp;
G_GNUC_UNUSED gint64 before = GDK_PROFILER_CURRENT_TIME;
@@ -370,8 +266,6 @@ gdk_load_png (GBytes *bytes,
return NULL;
}
color_state = gdk_png_get_color_state (png, info);
bpp = gdk_memory_format_bytes_per_pixel (format);
if (!g_size_checked_mul (&stride, width, bpp) ||
!g_size_checked_add (&stride, stride, (8 - stride % 8) % 8))
@@ -387,7 +281,6 @@ gdk_load_png (GBytes *bytes,
if (!buffer || !row_pointers)
{
g_object_unref (color_state);
g_free (buffer);
g_free (row_pointers);
png_destroy_read_struct (&png, &info, NULL);
@@ -404,11 +297,8 @@ gdk_load_png (GBytes *bytes,
png_read_end (png, info);
out_bytes = g_bytes_new_take (buffer, height * stride);
texture = gdk_memory_texture_new_with_color_state (width, height,
format, color_state,
out_bytes, stride);
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
g_bytes_unref (out_bytes);
g_object_unref (color_state);
if (options && png_get_text (png, info, &text, &num_texts))
{
@@ -447,13 +337,11 @@ gdk_save_png (GdkTexture *texture)
GBytes *bytes;
gsize stride;
const guchar *data;
GdkColorState *color_state;
int png_format;
int depth;
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
color_state = gdk_texture_get_color_state (texture);
format = gdk_texture_get_format (texture);
switch (format)
@@ -577,8 +465,6 @@ gdk_save_png (GdkTexture *texture)
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
gdk_png_set_color_state (png, info, color_state);
png_write_info (png, info);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN

View File

@@ -24,7 +24,6 @@
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkcolorstate.h"
#include <tiffio.h>
@@ -220,44 +219,6 @@ tiff_open_write (GBytes **result)
NULL, NULL);
}
/* }}} */
/* {{{ Color profile handling */
static GdkColorState *
gdk_tiff_get_color_state (TIFF *tiff)
{
const char *icc_data;
guint icc_len;
if (TIFFGetField (tiff, TIFFTAG_ICCPROFILE, &icc_len, &icc_data))
{
GBytes *icc_bytes;
GdkColorState *color_state;
icc_bytes = g_bytes_new (icc_data, icc_len);
color_state = gdk_color_state_new_from_icc_profile (icc_bytes, NULL);
g_bytes_unref (icc_bytes);
if (color_state)
return color_state;
}
return g_object_ref (gdk_color_state_get_srgb ());
}
static void
gdk_tiff_set_color_state (TIFF *tiff,
GdkColorState *color_state)
{
GBytes *bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
TIFFSetField (tiff, TIFFTAG_ICCPROFILE,
g_bytes_get_size (bytes),
g_bytes_get_data (bytes, NULL));
g_bytes_unref (bytes);
}
/* }}} */
/* {{{ Public API */
@@ -321,7 +282,6 @@ gdk_save_tiff (GdkTexture *texture)
GBytes *bytes, *result = NULL;
GdkTextureDownloader downloader;
GdkMemoryFormat format;
GdkColorState *color_state;
const FormatData *fdata = NULL;
tif = tiff_open_write (&result);
@@ -329,7 +289,6 @@ gdk_save_tiff (GdkTexture *texture)
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
format = gdk_texture_get_format (texture);
color_state = gdk_texture_get_color_state (texture);
fdata = &format_data[format];
if (fdata == NULL)
@@ -349,8 +308,6 @@ gdk_save_tiff (GdkTexture *texture)
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
gdk_tiff_set_color_state (tif, color_state);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, fdata->format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
@@ -387,7 +344,6 @@ load_fallback (TIFF *tif,
int width, height;
guchar *data;
GBytes *bytes;
GdkColorState *color_state;
GdkTexture *texture;
TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &width);
@@ -404,15 +360,12 @@ load_fallback (TIFF *tif,
return NULL;
}
color_state = gdk_tiff_get_color_state (tif);
bytes = g_bytes_new_take (data, width * height * 4);
texture = gdk_memory_texture_new_with_color_state (width, height,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
color_state,
bytes,
width * 4);
texture = gdk_memory_texture_new (width, height,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
bytes,
width * 4);
g_bytes_unref (bytes);
@@ -437,7 +390,6 @@ gdk_load_tiff (GBytes *input_bytes,
gsize stride;
int bpp;
GBytes *bytes;
GdkColorState *color_state;
GdkTexture *texture;
G_GNUC_UNUSED gint64 before = GDK_PROFILER_CURRENT_TIME;
@@ -538,16 +490,13 @@ gdk_load_tiff (GBytes *input_bytes,
line += stride;
}
color_state = gdk_tiff_get_color_state (tif);
bpp = gdk_memory_format_bytes_per_pixel (format);
bytes = g_bytes_new_take (data, width * height * bpp);
texture = gdk_memory_texture_new_with_color_state (width, height,
format, color_state,
bytes, width * bpp);
texture = gdk_memory_texture_new (width, height,
format,
bytes, width * bpp);
g_bytes_unref (bytes);
g_object_unref (color_state);
TIFFClose (tif);

View File

@@ -96,12 +96,12 @@ _gdk_macos_drag_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (self, window);
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setDecorated:NO];
_gdk_macos_surface_set_native (self, window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);

View File

@@ -52,7 +52,6 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
GdkRectangle bounds;
GdkRectangle final_rect;
int x, y;
int shadow_left, shadow_right, shadow_top, shadow_bottom;
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
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));
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),
width,
height,
shadow_left,
shadow_right,
shadow_top,
shadow_bottom,
0, 0, 0, 0, /* shadow-left/right/top/bottom */
monitor,
&bounds,
self->layout,
@@ -316,14 +306,14 @@ _gdk_macos_popup_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setDecorated:NO];
[window setExcludedFromWindowsMenu:YES];
[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_END_MACOS_ALLOC_POOL;

View File

@@ -591,11 +591,11 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
/* Allow NSWindow to go fullscreen */
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);

View File

@@ -6,10 +6,6 @@ gdk_public_sources = files([
'gdkcairo.c',
'gdkcairocontext.c',
'gdkclipboard.c',
'gdkcolor.c',
'gdkcolorstate.c',
'gdklcmscolorstate.c',
'gdknamedcolorstate.c',
'gdkcontentdeserializer.c',
'gdkcontentformats.c',
'gdkcontentprovider.c',
@@ -79,7 +75,6 @@ gdk_public_headers = files([
'gdkcairo.h',
'gdkcairocontext.h',
'gdkclipboard.h',
'gdkcolorstate.h',
'gdkcontentdeserializer.h',
'gdkcontentformats.h',
'gdkcontentprovider.h',
@@ -133,8 +128,8 @@ install_headers(gdk_deprecated_headers, subdir: 'gtk-4.0/gdk/deprecated')
gdk_sources = gdk_public_sources + gdk_deprecated_sources
gdk_private_h_sources = files([
'gdkdevicetoolprivate.h',
'gdkeventsprivate.h',
'gdkdevicetoolprivate.h',
'gdkhslaprivate.h',
'gdkmonitorprivate.h',
'gdkseatdefaultprivate.h',
@@ -229,7 +224,6 @@ gdk_deps = [
fontconfig_dep,
platform_gio_dep,
pangocairo_dep,
lcms2_dep,
vulkan_dep,
libdrm_dep,
png_dep,

View File

@@ -158,9 +158,6 @@ gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
else
self->paint_surface = gdk_wayland_cairo_context_create_surface (self);
gdk_cairo_surface_set_color_state (self->paint_surface,
gdk_surface_get_color_state (gdk_draw_context_get_surface (draw_context)));
surface_region = gdk_wayland_cairo_context_surface_get_region (self->paint_surface);
if (surface_region)
cairo_region_union (region, surface_region);

View File

@@ -165,29 +165,25 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
double *scale)
{
GdkTexture *texture;
int desired_scale_factor;
desired_scale_factor = (int) ceil (desired_scale);
if (gdk_cursor_get_name (cursor))
{
struct wl_cursor *c;
int scale_factor;
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
{
*hotspot_x = *hotspot_y = 0;
*width = *height = 0;
*scale = 1;
return NULL;
}
scale_factor = (int) ceil (desired_scale);
goto none;
c = gdk_wayland_cursor_load_for_name (display,
display->cursor_theme,
scale_factor,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale_factor,
gdk_cursor_get_name (cursor));
if (c && c->image_count > 0)
{
struct wl_cursor_image *image;
int cursor_scale;
if (image_index >= c->image_count)
{
@@ -199,23 +195,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
image = c->images[image_index];
*width = display->cursor_theme_size;
*height = display->cursor_theme_size;
*scale = image->width / (double) *width;
*hotspot_x = image->hotspot_x / scale_factor;
*hotspot_y = image->hotspot_y / scale_factor;
if (*scale != scale_factor && !use_viewporter)
cursor_scale = desired_scale_factor;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
{
g_warning (G_STRLOC " cursor image size (%d) not an integer "
"multiple of theme size (%d)", image->width, *width);
*width = image->width;
*height = image->height;
*hotspot_x = image->hotspot_x;
*hotspot_y = image->hotspot_y;
*scale = 1;
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
cursor_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);
}
}
@@ -261,7 +257,7 @@ from_texture:
else
{
if (!use_viewporter)
*scale = ceil (desired_scale);
*scale = desired_scale_factor;
else
*scale = desired_scale;
@@ -298,23 +294,28 @@ from_texture:
}
if (gdk_cursor_get_fallback (cursor))
{
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
}
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
else
{
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
goto from_texture;
}
g_assert_not_reached ();
none:
*hotspot_x = 0;
*hotspot_y = 0;
*width = 0;
*height = 0;
*scale = 1;
return NULL;
}
guint

View File

@@ -97,7 +97,6 @@
#define OUTPUT_VERSION_WITH_DONE 2
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
#define OUTPUT_VERSION 3
#define XDG_WM_DIALOG_VERSION 1
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
#define XDG_WM_BASE_VERSION 6
@@ -383,13 +382,6 @@ gdk_registry_handle_global (void *data,
{
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)
{
display_wayland->gtk_shell =

View File

@@ -41,7 +41,6 @@
#include <gdk/wayland/viewporter-client-protocol.h>
#include <gdk/wayland/presentation-time-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 <gdk/gdkkeys.h>
@@ -103,7 +102,6 @@ struct _GdkWaylandDisplay
DmabufFormatsInfo *dmabuf_formats_info;
struct xdg_wm_base *xdg_wm_base;
struct zxdg_shell_v6 *zxdg_shell_v6;
struct xdg_wm_dialog_v1 *xdg_wm_dialog;
struct gtk_shell1 *gtk_shell;
struct wl_data_device_manager *data_device_manager;
struct wl_subcompositor *subcompositor;

View File

@@ -3866,25 +3866,9 @@ pointer_surface_leave (void *data,
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 = {
pointer_surface_enter,
pointer_surface_leave,
pointer_surface_preferred_buffer_scale,
pointer_surface_preferred_buffer_transform,
pointer_surface_leave
};
static void

View File

@@ -37,7 +37,6 @@
#include <wayland/presentation-time-client-protocol.h>
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
#include <wayland/xdg-dialog-v1-client-protocol.h>
#include <stdlib.h>
#include <stdio.h>
@@ -85,7 +84,6 @@ struct _GdkWaylandToplevel
struct gtk_surface1 *gtk_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_v6 *zxdg_toplevel_v6;
struct xdg_dialog_v1 *xdg_dialog;
} display_server;
GdkWaylandToplevel *transient_for;
@@ -207,7 +205,6 @@ gdk_wayland_toplevel_clear_saved_size (GdkWaylandToplevel *toplevel)
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandToplevel *wayland_toplevel);
static void maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel);
static gboolean maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel);
static void
gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
@@ -218,7 +215,6 @@ gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
g_clear_pointer (&toplevel->display_server.xdg_toplevel, xdg_toplevel_destroy);
g_clear_pointer (&toplevel->display_server.zxdg_toplevel_v6, zxdg_toplevel_v6_destroy);
g_clear_pointer (&toplevel->display_server.xdg_dialog, xdg_dialog_v1_destroy);
if (toplevel->display_server.gtk_surface)
{
@@ -881,8 +877,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *wayland_toplevel)
gdk_wayland_toplevel_set_application_id (GDK_TOPLEVEL (wayland_toplevel), app_id);
maybe_set_gtk_surface_dbus_properties (wayland_toplevel);
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
maybe_set_gtk_surface_modal (wayland_toplevel);
maybe_set_gtk_surface_modal (wayland_toplevel);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
wl_surface_commit (wayland_surface->display_server.wl_surface);
@@ -1094,40 +1089,12 @@ maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel)
}
static gboolean
maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel)
{
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (wayland_toplevel)));
if (!display_wayland->xdg_wm_dialog)
return FALSE;
if (!is_realized_toplevel (GDK_WAYLAND_SURFACE (wayland_toplevel)))
return FALSE;
if (!wayland_toplevel->display_server.xdg_dialog)
{
wayland_toplevel->display_server.xdg_dialog =
xdg_wm_dialog_v1_get_xdg_dialog (display_wayland->xdg_wm_dialog,
wayland_toplevel->display_server.xdg_toplevel);
}
if (GDK_SURFACE (wayland_toplevel)->modal_hint)
xdg_dialog_v1_set_modal (wayland_toplevel->display_server.xdg_dialog);
else
xdg_dialog_v1_unset_modal (wayland_toplevel->display_server.xdg_dialog);
return TRUE;
}
static void
gdk_wayland_toplevel_set_modal_hint (GdkWaylandToplevel *wayland_toplevel,
gboolean modal)
{
GDK_SURFACE (wayland_toplevel)->modal_hint = modal;
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
maybe_set_gtk_surface_modal (wayland_toplevel);
maybe_set_gtk_surface_modal (wayland_toplevel);
}
void

View File

@@ -48,133 +48,36 @@ gdk_wayland_deps = [
wlegldep,
]
# Fields:
# - name: protocol name
# - stability: protocol stability ('private', 'stable' or 'unstable')
# - version: protocol version
# - required: wayland_protocols version check
wlmod = import('unstable-wayland')
proto_sources = [
{
'name': 'gtk-shell',
'stability': 'private',
},
{
'name': 'primary-selection',
'stability': 'unstable',
'version': 1,
},
{
'name': 'pointer-gestures',
'stability': 'unstable',
'version': 1,
},
{
'name': 'viewporter',
'stability': 'stable',
},
{
'name': 'xdg-shell',
'stability': 'unstable',
'version': 6,
},
{
'name': 'xdg-shell',
'stability': 'stable',
},
{
'name': 'xdg-foreign',
'stability': 'unstable',
'version': 1,
},
{
'name': 'xdg-foreign',
'stability': 'unstable',
'version': 2,
},
{
'name': 'tablet',
'stability': 'unstable',
'version': 2,
},
{
'name': 'keyboard-shortcuts-inhibit',
'stability': 'unstable',
'version': 1,
},
{
'name': 'server-decoration',
'stability': 'private',
},
{
'name': 'xdg-output',
'stability': 'unstable',
'version': 1,
},
{
'name': 'idle-inhibit',
'stability': 'unstable',
'version': 1,
},
{
'name': 'xdg-activation',
'stability': 'staging',
'version': 1,
},
{
'name': 'fractional-scale',
'stability': 'staging',
'version': 1,
},
{
'name': 'linux-dmabuf',
'stability': 'unstable',
'version': 1,
},
{
'name': 'presentation-time',
'stability': 'stable',
'version': 1,
},
{
'name': 'single-pixel-buffer',
'stability': 'staging',
'version': 1,
},
{
'name': 'xdg-dialog',
'stability': 'staging',
'version': 1,
},
'protocol/gtk-shell.xml',
'protocol/server-decoration.xml',
wlmod.find_protocol('primary-selection', state: 'unstable', version: 1),
wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1),
wlmod.find_protocol('viewporter', state: 'stable'),
wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6),
wlmod.find_protocol('xdg-shell', state: 'stable'),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2),
wlmod.find_protocol('tablet', state: 'unstable', version: 2),
wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-output', state: 'unstable', version: 1),
wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-activation', state: 'staging', version: 1),
wlmod.find_protocol('fractional-scale', state: 'staging', version: 1),
wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
wlmod.find_protocol('presentation-time', state: 'stable'),
wlmod.find_protocol('single-pixel-buffer', state: 'staging', version: 1),
]
gdk_wayland_gen_headers = []
wlmod = import('unstable-wayland')
foreach p: proto_sources
if wlprotocolsdep.version().version_compare(p.get('required', '>=0'))
if p.get('stability') == 'private'
if (p.has_key('version'))
proto_file = 'protocol/@0@-v@1@.xml'.format(p.get('name'), p.get('version'))
else
proto_file = 'protocol/@0@.xml'.format(p.get('name'))
endif
elif p.get('stability') == 'stable'
proto_file = wlmod.find_protocol(p.get('name'),
state: p.get('stability'),
)
else
proto_file = wlmod.find_protocol(p.get('name'),
state: p.get('stability'),
version: p.get('version'),
)
endif
# Returns a list [.c, .h]
gen = wlmod.scan_xml(proto_file)
assert(gen.length() == 2)
gdk_wayland_sources += gen[0]
gdk_wayland_gen_headers += gen[1]
endif
# Returns a list [.c, .h]
gen = wlmod.scan_xml(p)
assert(gen.length() == 2)
gdk_wayland_sources += gen[0]
gdk_wayland_gen_headers += gen[1]
endforeach
libgdk_wayland = static_library('gdk-wayland',

View File

@@ -47,7 +47,6 @@ create_cairo_surface_for_surface (GdkSurface *surface,
cairo_surface = cairo_win32_surface_create_with_format (hdc, CAIRO_FORMAT_ARGB32);
cairo_surface_set_device_scale (cairo_surface, scale, scale);
gdk_cairo_surface_set_color_state (cairo_surface, gdk_surface_get_color_state (surface));
return cairo_surface;
}

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