Compare commits
334 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f8076a085 | |||
| ca6fe07b27 | |||
| bdb6552408 | |||
| 7626f8262d | |||
| 05e470f2cd | |||
| c5883853d7 | |||
| 2250761474 | |||
| d35df199b0 | |||
| 87f9c26414 | |||
| d2cc2b6ea8 | |||
| f73a34e71a | |||
| b5f5e6e34b | |||
| 7f71443d6b | |||
| bb130960e2 | |||
| 0ebc7660a2 | |||
| fe885d9f41 | |||
| 3076cd9a47 | |||
| b710e72e1e | |||
| c6bb894507 | |||
| a6351ea8be | |||
| 68e132d2c0 | |||
| dd79dd0a52 | |||
| f7ff943d08 | |||
| 6f37b64e4c | |||
| 7f7b104438 | |||
| c76a22224b | |||
| 531ca56a20 | |||
| 5eaba3b123 | |||
| d697cce5b0 | |||
| ccc646dda7 | |||
| f5b7e131d6 | |||
| 51012c1802 | |||
| b5c1e77d4c | |||
| 85149445e0 | |||
| 61d0043f9c | |||
| 5c97089e59 | |||
| 6f5c610858 | |||
| a05dd4d194 | |||
| b1a840bec0 | |||
| 31fabecddd | |||
| 96cb38dd05 | |||
| b672dabee8 | |||
| 5fbdec2a29 | |||
| f22ae99b98 | |||
| 3be7ef17ff | |||
| 146422fabd | |||
| a274a5ff4b | |||
| d1d4d80a1d | |||
| 167d32811d | |||
| 6ec4a2a4a5 | |||
| a11abf57e1 | |||
| a63a201812 | |||
| f09caced9b | |||
| 01cd2fe4bb | |||
| 45b93644b7 | |||
| 76a80d8f45 | |||
| 153b8399f7 | |||
| da41271dd5 | |||
| 5610af1b77 | |||
| 8da70fec91 | |||
| f9cd30a859 | |||
| 763d620a23 | |||
| 500a3a6dee | |||
| 57073e1057 | |||
| 6bbfd2f62a | |||
| 6c69a96cd7 | |||
| fa247d5a84 | |||
| 0320c4ac14 | |||
| 36993ac707 | |||
| 2f93eb4a28 | |||
| 5a2982ac31 | |||
| 441b704afd | |||
| abf6ebd7fe | |||
| 34fb08af6e | |||
| 0b9dfdd41f | |||
| 701e0812e4 | |||
| 4918a46172 | |||
| ef5e3fae64 | |||
| 9fcf55571e | |||
| 260898ecf6 | |||
| 66c9132abe | |||
| c5abdfb72b | |||
| 4fe37847ba | |||
| c99a0b0518 | |||
| 31f3edec5c | |||
| dee372c08e | |||
| 8c0a4e5a6e | |||
| 7195514fb5 | |||
| 420bd5bc16 | |||
| f024ee1adf | |||
| 18c2c71cd5 | |||
| 2d1bfc84b9 | |||
| 8edfa759fb | |||
| 2d1e978599 | |||
| d71fc41152 | |||
| d141cb7b72 | |||
| 7010067884 | |||
| 0ec29c4176 | |||
| 42c6e0249f | |||
| 54eb85f814 | |||
| 18b3b4feed | |||
| 0045ac839b | |||
| a9da807de3 | |||
| 366639b7e4 | |||
| 7d2e2171be | |||
| e3ceda15ac | |||
| 7291a21a85 | |||
| 888afe3e46 | |||
| 171bfde133 | |||
| 82d1fdb714 | |||
| 82b19daa7e | |||
| dc1ff3c2e3 | |||
| 6602ac5eae | |||
| 5dab5bf0e9 | |||
| 721be8fe9f | |||
| 58fe590eae | |||
| c18a7ff5cf | |||
| 24fc38b287 | |||
| aa03c50f05 | |||
| 03e971b2e3 | |||
| a595133b77 | |||
| e50f4ecccf | |||
| 67913e4af0 | |||
| b3d1795327 | |||
| 6edcc8f256 | |||
| d5e5f47666 | |||
| 0524c40640 | |||
| b5fd894f77 | |||
| d8492121aa | |||
| 4a0bf603d7 | |||
| 02fa89df9e | |||
| 5b6dde9a73 | |||
| e9d8ebdfc9 | |||
| 366efc3d61 | |||
| 3b890fd3c1 | |||
| 5de373a14b | |||
| 24cb9d2437 | |||
| 83aa176466 | |||
| 0e94e5ecda | |||
| 130485a583 | |||
| f34c10abb5 | |||
| 48b00f0ac1 | |||
| 743329a3af | |||
| f5783f1637 | |||
| 67f61a8d39 | |||
| f7df663dea | |||
| c99278aa58 | |||
| 1765e1b7c2 | |||
| bf1a434d5c | |||
| 9256b5b552 | |||
| 577e4afb3c | |||
| 2a05c04db7 | |||
| a6ffd6b3b2 | |||
| 24eba7c4c1 | |||
| 80de844922 | |||
| a2223c0884 | |||
| 5ffa2b757c | |||
| b660fa27d3 | |||
| 77f0e5e1ba | |||
| 1080822ffa | |||
| 3fef45683c | |||
| cfcc5c5c0b | |||
| 856f1808de | |||
| 4341344545 | |||
| 20392e8840 | |||
| 426fefff81 | |||
| 13013053f7 | |||
| 62b9a4af75 | |||
| 76caf2c812 | |||
| 3d5fce1b9f | |||
| bfe8adbee4 | |||
| 827642303c | |||
| 6b6a0e1257 | |||
| 7a98176a02 | |||
| a93a986ef2 | |||
| 39dbc5ea87 | |||
| cf4d13bee3 | |||
| 0bacde8e0a | |||
| 949cd45bb7 | |||
| 2e9e216641 | |||
| 1ab8ffaceb | |||
| 3cc1726856 | |||
| 30eaa2c3cc | |||
| ba5993195a | |||
| bf42351ebf | |||
| ee277f4d92 | |||
| 00acc7957f | |||
| a931335f24 | |||
| 1ef320a9ec | |||
| 411b7f12b5 | |||
| 611fcfb1c7 | |||
| 6257a51f4f | |||
| e24630bd18 | |||
| 6b0b3a4db7 | |||
| fd19c7c2ab | |||
| 4aa2206699 | |||
| eae23ebf69 | |||
| ecd27f6c3c | |||
| 01f3c72338 | |||
| 87be414c05 | |||
| f6d676cc8a | |||
| 4961241f26 | |||
| 60c944bb94 | |||
| 740c10282f | |||
| 3a4c69f370 | |||
| c3083572fb | |||
| 8ecb00be66 | |||
| 48e707aceb | |||
| e2f9ff2304 | |||
| fa3a72c8f6 | |||
| fc45d90834 | |||
| fcd95cd5c6 | |||
| b8c1ac41d2 | |||
| 90e1ce0906 | |||
| d121fd5b7d | |||
| 4d88fcc1db | |||
| 85fcda178e | |||
| ecc678454b | |||
| 5a85bc691e | |||
| d506a5eea8 | |||
| aefa79413b | |||
| 73e4eb7552 | |||
| dff340530a | |||
| f6ea3e1684 | |||
| f790441505 | |||
| 0c307f7563 | |||
| f89dc9644c | |||
| 735455b523 | |||
| d037cfaf44 | |||
| 293d63425a | |||
| 38f9bb87bc | |||
| 64abadb370 | |||
| 6f85827fcb | |||
| b0e321cfb8 | |||
| 46d0569365 | |||
| 2eea911a0f | |||
| ee4a817121 | |||
| 3d1f914271 | |||
| 7bb0639a75 | |||
| f8f38aab63 | |||
| 75c2bd53aa | |||
| 83921750ae | |||
| 413512eba7 | |||
| e824764dc3 | |||
| 61b12abdab | |||
| 07bd5c7b05 | |||
| 1dc20eda28 | |||
| 5a9299f626 | |||
| 9c86c67f06 | |||
| e6ca7668be | |||
| 0b540b9ad1 | |||
| 514cdf7398 | |||
| 2ab52d73ab | |||
| b3ae172c1e | |||
| a6d1df66ec | |||
| ba92ce342e | |||
| 9f4c715516 | |||
| 5aa47b6e45 | |||
| 3b40d95581 | |||
| 3ad2d91e1c | |||
| d4c586e882 | |||
| 612c547ed3 | |||
| 1a777ce7f3 | |||
| 7ec4f6e297 | |||
| afaa0f3afd | |||
| 8841a002ed | |||
| 6da606aaad | |||
| 51bd155670 | |||
| 8fa16ec1cc | |||
| 04e5a0006d | |||
| a1d2169992 | |||
| 778976f8da | |||
| f81dea58a2 | |||
| e82606a538 | |||
| fe5b28f5b8 | |||
| 82fd0d7eef | |||
| 16761fcb49 | |||
| 4fac5680fb | |||
| 4ec4280e51 | |||
| 15bb77472d | |||
| 5c92d5e081 | |||
| 1626c5f1e7 | |||
| 3b5f0ed05e | |||
| d2298f1c8f | |||
| 085062ab89 | |||
| 9741082467 | |||
| 3db4a05493 | |||
| e3b9df2cec | |||
| 4a4e445a35 | |||
| db0f9b60ac | |||
| d51de390ba | |||
| c14e167a11 | |||
| 2837a85461 | |||
| 282510e113 | |||
| accabe3eee | |||
| 9dbdbaca43 | |||
| 5935bc95b7 | |||
| 4c677e4dcd | |||
| d4c25c9ec0 | |||
| b69df2bc4d | |||
| 7f9363d471 | |||
| 01d86eab66 | |||
| 09e85aa809 | |||
| d49816d2e6 | |||
| 59a00d6768 | |||
| 6bd6c6acba | |||
| be2ff60787 | |||
| 070b9a87b6 | |||
| ecbe6a421e | |||
| 317e68a58c | |||
| 9b42377347 | |||
| 7372a845fb | |||
| cf8c3be030 | |||
| 4eb715cf81 | |||
| d4899fdf1f | |||
| 4142c4d79e | |||
| ca442f8641 | |||
| 3c1491423a | |||
| eb4993d3fb | |||
| aa057da1ca | |||
| 1de09d59fb | |||
| 130a6fe0cf | |||
| e1f7c027d7 | |||
| 396ef5ebe5 | |||
| 840a20db3b | |||
| 8c6f7d1ae9 | |||
| c69fa6221b | |||
| 3c92c81705 | |||
| 297de981c4 | |||
| ed8255993f | |||
| e1431f31c1 | |||
| 32a4f805b8 | |||
| 54a86a2a7e | |||
| 06351844bb |
@@ -459,6 +459,7 @@ 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/
|
||||
|
||||
@@ -1,12 +1,54 @@
|
||||
Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
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
|
||||
=========================================
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Don't crash without a child
|
||||
|
||||
* GtkSpinner:
|
||||
- Don't animate when unmapped
|
||||
|
||||
* CSS:
|
||||
- Support the :root selector
|
||||
- Support variables and custom properties
|
||||
- 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
|
||||
@@ -43,12 +85,20 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
|
||||
* 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
|
||||
|
||||
@@ -299,7 +299,7 @@ node_editor_application_new (void)
|
||||
|
||||
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
|
||||
"application-id", "org.gtk.gtk4.NodeEditor",
|
||||
"flags", G_APPLICATION_HANDLES_OPEN,
|
||||
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE,
|
||||
NULL);
|
||||
|
||||
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
|
||||
|
||||
@@ -15,16 +15,16 @@ spec.
|
||||
The following units are supported for basic datatypes:
|
||||
|
||||
Length
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm
|
||||
|
||||
Percentage
|
||||
: %, calc()
|
||||
: %
|
||||
|
||||
Angle
|
||||
: deg, rad, grad, turn, calc()
|
||||
: deg, rad, grad, turn
|
||||
|
||||
Time
|
||||
: s, ms, calc()
|
||||
: s, ms
|
||||
|
||||
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,11 +33,15 @@ 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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
@@ -82,36 +86,54 @@ color: var(--prop, green);
|
||||
|
||||
## Colors
|
||||
|
||||
GTK extends the CSS syntax with several additional ways to specify 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.
|
||||
|
||||
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)`
|
||||
: replaces the alpha value of color with number (between 0 and 1)
|
||||
`alpha(color, number)`
|
||||
: multiplies the alpha value of `color` by `number` (between 0 and 1).
|
||||
|
||||
`mix(Color1, Color2, Number)`
|
||||
: interpolates between the two colors
|
||||
`mix(color1, color2, number)`
|
||||
: interpolates between the two colors.
|
||||
|
||||
## Images
|
||||
|
||||
@@ -119,7 +141,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
|
||||
@@ -148,14 +170,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
|
||||
|
||||
@@ -99,16 +99,15 @@ reaches the requested phase. However, in practice most things
|
||||
happen at higher levels:
|
||||
|
||||
- If you are doing an animation, you can use
|
||||
gtk_widget_add_tick_callback() which will cause a regular
|
||||
[method@Gtk.Widget.add_tick_callback] which will cause a regular
|
||||
beating of the clock with a callback in the Update phase
|
||||
until you stop the tick.
|
||||
- If some state changes that causes the size of your widget to
|
||||
change you call gtk_widget_queue_resize() which will request
|
||||
change you call [method@Gtk.Widget.queue_resize] which will request
|
||||
a Layout phase and mark your widget as needing relayout.
|
||||
- If some state changes so you need to redraw some area of
|
||||
your widget you use the normal gtk_widget_queue_draw()
|
||||
set of functions. These will request a Paint phase and
|
||||
mark the region as needing redraw.
|
||||
- If some state changes so you need to redraw your widget you
|
||||
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
|
||||
your widget.
|
||||
|
||||
There are also a lot of implicit triggers of these from the
|
||||
CSS layer (which does animations, resizes and repaints as needed).
|
||||
|
||||
@@ -18,6 +18,7 @@ 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>
|
||||
@@ -99,3 +100,15 @@ 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).
|
||||
|
||||
@@ -77,11 +77,13 @@ 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 = [
|
||||
|
||||
@@ -14,6 +14,7 @@ expand_content_md_files = [
|
||||
'running.md',
|
||||
'migrating-2to4.md',
|
||||
'migrating-3to4.md',
|
||||
'migrating-4to5.md',
|
||||
'actions.md',
|
||||
'input-handling.md',
|
||||
'drawing-model.md',
|
||||
@@ -25,7 +26,8 @@ expand_content_md_files = [
|
||||
'section-tree-widget.md',
|
||||
'section-list-widget.md',
|
||||
'question_index.md',
|
||||
'visual_index.md'
|
||||
'visual_index.md',
|
||||
'tools.md',
|
||||
]
|
||||
|
||||
gtk_images = []
|
||||
@@ -60,39 +62,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: false)
|
||||
if get_option('man-pages') and not rst2man.found()
|
||||
error('No rst2man found, but man pages were explicitly enabled')
|
||||
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', ],
|
||||
]
|
||||
endif
|
||||
|
||||
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', ],
|
||||
]
|
||||
rst2x_flags = [
|
||||
'--syntax-highlight=none',
|
||||
]
|
||||
|
||||
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',
|
||||
]
|
||||
if get_option('man-pages')
|
||||
|
||||
foreach rst: rst_files
|
||||
man_name = rst[0]
|
||||
@@ -103,12 +105,34 @@ if get_option('man-pages') and rst2man.found()
|
||||
output: '@0@.@1@'.format(man_name, man_section),
|
||||
command: [
|
||||
rst2man,
|
||||
rst2man_flags,
|
||||
rst2x_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
|
||||
|
||||
@@ -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_style_color].
|
||||
[method@Gtk.Widget.get_color].
|
||||
|
||||
## Local stylesheets are going away
|
||||
|
||||
@@ -73,6 +73,103 @@ 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
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
@@ -30,6 +30,7 @@
|
||||
#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>
|
||||
|
||||
@@ -522,8 +522,6 @@ 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
|
||||
@@ -638,9 +636,6 @@ 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.
|
||||
*/
|
||||
@@ -834,9 +829,6 @@ 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.
|
||||
@@ -895,9 +887,6 @@ 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.
|
||||
@@ -960,9 +949,6 @@ 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.
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
/* 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>
|
||||
|
||||
/**
|
||||
* GdkColorState:
|
||||
*
|
||||
* A `GdkColorState` object provides the information to interpret
|
||||
* colors and pixels in a variety of ways.
|
||||
*
|
||||
* They are also known as
|
||||
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
|
||||
*
|
||||
* Crucially, GTK knows how to convert colors from one color
|
||||
* state to another.
|
||||
*
|
||||
* `GdkColorState objects are immutable and therefore threadsafe.
|
||||
*
|
||||
* Since 4.16
|
||||
*/
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
|
||||
gdk_color_state_ref, gdk_color_state_unref);
|
||||
|
||||
/* {{{ Public API */
|
||||
|
||||
/**
|
||||
* gdk_color_state_ref:
|
||||
* @self: a `GdkColorState`
|
||||
*
|
||||
* Increase the reference count of @self.
|
||||
*
|
||||
* Returns: the object that was passed in
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
(gdk_color_state_ref) (GdkColorState *self)
|
||||
{
|
||||
return _gdk_color_state_ref (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_unref:
|
||||
* @self:a `GdkColorState`
|
||||
*
|
||||
* Decrease the reference count of @self.
|
||||
*
|
||||
* Unless @self is static, it will be freed
|
||||
* when the reference count reaches zero.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
(gdk_color_state_unref) (GdkColorState *self)
|
||||
{
|
||||
_gdk_color_state_unref (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_srgb:
|
||||
*
|
||||
* Returns the color state object representing the sRGB color space.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_srgb (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_srgb_linear:
|
||||
*
|
||||
* Returns the color state object representing the linearized sRGB color space.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_srgb_linear (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_equal:
|
||||
* @self: a `GdkColorState`
|
||||
* @other: another `GdkColorStatee`
|
||||
*
|
||||
* Compares two `GdkColorStates` for equality.
|
||||
*
|
||||
* Note that this function is not guaranteed to be perfect and two objects
|
||||
* describing the same color state may compare not equal. However, different
|
||||
* color states will never compare equal.
|
||||
*
|
||||
* Returns: %TRUE if the two color states compare equal
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
gboolean
|
||||
(gdk_color_state_equal) (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
return _gdk_color_state_equal (self, other);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Default implementation */
|
||||
|
||||
const char *
|
||||
gdk_color_state_get_name_from_id (GdkColorStateId id)
|
||||
{
|
||||
const char *names[] = {
|
||||
"srgb", "srgb-linear",
|
||||
};
|
||||
|
||||
return names[id];
|
||||
}
|
||||
|
||||
GdkColorState gdk_default_color_states[] = {
|
||||
{ NULL, 0 },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Private API */
|
||||
|
||||
const char *
|
||||
gdk_color_state_get_name (GdkColorState *self)
|
||||
{
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
||||
{
|
||||
switch (GDK_DEFAULT_COLOR_STATE_ID (self))
|
||||
{
|
||||
case GDK_COLOR_STATE_ID_SRGB: return "srgb";
|
||||
case GDK_COLOR_STATE_ID_SRGB_LINEAR: return "srgb-linear";
|
||||
default: g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
return self->klass->get_name (self);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_color_state_print (GdkColorState *self,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, gdk_color_state_get_name (self));
|
||||
}
|
||||
|
||||
GdkMemoryDepth
|
||||
gdk_color_state_get_min_depth (GdkColorState *self)
|
||||
{
|
||||
if (self == GDK_COLOR_STATE_SRGB || self == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
return GDK_MEMORY_U8;
|
||||
|
||||
return GDK_MEMORY_FLOAT16;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
@@ -0,0 +1,50 @@
|
||||
/* gdkcolorstate.h
|
||||
*
|
||||
* Copyright 2024 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GType gdk_color_state_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_ref (GdkColorState *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_color_state_unref (GdkColorState *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_srgb (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_srgb_linear (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
gboolean gdk_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkcolorstate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_COLOR_STATE_ID_SRGB,
|
||||
GDK_COLOR_STATE_ID_SRGB_LINEAR,
|
||||
} GdkColorStateId;
|
||||
|
||||
typedef struct _GdkColorStateClass GdkColorStateClass;
|
||||
|
||||
struct _GdkColorState
|
||||
{
|
||||
GdkColorStateClass *klass;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
struct _GdkColorStateClass
|
||||
{
|
||||
void (* free) (GdkColorState *self);
|
||||
gboolean (* equal) (GdkColorState *self,
|
||||
GdkColorState *other);
|
||||
const char * (* get_name) (GdkColorState *self);
|
||||
};
|
||||
|
||||
extern GdkColorState gdk_default_color_states[];
|
||||
|
||||
#define GDK_COLOR_STATE_SRGB (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
|
||||
#define GDK_COLOR_STATE_SRGB_LINEAR (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
|
||||
|
||||
#define GDK_IS_DEFAULT_COLOR_STATE(c) (GDK_COLOR_STATE_SRGB <= (c) && (c) <= GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (c - gdk_default_color_states))
|
||||
|
||||
const char * gdk_color_state_get_name (GdkColorState *color_state);
|
||||
const char * gdk_color_state_get_name_from_id (GdkColorStateId id);
|
||||
void gdk_color_state_print (GdkColorState *color_state,
|
||||
GString *string);
|
||||
|
||||
GdkMemoryDepth gdk_color_state_get_min_depth (GdkColorState *color_state);
|
||||
|
||||
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
|
||||
static inline GdkColorState *
|
||||
_gdk_color_state_ref (GdkColorState *self)
|
||||
{
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
||||
return self;
|
||||
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
|
||||
static inline void
|
||||
_gdk_color_state_unref (GdkColorState *self)
|
||||
{
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
||||
return;
|
||||
|
||||
self->ref_count--;
|
||||
|
||||
if (self->ref_count == 0)
|
||||
self->klass->free (self);
|
||||
}
|
||||
|
||||
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
|
||||
static inline gboolean
|
||||
_gdk_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
if (self == other)
|
||||
return TRUE;
|
||||
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self) || GDK_IS_DEFAULT_COLOR_STATE (other))
|
||||
return FALSE;
|
||||
|
||||
if (self->klass != other->klass)
|
||||
return FALSE;
|
||||
|
||||
return self->klass->equal (self, other);
|
||||
}
|
||||
|
||||
@@ -540,9 +540,6 @@ 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,
|
||||
|
||||
@@ -279,10 +279,6 @@ 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.
|
||||
|
||||
@@ -546,9 +546,6 @@ 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,
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ GdkCursor* gdk_cursor_new_from_name (const char *name,
|
||||
GdkCursor *fallback);
|
||||
|
||||
/**
|
||||
* GdkCursorGetTestureCallback:
|
||||
* GdkCursorGetTextureCallback:
|
||||
* @cursor: the `GdkCursor`
|
||||
* @cursor_size: the nominal cursor size, in application pixels
|
||||
* @scale: the device scale
|
||||
|
||||
@@ -1874,6 +1874,8 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
|
||||
self->have_egl_dma_buf_export =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
|
||||
self->have_egl_gl_colorspace =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
|
||||
|
||||
if (self->have_egl_no_config_context)
|
||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||
|
||||
@@ -130,6 +130,7 @@ struct _GdkDisplay
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
guint have_egl_dma_buf_import : 1;
|
||||
guint have_egl_dma_buf_export : 1;
|
||||
guint have_egl_gl_colorspace : 1;
|
||||
|
||||
GdkDmabufFormats *dmabuf_formats;
|
||||
GdkDmabufDownloader *dmabuf_downloaders[4];
|
||||
|
||||
@@ -62,6 +62,13 @@ 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)
|
||||
|
||||
+2
-6
@@ -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,10 +849,6 @@ 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.
|
||||
|
||||
@@ -1371,6 +1371,8 @@ 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,
|
||||
|
||||
@@ -152,6 +152,13 @@ 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)
|
||||
@@ -1751,6 +1758,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
|
||||
priv->features = supported_features & ~disabled_features;
|
||||
|
||||
glEnable (GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
gdk_gl_context_init_memory_flags (context);
|
||||
|
||||
if ((priv->features & GDK_GL_FEATURE_DEBUG) && gl_debug)
|
||||
|
||||
+7
-7
@@ -151,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
|
||||
|
||||
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
||||
{
|
||||
GLint q_internal_format;
|
||||
GLint q_internal_format, q_internal_srgb_format;
|
||||
GLenum q_format, q_type;
|
||||
GLint q_swizzle[4];
|
||||
|
||||
@@ -164,6 +164,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
|
||||
gdk_memory_format_gl_format (format,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
&q_internal_format,
|
||||
&q_internal_srgb_format,
|
||||
&q_format,
|
||||
&q_type,
|
||||
q_swizzle);
|
||||
@@ -187,7 +188,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
GdkMemoryFormat format;
|
||||
gsize expected_stride;
|
||||
Download *download = download_;
|
||||
GLint gl_internal_format;
|
||||
GLint gl_internal_format, gl_internal_srgb_format;
|
||||
GLenum gl_format, gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
|
||||
@@ -199,7 +200,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
{
|
||||
gdk_memory_format_gl_format (format,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
&gl_internal_format,
|
||||
&gl_internal_format, &gl_internal_srgb_format,
|
||||
&gl_format, &gl_type, gl_swizzle);
|
||||
if (download->stride == expected_stride &&
|
||||
download->format == format)
|
||||
@@ -262,7 +263,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
|
||||
gdk_memory_format_gl_format (actual_format,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
&gl_internal_format,
|
||||
&gl_internal_format, &gl_internal_srgb_format,
|
||||
&gl_read_format, &gl_read_type, gl_swizzle);
|
||||
}
|
||||
}
|
||||
@@ -274,7 +275,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
|
||||
gdk_memory_format_gl_format (actual_format,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
&gl_internal_format,
|
||||
&gl_internal_format, &gl_internal_srgb_format,
|
||||
&gl_read_format, &gl_read_type, gl_swizzle);
|
||||
}
|
||||
|
||||
@@ -471,8 +472,7 @@ 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,
|
||||
gdk_texture_get_format (texture)));
|
||||
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
|
||||
|
||||
drop_gl_resources (self);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gtk/gtkcolorutilsprivate.h"
|
||||
|
||||
#include "gsk/gl/fp16private.h"
|
||||
|
||||
@@ -327,6 +329,7 @@ ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
|
||||
|
||||
struct _GdkMemoryFormatDescription
|
||||
{
|
||||
const char *name;
|
||||
GdkMemoryAlpha alpha;
|
||||
GdkMemoryFormat premultiplied;
|
||||
GdkMemoryFormat straight;
|
||||
@@ -337,7 +340,9 @@ struct _GdkMemoryFormatDescription
|
||||
struct {
|
||||
GLint internal_gl_format;
|
||||
GLint internal_gles_format;
|
||||
GLint internal_srgb_format;
|
||||
GLenum format;
|
||||
GLenum srgb_format;
|
||||
GLenum type;
|
||||
GLint swizzle[4];
|
||||
/* -1 if none exists, ie the format is already RGBA
|
||||
@@ -347,6 +352,7 @@ struct _GdkMemoryFormatDescription
|
||||
} gl;
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
VkFormat vk_format;
|
||||
VkFormat vk_srgb_format;
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
guint32 dmabuf_fourcc;
|
||||
@@ -366,6 +372,7 @@ struct _GdkMemoryFormatDescription
|
||||
|
||||
static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
|
||||
.name = "*BGRA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_B8G8R8A8,
|
||||
@@ -378,6 +385,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_BGRA,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_BGRA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -386,6 +394,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
|
||||
@@ -394,6 +403,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = b8g8r8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
|
||||
.name = "*ARGB8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_A8R8G8B8,
|
||||
@@ -406,6 +416,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_BGRA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -414,6 +425,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
|
||||
@@ -422,6 +434,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a8r8g8b8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
|
||||
.name = "*RGBA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R8G8B8A8,
|
||||
@@ -434,6 +447,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -441,6 +455,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
|
||||
@@ -449,6 +464,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r8g8b8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = {
|
||||
.name = "*ABGR8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_A8B8G8R8,
|
||||
@@ -461,6 +477,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -469,6 +486,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
|
||||
@@ -477,6 +495,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a8b8g8r8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_B8G8R8A8] = {
|
||||
.name = "BGRA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_B8G8R8A8,
|
||||
@@ -489,6 +508,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_BGRA,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_BGRA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -497,6 +517,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
|
||||
@@ -505,6 +526,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = b8g8r8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8R8G8B8] = {
|
||||
.name = "ARGB8",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_A8R8G8B8,
|
||||
@@ -517,6 +539,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_BGRA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -525,6 +548,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
|
||||
@@ -533,6 +557,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a8r8g8b8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8A8] = {
|
||||
.name = "RGBA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R8G8B8A8,
|
||||
@@ -545,6 +570,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -552,6 +578,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
|
||||
@@ -560,6 +587,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r8g8b8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8B8G8R8] = {
|
||||
.name = "ABGR8",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_A8B8G8R8,
|
||||
@@ -572,6 +600,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -580,6 +609,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
|
||||
@@ -588,6 +618,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a8b8g8r8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_B8G8R8X8] = {
|
||||
.name = "BGRX8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_B8G8R8X8,
|
||||
.straight = GDK_MEMORY_B8G8R8X8,
|
||||
@@ -601,6 +632,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_BGRA,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_BGRA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
|
||||
@@ -609,6 +641,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_XRGB8888,
|
||||
@@ -617,6 +650,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = b8g8r8x8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_X8R8G8B8] = {
|
||||
.name = "XRGB8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_X8R8G8B8,
|
||||
.straight = GDK_MEMORY_X8R8G8B8,
|
||||
@@ -630,6 +664,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_BGRA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
|
||||
@@ -638,6 +673,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_BGRX8888,
|
||||
@@ -646,6 +682,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = x8r8g8b8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8X8] = {
|
||||
.name = "RGBX8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_R8G8B8X8,
|
||||
.straight = GDK_MEMORY_R8G8B8X8,
|
||||
@@ -659,6 +696,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
|
||||
@@ -666,6 +704,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_XBGR8888,
|
||||
@@ -674,6 +713,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r8g8b8x8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_X8B8G8R8] = {
|
||||
.name = "XBGR8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_X8B8G8R8,
|
||||
.straight = GDK_MEMORY_X8B8G8R8,
|
||||
@@ -687,6 +727,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA8,
|
||||
.internal_gles_format = GL_RGBA8,
|
||||
.internal_srgb_format = GL_SRGB8_ALPHA8,
|
||||
.format = GL_RGBA,
|
||||
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
|
||||
@@ -695,6 +736,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_UNDEFINED,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_RGBX8888,
|
||||
@@ -703,6 +745,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = x8b8g8r8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R8G8B8] = {
|
||||
.name = "RGB8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_R8G8B8,
|
||||
.straight = GDK_MEMORY_R8G8B8,
|
||||
@@ -716,6 +759,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGB8,
|
||||
.internal_gles_format = GL_RGB8,
|
||||
.internal_srgb_format = GL_SRGB8,
|
||||
.format = GL_RGB,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -723,6 +767,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8B8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_R8G8B8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_BGR888,
|
||||
@@ -731,6 +776,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r8g8b8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_B8G8R8] = {
|
||||
.name = "BGR8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_B8G8R8,
|
||||
.straight = GDK_MEMORY_B8G8R8,
|
||||
@@ -744,6 +790,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGB8,
|
||||
.internal_gles_format = GL_RGB8,
|
||||
.internal_srgb_format = GL_SRGB8,
|
||||
.format = GL_BGR,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -752,6 +799,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_B8G8R8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_B8G8R8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_RGB888,
|
||||
@@ -760,6 +808,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = b8g8r8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16] = {
|
||||
.name = "RGB16",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16,
|
||||
.straight = GDK_MEMORY_R16G16B16,
|
||||
@@ -776,6 +825,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGB16,
|
||||
.internal_gles_format = GL_RGB16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGB,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -783,6 +833,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -791,6 +842,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
|
||||
.name = "*RGBA16",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R16G16B16A16,
|
||||
@@ -806,6 +858,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA16,
|
||||
.internal_gles_format = GL_RGBA16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -813,6 +866,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
|
||||
@@ -821,6 +875,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16] = {
|
||||
.name = "RGBA16",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R16G16B16A16,
|
||||
@@ -836,6 +891,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA16,
|
||||
.internal_gles_format = GL_RGBA16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -843,6 +899,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
|
||||
@@ -851,6 +908,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = {
|
||||
.name = "RGBA16f",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16_FLOAT,
|
||||
.straight = GDK_MEMORY_R16G16B16_FLOAT,
|
||||
@@ -866,6 +924,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGB16F,
|
||||
.internal_gles_format = GL_RGB16F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGB,
|
||||
.type = GL_HALF_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -873,6 +932,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -881,6 +941,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
|
||||
.name = "*RGBA16f",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
|
||||
@@ -895,6 +956,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA16F,
|
||||
.internal_gles_format = GL_RGBA16F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_HALF_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -902,6 +964,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
|
||||
@@ -910,6 +973,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16a16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = {
|
||||
.name = "RGBA16f",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
|
||||
@@ -924,6 +988,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA16F,
|
||||
.internal_gles_format = GL_RGBA16F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_HALF_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -931,6 +996,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
|
||||
@@ -939,6 +1005,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r16g16b16a16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = {
|
||||
.name = "RGB32f",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_R32G32B32_FLOAT,
|
||||
.straight = GDK_MEMORY_R32G32B32_FLOAT,
|
||||
@@ -954,6 +1021,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGB32F,
|
||||
.internal_gles_format = GL_RGB32F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGB,
|
||||
.type = GL_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -961,6 +1029,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R32G32B32_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -969,6 +1038,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r32g32b32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
|
||||
.name = "*RGBA32f",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
|
||||
@@ -983,6 +1053,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA32F,
|
||||
.internal_gles_format = GL_RGBA32F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -990,6 +1061,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -998,6 +1070,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r32g32b32a32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = {
|
||||
.name = "RGBA32f",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
|
||||
@@ -1012,6 +1085,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RGBA32F,
|
||||
.internal_gles_format = GL_RGBA32F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RGBA,
|
||||
.type = GL_FLOAT,
|
||||
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
|
||||
@@ -1019,6 +1093,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1027,6 +1102,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = r32g32b32a32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
|
||||
.name = "*GA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_G8A8,
|
||||
@@ -1040,6 +1116,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RG8,
|
||||
.internal_gles_format = GL_RG8,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RG,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
|
||||
@@ -1047,6 +1124,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1055,6 +1133,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8] = {
|
||||
.name = "GA8",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_G8A8,
|
||||
@@ -1068,6 +1147,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RG8,
|
||||
.internal_gles_format = GL_RG8,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RG,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
|
||||
@@ -1075,6 +1155,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8G8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1083,6 +1164,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8] = {
|
||||
.name = "G8",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_G8,
|
||||
.straight = GDK_MEMORY_G8,
|
||||
@@ -1096,6 +1178,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R8,
|
||||
.internal_gles_format = GL_R8,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
|
||||
@@ -1103,6 +1186,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_R8_SRGB,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_R8,
|
||||
@@ -1111,6 +1195,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
|
||||
.name = "*GA16",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_G16A16,
|
||||
@@ -1127,6 +1212,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RG16,
|
||||
.internal_gles_format = GL_RG16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RG,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
|
||||
@@ -1134,6 +1220,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1142,6 +1229,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g16a16_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16] = {
|
||||
.name = "GA16",
|
||||
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
|
||||
.straight = GDK_MEMORY_G16A16,
|
||||
@@ -1158,6 +1246,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_RG16,
|
||||
.internal_gles_format = GL_RG16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RG,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
|
||||
@@ -1165,6 +1254,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16G16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1173,6 +1263,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16] = {
|
||||
.name = "G16",
|
||||
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
|
||||
.premultiplied = GDK_MEMORY_G16,
|
||||
.straight = GDK_MEMORY_G16,
|
||||
@@ -1189,6 +1280,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R16,
|
||||
.internal_gles_format = GL_R16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
|
||||
@@ -1196,6 +1288,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = DRM_FORMAT_R16,
|
||||
@@ -1204,6 +1297,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = g16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8] = {
|
||||
.name = "A8",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A8,
|
||||
.straight = GDK_MEMORY_A8,
|
||||
@@ -1217,6 +1311,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R8,
|
||||
.internal_gles_format = GL_R8,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_UNSIGNED_BYTE,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
|
||||
@@ -1224,6 +1319,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R8_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1232,6 +1328,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A16] = {
|
||||
.name = "A16",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A16,
|
||||
.straight = GDK_MEMORY_A16,
|
||||
@@ -1248,6 +1345,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R16,
|
||||
.internal_gles_format = GL_R16,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_UNSIGNED_SHORT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
|
||||
@@ -1255,6 +1353,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16_UNORM,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1263,6 +1362,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A16_FLOAT] = {
|
||||
.name = "A16f",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A16_FLOAT,
|
||||
.straight = GDK_MEMORY_A16_FLOAT,
|
||||
@@ -1278,6 +1378,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R16F,
|
||||
.internal_gles_format = GL_R16F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_HALF_FLOAT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
|
||||
@@ -1285,6 +1386,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R16_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1293,6 +1395,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.from_float = a16_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A32_FLOAT] = {
|
||||
.name = "A32f",
|
||||
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
.premultiplied = GDK_MEMORY_A32_FLOAT,
|
||||
.straight = GDK_MEMORY_A32_FLOAT,
|
||||
@@ -1308,6 +1411,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
.gl = {
|
||||
.internal_gl_format = GL_R32F,
|
||||
.internal_gles_format = GL_R32F,
|
||||
.internal_srgb_format = -1,
|
||||
.format = GL_RED,
|
||||
.type = GL_FLOAT,
|
||||
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
|
||||
@@ -1315,6 +1419,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
},
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
.vk_format = VK_FORMAT_R32_SFLOAT,
|
||||
.vk_srgb_format = VK_FORMAT_UNDEFINED,
|
||||
#endif
|
||||
#ifdef HAVE_DMABUF
|
||||
.dmabuf_fourcc = 0,
|
||||
@@ -1509,6 +1614,7 @@ void
|
||||
gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
GLint *out_internal_format,
|
||||
GLint *out_internal_srgb_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4])
|
||||
@@ -1517,6 +1623,7 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
*out_internal_format = memory_formats[format].gl.internal_gles_format;
|
||||
else
|
||||
*out_internal_format = memory_formats[format].gl.internal_gl_format;
|
||||
*out_internal_srgb_format = memory_formats[format].gl.internal_srgb_format;
|
||||
*out_format = memory_formats[format].gl.format;
|
||||
*out_type = memory_formats[format].gl.type;
|
||||
memcpy (out_swizzle, memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
|
||||
@@ -1528,6 +1635,8 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
* @gles: TRUE for GLES, FALSE for GL
|
||||
* @out_actual_format: The actual RGBA format
|
||||
* @out_internal_format: the GL internal format
|
||||
* @out_internal_srgb_format: the GL internal format to use for automatic
|
||||
* sRGB<=>linear conversion
|
||||
* @out_format: the GL format
|
||||
* @out_type: the GL type
|
||||
* @out_swizzle: The swizzle to use
|
||||
@@ -1546,6 +1655,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
GdkMemoryFormat *out_actual_format,
|
||||
GLint *out_internal_format,
|
||||
GLint *out_internal_srgb_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4])
|
||||
@@ -1560,6 +1670,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
|
||||
*out_internal_format = memory_formats[actual].gl.internal_gles_format;
|
||||
else
|
||||
*out_internal_format = memory_formats[actual].gl.internal_gl_format;
|
||||
*out_internal_srgb_format = memory_formats[actual].gl.internal_srgb_format;
|
||||
*out_format = memory_formats[actual].gl.format;
|
||||
*out_type = memory_formats[actual].gl.type;
|
||||
memcpy (out_swizzle, memory_formats[format].gl.rgba_swizzle, sizeof(GLint) * 4);
|
||||
@@ -1613,6 +1724,14 @@ gdk_memory_format_vk_format (GdkMemoryFormat format,
|
||||
return memory_formats[format].vk_format;
|
||||
}
|
||||
|
||||
/* Gets the matching SRGB version of a VkFormat
|
||||
* Returns VK_FORMAT_UNDEFINED if none exists */
|
||||
VkFormat
|
||||
gdk_memory_format_vk_srgb_format (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].vk_srgb_format;
|
||||
}
|
||||
|
||||
/* Vulkan version of gdk_memory_format_gl_rgba_format()
|
||||
* Returns VK_FORMAT_UNDEFINED on failure */
|
||||
VkFormat
|
||||
@@ -1661,6 +1780,12 @@ gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format)
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
gdk_memory_format_get_name (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].name;
|
||||
}
|
||||
|
||||
static void
|
||||
premultiply (float *rgba,
|
||||
gsize n)
|
||||
@@ -1708,6 +1833,10 @@ gdk_memory_convert (guchar *dest_data,
|
||||
|
||||
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
|
||||
g_assert (src_format < GDK_MEMORY_N_FORMATS);
|
||||
/* We don't allow overlap here. If you want to do in-place color state conversions,
|
||||
* use gdk_memory_convert_color_state.
|
||||
*/
|
||||
g_assert (dest_data + height * dest_stride < src_data || src_data + height * src_stride < dest_data);
|
||||
|
||||
if (src_format == dest_format)
|
||||
{
|
||||
@@ -1793,3 +1922,201 @@ gdk_memory_convert (guchar *dest_data,
|
||||
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
static const guchar srgb_lookup[] = {
|
||||
0, 12, 21, 28, 33, 38, 42, 46, 49, 52, 55, 58, 61, 63, 66, 68,
|
||||
70, 73, 75, 77, 79, 81, 82, 84, 86, 88, 89, 91, 93, 94, 96, 97,
|
||||
99, 100, 102, 103, 104, 106, 107, 109, 110, 111, 112, 114, 115, 116, 117, 118,
|
||||
120, 121, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136,
|
||||
137, 138, 139, 140, 141, 142, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
|
||||
151, 152, 153, 154, 155, 156, 157, 157, 158, 159, 160, 161, 161, 162, 163, 164,
|
||||
165, 165, 166, 167, 168, 168, 169, 170, 171, 171, 172, 173, 174, 174, 175, 176,
|
||||
176, 177, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187,
|
||||
187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 194, 195, 196, 196, 197,
|
||||
197, 198, 199, 199, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206,
|
||||
207, 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215,
|
||||
216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
|
||||
224, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232,
|
||||
233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 237, 238, 238, 239, 239, 240,
|
||||
240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 247, 247,
|
||||
248, 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255
|
||||
};
|
||||
|
||||
static const guchar srgb_inverse_lookup[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
|
||||
3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7,
|
||||
7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
|
||||
13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19,
|
||||
20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29,
|
||||
29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40,
|
||||
41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54,
|
||||
55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70,
|
||||
71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88,
|
||||
89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109,
|
||||
110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132,
|
||||
134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159,
|
||||
160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188,
|
||||
190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220,
|
||||
222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255
|
||||
};
|
||||
|
||||
static void
|
||||
convert_srgb_to_srgb_linear (guchar *data,
|
||||
gsize n)
|
||||
{
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
guint8 r = data[0];
|
||||
guint8 g = data[1];
|
||||
guint8 b = data[2];
|
||||
guchar a = data[3];
|
||||
float f = a / 255.0;
|
||||
if (a < 255)
|
||||
{
|
||||
r = r / f;
|
||||
g = g / f;
|
||||
b = b / f;
|
||||
}
|
||||
r = srgb_inverse_lookup[r];
|
||||
g = srgb_inverse_lookup[g];
|
||||
b = srgb_inverse_lookup[b];
|
||||
|
||||
data[0] = r * f;
|
||||
data[1] = g * f;
|
||||
data[2] = b * f;
|
||||
data += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
convert_srgb_linear_to_srgb (guchar *data,
|
||||
gsize n)
|
||||
{
|
||||
for (gsize i = 0; i < n; i++)
|
||||
{
|
||||
guint8 r = data[0];
|
||||
guint8 g = data[1];
|
||||
guint8 b = data[2];
|
||||
guchar a = data[3];
|
||||
float f = a / 255.0;
|
||||
if (a < 255)
|
||||
{
|
||||
r = r / f;
|
||||
g = g / f;
|
||||
b = b / f;
|
||||
}
|
||||
r = srgb_lookup[r];
|
||||
g = srgb_lookup[g];
|
||||
b = srgb_lookup[b];
|
||||
|
||||
data[0] = r * f;
|
||||
data[1] = g * f;
|
||||
data[2] = b * f;
|
||||
data += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
convert_srgb_to_srgb_linear_in_place (guchar *data,
|
||||
gsize stride,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
if (stride == width * 4)
|
||||
{
|
||||
convert_srgb_to_srgb_linear (data, height * width);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gsize y = 0; y < height; y++)
|
||||
{
|
||||
convert_srgb_to_srgb_linear (data, width);
|
||||
data += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
convert_srgb_linear_to_srgb_in_place (guchar *data,
|
||||
gsize stride,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
if (stride == width * 4)
|
||||
{
|
||||
convert_srgb_linear_to_srgb (data, height * width);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gsize y = 0; y < height; y++)
|
||||
{
|
||||
convert_srgb_linear_to_srgb (data, width);
|
||||
data += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (* StepFunc) (float s0, float s1, float s2,
|
||||
float *d0, float *d1, float *d2);
|
||||
|
||||
void
|
||||
gdk_memory_convert_color_state (guchar *data,
|
||||
gsize stride,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *src_color_state,
|
||||
GdkColorState *dest_color_state,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
|
||||
src_color_state == GDK_COLOR_STATE_SRGB &&
|
||||
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
{
|
||||
convert_srgb_to_srgb_linear_in_place (data, stride, width, height);
|
||||
}
|
||||
else if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
|
||||
src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
|
||||
dest_color_state == GDK_COLOR_STATE_SRGB)
|
||||
{
|
||||
convert_srgb_linear_to_srgb_in_place (data, stride, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* General case, treat it just like gdk_memory_convert */
|
||||
|
||||
const GdkMemoryFormatDescription *desc = &memory_formats[format];
|
||||
StepFunc func;
|
||||
float *tmp;
|
||||
|
||||
if (src_color_state == GDK_COLOR_STATE_SRGB &&
|
||||
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
func = gtk_rgb_to_linear_srgb;
|
||||
else if (src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
|
||||
dest_color_state == GDK_COLOR_STATE_SRGB)
|
||||
func = gtk_linear_srgb_to_rgb;
|
||||
else
|
||||
return;
|
||||
|
||||
tmp = g_new (float, width * 4);
|
||||
|
||||
for (gsize y = 0; y < height; y++)
|
||||
{
|
||||
desc->to_float (tmp, data, width);
|
||||
|
||||
if (desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED)
|
||||
unpremultiply (tmp, width);
|
||||
|
||||
for (gsize x = 0; x < 4 * width; x += 4)
|
||||
func (tmp[x], tmp[x+1], tmp[x+2], &tmp[x], &tmp[x+1], &tmp[x+2]);
|
||||
|
||||
if (desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
premultiply (tmp, width);
|
||||
|
||||
desc->from_float (data, tmp, width);
|
||||
data += stride;
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth
|
||||
void gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
GLint *out_internal_format,
|
||||
GLint *out_internal_srgb_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4]);
|
||||
@@ -64,18 +65,20 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
|
||||
gboolean gles,
|
||||
GdkMemoryFormat *out_actual_format,
|
||||
GLint *out_internal_format,
|
||||
GLint *out_internal_srgb_format,
|
||||
GLenum *out_format,
|
||||
GLenum *out_type,
|
||||
GLint out_swizzle[4]);
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
|
||||
VkComponentMapping *out_swizzle);
|
||||
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
|
||||
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
|
||||
GdkMemoryFormat *out_rgba_format,
|
||||
VkComponentMapping *out_swizzle);
|
||||
#endif
|
||||
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
|
||||
|
||||
const char * gdk_memory_format_get_name (GdkMemoryFormat format);
|
||||
|
||||
void gdk_memory_convert (guchar *dest_data,
|
||||
gsize dest_stride,
|
||||
@@ -85,6 +88,13 @@ void gdk_memory_convert (guchar
|
||||
GdkMemoryFormat src_format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
void gdk_memory_convert_color_state (guchar *data,
|
||||
gsize stride,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *src_color_state,
|
||||
GdkColorState *dest_color_state,
|
||||
gsize width,
|
||||
gsize height);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+5
-11
@@ -202,8 +202,7 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
||||
}
|
||||
|
||||
GdkMemoryTexture *
|
||||
gdk_memory_texture_from_texture (GdkTexture *texture,
|
||||
GdkMemoryFormat format)
|
||||
gdk_memory_texture_from_texture (GdkTexture *texture)
|
||||
{
|
||||
GdkTexture *result;
|
||||
GBytes *bytes;
|
||||
@@ -213,21 +212,16 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
|
||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
|
||||
|
||||
if (GDK_IS_MEMORY_TEXTURE (texture))
|
||||
{
|
||||
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
|
||||
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
|
||||
|
||||
if (gdk_texture_get_format (texture) == format)
|
||||
return g_object_ref (memtex);
|
||||
}
|
||||
|
||||
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
|
||||
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
|
||||
data = g_malloc_n (stride, texture->height);
|
||||
|
||||
gdk_texture_do_download (texture, format, data, stride);
|
||||
gdk_texture_do_download (texture, texture->format, data, stride);
|
||||
bytes = g_bytes_new_take (data, stride * texture->height);
|
||||
result = gdk_memory_texture_new (texture->width,
|
||||
texture->height,
|
||||
format,
|
||||
texture->format,
|
||||
bytes,
|
||||
stride);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
@@ -28,8 +28,7 @@ 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,
|
||||
GdkMemoryFormat format);
|
||||
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
|
||||
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
|
||||
int x,
|
||||
int y,
|
||||
|
||||
+13
-2
@@ -396,10 +396,18 @@ 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)
|
||||
{
|
||||
return g_strdup_printf ("rgb(%d,%d,%d)",
|
||||
g_string_append_printf (string,
|
||||
"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.));
|
||||
@@ -410,12 +418,15 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
|
||||
|
||||
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
|
||||
|
||||
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
|
||||
g_string_append_printf (string,
|
||||
"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
|
||||
|
||||
@@ -72,5 +72,8 @@ _gdk_rgba_equal (gconstpointer p1,
|
||||
rgba1->alpha == rgba2->alpha;
|
||||
}
|
||||
|
||||
GString * gdk_rgba_print (const GdkRGBA *rgba,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+24
-3
@@ -1148,9 +1148,11 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||
|
||||
g_return_if_fail (priv->egl_native_window != NULL);
|
||||
|
||||
if (gdk_display_get_egl_config_high_depth (display) == gdk_display_get_egl_config (display))
|
||||
high_depth = FALSE;
|
||||
|
||||
if (priv->egl_surface_high_depth != high_depth &&
|
||||
priv->egl_surface != NULL &&
|
||||
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
|
||||
priv->egl_surface != NULL)
|
||||
{
|
||||
gdk_gl_context_clear_current_if_surface (self);
|
||||
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
|
||||
@@ -1159,16 +1161,35 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||
|
||||
if (priv->egl_surface == NULL)
|
||||
{
|
||||
EGLint attribs[4];
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (!high_depth && display->have_egl_gl_colorspace)
|
||||
{
|
||||
attribs[i++] = EGL_GL_COLORSPACE_KHR;
|
||||
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
|
||||
}
|
||||
g_assert (i < G_N_ELEMENTS (attribs));
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
||||
high_depth ? gdk_display_get_egl_config_high_depth (display)
|
||||
: gdk_display_get_egl_config (display),
|
||||
(EGLNativeWindowType) priv->egl_native_window,
|
||||
NULL);
|
||||
attribs);
|
||||
priv->egl_surface_high_depth = high_depth;
|
||||
self->is_srgb = !high_depth && display->have_egl_gl_colorspace;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_surface_get_gl_is_srgb (GdkSurface *self)
|
||||
{
|
||||
return self->is_srgb;
|
||||
}
|
||||
|
||||
GdkGLContext *
|
||||
gdk_surface_get_paint_gl_context (GdkSurface *surface,
|
||||
GError **error)
|
||||
|
||||
@@ -70,6 +70,7 @@ struct _GdkSurface
|
||||
guint shortcuts_inhibited : 1;
|
||||
guint request_motion : 1;
|
||||
guint has_pointer : 1;
|
||||
guint is_srgb : 1;
|
||||
|
||||
guint request_motion_id;
|
||||
|
||||
@@ -302,6 +303,8 @@ void gdk_surface_ensure_egl_surface (GdkSurface
|
||||
gboolean hdr);
|
||||
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
|
||||
|
||||
gboolean gdk_surface_get_gl_is_srgb (GdkSurface *self);
|
||||
|
||||
void gdk_surface_set_widget (GdkSurface *self,
|
||||
gpointer widget);
|
||||
gpointer gdk_surface_get_widget (GdkSurface *self);
|
||||
|
||||
@@ -44,12 +44,20 @@
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
#include "gdkpaintable.h"
|
||||
#include "gdksnapshot.h"
|
||||
#include "gdkcolorstateprivate.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 */
|
||||
@@ -62,6 +70,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT,
|
||||
PROP_COLOR_STATE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
@@ -275,6 +284,15 @@ gdk_texture_set_property (GObject *gobject,
|
||||
self->height = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
if (self->color_state)
|
||||
gdk_color_state_unref (self->color_state);
|
||||
if (g_value_get_boxed (value))
|
||||
self->color_state = gdk_color_state_ref (g_value_get_boxed (value));
|
||||
else
|
||||
self->color_state = GDK_COLOR_STATE_SRGB;
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@@ -299,6 +317,10 @@ gdk_texture_get_property (GObject *gobject,
|
||||
g_value_set_int (value, self->height);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
g_value_set_boxed (value, self->color_state);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@@ -337,6 +359,8 @@ gdk_texture_dispose (GObject *object)
|
||||
|
||||
gdk_texture_clear_render_data (self);
|
||||
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
|
||||
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -381,12 +405,28 @@ 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_boxed ("color-state", NULL, NULL,
|
||||
GDK_TYPE_COLOR_STATE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_texture_init (GdkTexture *self)
|
||||
{
|
||||
self->color_state = GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -720,6 +760,23 @@ 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,
|
||||
|
||||
@@ -83,6 +83,9 @@ 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,
|
||||
|
||||
@@ -26,6 +26,8 @@ struct _GdkTexture
|
||||
int width;
|
||||
int height;
|
||||
|
||||
GdkColorState *color_state;
|
||||
|
||||
gpointer render_key;
|
||||
gpointer render_data;
|
||||
GDestroyNotify render_notify;
|
||||
|
||||
@@ -767,9 +767,6 @@ 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.
|
||||
*
|
||||
|
||||
+6
-3
@@ -118,9 +118,12 @@ typedef enum
|
||||
|
||||
/**
|
||||
* GdkTitlebarGesture:
|
||||
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
|
||||
* @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].
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
|
||||
@@ -74,6 +74,7 @@ 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;
|
||||
|
||||
+37
-9
@@ -30,6 +30,7 @@
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include "gdkmemorytexture.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -94,6 +95,13 @@ 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 };
|
||||
@@ -640,15 +648,18 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
{
|
||||
if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
|
||||
{
|
||||
GdkMemoryDepth old_format = priv->current_format;
|
||||
GError *error = NULL;
|
||||
|
||||
priv->current_format = depth;
|
||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
priv->current_format = old_format;
|
||||
return;
|
||||
}
|
||||
}
|
||||
priv->current_format = depth;
|
||||
}
|
||||
for (i = 0; i < priv->n_images; i++)
|
||||
{
|
||||
@@ -873,7 +884,9 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
||||
switch ((int) formats[i].format)
|
||||
{
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
|
||||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_B8G8R8A8_UNORM)
|
||||
{
|
||||
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||
@@ -882,7 +895,9 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
||||
break;
|
||||
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
|
||||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_R8G8B8A8_UNORM)
|
||||
{
|
||||
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
@@ -1287,6 +1302,15 @@ gdk_vulkan_context_get_image_format (GdkVulkanContext *context)
|
||||
return priv->formats[priv->current_format].vk_format.format;
|
||||
}
|
||||
|
||||
GdkMemoryFormat
|
||||
gdk_vulkan_context_get_memory_format (GdkVulkanContext *context)
|
||||
{
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), GDK_MEMORY_DEFAULT);
|
||||
|
||||
return priv->formats[priv->current_format].gdk_format;
|
||||
}
|
||||
/**
|
||||
* gdk_vulkan_context_get_n_images:
|
||||
* @context: a `GdkVulkanContext`
|
||||
@@ -1859,8 +1883,9 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
||||
{
|
||||
g_free (key);
|
||||
vkDestroyShaderModule (display->vk_device,
|
||||
value,
|
||||
*((VkShaderModule *)value),
|
||||
NULL);
|
||||
g_free (value);
|
||||
}
|
||||
g_hash_table_unref (display->vk_shader_modules);
|
||||
|
||||
@@ -1988,13 +2013,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)
|
||||
@@ -2004,6 +2029,7 @@ 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,
|
||||
@@ -2011,18 +2037,20 @@ 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
|
||||
{
|
||||
shader = VK_NULL_HANDLE;
|
||||
g_free (shader);
|
||||
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return shader;
|
||||
return *shader;
|
||||
}
|
||||
|
||||
#else /* GDK_RENDERING_VULKAN */
|
||||
|
||||
@@ -94,6 +94,7 @@ VkDevice gdk_vulkan_context_get_device (GdkVulk
|
||||
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
|
||||
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
|
||||
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
|
||||
GdkMemoryFormat gdk_vulkan_context_get_memory_format (GdkVulkanContext *context);
|
||||
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
|
||||
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
|
||||
guint id);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -52,6 +52,7 @@ 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);
|
||||
@@ -68,10 +69,19 @@ 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,
|
||||
0, 0, 0, 0, /* shadow-left/right/top/bottom */
|
||||
shadow_left,
|
||||
shadow_right,
|
||||
shadow_top,
|
||||
shadow_bottom,
|
||||
monitor,
|
||||
&bounds,
|
||||
self->layout,
|
||||
@@ -306,14 +316,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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@ gdk_public_sources = files([
|
||||
'gdkcairo.c',
|
||||
'gdkcairocontext.c',
|
||||
'gdkclipboard.c',
|
||||
'gdkcolorstate.c',
|
||||
'gdkcontentdeserializer.c',
|
||||
'gdkcontentformats.c',
|
||||
'gdkcontentprovider.c',
|
||||
@@ -75,6 +76,7 @@ gdk_public_headers = files([
|
||||
'gdkcairo.h',
|
||||
'gdkcairocontext.h',
|
||||
'gdkclipboard.h',
|
||||
'gdkcolorstate.h',
|
||||
'gdkcontentdeserializer.h',
|
||||
'gdkcontentformats.h',
|
||||
'gdkcontentprovider.h',
|
||||
@@ -128,8 +130,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([
|
||||
'gdkeventsprivate.h',
|
||||
'gdkdevicetoolprivate.h',
|
||||
'gdkeventsprivate.h',
|
||||
'gdkhslaprivate.h',
|
||||
'gdkmonitorprivate.h',
|
||||
'gdkseatdefaultprivate.h',
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
#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
|
||||
@@ -382,6 +383,13 @@ 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 =
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#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>
|
||||
@@ -102,6 +103,7 @@ 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;
|
||||
|
||||
@@ -3866,9 +3866,25 @@ 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_leave,
|
||||
pointer_surface_preferred_buffer_scale,
|
||||
pointer_surface_preferred_buffer_transform,
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#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>
|
||||
@@ -84,6 +85,7 @@ 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;
|
||||
@@ -205,6 +207,7 @@ 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)
|
||||
@@ -215,6 +218,7 @@ 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)
|
||||
{
|
||||
@@ -877,7 +881,8 @@ 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);
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
if (!maybe_set_xdg_dialog_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);
|
||||
@@ -1089,12 +1094,40 @@ 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;
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
|
||||
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+121
-24
@@ -48,36 +48,133 @@ gdk_wayland_deps = [
|
||||
wlegldep,
|
||||
]
|
||||
|
||||
wlmod = import('unstable-wayland')
|
||||
# Fields:
|
||||
# - name: protocol name
|
||||
# - stability: protocol stability ('private', 'stable' or 'unstable')
|
||||
# - version: protocol version
|
||||
# - required: wayland_protocols version check
|
||||
proto_sources = [
|
||||
'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),
|
||||
{
|
||||
'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,
|
||||
},
|
||||
]
|
||||
|
||||
gdk_wayland_gen_headers = []
|
||||
|
||||
wlmod = import('unstable-wayland')
|
||||
foreach p: proto_sources
|
||||
# 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]
|
||||
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
|
||||
endforeach
|
||||
|
||||
libgdk_wayland = static_library('gdk-wayland',
|
||||
|
||||
@@ -1408,7 +1408,7 @@ register_clipboard_notification ()
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
|
||||
wclass.lpszClassName = "GdkClipboardNotification";
|
||||
wclass.lpszClassName = L"GdkClipboardNotification";
|
||||
wclass.lpfnWndProc = _clipboard_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
|
||||
@@ -1506,9 +1506,9 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
|
||||
GdkWin32ContentFormatPair fmt;
|
||||
HMODULE user32;
|
||||
|
||||
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
|
||||
thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP");
|
||||
|
||||
user32 = LoadLibrary ("user32.dll");
|
||||
user32 = LoadLibrary (L"user32.dll");
|
||||
win32_clipdrop->GetUpdatedClipboardFormats = (GetUpdatedClipboardFormatsFunc) GetProcAddress (user32, "GetUpdatedClipboardFormats");
|
||||
FreeLibrary (user32);
|
||||
|
||||
@@ -1557,21 +1557,21 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
|
||||
* the lead and map the GDK contentformat "image/png" to the clipboard
|
||||
* format name "PNG" etc.
|
||||
*/
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_PNG) = RegisterClipboardFormatA ("PNG");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_JFIF) = RegisterClipboardFormatA ("JFIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_GIF) = RegisterClipboardFormatA ("GIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_PNG) = RegisterClipboardFormat (L"PNG");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_JFIF) = RegisterClipboardFormat (L"JFIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_GIF) = RegisterClipboardFormat (L"GIF");
|
||||
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW) = RegisterClipboardFormatA ("UniformResourceLocatorW");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST) = RegisterClipboardFormatA (CFSTR_SHELLIDLIST);
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_HTML_FORMAT) = RegisterClipboardFormatA ("HTML Format");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_HTML) = RegisterClipboardFormatA ("text/html");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW) = RegisterClipboardFormat (L"UniformResourceLocatorW");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST) = RegisterClipboardFormat (CFSTR_SHELLIDLIST);
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_HTML_FORMAT) = RegisterClipboardFormat (L"HTML Format");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_HTML) = RegisterClipboardFormat (L"text/html");
|
||||
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_PNG) = RegisterClipboardFormatA ("image/png");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_JPEG) = RegisterClipboardFormatA ("image/jpeg");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_BMP) = RegisterClipboardFormatA ("image/bmp");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_GIF) = RegisterClipboardFormatA ("image/gif");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_URI_LIST) = RegisterClipboardFormatA ("text/uri-list");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_PLAIN_UTF8) = RegisterClipboardFormatA ("text/plain;charset=utf-8");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_PNG) = RegisterClipboardFormat (L"image/png");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_JPEG) = RegisterClipboardFormat (L"image/jpeg");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_BMP) = RegisterClipboardFormat (L"image/bmp");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_GIF) = RegisterClipboardFormat (L"image/gif");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_URI_LIST) = RegisterClipboardFormat (L"text/uri-list");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_PLAIN_UTF8) = RegisterClipboardFormat (L"text/plain;charset=utf-8");
|
||||
|
||||
win32_clipdrop->active_source_drags = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL);
|
||||
|
||||
@@ -2364,9 +2364,9 @@ transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
* check?
|
||||
*/
|
||||
(IsClipboardFormatAvailable
|
||||
(RegisterClipboardFormatA ("application/x-moz-nativeimage")) ||
|
||||
(RegisterClipboardFormat (L"application/x-moz-nativeimage")) ||
|
||||
IsClipboardFormatAvailable
|
||||
(RegisterClipboardFormatA ("UniformResourceLocatorW"))) &&
|
||||
(RegisterClipboardFormat (L"UniformResourceLocatorW"))) &&
|
||||
#endif
|
||||
TRUE)
|
||||
{
|
||||
|
||||
+36
-35
@@ -31,12 +31,13 @@
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
char *id;
|
||||
const wchar_t *id;
|
||||
} default_cursors[] = {
|
||||
/* -- Win32 cursor names: -- */
|
||||
{ "appstarting", IDC_APPSTARTING },
|
||||
{ "arrow", IDC_ARROW },
|
||||
{ "cross", IDC_CROSS },
|
||||
{ "dnd-move", IDC_ARROW },
|
||||
{ "hand", IDC_HAND },
|
||||
{ "help", IDC_HELP },
|
||||
{ "ibeam", IDC_IBEAM },
|
||||
@@ -456,32 +457,32 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (NULL,
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImage (NULL,
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (GetModuleHandle (NULL),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImage (GetModuleHandle (NULL),
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (this_module (),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImage (this_module (),
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_CREATE:
|
||||
@@ -498,12 +499,12 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
}
|
||||
|
||||
static Win32Cursor *
|
||||
win32_cursor_new (GdkWin32CursorLoadType load_type,
|
||||
gpointer resource_name,
|
||||
int width,
|
||||
int height,
|
||||
guint load_flags,
|
||||
int xcursor_number)
|
||||
win32_cursor_new (GdkWin32CursorLoadType load_type,
|
||||
wchar_t *resource_name,
|
||||
int width,
|
||||
int height,
|
||||
guint load_flags,
|
||||
int xcursor_number)
|
||||
{
|
||||
Win32Cursor *result;
|
||||
|
||||
@@ -631,9 +632,9 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
|
||||
/* Prefer W32 cursors */
|
||||
if (cursors[i].builtin)
|
||||
shared_hcursor = LoadImageA (NULL, cursors[i].builtin, IMAGE_CURSOR,
|
||||
size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
shared_hcursor = LoadImage (NULL, cursors[i].builtin, IMAGE_CURSOR,
|
||||
size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
|
||||
/* Fall back to X cursors, but only if we've got no theme cursor */
|
||||
if (shared_hcursor == NULL && g_hash_table_lookup (theme->named_cursors, cursors[i].name) == NULL)
|
||||
@@ -645,7 +646,7 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
DestroyCursor (x_hcursor);
|
||||
|
||||
cursor = win32_cursor_new (shared_hcursor ? GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL : GDK_WIN32_CURSOR_CREATE,
|
||||
(gpointer) cursors[i].builtin,
|
||||
(wchar_t*) cursors[i].builtin,
|
||||
size,
|
||||
size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
|
||||
@@ -660,14 +661,14 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
if (default_cursors[i].name == NULL)
|
||||
break;
|
||||
|
||||
shared_hcursor = LoadImageA (NULL, default_cursors[i].id, IMAGE_CURSOR, size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
shared_hcursor = LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
|
||||
if (shared_hcursor == NULL)
|
||||
continue;
|
||||
|
||||
cursor = win32_cursor_new (GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL,
|
||||
(gpointer) default_cursors[i].id,
|
||||
(wchar_t*) default_cursors[i].id,
|
||||
size,
|
||||
size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
|
||||
@@ -779,8 +780,8 @@ win32hcursor_idc_from_name (GdkWin32Display *display,
|
||||
continue;
|
||||
|
||||
return gdk_win32_hcursor_new (display,
|
||||
LoadImageA (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
|
||||
LR_SHARED | LR_DEFAULTSIZE),
|
||||
LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
|
||||
LR_SHARED | LR_DEFAULTSIZE),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
@@ -884,7 +885,7 @@ gdk_win32hcursor_create_for_name (GdkWin32Display *display,
|
||||
/* Allow to load named cursor resources linked into the executable.
|
||||
* Cursors obtained with LoadCursor() cannot be destroyed.
|
||||
*/
|
||||
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
|
||||
return gdk_win32_hcursor_new (display, LoadCursorA (hinstance, name), FALSE);
|
||||
}
|
||||
|
||||
static HICON
|
||||
|
||||
@@ -121,7 +121,7 @@ gdk_device_manager_win32_finalize (GObject *object)
|
||||
#if DEBUG_WINTAB
|
||||
|
||||
static void
|
||||
print_lc(LOGCONTEXT *lc)
|
||||
print_lc(LOGCONTEXTA *lc)
|
||||
{
|
||||
g_print ("lcName = %s\n", lc->lcName);
|
||||
g_print ("lcOptions =");
|
||||
@@ -374,13 +374,13 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
|
||||
wintab_contexts = NULL;
|
||||
|
||||
n = GetSystemDirectory (&dummy, 0);
|
||||
n = GetSystemDirectoryA (&dummy, 0);
|
||||
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
wintab32_dll_path = g_malloc (n + 1 + strlen (WINTAB32_DLL));
|
||||
k = GetSystemDirectory (wintab32_dll_path, n);
|
||||
k = GetSystemDirectoryA (wintab32_dll_path, n);
|
||||
|
||||
if (k == 0 || k > n)
|
||||
{
|
||||
@@ -392,7 +392,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
strcat (wintab32_dll_path, G_DIR_SEPARATOR_S);
|
||||
strcat (wintab32_dll_path, WINTAB32_DLL);
|
||||
|
||||
if ((wintab32 = LoadLibrary (wintab32_dll_path)) == NULL)
|
||||
if ((wintab32 = LoadLibraryA (wintab32_dll_path)) == NULL)
|
||||
return;
|
||||
|
||||
if ((p_WTInfoA = (t_WTInfoA) GetProcAddress (wintab32, "WTInfoA")) == NULL)
|
||||
@@ -433,7 +433,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
|
||||
for (devix = 0; devix < ndevices; devix++)
|
||||
{
|
||||
LOGCONTEXT lc;
|
||||
LOGCONTEXTA lc;
|
||||
|
||||
/* We open the Wintab device (hmm, what if there are several, or
|
||||
* can there even be several, probably not?) as a system
|
||||
|
||||
@@ -480,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
|
||||
wclass.lpszClassName = "GdkDisplayChange";
|
||||
wclass.lpszClassName = L"GdkDisplayChange";
|
||||
wclass.lpfnWndProc = display_change_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
@@ -606,7 +606,7 @@ gdk_win32_display_get_name (GdkDisplay *display)
|
||||
window_station_name = "WinSta0";
|
||||
}
|
||||
|
||||
processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle ("kernel32.dll"), "ProcessIdToSessionId");
|
||||
processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle (L"kernel32.dll"), "ProcessIdToSessionId");
|
||||
if (!processIdToSessionId || !processIdToSessionId (GetCurrentProcessId (), &session_id))
|
||||
session_id = 0;
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ struct _GdkWin32Display
|
||||
guint hasWglEXTSwapControl : 1;
|
||||
guint hasWglOMLSyncControl : 1;
|
||||
guint hasWglARBPixelFormat : 1;
|
||||
guint force_enable_depth_bits : 1;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
guint hasEglKHRCreateContext : 1;
|
||||
|
||||
@@ -658,7 +658,7 @@ _gdk_win32_dnd_thread_main (gpointer data)
|
||||
/* Create a message queue */
|
||||
PeekMessage (&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
||||
|
||||
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
|
||||
thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP");
|
||||
|
||||
/* Signal the main thread that we're ready.
|
||||
* This is the only time the queue works in reverse.
|
||||
|
||||
@@ -419,7 +419,7 @@ set_up_low_level_keyboard_hook (void)
|
||||
else
|
||||
WIN32_API_FAILED ("SetWindowsHookEx");
|
||||
|
||||
aerosnap_message = RegisterWindowMessage ("GDK_WIN32_AEROSNAP_MESSAGE");
|
||||
aerosnap_message = RegisterWindowMessage (L"GDK_WIN32_AEROSNAP_MESSAGE");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -470,7 +470,7 @@ _gdk_events_init (GdkDisplay *display)
|
||||
};
|
||||
#endif
|
||||
|
||||
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
|
||||
got_gdk_events_message = RegisterWindowMessage (L"GDK_WIN32_GOT_EVENTS");
|
||||
|
||||
#if 0
|
||||
/* Check if we have some input locale identifier loaded that uses a
|
||||
@@ -1685,7 +1685,7 @@ _gdk_win32_surface_fill_min_max_info (GdkSurface *window,
|
||||
nearest_monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
nearest_info.cbSize = sizeof (nearest_info);
|
||||
|
||||
if (GetMonitorInfoA (nearest_monitor, &nearest_info))
|
||||
if (GetMonitorInfo (nearest_monitor, &nearest_info))
|
||||
{
|
||||
/* MSDN says that we must specify maximized window
|
||||
* size as if it was located on the primary monitor.
|
||||
|
||||
@@ -142,8 +142,7 @@ get_wgl_pfd (HDC hdc,
|
||||
|
||||
pfd->nSize = sizeof (PIXELFORMATDESCRIPTOR);
|
||||
|
||||
if (display_win32 != NULL &&
|
||||
display_win32->hasWglARBPixelFormat)
|
||||
if (display_win32->hasWglARBPixelFormat)
|
||||
{
|
||||
UINT num_formats;
|
||||
int colorbits = GetDeviceCaps (hdc, BITSPIXEL);
|
||||
@@ -176,15 +175,18 @@ get_wgl_pfd (HDC hdc,
|
||||
pixelAttribs[i++] = WGL_ALPHA_BITS_ARB;
|
||||
pixelAttribs[i++] = 8;
|
||||
|
||||
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
pixelAttribs[i++] = WGL_STENCIL_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
pixelAttribs[i++] = WGL_ACCUM_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
if (!display_win32->force_enable_depth_bits)
|
||||
{
|
||||
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
}
|
||||
|
||||
/* end of "Update PIXEL_ATTRIBUTES above if any groups are added here!" */
|
||||
|
||||
pixelAttribs[i++] = 0; /* end of pixelAttribs */
|
||||
@@ -215,8 +217,20 @@ get_wgl_pfd (HDC hdc,
|
||||
pfd->cColorBits = GetDeviceCaps (hdc, BITSPIXEL);
|
||||
pfd->cAlphaBits = 8;
|
||||
pfd->iLayerType = PFD_MAIN_PLANE;
|
||||
pfd->cAccumBits = 0;
|
||||
pfd->cStencilBits = 0;
|
||||
|
||||
if (!display_win32->force_enable_depth_bits)
|
||||
pfd->cDepthBits = 0;
|
||||
|
||||
best_pf = ChoosePixelFormat (hdc, pfd);
|
||||
|
||||
/* try again if driver enforces depth buffers */
|
||||
if (best_pf == 0 && !display_win32->force_enable_depth_bits)
|
||||
{
|
||||
display_win32->force_enable_depth_bits = TRUE;
|
||||
get_wgl_pfd (hdc, pfd, display_win32);
|
||||
}
|
||||
}
|
||||
|
||||
return best_pf;
|
||||
@@ -234,7 +248,7 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
|
||||
|
||||
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
|
||||
|
||||
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
|
||||
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, display_win32);
|
||||
|
||||
if (best_idx != 0)
|
||||
set_pixel_format_result = SetPixelFormat (display_win32->dummy_context_wgl.hdc,
|
||||
@@ -269,7 +283,7 @@ create_dummy_gl_window (void)
|
||||
ATOM klass;
|
||||
HWND hwnd = NULL;
|
||||
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpszClassName = L"GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
@@ -730,7 +730,7 @@ _gdk_win32_key_to_string (LONG lParam)
|
||||
char buf[100];
|
||||
char *keyname_utf8;
|
||||
|
||||
if (GetKeyNameText (lParam, buf, sizeof (buf)) &&
|
||||
if (GetKeyNameTextA (lParam, buf, sizeof (buf)) &&
|
||||
(keyname_utf8 = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL)) != NULL)
|
||||
{
|
||||
char *retval = static_printf ("%s", keyname_utf8);
|
||||
@@ -780,7 +780,7 @@ _gdk_win32_cf_to_string (UINT format)
|
||||
if (format >= CF_PRIVATEFIRST &&
|
||||
format <= CF_PRIVATELAST)
|
||||
return static_printf ("CF_PRIVATE%d", format - CF_PRIVATEFIRST);
|
||||
if (GetClipboardFormatName (format, buf, sizeof (buf)))
|
||||
if (GetClipboardFormatNameA (format, buf, sizeof (buf)))
|
||||
return static_printf ("'%s'", buf);
|
||||
else
|
||||
return static_printf ("unk-%#lx", format);
|
||||
|
||||
@@ -197,7 +197,7 @@ typedef struct _Win32Cursor Win32Cursor;
|
||||
|
||||
struct _Win32Cursor {
|
||||
GdkWin32CursorLoadType load_type;
|
||||
gunichar2 *resource_name;
|
||||
wchar_t *resource_name;
|
||||
int width;
|
||||
int height;
|
||||
guint load_flags;
|
||||
|
||||
@@ -326,7 +326,7 @@ RegisterGdkClass (GType wtype)
|
||||
static WNDCLASSEXW wcl;
|
||||
ATOM klass = 0;
|
||||
|
||||
wcl.cbSize = sizeof (WNDCLASSEX);
|
||||
wcl.cbSize = sizeof (WNDCLASSEXW);
|
||||
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
|
||||
* on WM_SIZE and WM_MOVE. Flicker, Performance!
|
||||
*/
|
||||
@@ -340,7 +340,7 @@ RegisterGdkClass (GType wtype)
|
||||
/* initialize once! */
|
||||
if (0 == hAppIcon && 0 == hAppIconSm)
|
||||
{
|
||||
char sLoc [MAX_PATH+1];
|
||||
wchar_t sLoc [MAX_PATH+1];
|
||||
|
||||
// try to load first icon of executable program
|
||||
if (0 != GetModuleFileName (NULL, sLoc, MAX_PATH))
|
||||
@@ -2064,7 +2064,7 @@ stash_window (GdkSurface *window,
|
||||
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
hmonitor_info.cbSize = sizeof (hmonitor_info);
|
||||
|
||||
if (!GetMonitorInfoA (hmonitor, &hmonitor_info))
|
||||
if (!GetMonitorInfo (hmonitor, &hmonitor_info))
|
||||
return;
|
||||
|
||||
if (impl->snap_stash == NULL)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
static const struct { const char *name; const char *builtin; int type; guchar width; guchar height; guchar hotx; guchar hoty; char *data; } cursors[] = {
|
||||
static const struct { const char *name; const wchar_t *builtin; int type; guchar width; guchar height; guchar hotx; guchar hoty; char *data; } cursors[] = {
|
||||
{ "X_cursor", NULL, 0, 16, 16, 7, 7,
|
||||
"\125\000\000\125\152\100\001\251\152\220\006\251\152\244\032\251"
|
||||
"\032\251\152\244\006\252\252\220\001\252\252\100\000\152\251\000"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gdksurfaceprivate.h"
|
||||
|
||||
#include <cairo-xlib.h>
|
||||
|
||||
@@ -53,6 +54,9 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
|
||||
GdkX11Surface *self = GDK_X11_SURFACE (surface);
|
||||
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self));
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
Display *dpy = gdk_x11_display_get_xdisplay (display);
|
||||
XVisualInfo *visinfo;
|
||||
int value;
|
||||
|
||||
if (self->glx_drawable)
|
||||
return self->glx_drawable;
|
||||
@@ -62,6 +66,11 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
|
||||
gdk_x11_surface_get_xid (surface),
|
||||
NULL);
|
||||
|
||||
visinfo = glXGetVisualFromFBConfig (dpy, display_x11->glx_config);
|
||||
glXGetConfig (dpy, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
|
||||
surface->is_srgb = value != 0;
|
||||
XFree (visinfo);
|
||||
|
||||
return self->glx_drawable;
|
||||
}
|
||||
|
||||
@@ -758,6 +767,17 @@ visual_is_rgba (XVisualInfo *visinfo)
|
||||
visinfo->visual->blue_mask == 0x0000ff;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
visual_is_srgb (Display *display,
|
||||
XVisualInfo *visinfo)
|
||||
{
|
||||
int value;
|
||||
|
||||
glXGetConfig (display, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
|
||||
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
#define MAX_GLX_ATTRS 30
|
||||
|
||||
static gboolean
|
||||
@@ -777,6 +797,7 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
|
||||
WITH_STENCIL_AND_DEPTH_BUFFER,
|
||||
NO_ALPHA,
|
||||
NO_ALPHA_VISUAL,
|
||||
NO_SRGB,
|
||||
PERFECT
|
||||
} best_features;
|
||||
int i = 0;
|
||||
@@ -865,6 +886,20 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!visual_is_srgb (dpy, visinfo))
|
||||
{
|
||||
if (best_features < NO_SRGB)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Best GLX config is %u for visual 0x%lX with no SRGB", i, visinfo->visualid);
|
||||
best_features = NO_SRGB;
|
||||
*out_visual = visinfo->visual;
|
||||
*out_depth = visinfo->depth;
|
||||
self->glx_config = configs[i];
|
||||
}
|
||||
XFree (visinfo);
|
||||
continue;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "GLX config %u for visual 0x%lX is the perfect choice", i, visinfo->visualid);
|
||||
best_features = PERFECT;
|
||||
*out_visual = visinfo->visual;
|
||||
|
||||
@@ -1483,6 +1483,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
|
||||
gboolean ensure_mipmap,
|
||||
gboolean *out_can_mipmap,
|
||||
GLint *gl_internalformat,
|
||||
GLint *gl_internalsrgbformat,
|
||||
GLenum *gl_format,
|
||||
GLenum *gl_type,
|
||||
GLint gl_swizzle[4])
|
||||
@@ -1507,6 +1508,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
|
||||
gdk_memory_format_gl_format (data_format,
|
||||
gdk_gl_context_get_use_es (self->context),
|
||||
gl_internalformat,
|
||||
gl_internalsrgbformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle);
|
||||
@@ -1519,6 +1521,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
|
||||
gdk_gl_context_get_use_es (self->context),
|
||||
&alt_format,
|
||||
gl_internalformat,
|
||||
gl_internalsrgbformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
@@ -1534,6 +1537,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
|
||||
gdk_memory_format_gl_format (alt_format,
|
||||
gdk_gl_context_get_use_es (self->context),
|
||||
gl_internalformat,
|
||||
gl_internalsrgbformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle);
|
||||
@@ -1552,6 +1556,7 @@ memory_format_gl_format (GskGLCommandQueue *self,
|
||||
gdk_memory_format_gl_format (fallbacks[i],
|
||||
gdk_gl_context_get_use_es (self->context),
|
||||
gl_internalformat,
|
||||
gl_internalsrgbformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle);
|
||||
@@ -1670,7 +1675,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
int width, height;
|
||||
GdkMemoryFormat data_format;
|
||||
GLint gl_internalformat;
|
||||
GLint gl_internalformat, gl_internalsrgbformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
@@ -1713,6 +1718,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
ensure_mipmap,
|
||||
out_can_mipmap,
|
||||
&gl_internalformat,
|
||||
&gl_internalsrgbformat,
|
||||
&gl_format,
|
||||
&gl_type,
|
||||
gl_swizzle);
|
||||
|
||||
@@ -972,7 +972,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
|
||||
|
||||
if (texture_id == 0)
|
||||
{
|
||||
downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
|
||||
downloaded_texture = gdk_memory_texture_from_texture (texture);
|
||||
|
||||
/* The download_texture() call may have switched the GL context. Make sure
|
||||
* the right context is at work again.
|
||||
@@ -1471,8 +1471,7 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
|
||||
}
|
||||
|
||||
slices = g_new0 (GskGLTextureSlice, n_slices);
|
||||
memtex = gdk_memory_texture_from_texture (texture,
|
||||
gdk_texture_get_format (texture));
|
||||
memtex = gdk_memory_texture_from_texture (texture);
|
||||
|
||||
if (ensure_mipmap)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
#include <pango/pangofc-font.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
#endif
|
||||
|
||||
#define MAX_GLYPH_SIZE 128
|
||||
|
||||
G_DEFINE_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
|
||||
@@ -127,7 +134,7 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
|
||||
else
|
||||
{
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
@@ -218,6 +225,16 @@ render_glyph (cairo_surface_t *surface,
|
||||
cairo_t *cr;
|
||||
PangoGlyphString glyph_string;
|
||||
PangoGlyphInfo glyph_info;
|
||||
#ifdef HAVE_PANGOFT
|
||||
FT_Face face;
|
||||
FT_Bool darken = 1;
|
||||
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
face = pango_fc_font_lock_face (PANGO_FC_FONT (key->font));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
FT_Face_Properties (face, 1, &property);
|
||||
#endif
|
||||
|
||||
g_assert (surface != NULL);
|
||||
|
||||
@@ -236,6 +253,12 @@ render_glyph (cairo_surface_t *surface,
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pango_fc_font_unlock_face (PANGO_FC_FONT (key->font));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -293,7 +316,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
|
||||
{
|
||||
pixel_data = cairo_image_surface_get_data (surface);
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
|
||||
|
||||
@@ -125,7 +125,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
|
||||
{
|
||||
pixel_data = surface_data;
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
|
||||
|
||||
@@ -102,3 +102,8 @@ GSK_GL_DEFINE_PROGRAM_NO_CLIP (external,
|
||||
GSK_GL_DEFINE_PROGRAM_NO_CLIP (premultiply,
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("premultiply.glsl")),
|
||||
GSK_GL_NO_UNIFORMS)
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (colorconvert,
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("colorconvert.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, TO_LINEAR, u_to_linear))
|
||||
|
||||
|
||||
+24
-2
@@ -34,6 +34,7 @@
|
||||
#include <gdk/gdkglcontextprivate.h>
|
||||
#include <gdk/gdksurfaceprivate.h>
|
||||
#include <gdk/gdksubsurfaceprivate.h>
|
||||
#include <gdk/gdkcolorstateprivate.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gsk/gskdebugprivate.h>
|
||||
#include <gsk/gskrendererprivate.h>
|
||||
@@ -41,6 +42,15 @@
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
#include <gsk/gskrectprivate.h>
|
||||
|
||||
/**
|
||||
* GskGLRenderer:
|
||||
*
|
||||
* A GL based renderer.
|
||||
*
|
||||
* See [class@Gsk.Renderer].
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
struct _GskGLRendererClass
|
||||
{
|
||||
GskRendererClass parent_class;
|
||||
@@ -353,6 +363,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
GdkSurface *surface;
|
||||
gboolean clear_framebuffer;
|
||||
float scale;
|
||||
GdkColorState *target_color_state;
|
||||
|
||||
g_assert (GSK_IS_GL_RENDERER (renderer));
|
||||
g_assert (root != NULL);
|
||||
@@ -375,6 +386,17 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
gsk_render_node_get_preferred_depth (root),
|
||||
update_area);
|
||||
|
||||
if (gdk_surface_get_gl_is_srgb (surface))
|
||||
{
|
||||
g_debug ("Relying on GL to do srgb-linear->srgb conversion");
|
||||
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
|
||||
target_color_state = GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
gdk_gl_context_make_current (self->context);
|
||||
|
||||
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
|
||||
@@ -383,7 +405,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
|
||||
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
|
||||
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, clear_framebuffer);
|
||||
gsk_gl_render_job_render (job, root);
|
||||
gsk_gl_render_job_render (job, root, target_color_state);
|
||||
gsk_gl_driver_end_frame (self->driver);
|
||||
gsk_gl_render_job_free (job);
|
||||
|
||||
@@ -467,7 +489,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
{
|
||||
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
|
||||
job = gsk_gl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id, TRUE);
|
||||
gsk_gl_render_job_render_flipped (job, root);
|
||||
gsk_gl_render_job_render_flipped (job, root, GDK_COLOR_STATE_SRGB);
|
||||
texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE);
|
||||
texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id, gdk_format);
|
||||
gsk_gl_driver_end_frame (self->driver);
|
||||
|
||||
+85
-10
@@ -33,6 +33,7 @@
|
||||
#include <gdk/gdkdmabuftexture.h>
|
||||
#include <gdk/gdksurfaceprivate.h>
|
||||
#include <gdk/gdksubsurfaceprivate.h>
|
||||
#include <gdk/gdkcolorstateprivate.h>
|
||||
#include <gsk/gsktransformprivate.h>
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
#include <gsk/gskrectprivate.h>
|
||||
@@ -972,11 +973,28 @@ gsk_gl_render_job_update_clip (GskGLRenderJob *job,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static inline float
|
||||
srgb_inverse_transfer_function (float v)
|
||||
{
|
||||
if (v >= 0.04045)
|
||||
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
|
||||
else
|
||||
return v / 12.92;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rgba_to_half (const GdkRGBA *rgba,
|
||||
guint16 h[4])
|
||||
{
|
||||
float_to_half4 ((const float *)rgba, h);
|
||||
float v[4];
|
||||
|
||||
v[0] = srgb_inverse_transfer_function (rgba->red);
|
||||
v[1] = srgb_inverse_transfer_function (rgba->green);
|
||||
v[2] = srgb_inverse_transfer_function (rgba->blue);
|
||||
v[3] = rgba->alpha;
|
||||
|
||||
float_to_half4 (v, h);
|
||||
}
|
||||
|
||||
/* fill_vertex_data */
|
||||
@@ -3677,8 +3695,11 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
|
||||
g_assert (offscreen.texture_id);
|
||||
g_assert (offscreen.was_offscreen == FALSE);
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
gsk_gl_program_set_uniform1i (job->current_program,
|
||||
UNIFORM_TO_LINEAR, 0,
|
||||
1);
|
||||
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -3704,7 +3725,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
|
||||
g_assert (slices != NULL);
|
||||
g_assert (n_slices > 0);
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
for (unsigned int i = 0; i < n_slices; i++)
|
||||
{
|
||||
@@ -3718,6 +3739,9 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
|
||||
|
||||
if (i > 0)
|
||||
gsk_gl_render_job_split_draw (job);
|
||||
gsk_gl_program_set_uniform1i (job->current_program,
|
||||
UNIFORM_TO_LINEAR, 0,
|
||||
1);
|
||||
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -3832,8 +3856,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
|
||||
u1 = (clip_rect.origin.x + clip_rect.size.width - bounds->origin.x) / bounds->size.width;
|
||||
v1 = (clip_rect.origin.y + clip_rect.size.height - bounds->origin.y) / bounds->size.height;
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
gsk_gl_program_set_uniform1i (job->current_program,
|
||||
UNIFORM_TO_LINEAR, 0,
|
||||
1);
|
||||
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -3859,7 +3886,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
|
||||
|
||||
gsk_gl_driver_slice_texture (job->driver, texture, need_mipmap, &slices, &n_slices);
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
for (guint i = 0; i < n_slices; i++)
|
||||
{
|
||||
@@ -3877,6 +3904,9 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
|
||||
if (i > 0)
|
||||
gsk_gl_render_job_split_draw (job);
|
||||
|
||||
gsk_gl_program_set_uniform1i (job->current_program,
|
||||
UNIFORM_TO_LINEAR, 0,
|
||||
1);
|
||||
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -3910,8 +3940,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
|
||||
gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
|
||||
|
||||
render_texture:
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
gsk_gl_program_set_uniform1i (job->current_program,
|
||||
UNIFORM_TO_LINEAR, 0,
|
||||
1);
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -4464,7 +4497,8 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
|
||||
void
|
||||
gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
|
||||
GskRenderNode *root)
|
||||
GskRenderNode *root,
|
||||
GdkColorState *target_color_state)
|
||||
{
|
||||
graphene_matrix_t proj;
|
||||
guint framebuffer_id;
|
||||
@@ -4506,8 +4540,17 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
|
||||
gsk_gl_render_job_set_alpha (job, 1.0f);
|
||||
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
|
||||
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
|
||||
|
||||
GskGLProgram *program;
|
||||
if (target_color_state == GDK_COLOR_STATE_SRGB)
|
||||
program = CHOOSE_PROGRAM (job, colorconvert);
|
||||
else
|
||||
program = CHOOSE_PROGRAM (job, blit);
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, program))
|
||||
{
|
||||
if (target_color_state == GDK_COLOR_STATE_SRGB)
|
||||
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
@@ -4528,7 +4571,8 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
|
||||
|
||||
void
|
||||
gsk_gl_render_job_render (GskGLRenderJob *job,
|
||||
GskRenderNode *root)
|
||||
GskRenderNode *root,
|
||||
GdkColorState *target_color_state)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time;
|
||||
float scale;
|
||||
@@ -4551,7 +4595,38 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
|
||||
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
|
||||
if (job->clear_framebuffer)
|
||||
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
|
||||
gsk_gl_render_job_visit_node (job, root);
|
||||
|
||||
if (target_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
{
|
||||
gsk_gl_render_job_visit_node (job, root);
|
||||
}
|
||||
else
|
||||
{
|
||||
GskGLRenderOffscreen offscreen = {0};
|
||||
|
||||
offscreen.bounds = &root->bounds;
|
||||
offscreen.force_offscreen = TRUE;
|
||||
offscreen.reset_clip = TRUE;
|
||||
offscreen.do_not_cache = TRUE;
|
||||
|
||||
gsk_gl_render_job_visit_node_with_offscreen (job, root, &offscreen);
|
||||
|
||||
g_assert (offscreen.texture_id);
|
||||
|
||||
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
|
||||
{
|
||||
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
offscreen.texture_id);
|
||||
job->source_is_glyph_atlas = FALSE;
|
||||
gsk_gl_render_job_draw_offscreen_rect (job, &root->bounds);
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
}
|
||||
}
|
||||
|
||||
gdk_gl_context_pop_debug_group (job->command_queue->context);
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Build GL command queue", "");
|
||||
|
||||
@@ -30,7 +30,9 @@ GskGLRenderJob *gsk_gl_render_job_new (GskGLDriver *dri
|
||||
gboolean clear_framebuffer);
|
||||
void gsk_gl_render_job_free (GskGLRenderJob *job);
|
||||
void gsk_gl_render_job_render (GskGLRenderJob *job,
|
||||
GskRenderNode *root);
|
||||
GskRenderNode *root,
|
||||
GdkColorState *color_state);
|
||||
void gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
|
||||
GskRenderNode *root);
|
||||
GskRenderNode *root,
|
||||
GdkColorState *color_state);
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// VERTEX_SHADER:
|
||||
// colorconvert.glsl
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
// colorconvert.glsl
|
||||
|
||||
uniform int u_to_linear;
|
||||
|
||||
float
|
||||
srgb_transfer_function (float v)
|
||||
{
|
||||
if (v >= 0.04045)
|
||||
return pow (((v + 0.055)/(1.0 + 0.055)), 2.4);
|
||||
else
|
||||
return v / 12.92;
|
||||
}
|
||||
|
||||
float
|
||||
srgb_inverse_transfer_function (float v)
|
||||
{
|
||||
if (v > 0.0031308)
|
||||
return 1.055 * pow (v, 1.0/2.4) - 0.055;
|
||||
else
|
||||
return 12.92 * v;
|
||||
}
|
||||
|
||||
vec4
|
||||
srgb_to_linear_srgb (vec4 color)
|
||||
{
|
||||
return vec4 (srgb_transfer_function (color.r),
|
||||
srgb_transfer_function (color.g),
|
||||
srgb_transfer_function (color.b),
|
||||
color.a);
|
||||
}
|
||||
|
||||
vec4
|
||||
linear_srgb_to_srgb (vec4 color)
|
||||
{
|
||||
return vec4 (srgb_inverse_transfer_function (color.r),
|
||||
srgb_inverse_transfer_function (color.g),
|
||||
srgb_inverse_transfer_function (color.b),
|
||||
color.a);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = GskTexture(u_source, vUv);
|
||||
|
||||
if (color.a != 0.0)
|
||||
color.rgb /= color.a;
|
||||
|
||||
if (u_to_linear != 0)
|
||||
color = srgb_to_linear_srgb (color);
|
||||
else
|
||||
color = linear_srgb_to_srgb (color);
|
||||
|
||||
gskSetOutputColor(gsk_scaled_premultiply(color, u_alpha));
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "gdk/gdkdisplayprivate.h"
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
#include "gdk/gdkprofilerprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@@ -76,6 +77,7 @@ gsk_gl_device_create_offscreen_image (GskGpuDevice *device,
|
||||
|
||||
return gsk_gl_image_new (self,
|
||||
gdk_memory_depth_get_format (depth),
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE,
|
||||
width,
|
||||
height);
|
||||
@@ -85,6 +87,7 @@ static GskGpuImage *
|
||||
gsk_gl_device_create_upload_image (GskGpuDevice *device,
|
||||
gboolean with_mipmap,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
@@ -92,6 +95,7 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device,
|
||||
|
||||
return gsk_gl_image_new (self,
|
||||
format,
|
||||
color_state,
|
||||
0,
|
||||
width,
|
||||
height);
|
||||
@@ -107,6 +111,7 @@ gsk_gl_device_create_download_image (GskGpuDevice *device,
|
||||
|
||||
return gsk_gl_image_new (self,
|
||||
gdk_memory_depth_get_format (depth),
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
GSK_GPU_IMAGE_RENDERABLE,
|
||||
width,
|
||||
height);
|
||||
@@ -121,6 +126,7 @@ gsk_gl_device_create_atlas_image (GskGpuDevice *device,
|
||||
|
||||
return gsk_gl_image_new (self,
|
||||
GDK_MEMORY_DEFAULT,
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
GSK_GPU_IMAGE_RENDERABLE,
|
||||
width,
|
||||
height);
|
||||
@@ -635,6 +641,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
|
||||
GdkMemoryFormat *out_format,
|
||||
GskGpuImageFlags *out_flags,
|
||||
GLint *out_gl_internal_format,
|
||||
GLint *out_gl_internal_srgb_format,
|
||||
GLenum *out_gl_format,
|
||||
GLenum *out_gl_type,
|
||||
GLint out_swizzle[4])
|
||||
@@ -654,6 +661,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
|
||||
gdk_memory_format_gl_format (format,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
out_gl_internal_format,
|
||||
out_gl_internal_srgb_format,
|
||||
out_gl_format,
|
||||
out_gl_type,
|
||||
out_swizzle);
|
||||
@@ -665,6 +673,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
|
||||
gdk_gl_context_get_use_es (context),
|
||||
&alt_format,
|
||||
out_gl_internal_format,
|
||||
out_gl_internal_srgb_format,
|
||||
out_gl_format,
|
||||
out_gl_type,
|
||||
out_swizzle) &&
|
||||
@@ -688,6 +697,7 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
|
||||
gdk_memory_format_gl_format (fallbacks[i],
|
||||
gdk_gl_context_get_use_es (context),
|
||||
out_gl_internal_format,
|
||||
out_gl_internal_srgb_format,
|
||||
out_gl_format,
|
||||
out_gl_type,
|
||||
out_swizzle);
|
||||
|
||||
@@ -26,6 +26,7 @@ void gsk_gl_device_find_gl_format (GskGLDe
|
||||
GdkMemoryFormat *out_format,
|
||||
GskGpuImageFlags *out_flags,
|
||||
GLint *out_gl_internal_format,
|
||||
GLint *out_gl_internal_srgb_format,
|
||||
GLenum *out_gl_format,
|
||||
GLenum *out_gl_type,
|
||||
GLint out_swizzle[4]);
|
||||
|
||||
@@ -70,7 +70,10 @@ gsk_gl_frame_cleanup (GskGpuFrame *frame)
|
||||
if (self->sync)
|
||||
{
|
||||
glClientWaitSync (self->sync, 0, -1);
|
||||
g_clear_pointer (&self->sync, glDeleteSync);
|
||||
|
||||
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
|
||||
glDeleteSync (self->sync);
|
||||
self->sync = NULL;
|
||||
}
|
||||
|
||||
self->next_texture_slot = 0;
|
||||
|
||||
+43
-7
@@ -1,9 +1,10 @@
|
||||
#include "config.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "gskglimageprivate.h"
|
||||
|
||||
#include "gdk/gdkdisplayprivate.h"
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
struct _GskGLImage
|
||||
{
|
||||
@@ -73,11 +74,13 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
GdkGLContext *context,
|
||||
GdkMemoryFormat format,
|
||||
gsize width,
|
||||
gsize height)
|
||||
gsize height,
|
||||
gboolean is_srgb)
|
||||
{
|
||||
GskGLImage *self;
|
||||
GskGpuImageFlags flags;
|
||||
GLint swizzle[4];
|
||||
GLint gl_internal_format, gl_internal_srgb_format;
|
||||
|
||||
self = g_object_new (GSK_TYPE_GL_IMAGE, NULL);
|
||||
|
||||
@@ -87,11 +90,25 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
0,
|
||||
&format,
|
||||
&flags,
|
||||
&self->gl_internal_format,
|
||||
&gl_internal_format,
|
||||
&gl_internal_srgb_format,
|
||||
&self->gl_format,
|
||||
&self->gl_type,
|
||||
swizzle);
|
||||
|
||||
|
||||
if (is_srgb)
|
||||
{
|
||||
if (gl_internal_srgb_format != -1)
|
||||
self->gl_internal_format = gl_internal_srgb_format;
|
||||
else /* FIXME: not really correct */
|
||||
self->gl_internal_format = gl_internal_format;
|
||||
flags |= GSK_GPU_IMAGE_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->gl_internal_format = gl_internal_format;
|
||||
}
|
||||
|
||||
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, format, width, height);
|
||||
|
||||
/* texture_id == 0 means backbuffer */
|
||||
@@ -109,6 +126,7 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
GskGpuImage *
|
||||
gsk_gl_image_new (GskGLDevice *device,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
GskGpuImageFlags required_flags,
|
||||
gsize width,
|
||||
gsize height)
|
||||
@@ -116,6 +134,7 @@ gsk_gl_image_new (GskGLDevice *device,
|
||||
GskGLImage *self;
|
||||
GLint swizzle[4];
|
||||
GskGpuImageFlags flags;
|
||||
GLint gl_internal_format, gl_internal_srgb_format;
|
||||
gsize max_size;
|
||||
|
||||
max_size = gsk_gpu_device_get_max_image_size (GSK_GPU_DEVICE (device));
|
||||
@@ -129,11 +148,23 @@ gsk_gl_image_new (GskGLDevice *device,
|
||||
required_flags,
|
||||
&format,
|
||||
&flags,
|
||||
&self->gl_internal_format,
|
||||
&gl_internal_format,
|
||||
&gl_internal_srgb_format,
|
||||
&self->gl_format,
|
||||
&self->gl_type,
|
||||
swizzle);
|
||||
|
||||
|
||||
if (gl_internal_srgb_format != -1 &&
|
||||
gdk_color_state_equal (color_state, GDK_COLOR_STATE_SRGB))
|
||||
{
|
||||
self->gl_internal_format = gl_internal_srgb_format;
|
||||
flags |= GSK_GPU_IMAGE_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->gl_internal_format = gl_internal_format;
|
||||
}
|
||||
|
||||
gsk_gpu_image_setup (GSK_GPU_IMAGE (self),
|
||||
flags,
|
||||
format,
|
||||
@@ -177,6 +208,7 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
|
||||
GdkMemoryFormat format, real_format;
|
||||
GskGpuImageFlags flags;
|
||||
GskGLImage *self;
|
||||
GLint gl_internal_format, gl_internal_srgb_format;
|
||||
GLint swizzle[4];
|
||||
|
||||
format = gdk_texture_get_format (owner);
|
||||
@@ -188,10 +220,14 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
|
||||
0,
|
||||
&real_format,
|
||||
&flags,
|
||||
&self->gl_internal_format,
|
||||
&gl_internal_format,
|
||||
&gl_internal_srgb_format,
|
||||
&self->gl_format,
|
||||
&self->gl_type,
|
||||
swizzle);
|
||||
|
||||
self->gl_internal_format = gl_internal_format;
|
||||
|
||||
if (format != real_format)
|
||||
flags = GSK_GPU_IMAGE_NO_BLIT |
|
||||
(gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0);
|
||||
|
||||
@@ -14,9 +14,11 @@ GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDe
|
||||
GdkGLContext *context,
|
||||
GdkMemoryFormat format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
gsize height,
|
||||
gboolean converts_srgb);
|
||||
GskGpuImage * gsk_gl_image_new (GskGLDevice *device,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
GskGpuImageFlags required_flags,
|
||||
gsize width,
|
||||
gsize height);
|
||||
|
||||
@@ -23,6 +23,7 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
|
||||
{
|
||||
GskGpuBlendmodeInstance *instance = (GskGpuBlendmodeInstance *) instance_;
|
||||
|
||||
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id);
|
||||
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
|
||||
|
||||
@@ -21,7 +21,7 @@ color_equal (const float *color1,
|
||||
const float *color2)
|
||||
{
|
||||
return gdk_rgba_equal (&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] },
|
||||
&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] });
|
||||
&(GdkRGBA) { color2[0], color2[1], color2[2], color2[3] });
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+5
-14
@@ -14,7 +14,7 @@ struct _GskGpuClearOp
|
||||
GskGpuOp op;
|
||||
|
||||
cairo_rectangle_int_t rect;
|
||||
GdkRGBA color;
|
||||
float color[4];
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -29,23 +29,14 @@ gsk_gpu_clear_op_print (GskGpuOp *op,
|
||||
guint indent)
|
||||
{
|
||||
GskGpuClearOp *self = (GskGpuClearOp *) op;
|
||||
float rgba[4];
|
||||
|
||||
gsk_gpu_print_op (string, indent, "clear");
|
||||
gsk_gpu_print_int_rect (string, &self->rect);
|
||||
gsk_gpu_rgba_to_float (&self->color, rgba);
|
||||
gsk_gpu_print_rgba (string, rgba);
|
||||
gsk_gpu_print_rgba (string, self->color);
|
||||
gsk_gpu_print_newline (string);
|
||||
}
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
static void
|
||||
gsk_gpu_init_clear_value (VkClearValue *value,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
gsk_gpu_rgba_to_float (rgba, value->color.float32);
|
||||
}
|
||||
|
||||
static GskGpuOp *
|
||||
gsk_gpu_clear_op_vk_command (GskGpuOp *op,
|
||||
GskGpuFrame *frame,
|
||||
@@ -54,7 +45,7 @@ gsk_gpu_clear_op_vk_command (GskGpuOp *op,
|
||||
GskGpuClearOp *self = (GskGpuClearOp *) op;
|
||||
VkClearValue clear_value;
|
||||
|
||||
gsk_gpu_init_clear_value (&clear_value, &self->color);
|
||||
memcpy (clear_value.color.float32, self->color, sizeof (float) * 4);
|
||||
|
||||
vkCmdClearAttachments (state->vk_command_buffer,
|
||||
1,
|
||||
@@ -92,7 +83,7 @@ gsk_gpu_clear_op_gl_command (GskGpuOp *op,
|
||||
else
|
||||
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height);
|
||||
|
||||
glClearColor (self->color.red, self->color.green, self->color.blue, self->color.alpha);
|
||||
glClearColor (self->color[0], self->color[1], self->color[2], self->color[3]);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
@@ -121,5 +112,5 @@ gsk_gpu_clear_op (GskGpuFrame *frame,
|
||||
self = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
|
||||
|
||||
self->rect = *rect;
|
||||
self->color = *color;
|
||||
gsk_gpu_rgba_to_float (color, self->color);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskgpucolorconvertopprivate.h"
|
||||
|
||||
#include "gskgpuframeprivate.h"
|
||||
#include "gskgpuprintprivate.h"
|
||||
#include "gskrectprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
#include "gpu/shaders/gskgpucolorconvertinstance.h"
|
||||
|
||||
typedef struct _GskGpuColorConvertOp GskGpuColorConvertOp;
|
||||
|
||||
struct _GskGpuColorConvertOp
|
||||
{
|
||||
GskGpuShaderOp op;
|
||||
};
|
||||
|
||||
static guint
|
||||
gsk_gpu_color_conversion (GdkColorState *from,
|
||||
GdkColorState *to)
|
||||
{
|
||||
if (from == to)
|
||||
return 0;
|
||||
|
||||
return GDK_DEFAULT_COLOR_STATE_ID (from) | (GDK_DEFAULT_COLOR_STATE_ID (to) << 16);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_color_convert_op_print_instance (GskGpuShaderOp *shader,
|
||||
gpointer instance_,
|
||||
GString *string)
|
||||
{
|
||||
GskGpuColorconvertInstance *instance = (GskGpuColorconvertInstance *) instance_;
|
||||
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
gsk_gpu_print_color_conversion (string, shader->variation);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLOR_CONVERT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorConvertOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
gsk_gpu_shader_op_finish,
|
||||
gsk_gpu_shader_op_print,
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
gsk_gpu_shader_op_vk_command,
|
||||
#endif
|
||||
gsk_gpu_shader_op_gl_command
|
||||
},
|
||||
"gskgpucolorconvert",
|
||||
sizeof (GskGpuColorconvertInstance),
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
&gsk_gpu_colorconvert_info,
|
||||
#endif
|
||||
gsk_gpu_color_convert_op_print_instance,
|
||||
gsk_gpu_colorconvert_setup_attrib_locations,
|
||||
gsk_gpu_colorconvert_setup_vao
|
||||
};
|
||||
|
||||
void
|
||||
gsk_gpu_color_convert_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
GdkColorState *from,
|
||||
GdkColorState *to,
|
||||
GskGpuDescriptors *desc,
|
||||
guint32 descriptor,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *tex_rect)
|
||||
{
|
||||
GskGpuColorconvertInstance *instance;
|
||||
|
||||
gsk_gpu_shader_op_alloc (frame,
|
||||
&GSK_GPU_COLOR_CONVERT_OP_CLASS,
|
||||
gsk_gpu_color_conversion (from, to),
|
||||
clip,
|
||||
desc,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
gsk_gpu_rect_to_float (tex_rect, offset, instance->tex_rect);
|
||||
instance->tex_id = descriptor;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "gskgpushaderopprivate.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gsk_gpu_color_convert_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
GdkColorState *from,
|
||||
GdkColorState *to,
|
||||
GskGpuDescriptors *desc,
|
||||
guint32 descriptor,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *tex_rect);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+63
-20
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "gsk/gskdebugprivate.h"
|
||||
#include "gsk/gskprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
#define MAX_SLICES_PER_ATLAS 64
|
||||
|
||||
@@ -252,6 +253,9 @@ struct _GskGpuCachedTexture
|
||||
|
||||
GdkTexture *texture;
|
||||
GskGpuImage *image;
|
||||
GdkColorState *color_state;
|
||||
GskGpuImage *image2;
|
||||
GdkColorState *color_state2;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -263,6 +267,9 @@ gsk_gpu_cached_texture_free (GskGpuDevice *device,
|
||||
gpointer key, value;
|
||||
|
||||
g_clear_object (&self->image);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
g_clear_object (&self->image2);
|
||||
g_clear_pointer (&self->color_state2, gdk_color_state_unref);
|
||||
|
||||
if (g_hash_table_steal_extended (priv->texture_cache, self->texture, &key, &value))
|
||||
{
|
||||
@@ -325,9 +332,10 @@ gsk_gpu_cached_texture_destroy_cb (gpointer data)
|
||||
}
|
||||
|
||||
static GskGpuCachedTexture *
|
||||
gsk_gpu_cached_texture_new (GskGpuDevice *device,
|
||||
GdkTexture *texture,
|
||||
GskGpuImage *image)
|
||||
gsk_gpu_cached_texture_new (GskGpuDevice *device,
|
||||
GdkTexture *texture,
|
||||
GskGpuImage *image,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device);
|
||||
GskGpuCachedTexture *self;
|
||||
@@ -340,6 +348,9 @@ gsk_gpu_cached_texture_new (GskGpuDevice *device,
|
||||
self = gsk_gpu_cached_new (device, &GSK_GPU_CACHED_TEXTURE_CLASS, NULL);
|
||||
self->texture = texture;
|
||||
self->image = g_object_ref (image);
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
self->image2 = NULL;
|
||||
self->color_state2 = NULL;
|
||||
((GskGpuCached *)self)->pixels = gsk_gpu_image_get_width (image) * gsk_gpu_image_get_height (image);
|
||||
self->dead_pixels_counter = &priv->dead_texture_pixels;
|
||||
self->use_count = 2;
|
||||
@@ -696,13 +707,14 @@ gsk_gpu_device_create_offscreen_image (GskGpuDevice *self,
|
||||
}
|
||||
|
||||
GskGpuImage *
|
||||
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
|
||||
gboolean with_mipmap,
|
||||
GdkMemoryFormat format,
|
||||
gsize width,
|
||||
gsize height)
|
||||
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
|
||||
gboolean with_mipmap,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, width, height);
|
||||
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, color_state, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -850,34 +862,65 @@ gsk_gpu_device_add_atlas_image (GskGpuDevice *self,
|
||||
}
|
||||
|
||||
GskGpuImage *
|
||||
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
gint64 timestamp)
|
||||
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
GdkColorState *color_state,
|
||||
gint64 timestamp)
|
||||
{
|
||||
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self);
|
||||
GskGpuCachedTexture *cache;
|
||||
GskGpuImage *image;
|
||||
|
||||
cache = gdk_texture_get_render_data (texture, self);
|
||||
if (cache == NULL)
|
||||
cache = g_hash_table_lookup (priv->texture_cache, texture);
|
||||
|
||||
if (!cache || !cache->image || gsk_gpu_cached_texture_is_invalid (cache))
|
||||
if (!cache || gsk_gpu_cached_texture_is_invalid (cache))
|
||||
return NULL;
|
||||
|
||||
if (gdk_color_state_equal (color_state, cache->color_state))
|
||||
image = cache->image;
|
||||
else if (cache->color_state2 && gdk_color_state_equal (color_state, cache->color_state2))
|
||||
image = cache->image2;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
|
||||
|
||||
return g_object_ref (cache->image);
|
||||
return g_object_ref (image);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *image)
|
||||
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *image,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
GskGpuCachedTexture *cache;
|
||||
|
||||
cache = gsk_gpu_cached_texture_new (self, texture, image);
|
||||
cache = gdk_texture_get_render_data (texture, self);
|
||||
if (cache)
|
||||
{
|
||||
if (gdk_color_state_equal (color_state, gdk_texture_get_color_state (texture)))
|
||||
{
|
||||
g_clear_pointer (&cache->color_state, gdk_color_state_unref);
|
||||
g_clear_object (&cache->image);
|
||||
cache->color_state = gdk_color_state_ref (color_state);
|
||||
cache->image = g_object_ref (image);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_clear_pointer (&cache->color_state2, gdk_color_state_unref);
|
||||
g_clear_object (&cache->image2);
|
||||
cache->color_state2 = gdk_color_state_ref (color_state);
|
||||
cache->image2 = g_object_ref (image);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cache = gsk_gpu_cached_texture_new (self, texture, image, color_state);
|
||||
}
|
||||
|
||||
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
|
||||
}
|
||||
@@ -950,7 +993,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height),
|
||||
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, GDK_COLOR_STATE_SRGB, rect.size.width, rect.size.height),
|
||||
rect.origin.x = 0;
|
||||
rect.origin.y = 0;
|
||||
padding = 0;
|
||||
|
||||
@@ -35,6 +35,7 @@ struct _GskGpuDeviceClass
|
||||
GskGpuImage * (* create_upload_image) (GskGpuDevice *self,
|
||||
gboolean with_mipmap,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskGpuImage * (* create_download_image) (GskGpuDevice *self,
|
||||
@@ -64,6 +65,7 @@ GskGpuImage * gsk_gpu_device_create_offscreen_image (GskGpuD
|
||||
GskGpuImage * gsk_gpu_device_create_upload_image (GskGpuDevice *self,
|
||||
gboolean with_mipmap,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskGpuImage * gsk_gpu_device_create_download_image (GskGpuDevice *self,
|
||||
@@ -73,11 +75,13 @@ GskGpuImage * gsk_gpu_device_create_download_image (GskGpuD
|
||||
void gsk_gpu_device_make_current (GskGpuDevice *self);
|
||||
GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
GdkColorState *color_state,
|
||||
gint64 timestamp);
|
||||
void gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
|
||||
GdkTexture *texture,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *image);
|
||||
GskGpuImage *image,
|
||||
GdkColorState *color_state);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "gskvulkanimageprivate.h"
|
||||
#endif
|
||||
|
||||
#include "gdk/gdkdmabuftexturebuilderprivate.h"
|
||||
#include "gdk/gdkdmabuftextureprivate.h"
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
|
||||
@@ -145,7 +146,7 @@ gsk_gpu_download_op_vk_command (GskGpuOp *op,
|
||||
GskVulkanDevice *device = GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame));
|
||||
VkDevice vk_device = gsk_vulkan_device_get_vk_device (device);
|
||||
|
||||
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image);
|
||||
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image, gdk_texture_get_color_state (self->texture));
|
||||
|
||||
if (gsk_vulkan_device_has_feature (device, GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT))
|
||||
{
|
||||
@@ -249,13 +250,36 @@ gsk_gl_texture_data_free (gpointer user_data)
|
||||
|
||||
gdk_gl_context_make_current (data->context);
|
||||
|
||||
g_clear_pointer (&data->sync, glDeleteSync);
|
||||
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
|
||||
if (data->sync)
|
||||
{
|
||||
glDeleteSync (data->sync);
|
||||
data->sync = NULL;
|
||||
}
|
||||
|
||||
glDeleteTextures (1, &data->texture_id);
|
||||
g_object_unref (data->context);
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
typedef struct
|
||||
{
|
||||
GdkDmabuf dmabuf;
|
||||
} Texture;
|
||||
|
||||
static void
|
||||
release_dmabuf_texture (gpointer data)
|
||||
{
|
||||
Texture *texture = data;
|
||||
|
||||
for (unsigned int i = 0; i < texture->dmabuf.n_planes; i++)
|
||||
g_close (texture->dmabuf.planes[i].fd, NULL);
|
||||
g_free (texture);
|
||||
}
|
||||
#endif
|
||||
|
||||
static GskGpuOp *
|
||||
gsk_gpu_download_op_gl_command (GskGpuOp *op,
|
||||
GskGpuFrame *frame,
|
||||
@@ -265,12 +289,44 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
|
||||
GdkGLTextureBuilder *builder;
|
||||
GskGLTextureData *data;
|
||||
GdkGLContext *context;
|
||||
guint texture_id;
|
||||
|
||||
context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame));
|
||||
texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
if (self->allow_dmabuf)
|
||||
{
|
||||
Texture *texture;
|
||||
|
||||
texture = g_new0 (Texture, 1);
|
||||
|
||||
if (gdk_gl_context_export_dmabuf (context, texture_id, &texture->dmabuf))
|
||||
{
|
||||
GdkDmabufTextureBuilder *db;
|
||||
|
||||
db = gdk_dmabuf_texture_builder_new ();
|
||||
gdk_dmabuf_texture_builder_set_display (db, gdk_gl_context_get_display (context));
|
||||
gdk_dmabuf_texture_builder_set_dmabuf (db, &texture->dmabuf);
|
||||
gdk_dmabuf_texture_builder_set_premultiplied (db, gdk_memory_format_get_premultiplied (gsk_gpu_image_get_format (self->image)));
|
||||
gdk_dmabuf_texture_builder_set_width (db, gsk_gpu_image_get_width (self->image));
|
||||
gdk_dmabuf_texture_builder_set_height (db, gsk_gpu_image_get_height (self->image));
|
||||
|
||||
self->texture = gdk_dmabuf_texture_builder_build (db, release_dmabuf_texture, texture, NULL);
|
||||
|
||||
g_object_unref (db);
|
||||
|
||||
if (self->texture)
|
||||
return op->next;
|
||||
}
|
||||
|
||||
g_free (texture);
|
||||
}
|
||||
#endif
|
||||
|
||||
data = g_new (GskGLTextureData, 1);
|
||||
data->context = g_object_ref (context);
|
||||
data->texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
|
||||
data->texture_id = texture_id;
|
||||
|
||||
if (gdk_gl_context_has_feature (context, GDK_GL_FEATURE_SYNC))
|
||||
data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
|
||||
+24
-8
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "gdk/gdkdmabufdownloaderprivate.h"
|
||||
#include "gdk/gdktexturedownloaderprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
#define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024
|
||||
|
||||
@@ -402,17 +403,26 @@ gsk_gpu_frame_get_last_op (GskGpuFrame *self)
|
||||
}
|
||||
|
||||
GskGpuImage *
|
||||
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
|
||||
gboolean with_mipmap,
|
||||
GdkTexture *texture)
|
||||
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
|
||||
gboolean with_mipmap,
|
||||
GdkTexture *texture,
|
||||
GdkColorState **out_color_state)
|
||||
{
|
||||
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
|
||||
GskGpuImage *image;
|
||||
GdkColorState *color_state;
|
||||
|
||||
image = GSK_GPU_FRAME_GET_CLASS (self)->upload_texture (self, with_mipmap, texture);
|
||||
|
||||
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
|
||||
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
else
|
||||
color_state = gdk_texture_get_color_state (texture);
|
||||
|
||||
if (image)
|
||||
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image);
|
||||
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image, color_state);
|
||||
|
||||
*out_color_state = color_state;
|
||||
|
||||
return image;
|
||||
}
|
||||
@@ -561,6 +571,7 @@ copy_texture (gpointer user_data,
|
||||
static void
|
||||
gsk_gpu_frame_record_rect (GskGpuFrame *self,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_rectangle_int_t *clip,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport)
|
||||
@@ -572,6 +583,7 @@ gsk_gpu_frame_record_rect (GskGpuFrame *self,
|
||||
|
||||
gsk_gpu_node_processor_process (self,
|
||||
target,
|
||||
target_color_state,
|
||||
clip,
|
||||
node,
|
||||
viewport);
|
||||
@@ -585,6 +597,7 @@ static void
|
||||
gsk_gpu_frame_record (GskGpuFrame *self,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_region_t *clip,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport,
|
||||
@@ -603,13 +616,14 @@ gsk_gpu_frame_record (GskGpuFrame *self,
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (clip, i, &rect);
|
||||
gsk_gpu_frame_record_rect (self, target, &rect, node, viewport);
|
||||
gsk_gpu_frame_record_rect (self, target, target_color_state, &rect, node, viewport);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gsk_gpu_frame_record_rect (self,
|
||||
target,
|
||||
target_color_state,
|
||||
&(cairo_rectangle_int_t) {
|
||||
0, 0,
|
||||
gsk_gpu_image_get_width (target),
|
||||
@@ -656,6 +670,7 @@ void
|
||||
gsk_gpu_frame_render (GskGpuFrame *self,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_region_t *region,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport,
|
||||
@@ -663,7 +678,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
|
||||
{
|
||||
gsk_gpu_frame_cleanup (self);
|
||||
|
||||
gsk_gpu_frame_record (self, timestamp, target, region, node, viewport, texture);
|
||||
gsk_gpu_frame_record (self, timestamp, target, target_color_state, region, node, viewport, texture);
|
||||
|
||||
gsk_gpu_frame_submit (self);
|
||||
}
|
||||
@@ -702,10 +717,11 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
|
||||
{
|
||||
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
|
||||
GskGpuImage *image;
|
||||
GdkColorState *color_state;
|
||||
|
||||
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, timestamp);
|
||||
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, GDK_COLOR_STATE_SRGB, timestamp);
|
||||
if (image == NULL)
|
||||
image = gsk_gpu_frame_upload_texture (self, FALSE, texture);
|
||||
image = gsk_gpu_frame_upload_texture (self, FALSE, texture, &color_state);
|
||||
if (image == NULL)
|
||||
{
|
||||
g_critical ("Could not upload texture");
|
||||
|
||||
@@ -58,7 +58,8 @@ gpointer gsk_gpu_frame_alloc_op (GskGpuF
|
||||
gsize size);
|
||||
GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self,
|
||||
gboolean with_mipmap,
|
||||
GdkTexture *texture);
|
||||
GdkTexture *texture,
|
||||
GdkColorState **out_color_state);
|
||||
GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self);
|
||||
gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self,
|
||||
gsize size);
|
||||
@@ -75,6 +76,7 @@ void gsk_gpu_frame_wait (GskGpuF
|
||||
void gsk_gpu_frame_render (GskGpuFrame *self,
|
||||
gint64 timestamp,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_region_t *region,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport,
|
||||
|
||||
@@ -114,7 +114,7 @@ gsk_gpu_image_toggle_ref_texture (GskGpuImage *self,
|
||||
g_object_add_toggle_ref (G_OBJECT (self), gsk_gpu_image_texture_toggle_ref_cb, texture);
|
||||
g_object_unref (self);
|
||||
}
|
||||
|
||||
|
||||
GdkMemoryFormat
|
||||
gsk_gpu_image_get_format (GskGpuImage *self)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "gskgpuframeprivate.h"
|
||||
#include "gskgpuprintprivate.h"
|
||||
#include "gskrectprivate.h"
|
||||
#include "gskenumtypes.h"
|
||||
|
||||
#include "gpu/shaders/gskgpumaskinstance.h"
|
||||
|
||||
@@ -22,6 +23,7 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
|
||||
{
|
||||
GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_;
|
||||
|
||||
gsk_gpu_print_enum (string, GSK_TYPE_MASK_MODE, shader->variation);
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
|
||||
|
||||
+201
-24
@@ -10,6 +10,7 @@
|
||||
#include "gskgpubluropprivate.h"
|
||||
#include "gskgpuclearopprivate.h"
|
||||
#include "gskgpuclipprivate.h"
|
||||
#include "gskgpucolorconvertopprivate.h"
|
||||
#include "gskgpucolorizeopprivate.h"
|
||||
#include "gskgpucolormatrixopprivate.h"
|
||||
#include "gskgpucoloropprivate.h"
|
||||
@@ -44,6 +45,7 @@
|
||||
|
||||
#include "gdk/gdkrgbaprivate.h"
|
||||
#include "gdk/gdksubsurfaceprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
/* the epsilon we allow pixels to be off due to rounding errors.
|
||||
* Chosen rather randomly.
|
||||
@@ -120,6 +122,7 @@ struct _GskGpuNodeProcessor
|
||||
float opacity;
|
||||
|
||||
GskGpuGlobals pending_globals;
|
||||
GdkColorState *color_state;
|
||||
};
|
||||
|
||||
#define GDK_ARRAY_NAME pattern_buffer
|
||||
@@ -141,6 +144,7 @@ struct _GskGpuPatternWriter
|
||||
guint stack;
|
||||
|
||||
PatternBuffer buffer;
|
||||
GdkColorState *color_state;
|
||||
};
|
||||
|
||||
static void gsk_gpu_node_processor_add_node (GskGpuNodeProcessor *self,
|
||||
@@ -153,6 +157,7 @@ gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
|
||||
{
|
||||
g_clear_pointer (&self->modelview, gsk_transform_unref);
|
||||
g_clear_object (&self->desc);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -160,6 +165,7 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
|
||||
GskGpuFrame *frame,
|
||||
GskGpuDescriptors *desc,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *color_state,
|
||||
const cairo_rectangle_int_t *clip,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
@@ -202,6 +208,8 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
|
||||
-viewport->origin.y);
|
||||
self->opacity = 1.0;
|
||||
self->pending_globals = GSK_GPU_GLOBAL_MATRIX | GSK_GPU_GLOBAL_SCALE | GSK_GPU_GLOBAL_CLIP | GSK_GPU_GLOBAL_SCISSOR | GSK_GPU_GLOBAL_BLEND;
|
||||
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -338,6 +346,7 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
||||
GskGpuFrame *frame,
|
||||
GdkMemoryDepth depth,
|
||||
const graphene_vec2_t *scale,
|
||||
GdkColorState *color_state,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
GskGpuImage *image;
|
||||
@@ -359,6 +368,7 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
||||
frame,
|
||||
NULL,
|
||||
image,
|
||||
color_state,
|
||||
&area,
|
||||
viewport);
|
||||
|
||||
@@ -381,9 +391,97 @@ gsk_gpu_node_processor_finish_draw (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_node_processor_finish (self);
|
||||
}
|
||||
|
||||
static GskGpuImage *
|
||||
gsk_gpu_color_convert (GskGpuFrame *frame,
|
||||
GskGpuImage *image,
|
||||
GdkColorState *from,
|
||||
GdkColorState *to)
|
||||
{
|
||||
GskGpuNodeProcessor other;
|
||||
int width, height;
|
||||
GdkMemoryDepth depth;
|
||||
GskGpuImage *copy;
|
||||
guint32 descriptor;
|
||||
graphene_rect_t rect;
|
||||
|
||||
if (gdk_color_state_equal (from, to))
|
||||
return image;
|
||||
|
||||
width = gsk_gpu_image_get_width (image);
|
||||
height = gsk_gpu_image_get_height (image);
|
||||
depth = gdk_memory_format_get_depth (gsk_gpu_image_get_format (image));
|
||||
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (from));
|
||||
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (to));
|
||||
rect = GRAPHENE_RECT_INIT (0, 0, width, height);
|
||||
|
||||
copy = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
depth,
|
||||
width, height);
|
||||
|
||||
gsk_gpu_node_processor_init (&other,
|
||||
frame,
|
||||
NULL,
|
||||
copy,
|
||||
to,
|
||||
&(cairo_rectangle_int_t) { 0, 0, width, height },
|
||||
&rect);
|
||||
|
||||
gsk_gpu_render_pass_begin_op (other.frame,
|
||||
copy,
|
||||
&(cairo_rectangle_int_t) { 0, 0, width, height },
|
||||
GSK_RENDER_PASS_OFFSCREEN);
|
||||
|
||||
descriptor = gsk_gpu_node_processor_add_image (&other, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
|
||||
gsk_gpu_node_processor_sync_globals (&other, 0);
|
||||
|
||||
gsk_gpu_color_convert_op (frame,
|
||||
GSK_GPU_SHADER_CLIP_NONE,
|
||||
from,
|
||||
to,
|
||||
other.desc,
|
||||
descriptor,
|
||||
&rect,
|
||||
&other.offset,
|
||||
&rect);
|
||||
|
||||
gsk_gpu_render_pass_end_op (other.frame,
|
||||
copy,
|
||||
GSK_RENDER_PASS_OFFSCREEN);
|
||||
|
||||
gsk_gpu_node_processor_finish (&other);
|
||||
|
||||
g_object_unref (image);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
|
||||
graphene_rect_t *out_bounds)
|
||||
{
|
||||
graphene_rect_offset_r (&self->clip.rect.bounds,
|
||||
- self->offset.x,
|
||||
- self->offset.y,
|
||||
out_bounds);
|
||||
|
||||
/* FIXME: We could try the scissor rect here.
|
||||
* But how often is that smaller than the clip bounds?
|
||||
*/
|
||||
}
|
||||
|
||||
static GskGpuImage * gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
const graphene_rect_t *clip_bounds,
|
||||
const graphene_vec2_t *scale,
|
||||
GdkColorState *color_state,
|
||||
GskRenderNode *node,
|
||||
graphene_rect_t *out_bounds);
|
||||
|
||||
void
|
||||
gsk_gpu_node_processor_process (GskGpuFrame *frame,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_rectangle_int_t *clip,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport)
|
||||
@@ -394,10 +492,46 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame,
|
||||
frame,
|
||||
NULL,
|
||||
target,
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
clip,
|
||||
viewport);
|
||||
|
||||
gsk_gpu_node_processor_add_node (&self, node);
|
||||
if (gdk_color_state_equal (target_color_state, GDK_COLOR_STATE_SRGB_LINEAR))
|
||||
{
|
||||
gsk_gpu_node_processor_add_node (&self, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
GskGpuImage *image;
|
||||
graphene_rect_t clip_bounds;
|
||||
graphene_rect_t bounds;
|
||||
guint32 descriptor;
|
||||
|
||||
gsk_gpu_node_processor_sync_globals (&self, 0);
|
||||
|
||||
gsk_gpu_node_processor_get_clip_bounds (&self, &clip_bounds);
|
||||
|
||||
image = gsk_gpu_get_node_as_image (frame,
|
||||
&clip_bounds,
|
||||
&self.scale,
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
node,
|
||||
&bounds);
|
||||
|
||||
descriptor = gsk_gpu_node_processor_add_image (&self, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
|
||||
gsk_gpu_color_convert_op (frame,
|
||||
GSK_GPU_SHADER_CLIP_NONE,
|
||||
GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
target_color_state,
|
||||
self.desc,
|
||||
descriptor,
|
||||
&bounds,
|
||||
&self.offset,
|
||||
&bounds);
|
||||
|
||||
g_object_unref (image);
|
||||
}
|
||||
|
||||
gsk_gpu_node_processor_finish (&self);
|
||||
}
|
||||
@@ -406,6 +540,7 @@ static void
|
||||
gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
|
||||
GskGpuFrame *frame,
|
||||
const graphene_vec2_t *scale,
|
||||
GdkColorState *color_state,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds)
|
||||
{
|
||||
@@ -419,6 +554,8 @@ gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
|
||||
self->scale = *scale;
|
||||
self->stack = 0;
|
||||
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
|
||||
pattern_buffer_init (&self->buffer);
|
||||
}
|
||||
|
||||
@@ -546,6 +683,7 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
|
||||
pattern_buffer_clear (&self->buffer);
|
||||
g_assert (self->stack == 0);
|
||||
g_clear_object (&self->desc);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -664,20 +802,6 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
|
||||
&& int_rect->height == rect->size.height * scale_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
|
||||
graphene_rect_t *out_bounds)
|
||||
{
|
||||
graphene_rect_offset_r (&self->clip.rect.bounds,
|
||||
- self->offset.x,
|
||||
- self->offset.y,
|
||||
out_bounds);
|
||||
|
||||
/* FIXME: We could try the scissor rect here.
|
||||
* But how often is that smaller than the clip bounds?
|
||||
*/
|
||||
}
|
||||
|
||||
static gboolean G_GNUC_WARN_UNUSED_RESULT
|
||||
gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self,
|
||||
GskRenderNode *node,
|
||||
@@ -742,6 +866,7 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self,
|
||||
static GskGpuImage *
|
||||
gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
|
||||
const graphene_vec2_t *scale,
|
||||
GdkColorState *color_state,
|
||||
const graphene_rect_t *viewport,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
@@ -752,6 +877,7 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
|
||||
frame,
|
||||
gsk_render_node_get_preferred_depth (node),
|
||||
scale,
|
||||
color_state,
|
||||
viewport);
|
||||
if (image == NULL)
|
||||
return NULL;
|
||||
@@ -768,6 +894,7 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
|
||||
* @frame: frame to render in
|
||||
* @clip_bounds: region of node that must be included in image
|
||||
* @scale: scale factor to use for the image
|
||||
* @color_state: the color state to composite in
|
||||
* @node: the node to render
|
||||
* @out_bounds: the actual bounds of the result
|
||||
*
|
||||
@@ -789,10 +916,12 @@ static GskGpuImage *
|
||||
gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
const graphene_rect_t *clip_bounds,
|
||||
const graphene_vec2_t *scale,
|
||||
GdkColorState *color_state,
|
||||
GskRenderNode *node,
|
||||
graphene_rect_t *out_bounds)
|
||||
{
|
||||
GskGpuImage *result;
|
||||
GdkColorState *image_color_state;
|
||||
|
||||
switch ((guint) gsk_render_node_get_node_type (node))
|
||||
{
|
||||
@@ -801,9 +930,19 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
GdkTexture *texture = gsk_texture_node_get_texture (node);
|
||||
GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
|
||||
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
|
||||
result = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
|
||||
|
||||
result = gsk_gpu_device_lookup_texture_image (device, texture, color_state, timestamp);
|
||||
if (result == NULL)
|
||||
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
|
||||
{
|
||||
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture, &image_color_state);
|
||||
|
||||
if (result &&
|
||||
!gdk_color_state_equal (image_color_state, color_state))
|
||||
{
|
||||
result = gsk_gpu_color_convert (frame, result, image_color_state, color_state);
|
||||
gsk_gpu_device_cache_texture_image (device, texture, timestamp, result, color_state);
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -821,6 +960,8 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
gsk_render_node_ref (node),
|
||||
(GDestroyNotify) gsk_render_node_unref);
|
||||
|
||||
result = gsk_gpu_color_convert (frame, result, GDK_COLOR_STATE_SRGB, color_state);
|
||||
|
||||
g_object_ref (result);
|
||||
|
||||
*out_bounds = *clip_bounds;
|
||||
@@ -833,6 +974,7 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
GSK_DEBUG (FALLBACK, "Offscreening node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
|
||||
result = gsk_gpu_node_processor_create_offscreen (frame,
|
||||
scale,
|
||||
color_state,
|
||||
clip_bounds,
|
||||
node);
|
||||
|
||||
@@ -843,6 +985,7 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
|
||||
static GskGpuImage *
|
||||
gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
|
||||
GskGpuImage *image,
|
||||
GdkColorState *color_state,
|
||||
GskGpuImageFlags required_flags,
|
||||
GskGpuImageFlags disallowed_flags)
|
||||
{
|
||||
@@ -895,6 +1038,7 @@ gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
|
||||
frame,
|
||||
NULL,
|
||||
copy,
|
||||
color_state,
|
||||
&(cairo_rectangle_int_t) { 0, 0, width, height },
|
||||
&rect);
|
||||
|
||||
@@ -968,6 +1112,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
|
||||
image = gsk_gpu_get_node_as_image (self->frame,
|
||||
&clip,
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
node,
|
||||
out_bounds);
|
||||
if (image == NULL)
|
||||
@@ -975,6 +1120,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
|
||||
|
||||
ensure = gsk_gpu_node_processor_ensure_image (self->frame,
|
||||
image,
|
||||
self->color_state,
|
||||
required_flags,
|
||||
disallowed_flags);
|
||||
|
||||
@@ -985,7 +1131,8 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_device_cache_texture_image (gsk_gpu_frame_get_device (self->frame),
|
||||
gsk_texture_node_get_texture (node),
|
||||
gsk_gpu_frame_get_timestamp (self->frame),
|
||||
ensure);
|
||||
ensure,
|
||||
self->color_state);
|
||||
}
|
||||
|
||||
return ensure;
|
||||
@@ -1026,6 +1173,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
|
||||
self->frame,
|
||||
source_depth,
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
&intermediate_rect);
|
||||
|
||||
gsk_gpu_node_processor_sync_globals (&other, 0);
|
||||
@@ -1205,6 +1353,7 @@ gsk_gpu_node_processor_try_node_as_pattern (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_pattern_writer_init (&writer,
|
||||
self->frame,
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
&self->offset,
|
||||
&clipped);
|
||||
|
||||
@@ -1454,6 +1603,7 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel
|
||||
self->frame,
|
||||
gsk_render_node_get_preferred_depth (node),
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
&clip_bounds);
|
||||
gsk_gpu_node_processor_sync_globals (&other, 0);
|
||||
gsk_gpu_rounded_color_op (other.frame,
|
||||
@@ -1927,15 +2077,16 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
GskGpuImage *image;
|
||||
GdkTexture *texture;
|
||||
gint64 timestamp;
|
||||
GdkColorState *image_color_state;
|
||||
|
||||
device = gsk_gpu_frame_get_device (self->frame);
|
||||
texture = gsk_texture_node_get_texture (node);
|
||||
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
|
||||
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
|
||||
if (image == NULL)
|
||||
{
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
|
||||
if (image == NULL)
|
||||
{
|
||||
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
|
||||
@@ -1945,6 +2096,12 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_node_processor_add_fallback_node (self, node);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gdk_color_state_equal (image_color_state, self->color_state))
|
||||
{
|
||||
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
|
||||
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
|
||||
}
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
|
||||
@@ -1955,6 +2112,7 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
|
||||
image = gsk_gpu_node_processor_ensure_image (self->frame,
|
||||
image,
|
||||
self->color_state,
|
||||
GSK_GPU_IMAGE_MIPMAP,
|
||||
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_MIPMAP_DEFAULT);
|
||||
@@ -2001,17 +2159,24 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
|
||||
guint32 descriptor;
|
||||
GskGpuImage *image;
|
||||
GskGpuSampler sampler;
|
||||
GdkColorState *image_color_state;
|
||||
|
||||
device = gsk_gpu_frame_get_device (self->frame);
|
||||
texture = gsk_texture_node_get_texture (node);
|
||||
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
|
||||
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
|
||||
if (image == NULL)
|
||||
{
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
|
||||
if (image == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gdk_color_state_equal (image_color_state, self->color_state))
|
||||
{
|
||||
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
|
||||
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
|
||||
}
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
|
||||
@@ -2020,6 +2185,7 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
|
||||
{
|
||||
image = gsk_gpu_node_processor_ensure_image (self->frame,
|
||||
image,
|
||||
self->color_state,
|
||||
GSK_GPU_IMAGE_MIPMAP,
|
||||
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
|
||||
sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT;
|
||||
@@ -2058,6 +2224,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
gint64 timestamp;
|
||||
guint32 descriptor;
|
||||
gboolean need_mipmap, need_offscreen;
|
||||
GdkColorState *image_color_state;
|
||||
|
||||
need_offscreen = self->modelview != NULL ||
|
||||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ());
|
||||
@@ -2081,6 +2248,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
clip_bounds.size.height = ceilf (clip_bounds.size.height);
|
||||
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
|
||||
graphene_vec2_one (),
|
||||
self->color_state,
|
||||
&clip_bounds,
|
||||
node);
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT);
|
||||
@@ -2101,10 +2269,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
|
||||
need_mipmap = scaling_filter == GSK_SCALING_FILTER_TRILINEAR;
|
||||
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
|
||||
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
|
||||
if (image == NULL)
|
||||
{
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture);
|
||||
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture, &image_color_state);
|
||||
if (image == NULL)
|
||||
{
|
||||
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
|
||||
@@ -2114,10 +2282,16 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_node_processor_add_fallback_node (self, node);
|
||||
return;
|
||||
}
|
||||
if (!gdk_color_state_equal (image_color_state, self->color_state))
|
||||
{
|
||||
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
|
||||
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
|
||||
}
|
||||
}
|
||||
|
||||
image = gsk_gpu_node_processor_ensure_image (self->frame,
|
||||
image,
|
||||
self->color_state,
|
||||
need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0,
|
||||
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
|
||||
|
||||
@@ -2282,6 +2456,7 @@ gsk_gpu_node_processor_add_gradient_node (GskGpuNodeProcessor *self,
|
||||
self->frame,
|
||||
gsk_render_node_get_preferred_depth (node),
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
&bounds);
|
||||
|
||||
other.blend = GSK_GPU_BLEND_ADD;
|
||||
@@ -3331,6 +3506,7 @@ gsk_gpu_node_processor_repeat_tile (GskGpuNodeProcessor *self,
|
||||
GSK_DEBUG (FALLBACK, "Offscreening node '%s' for tiling", g_type_name_from_instance ((GTypeInstance *) child));
|
||||
image = gsk_gpu_node_processor_create_offscreen (self->frame,
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
&clipped_child_bounds,
|
||||
child);
|
||||
|
||||
@@ -4123,6 +4299,7 @@ gsk_gpu_node_processor_create_node_pattern (GskGpuPatternWriter *self,
|
||||
image = gsk_gpu_get_node_as_image (self->frame,
|
||||
&bounds,
|
||||
&self->scale,
|
||||
self->color_state,
|
||||
node,
|
||||
&bounds);
|
||||
if (image == NULL)
|
||||
|
||||
@@ -7,6 +7,7 @@ G_BEGIN_DECLS
|
||||
|
||||
void gsk_gpu_node_processor_process (GskGpuFrame *frame,
|
||||
GskGpuImage *target,
|
||||
GdkColorState *target_color_state,
|
||||
const cairo_rectangle_int_t *clip,
|
||||
GskRenderNode *node,
|
||||
const graphene_rect_t *viewport);
|
||||
|
||||
+13
-2
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "gskgpuprintprivate.h"
|
||||
|
||||
#include "gdk/gdkrgbaprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
#include "gskgpudescriptorsprivate.h"
|
||||
#include "gskgpuimageprivate.h"
|
||||
|
||||
@@ -140,9 +142,10 @@ void
|
||||
gsk_gpu_print_image (GString *string,
|
||||
GskGpuImage *image)
|
||||
{
|
||||
g_string_append_printf (string, "%zux%zu ",
|
||||
g_string_append_printf (string, "%zux%zu %s ",
|
||||
gsk_gpu_image_get_width (image),
|
||||
gsk_gpu_image_get_height (image));
|
||||
gsk_gpu_image_get_height (image),
|
||||
gdk_memory_format_get_name (gsk_gpu_image_get_format (image)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -154,3 +157,11 @@ gsk_gpu_print_image_descriptor (GString *string,
|
||||
gsk_gpu_print_image (string, gsk_gpu_descriptors_get_image (desc, id));
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gpu_print_color_conversion (GString *string,
|
||||
guint conversion)
|
||||
{
|
||||
g_string_append_printf (string, "%s->%s ",
|
||||
gdk_color_state_get_name_from_id (conversion & 0xffff),
|
||||
gdk_color_state_get_name_from_id (conversion >> 16));
|
||||
}
|
||||
|
||||
@@ -35,3 +35,5 @@ void gsk_gpu_print_image (GString
|
||||
void gsk_gpu_print_image_descriptor (GString *string,
|
||||
GskGpuDescriptors *desc,
|
||||
guint32 descriptor);
|
||||
void gsk_gpu_print_color_conversion (GString *string,
|
||||
guint conversion);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdktexturedownloaderprivate.h"
|
||||
#include "gdk/gdkdrawcontextprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
@@ -298,6 +299,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
|
||||
gsk_gpu_frame_render (frame,
|
||||
g_get_monotonic_time (),
|
||||
image,
|
||||
GDK_COLOR_STATE_SRGB,
|
||||
NULL,
|
||||
root,
|
||||
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
|
||||
@@ -360,6 +362,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
|
||||
gsk_gpu_frame_render (frame,
|
||||
g_get_monotonic_time (),
|
||||
image,
|
||||
GDK_COLOR_STATE_SRGB,
|
||||
NULL,
|
||||
root,
|
||||
&rounded_viewport,
|
||||
@@ -387,6 +390,8 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
|
||||
GskGpuImage *backbuffer;
|
||||
cairo_region_t *render_region;
|
||||
double scale;
|
||||
GdkMemoryDepth depth;
|
||||
GdkColorState *target_color_state;
|
||||
|
||||
if (cairo_region_is_empty (region))
|
||||
{
|
||||
@@ -394,9 +399,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_draw_context_begin_frame_full (priv->context,
|
||||
gsk_render_node_get_preferred_depth (root),
|
||||
region);
|
||||
depth = gsk_render_node_get_preferred_depth (root);
|
||||
|
||||
gdk_draw_context_begin_frame_full (priv->context, depth, region);
|
||||
|
||||
gsk_gpu_device_maybe_gc (priv->device);
|
||||
|
||||
@@ -408,9 +413,21 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
|
||||
render_region = get_render_region (self);
|
||||
scale = gsk_gpu_renderer_get_scale (self);
|
||||
|
||||
if (gsk_gpu_image_get_flags (backbuffer) & GSK_GPU_IMAGE_SRGB)
|
||||
{
|
||||
g_debug ("Relying on GL/Vulkan to do srgb-linear->srgb conversion");
|
||||
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
|
||||
target_color_state = GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
gsk_gpu_frame_render (frame,
|
||||
g_get_monotonic_time (),
|
||||
backbuffer,
|
||||
target_color_state,
|
||||
render_region,
|
||||
root,
|
||||
&GRAPHENE_RECT_INIT (
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "gskgputypesprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _GskGpuShaderOp
|
||||
@@ -63,13 +65,23 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO
|
||||
GskGpuFrame *frame,
|
||||
GskGLCommandState *state);
|
||||
|
||||
|
||||
static inline float
|
||||
srgb_inverse_transfer_function (float v)
|
||||
{
|
||||
if (v >= 0.04045)
|
||||
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
|
||||
else
|
||||
return v / 12.92;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gpu_rgba_to_float (const GdkRGBA *rgba,
|
||||
float values[4])
|
||||
{
|
||||
values[0] = rgba->red;
|
||||
values[1] = rgba->green;
|
||||
values[2] = rgba->blue;
|
||||
values[0] = srgb_inverse_transfer_function (rgba->red);
|
||||
values[1] = srgb_inverse_transfer_function (rgba->green);
|
||||
values[2] = srgb_inverse_transfer_function (rgba->blue);
|
||||
values[3] = rgba->alpha;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ typedef enum {
|
||||
GSK_GPU_IMAGE_MIPMAP = (1 << 5),
|
||||
GSK_GPU_IMAGE_FILTERABLE = (1 << 6),
|
||||
GSK_GPU_IMAGE_RENDERABLE = (1 << 7),
|
||||
GSK_GPU_IMAGE_SRGB = (1 << 8),
|
||||
} GskGpuImageFlags;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -14,6 +14,15 @@
|
||||
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
#include "gsk/gskdebugprivate.h"
|
||||
#include "gdk/gdkcolorstateprivate.h"
|
||||
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
#include <pango/pangofc-font.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
#endif
|
||||
|
||||
static GskGpuOp *
|
||||
gsk_gpu_upload_op_gl_command_with_area (GskGpuOp *op,
|
||||
@@ -304,6 +313,7 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
|
||||
image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
|
||||
with_mipmap,
|
||||
gdk_texture_get_format (texture),
|
||||
gdk_texture_get_color_state (texture),
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
if (image == NULL)
|
||||
@@ -470,6 +480,7 @@ gsk_gpu_upload_cairo_op (GskGpuFrame *frame,
|
||||
self->image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
GDK_MEMORY_DEFAULT,
|
||||
GDK_COLOR_STATE_SRGB,
|
||||
ceil (graphene_vec2_get_x (scale) * viewport->size.width),
|
||||
ceil (graphene_vec2_get_y (scale) * viewport->size.height));
|
||||
self->viewport = *viewport;
|
||||
@@ -537,6 +548,16 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
PangoRectangle ink_rect = { 0, };
|
||||
#ifdef HAVE_PANGOFT
|
||||
FT_Face face;
|
||||
FT_Bool darken = 1;
|
||||
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
face = pango_fc_font_lock_face (PANGO_FC_FONT (self->font));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
FT_Face_Properties (face, 1, &property);
|
||||
#endif
|
||||
|
||||
surface = cairo_image_surface_create_for_data (data,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
@@ -578,6 +599,12 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
|
||||
|
||||
cairo_surface_finish (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pango_fc_font_unlock_face (PANGO_FC_FONT (self->font));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
|
||||
@@ -13,6 +13,15 @@
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GskNglRenderer:
|
||||
*
|
||||
* A GL based renderer.
|
||||
*
|
||||
* See [class@Gsk.Renderer].
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
struct _GskNglRenderer
|
||||
{
|
||||
GskGpuRenderer parent_instance;
|
||||
@@ -108,7 +117,8 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
|
||||
GDK_GL_CONTEXT (context),
|
||||
GDK_MEMORY_DEFAULT /* FIXME */,
|
||||
ceil (gdk_surface_get_width (surface) * scale),
|
||||
ceil (gdk_surface_get_height (surface) * scale));
|
||||
ceil (gdk_surface_get_height (surface) * scale),
|
||||
gdk_surface_get_gl_is_srgb (surface));
|
||||
}
|
||||
|
||||
return self->backbuffer;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user