Compare commits
448 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a71e97fbe8 | |||
| a5a3ea73d3 | |||
| 7ae4b41cb5 | |||
| 67992454a7 | |||
| 5c3bb62ca4 | |||
| 2f032ad0e1 | |||
| 88613204eb | |||
| ead70de246 | |||
| 0136696e34 | |||
| 400ae52809 | |||
| 2c2d868366 | |||
| 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 | |||
| 53beb054b6 | |||
| 0431492284 | |||
| aed9cc1874 | |||
| c15804d124 | |||
| 1bd208d937 | |||
| b70bcd6bfe | |||
| 74a1d45238 | |||
| 3ada35460d | |||
| 1f133c3d64 | |||
| 4440ce874e | |||
| db302df82a | |||
| b550b58e8f | |||
| ed889b951b | |||
| b603479fe2 | |||
| 7c39b2cea3 | |||
| b1bce7a62b | |||
| fa73e17fba | |||
| dee2150a04 | |||
| f647fc3fe2 | |||
| 6bae80c331 | |||
| 2aeb80f490 | |||
| 8a2f434443 | |||
| d4134430fc | |||
| 73f64971c8 | |||
| ecc2c953e5 | |||
| e353117937 | |||
| 492ae6df35 | |||
| a19d0471e9 | |||
| 5b5ba36999 | |||
| 89b64cbf47 | |||
| e65d1f2122 | |||
| 2756496d47 | |||
| 8b653f21cc | |||
| 4e6759a126 | |||
| d20e0b0370 | |||
| ed8255993f | |||
| f5d69fa0c5 | |||
| e1431f31c1 | |||
| f191fc0047 | |||
| b60c60f03b | |||
| af0c277bba | |||
| 88203fbf4d | |||
| 970c9eef63 | |||
| 2439876bd3 | |||
| 97582ae9ad | |||
| a5b85f0dc5 | |||
| aefb16510b | |||
| 4360d433b5 | |||
| 5927319589 | |||
| 25db645f65 | |||
| b3c6a98132 | |||
| 031109aec3 | |||
| 18d2f9c8a4 | |||
| 0ae721f144 | |||
| 7898d1b46d | |||
| 3648398f6d | |||
| 019916c5b9 | |||
| ebb31590ae | |||
| 32ea1cf32d | |||
| 172cdf8e21 | |||
| dc07bcf3a3 | |||
| bd96c10563 | |||
| 76299396cf | |||
| a96dd2ad0a | |||
| 1e210e83bb | |||
| 14f1a91bff | |||
| 3f2bcdf82e | |||
| c61d8bc188 | |||
| 4e5976427b | |||
| 7fcdb0205f | |||
| 4814c5f653 | |||
| eb24e3548f | |||
| 87f0f374a9 | |||
| 0cd95951e6 | |||
| c45815c217 | |||
| b914869715 | |||
| ff5699e097 | |||
| 8846f85874 | |||
| fc1c6cfb1a | |||
| 77028362ab | |||
| 496aee5b02 | |||
| b2fb624496 | |||
| f2ef5d85ea | |||
| 7eca32edf0 | |||
| 7775bcf2fb | |||
| ed35f6f8b8 | |||
| 307942e1f7 | |||
| 92b7231168 | |||
| 14d7eb97d2 | |||
| fed1c3d3fc | |||
| e1ac97a185 | |||
| 08a48dd97e | |||
| 50df3ebb46 | |||
| df77f22740 | |||
| 2437a551ec | |||
| 46ab71fc8a | |||
| f922ff8597 | |||
| 690c06109e | |||
| 94505987fe | |||
| c6d7b704cb | |||
| 349509c332 | |||
| 84fd420271 | |||
| 0c40defaf1 | |||
| d665274eb1 | |||
| 81b6251073 | |||
| 32a4f805b8 | |||
| 54a86a2a7e | |||
| 06351844bb | |||
| bcf78aeb39 |
@@ -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,11 +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 (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
|
||||
@@ -14,19 +57,22 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
* Accessibility:
|
||||
- Make the gtk-demo sidebar search more accessible
|
||||
- Stop emitting focus events
|
||||
- Realize child contexts when necessary
|
||||
|
||||
* GDK:
|
||||
- Support XDG_ACTIVATION_TOKEN
|
||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||
- dmabuf: Use narrow range for YUV
|
||||
- vulkan: Recreate swapchains when necessary or beneficial
|
||||
|
||||
* GSK:
|
||||
- Improve logging for GDK_DEBUG=offload
|
||||
- Improve logging for GSK_DEBUG=renderer
|
||||
- gpu: Warn about inefficient texture import
|
||||
- gpu: Handle tiny offscreens correctly
|
||||
- gpu: Handle tiny offscreens correctly
|
||||
- vulkan: Add profiler marks in various places
|
||||
- vulkan: Fix a problem with imported dmabufs showing up black
|
||||
- cairo: Speed up mask nodes, since we use them for symbolic icons
|
||||
|
||||
* Wayland:
|
||||
- Use wl_compositor version 6
|
||||
@@ -39,13 +85,22 @@ 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, 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
|
||||
@@ -56,38 +60,80 @@ follows:
|
||||
1 value:
|
||||
: all
|
||||
|
||||
## Custom Properties
|
||||
|
||||
GTK supports custom properties as defined in the
|
||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
|
||||
spec.
|
||||
|
||||
Custom properties are defined as follows:
|
||||
|
||||
```css
|
||||
--prop: red;
|
||||
```
|
||||
|
||||
and used via the `var` keyword:
|
||||
|
||||
```css
|
||||
color: var(--prop);
|
||||
```
|
||||
|
||||
Custom properties can have a fallback for when the referred property is invalid:
|
||||
|
||||
```css
|
||||
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
|
||||
|
||||
@@ -95,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
|
||||
@@ -124,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>
|
||||
|
||||
+16
-8
@@ -41,8 +41,10 @@ G_BEGIN_DECLS
|
||||
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
|
||||
#else
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
|
||||
#endif
|
||||
|
||||
/* make this readable */
|
||||
@@ -177,18 +179,23 @@ G_GNUC_UNUSED static inline void
|
||||
gdk_array(reserve) (GdkArray *self,
|
||||
gsize n)
|
||||
{
|
||||
gsize new_size, size;
|
||||
gsize new_capacity, size, capacity;
|
||||
|
||||
if (n <= gdk_array(get_capacity) (self))
|
||||
return;
|
||||
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
|
||||
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
|
||||
|
||||
capacity = gdk_array(get_capacity) (self);
|
||||
if (n <= capacity)
|
||||
return;
|
||||
|
||||
size = gdk_array(get_size) (self);
|
||||
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
|
||||
/* capacity * 2 can overflow, that's why we MAX() */
|
||||
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
|
||||
|
||||
#ifdef GDK_ARRAY_PREALLOC
|
||||
if (self->start == self->preallocated)
|
||||
{
|
||||
self->start = g_new (_T_, new_size);
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
||||
}
|
||||
else
|
||||
@@ -196,15 +203,15 @@ gdk_array(reserve) (GdkArray *self,
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
if (self->start == NULL)
|
||||
{
|
||||
self->start = g_new (_T_, new_size);
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
*self->start = *(_T_[1]) { 0 };
|
||||
}
|
||||
else
|
||||
#endif
|
||||
self->start = g_renew (_T_, self->start, new_size);
|
||||
self->start = g_renew (_T_, self->start, new_capacity);
|
||||
|
||||
self->end = self->start + size;
|
||||
self->end_allocation = self->start + new_size;
|
||||
self->end_allocation = self->start + new_capacity;
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
self->end_allocation--;
|
||||
#endif
|
||||
@@ -312,6 +319,7 @@ gdk_array(get) (const GdkArray *self,
|
||||
#undef gdk_array_paste
|
||||
#undef gdk_array
|
||||
#undef GDK_ARRAY_REAL_SIZE
|
||||
#undef GDK_ARRAY_MAX_SIZE
|
||||
|
||||
#undef GDK_ARRAY_BY_VALUE
|
||||
#undef GDK_ARRAY_ELEMENT_TYPE
|
||||
|
||||
@@ -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,355 @@
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_color_state_new_from_icc_profile:
|
||||
* @icc_profile: The ICC profiles given as a `GBytes`
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Creates a new color state for the given ICC profile data.
|
||||
*
|
||||
* If the given ICC profile can not be represented as a
|
||||
* [struct@Gdk.ColorState], `NULL` is returned and an error
|
||||
* is raised.
|
||||
*
|
||||
* Returns: a new `GdkColorState` or %NULL on error
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_new_from_icc_profile (GBytes *icc_profile,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
g_return_val_if_fail (icc_profile != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb.icc", 0, NULL);
|
||||
if (g_bytes_equal (icc_profile, bytes))
|
||||
{
|
||||
g_bytes_unref (bytes);
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb-linear.icc", 0, NULL);
|
||||
if (g_bytes_equal (icc_profile, bytes))
|
||||
{
|
||||
g_bytes_unref (bytes);
|
||||
return GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
}
|
||||
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("Failed to load ICC profile"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_color_state_new_from_cicp_data:
|
||||
* @color_primaries: the color primaries
|
||||
* @transfer_characteristics: the transfer function
|
||||
* @matrix_coefficients: the color matrix
|
||||
* @full_range: whether the data is 'full-range'
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Creates a new color state for the given CICP data.
|
||||
*
|
||||
* If the given CICP data can not be represented as a
|
||||
* [struct@Gdk.ColorState], `NULL` is returned and an error
|
||||
* is raised.
|
||||
*
|
||||
* See [CICP](https://en.wikipedia.org/wiki/Coding-independent_code_points)
|
||||
* for more information about CICP.
|
||||
*
|
||||
* Returns: a new `GdkColorState` or %NULL on error
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_new_from_cicp_data (int color_primaries,
|
||||
int transfer_characteristics,
|
||||
int matrix_coefficients,
|
||||
gboolean full_range)
|
||||
{
|
||||
if (color_primaries == 0 && transfer_characteristics == 13 &&
|
||||
matrix_coefficients == 0 && full_range)
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
else if (color_primaries == 0 && transfer_characteristics == 8 &&
|
||||
matrix_coefficients == 0 && full_range)
|
||||
return GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_color_state_save_to_icc_profile:
|
||||
* @self: a `GdkColorState`
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Saves the color state to an
|
||||
* [ICC profile](https://en.wikipedia.org/wiki/ICC_profile).
|
||||
*
|
||||
* It may not be possible to represent a color state as ICC profile.
|
||||
* In that case, @error will be set and %NULL will be returned.
|
||||
*
|
||||
* Returns: (nullable): A new `GBytes` containing the ICC profile
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GBytes *
|
||||
gdk_color_state_save_to_icc_profile (GdkColorState *self,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
if (self == GDK_COLOR_STATE_SRGB)
|
||||
{
|
||||
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb.icc", 0, NULL);
|
||||
g_assert (bytes != NULL);
|
||||
}
|
||||
else if (self == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
{
|
||||
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb-linear.icc", 0, NULL);
|
||||
g_assert (bytes != NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = NULL;
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("ICC profile not supported for this color state"));
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_color_state_save_to_cicp_data:
|
||||
* @self: a `GdkColorState`
|
||||
* @color_primaries: return location for color primaries
|
||||
* @transfer_characteristics: return location for transfer characteristics
|
||||
* @matrix_coefficients: return location for matrix_coefficients
|
||||
* @full_range: return location for the full range flag
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Saves the color state as CICP data.
|
||||
*
|
||||
* It may not be possible to represent a color state as CICP data.
|
||||
* In that case, @error will be set and `FALSE` will be returned.
|
||||
*
|
||||
* See [CICP](https://en.wikipedia.org/wiki/Coding-independent_code_points)
|
||||
* for more information about CICP.
|
||||
*
|
||||
* Returns: (nullable): `TRUE` if the out arguments were set
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
gboolean
|
||||
gdk_color_state_save_to_cicp_data (GdkColorState *self,
|
||||
int *color_primaries,
|
||||
int *transfer_characteristics,
|
||||
int *matrix_coefficients,
|
||||
gboolean *full_range,
|
||||
GError **error)
|
||||
{
|
||||
if (self == GDK_COLOR_STATE_SRGB)
|
||||
{
|
||||
*color_primaries = 0;
|
||||
*transfer_characteristics = 13;
|
||||
*matrix_coefficients = 0;
|
||||
*full_range = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else if (self == GDK_COLOR_STATE_SRGB_LINEAR)
|
||||
{
|
||||
*color_primaries = 0;
|
||||
*transfer_characteristics = 8;
|
||||
*matrix_coefficients = 0;
|
||||
*full_range = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("This color state does not support CICP data"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ 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,102 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
GdkColorState * gdk_color_state_new_from_icc_profile (GBytes *icc_profile,
|
||||
GError **error);
|
||||
|
||||
GdkColorState * gdk_color_state_new_from_cicp_data (int color_primaries,
|
||||
int transfer_characteristics,
|
||||
int matrix_coefficients,
|
||||
gboolean full_range);
|
||||
|
||||
GBytes * gdk_color_state_save_to_icc_profile (GdkColorState *self,
|
||||
GError **error);
|
||||
|
||||
gboolean gdk_color_state_save_to_cicp_data (GdkColorState *self,
|
||||
int *color_primaries,
|
||||
int *transfer_characteristic,
|
||||
int *matrix_coefficients,
|
||||
gboolean *full_range,
|
||||
GError **error);
|
||||
|
||||
@@ -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)
|
||||
@@ -193,6 +200,7 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"color-state", gdk_dmabuf_texture_builder_get_color_state (builder),
|
||||
NULL);
|
||||
|
||||
g_set_object (&self->display, display);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkcolorstate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdmabuftexturebuilderprivate.h"
|
||||
|
||||
@@ -41,6 +42,8 @@ struct _GdkDmabufTextureBuilder
|
||||
|
||||
GdkDmabuf dmabuf;
|
||||
|
||||
GdkColorState *color_state;
|
||||
|
||||
GdkTexture *update_texture;
|
||||
cairo_region_t *update_region;
|
||||
};
|
||||
@@ -124,6 +127,7 @@ enum
|
||||
PROP_MODIFIER,
|
||||
PROP_PREMULTIPLIED,
|
||||
PROP_N_PLANES,
|
||||
PROP_COLOR_STATE,
|
||||
PROP_UPDATE_REGION,
|
||||
PROP_UPDATE_TEXTURE,
|
||||
|
||||
@@ -141,6 +145,7 @@ gdk_dmabuf_texture_builder_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&self->update_texture);
|
||||
g_clear_pointer (&self->update_region, cairo_region_destroy);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
|
||||
G_OBJECT_CLASS (gdk_dmabuf_texture_builder_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -183,6 +188,10 @@ gdk_dmabuf_texture_builder_get_property (GObject *object,
|
||||
g_value_set_uint (value, self->dmabuf.n_planes);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
g_value_set_boxed (value, self->color_state);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
g_value_set_boxed (value, self->update_region);
|
||||
break;
|
||||
@@ -235,6 +244,10 @@ gdk_dmabuf_texture_builder_set_property (GObject *object,
|
||||
gdk_dmabuf_texture_builder_set_n_planes (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
gdk_dmabuf_texture_builder_set_color_state (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
gdk_dmabuf_texture_builder_set_update_region (self, g_value_get_boxed (value));
|
||||
break;
|
||||
@@ -347,6 +360,18 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
|
||||
1, GDK_DMABUF_MAX_PLANES, 1,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_color_state org.gtk.Property.set=gdk_dmabuf_texture_builder_set_color_state)
|
||||
*
|
||||
* The color state of the texture.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_COLOR_STATE] =
|
||||
g_param_spec_boxed ("color-state", NULL, NULL,
|
||||
GDK_TYPE_COLOR_STATE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDmabufTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_region org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_region)
|
||||
*
|
||||
@@ -383,6 +408,8 @@ gdk_dmabuf_texture_builder_init (GdkDmabufTextureBuilder *self)
|
||||
|
||||
for (int i = 0; i < GDK_DMABUF_MAX_PLANES; i++)
|
||||
self->dmabuf.planes[i].fd = -1;
|
||||
|
||||
self->color_state = gdk_color_state_get_srgb ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -843,6 +870,48 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
|
||||
self->dmabuf.planes[plane].offset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
*
|
||||
* Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().
|
||||
*
|
||||
* Returns: the color state
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->color_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
* @color_state: a `GdkColorState`
|
||||
*
|
||||
* Sets the color state for the texture. The default is SRGB.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (color_state != NULL);
|
||||
|
||||
if (self->color_state != color_state)
|
||||
{
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
|
||||
* @self: a `GdkDmabufTextureBuilder`
|
||||
|
||||
@@ -100,6 +100,12 @@ void gdk_dmabuf_texture_builder_set_offset (GdkDmabufT
|
||||
unsigned int plane,
|
||||
unsigned int offset);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
|
||||
GdkColorState *color_state);
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
GdkTexture * gdk_dmabuf_texture_builder_get_update_texture (GdkDmabufTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
|
||||
+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)
|
||||
|
||||
+8
-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);
|
||||
}
|
||||
@@ -488,6 +488,7 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
|
||||
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
||||
"width", gdk_gl_texture_builder_get_width (builder),
|
||||
"height", gdk_gl_texture_builder_get_height (builder),
|
||||
"color-state", gdk_gl_texture_builder_get_color_state (builder),
|
||||
NULL);
|
||||
|
||||
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkglcontext.h"
|
||||
#include "gdkcolorstate.h"
|
||||
#include "gdkgltextureprivate.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
@@ -38,6 +39,7 @@ struct _GdkGLTextureBuilder
|
||||
GdkMemoryFormat format;
|
||||
gboolean has_mipmap;
|
||||
gpointer sync;
|
||||
GdkColorState *color_state;
|
||||
|
||||
GdkTexture *update_texture;
|
||||
cairo_region_t *update_region;
|
||||
@@ -75,6 +77,7 @@ enum
|
||||
PROP_HEIGHT,
|
||||
PROP_ID,
|
||||
PROP_SYNC,
|
||||
PROP_COLOR_STATE,
|
||||
PROP_UPDATE_REGION,
|
||||
PROP_UPDATE_TEXTURE,
|
||||
PROP_WIDTH,
|
||||
@@ -95,6 +98,7 @@ gdk_gl_texture_builder_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&self->update_texture);
|
||||
g_clear_pointer (&self->update_region, cairo_region_destroy);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
|
||||
G_OBJECT_CLASS (gdk_gl_texture_builder_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -133,6 +137,10 @@ gdk_gl_texture_builder_get_property (GObject *object,
|
||||
g_value_set_pointer (value, self->sync);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
g_value_set_object (value, self->color_state);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
g_value_set_boxed (value, self->update_region);
|
||||
break;
|
||||
@@ -185,6 +193,10 @@ gdk_gl_texture_builder_set_property (GObject *object,
|
||||
gdk_gl_texture_builder_set_sync (self, g_value_get_pointer (value));
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
gdk_gl_texture_builder_set_color_state (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
gdk_gl_texture_builder_set_update_region (self, g_value_get_boxed (value));
|
||||
break;
|
||||
@@ -286,6 +298,18 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
|
||||
g_param_spec_pointer ("sync", NULL, NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_color_state org.gtk.Property.set=gdk_gl_texture_builder_set_color_state)
|
||||
*
|
||||
* The color state of the texture.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_COLOR_STATE] =
|
||||
g_param_spec_boxed ("color-state", NULL, NULL,
|
||||
GDK_TYPE_COLOR_STATE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_region org.gtk.Property.set=gdk_gl_texture_builder_set_update_region)
|
||||
*
|
||||
@@ -329,6 +353,7 @@ static void
|
||||
gdk_gl_texture_builder_init (GdkGLTextureBuilder *self)
|
||||
{
|
||||
self->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
self->color_state = gdk_color_state_get_srgb ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -672,6 +697,49 @@ gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FORMAT]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
|
||||
*
|
||||
* Returns: the color state
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->color_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @color_state: a `GdkColorState`
|
||||
*
|
||||
* Sets the color state for the texture.
|
||||
* Sets the color state of the texture. The default is SRGB.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (color_state != NULL);
|
||||
|
||||
if (self->color_state != color_state)
|
||||
{
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
|
||||
@@ -64,6 +64,12 @@ GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
|
||||
GdkMemoryFormat format);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
|
||||
GdkColorState *color_state);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
gboolean gdk_gl_texture_builder_get_has_mipmap (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
|
||||
@@ -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
|
||||
|
||||
+55
-21
@@ -22,6 +22,7 @@
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gsk/gl/fp16private.h"
|
||||
|
||||
/**
|
||||
@@ -131,11 +132,15 @@ gdk_memory_sanitize (GBytes *bytes,
|
||||
* @bytes: the `GBytes` containing the pixel data
|
||||
* @stride: rowstride for the data
|
||||
*
|
||||
* Creates a new texture for a blob of image data.
|
||||
* Creates a new texture for a blob of sRGB image data.
|
||||
*
|
||||
* The `GBytes` must contain @stride × @height pixels
|
||||
* in the given format.
|
||||
*
|
||||
* The data is assumed to be in SRGB. See
|
||||
* [constructor@Gdk.MemoryTexutre.new_with_color_state]
|
||||
* for data in other color states.
|
||||
*
|
||||
* Returns: (type GdkMemoryTexture): A newly-created `GdkTexture`
|
||||
*/
|
||||
GdkTexture *
|
||||
@@ -144,11 +149,43 @@ gdk_memory_texture_new (int width,
|
||||
GdkMemoryFormat format,
|
||||
GBytes *bytes,
|
||||
gsize stride)
|
||||
{
|
||||
return gdk_memory_texture_new_with_color_state (width, height, format,
|
||||
GDK_COLOR_STATE_SRGB,
|
||||
bytes, stride);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_memory_texture_new_with_color_state:
|
||||
* @width: the width of the texture
|
||||
* @height: the height of the texture
|
||||
* @format: the format of the data
|
||||
* @color_state: the `GdkColorState` of the data
|
||||
* @bytes: the `GBytes` containing the pixel data
|
||||
* @stride: rowstride for the data
|
||||
*
|
||||
* Creates a new texture for a blob of image data.
|
||||
*
|
||||
* The `GBytes` must contain @stride x @height pixels
|
||||
* in the given format and color state.
|
||||
*
|
||||
* Returns: A newly-created `GdkTexture`
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_memory_texture_new_with_color_state (int width,
|
||||
int height,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
GBytes *bytes,
|
||||
gsize stride)
|
||||
{
|
||||
GdkMemoryTexture *self;
|
||||
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail (color_state != NULL, NULL);
|
||||
g_return_val_if_fail (bytes != NULL, NULL);
|
||||
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
||||
/* needs to be this complex to support subtexture of the bottom right part */
|
||||
@@ -159,6 +196,7 @@ gdk_memory_texture_new (int width,
|
||||
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"color-state", color_state,
|
||||
NULL);
|
||||
|
||||
GDK_TEXTURE (self)->format = format;
|
||||
@@ -191,19 +229,19 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
||||
size = source->stride * (height - 1) + width * bpp;
|
||||
bytes = g_bytes_new_from_bytes (source->bytes, offset, size);
|
||||
|
||||
result = gdk_memory_texture_new (width,
|
||||
height,
|
||||
texture->format,
|
||||
bytes,
|
||||
source->stride);
|
||||
result = gdk_memory_texture_new_with_color_state (width,
|
||||
height,
|
||||
texture->format,
|
||||
texture->color_state,
|
||||
bytes,
|
||||
source->stride);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GdkMemoryTexture *
|
||||
gdk_memory_texture_from_texture (GdkTexture *texture,
|
||||
GdkMemoryFormat format)
|
||||
gdk_memory_texture_from_texture (GdkTexture *texture)
|
||||
{
|
||||
GdkTexture *result;
|
||||
GBytes *bytes;
|
||||
@@ -213,23 +251,19 @@ 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,
|
||||
bytes,
|
||||
stride);
|
||||
result = gdk_memory_texture_new_with_color_state (texture->width,
|
||||
texture->height,
|
||||
texture->format,
|
||||
texture->color_state,
|
||||
bytes,
|
||||
stride);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return GDK_MEMORY_TEXTURE (result);
|
||||
|
||||
@@ -68,6 +68,14 @@ GdkTexture * gdk_memory_texture_new (int
|
||||
GBytes *bytes,
|
||||
gsize stride);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkTexture * gdk_memory_texture_new_with_color_state (int width,
|
||||
int height,
|
||||
GdkMemoryFormat format,
|
||||
GdkColorState *color_state,
|
||||
GBytes *bytes,
|
||||
gsize stride);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+92
-7
@@ -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,12 @@ 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);
|
||||
self->color_state = gdk_color_state_ref (g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@@ -299,6 +314,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 +356,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 +402,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,6 +465,30 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
|
||||
return texture;
|
||||
}
|
||||
|
||||
static GdkColorState *
|
||||
gdk_color_state_from_pixbuf (GdkPixbuf *pixbuf)
|
||||
{
|
||||
const char *icc_profile_base64;
|
||||
GdkColorState *color_state = NULL;
|
||||
|
||||
icc_profile_base64 = gdk_pixbuf_get_option (pixbuf, "icc-profile");
|
||||
if (icc_profile_base64)
|
||||
{
|
||||
guchar *icc_data;
|
||||
gsize icc_len;
|
||||
GBytes *bytes;
|
||||
|
||||
icc_data = g_base64_decode (icc_profile_base64, &icc_len);
|
||||
bytes = g_bytes_new_take (icc_data, icc_len);
|
||||
color_state = gdk_color_state_new_from_icc_profile (bytes, NULL);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
if (!color_state)
|
||||
color_state = GDK_COLOR_STATE_SRGB;
|
||||
|
||||
return color_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_texture_new_for_pixbuf:
|
||||
* @pixbuf: a `GdkPixbuf`
|
||||
@@ -445,24 +506,31 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GBytes *bytes;
|
||||
GdkColorState *color_state;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
||||
|
||||
color_state = gdk_color_state_from_pixbuf (pixbuf);
|
||||
|
||||
bytes = g_bytes_new_with_free_func (gdk_pixbuf_get_pixels (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf)
|
||||
* (gsize) gdk_pixbuf_get_rowstride (pixbuf),
|
||||
g_object_unref,
|
||||
g_object_ref (pixbuf));
|
||||
texture = gdk_memory_texture_new (gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
gdk_pixbuf_get_has_alpha (pixbuf)
|
||||
? GDK_MEMORY_GDK_PIXBUF_ALPHA
|
||||
: GDK_MEMORY_GDK_PIXBUF_OPAQUE,
|
||||
bytes,
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
|
||||
texture = gdk_memory_texture_new_with_color_state (gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
gdk_pixbuf_get_has_alpha (pixbuf)
|
||||
? GDK_MEMORY_GDK_PIXBUF_ALPHA
|
||||
: GDK_MEMORY_GDK_PIXBUF_OPAQUE,
|
||||
color_state,
|
||||
bytes,
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
gdk_color_state_unref (color_state);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -720,6 +788,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;
|
||||
|
||||
+40
-10
@@ -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 };
|
||||
@@ -607,7 +615,8 @@ physical_device_check_features (VkPhysicalDevice device)
|
||||
features |= GDK_VULKAN_FEATURE_YCBCR;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
|
||||
features |= GDK_VULKAN_FEATURE_DMABUF;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
|
||||
@@ -639,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++)
|
||||
{
|
||||
@@ -872,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;
|
||||
@@ -881,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;
|
||||
@@ -1286,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`
|
||||
@@ -1517,6 +1542,7 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
||||
@@ -1857,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);
|
||||
|
||||
@@ -1986,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)
|
||||
@@ -2002,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,
|
||||
@@ -2009,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);
|
||||
|
||||
@@ -26,6 +26,8 @@ xml = '''<?xml version='1.0' encoding='UTF-8'?>
|
||||
<gresources>
|
||||
<gresource prefix='/org/gtk/libgdk'>
|
||||
<file alias='cursor/default'>default_cursor.png</file>
|
||||
<file alias='icc/srgb.icc'>srgb.icc</file>
|
||||
<file alias='icc/srgb-linear.icc'>srgb-linear.icc</file>
|
||||
'''
|
||||
|
||||
def get_files(subdir,extension):
|
||||
|
||||
+64
-6
@@ -24,6 +24,8 @@
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gdktexture.h"
|
||||
#include "gdktexturedownloaderprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
|
||||
#include "gdkprofilerprivate.h"
|
||||
|
||||
@@ -74,7 +76,51 @@ output_message_handler (j_common_ptr cinfo)
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Format conversion */
|
||||
/* {{{ Color profile handling */
|
||||
|
||||
static GdkColorState *
|
||||
gdk_jpeg_get_color_state (struct jpeg_decompress_struct *info)
|
||||
{
|
||||
GdkColorState *color_state;
|
||||
JOCTET *icc_data;
|
||||
unsigned int icc_len;
|
||||
|
||||
if (jpeg_read_icc_profile (info, &icc_data, &icc_len))
|
||||
{
|
||||
GBytes *icc_bytes = g_bytes_new_with_free_func (icc_data, icc_len, free, icc_data);
|
||||
color_state = gdk_color_state_new_from_icc_profile (icc_bytes, NULL);
|
||||
g_bytes_unref (icc_bytes);
|
||||
if (!color_state)
|
||||
{
|
||||
g_debug ("Failed to load icc profile, assuming SRGB");
|
||||
color_state = GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
}
|
||||
else
|
||||
color_state = GDK_COLOR_STATE_SRGB;
|
||||
|
||||
return color_state;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_jpeg_set_color_state (struct jpeg_compress_struct *info,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
jpeg_write_icc_profile (info,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes));
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Format conversion */
|
||||
|
||||
static void
|
||||
convert_grayscale_to_rgb (guchar *data,
|
||||
@@ -131,7 +177,7 @@ convert_cmyk_to_rgba (guchar *data,
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
|
||||
GdkTexture *
|
||||
@@ -146,6 +192,7 @@ gdk_load_jpeg (GBytes *input_bytes,
|
||||
GBytes *bytes;
|
||||
GdkTexture *texture;
|
||||
GdkMemoryFormat format;
|
||||
GdkColorState *color_state;
|
||||
G_GNUC_UNUSED guint64 before = GDK_PROFILER_CURRENT_TIME;
|
||||
|
||||
info.err = jpeg_std_error (&jerr.pub);
|
||||
@@ -169,6 +216,9 @@ gdk_load_jpeg (GBytes *input_bytes,
|
||||
g_bytes_get_data (input_bytes, NULL),
|
||||
g_bytes_get_size (input_bytes));
|
||||
|
||||
/* save color space */
|
||||
jpeg_save_markers (&info, JPEG_APP0 + 2, 0xFFFF);
|
||||
|
||||
jpeg_read_header (&info, TRUE);
|
||||
jpeg_start_decompress (&info);
|
||||
|
||||
@@ -226,19 +276,23 @@ gdk_load_jpeg (GBytes *input_bytes,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
color_state = gdk_jpeg_get_color_state (&info);
|
||||
|
||||
jpeg_finish_decompress (&info);
|
||||
jpeg_destroy_decompress (&info);
|
||||
|
||||
bytes = g_bytes_new_take (data, stride * height);
|
||||
|
||||
texture = gdk_memory_texture_new (width, height,
|
||||
format,
|
||||
bytes, stride);
|
||||
texture = gdk_memory_texture_new_with_color_state (width, height,
|
||||
format,
|
||||
color_state,
|
||||
bytes, stride);
|
||||
|
||||
gdk_color_state_unref (color_state);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
gdk_profiler_end_mark (before, "Load jpeg", NULL);
|
||||
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -257,9 +311,11 @@ gdk_save_jpeg (GdkTexture *texture)
|
||||
gsize texstride;
|
||||
guchar *row;
|
||||
int width, height;
|
||||
GdkColorState *color_state;
|
||||
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
color_state = gdk_texture_get_color_state (texture);
|
||||
|
||||
info.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = fatal_error_handler;
|
||||
@@ -298,6 +354,8 @@ gdk_save_jpeg (GdkTexture *texture)
|
||||
|
||||
jpeg_start_compress (&info, TRUE);
|
||||
|
||||
gdk_jpeg_set_color_state (&info, color_state);
|
||||
|
||||
while (info.next_scanline < info.image_height)
|
||||
{
|
||||
row = (guchar *) texdata + info.next_scanline * texstride;
|
||||
|
||||
+160
-1
@@ -20,11 +20,14 @@
|
||||
#include "gdkpngprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkmemorytexture.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include "gdktexturedownloaderprivate.h"
|
||||
#include "gsk/gl/fp16private.h"
|
||||
|
||||
#include <png.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -126,6 +129,143 @@ png_simple_warning_callback (png_structp png,
|
||||
{
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Color profile handling */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gboolean cicp_chunk_read;
|
||||
int color_primaries;
|
||||
int transfer_function;
|
||||
int matrix_coefficients;
|
||||
int full_range;
|
||||
} CICPData;
|
||||
|
||||
static int
|
||||
png_read_chunk_func (png_structp png,
|
||||
png_unknown_chunkp chunk)
|
||||
{
|
||||
if (strcmp ((char *) chunk->name, "cICP") == 0 &&
|
||||
chunk->size == 4)
|
||||
{
|
||||
CICPData *cicp = png_get_user_chunk_ptr (png);
|
||||
|
||||
cicp->cicp_chunk_read = TRUE;
|
||||
|
||||
cicp->color_primaries = chunk->data[0];
|
||||
cicp->transfer_function = chunk->data[1];
|
||||
cicp->matrix_coefficients = chunk->data[2];
|
||||
cicp->full_range = chunk->data[3];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GdkColorState *
|
||||
gdk_png_get_color_state (png_struct *png,
|
||||
png_info *info)
|
||||
{
|
||||
GdkColorState *color_state;
|
||||
guchar *icc_data;
|
||||
png_uint_32 icc_len;
|
||||
char *name;
|
||||
CICPData *cicp;
|
||||
int intent;
|
||||
|
||||
cicp = png_get_user_chunk_ptr (png);
|
||||
|
||||
if (cicp->cicp_chunk_read)
|
||||
{
|
||||
color_state = gdk_color_state_new_from_cicp_data (cicp->color_primaries,
|
||||
cicp->transfer_function,
|
||||
cicp->matrix_coefficients,
|
||||
cicp->full_range);
|
||||
if (color_state)
|
||||
{
|
||||
g_debug ("Color state from cICP data: %s", gdk_color_state_get_name (color_state));
|
||||
return color_state;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Failed to create color state from cICP data: %d/%d/%d %d",
|
||||
cicp->color_primaries,
|
||||
cicp->transfer_function,
|
||||
cicp->matrix_coefficients,
|
||||
cicp->full_range);
|
||||
}
|
||||
}
|
||||
|
||||
if (png_get_iCCP (png, info, &name, NULL, &icc_data, &icc_len))
|
||||
{
|
||||
GBytes *bytes = g_bytes_new (icc_data, icc_len);
|
||||
|
||||
color_state = gdk_color_state_new_from_icc_profile (bytes, NULL);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
if (color_state)
|
||||
return color_state;
|
||||
}
|
||||
|
||||
if (png_get_sRGB (png, info, &intent))
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
|
||||
/* If neither of those is valid, the result is sRGB */
|
||||
if (!png_get_valid (png, info, PNG_INFO_gAMA) &&
|
||||
!png_get_valid (png, info, PNG_INFO_cHRM))
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
|
||||
g_debug ("Failed to find color state, assuming SRGB");
|
||||
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_png_set_color_state (png_struct *png,
|
||||
png_info *info,
|
||||
GdkColorState *color_state,
|
||||
png_byte *chunk_data)
|
||||
{
|
||||
int cp, tc, mc;
|
||||
gboolean fr;
|
||||
GBytes *bytes;
|
||||
|
||||
if (gdk_color_state_save_to_cicp_data (color_state, &cp, &tc, &mc, &fr, NULL))
|
||||
{
|
||||
png_unknown_chunk chunk = {
|
||||
.name = { 'c', 'I', 'C', 'P', '\0' },
|
||||
.data = chunk_data,
|
||||
.size = 4,
|
||||
.location = PNG_HAVE_IHDR,
|
||||
};
|
||||
|
||||
chunk_data[0] = (png_byte)cp;
|
||||
chunk_data[1] = (png_byte)tc;
|
||||
chunk_data[2] = (png_byte)mc;
|
||||
chunk_data[3] = (png_byte)fr;
|
||||
|
||||
png_set_unknown_chunks (png, info, &chunk, 1);
|
||||
}
|
||||
|
||||
/* Since most tools don't understand cicp, we save an icc profile as well */
|
||||
bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
|
||||
if (bytes)
|
||||
{
|
||||
png_set_iCCP (png, info,
|
||||
"ICC profile",
|
||||
0,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes));
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
/* For good measure, we add an sRGB chunk too */
|
||||
if (color_state == GDK_COLOR_STATE_SRGB)
|
||||
png_set_sRGB (png, info, PNG_sRGB_INTENT_PERCEPTUAL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
|
||||
@@ -147,8 +287,11 @@ gdk_load_png (GBytes *bytes,
|
||||
guchar *buffer = NULL;
|
||||
guchar **row_pointers = NULL;
|
||||
GBytes *out_bytes;
|
||||
GdkColorState *color_state;
|
||||
GdkTexture *texture;
|
||||
int bpp;
|
||||
CICPData cicp = { FALSE, };
|
||||
|
||||
G_GNUC_UNUSED gint64 before = GDK_PROFILER_CURRENT_TIME;
|
||||
|
||||
io.data = (guchar *)g_bytes_get_data (bytes, &io.size);
|
||||
@@ -169,6 +312,7 @@ gdk_load_png (GBytes *bytes,
|
||||
g_error ("Out of memory");
|
||||
|
||||
png_set_read_fn (png, &io, png_read_func);
|
||||
png_set_read_user_chunk_fn (png, &cicp, png_read_chunk_func);
|
||||
|
||||
if (sigsetjmp (png_jmpbuf (png), 1))
|
||||
{
|
||||
@@ -266,6 +410,8 @@ gdk_load_png (GBytes *bytes,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color_state = gdk_png_get_color_state (png, info);
|
||||
|
||||
bpp = gdk_memory_format_bytes_per_pixel (format);
|
||||
if (!g_size_checked_mul (&stride, width, bpp) ||
|
||||
!g_size_checked_add (&stride, stride, (8 - stride % 8) % 8))
|
||||
@@ -281,6 +427,7 @@ gdk_load_png (GBytes *bytes,
|
||||
|
||||
if (!buffer || !row_pointers)
|
||||
{
|
||||
gdk_color_state_unref (color_state);
|
||||
g_free (buffer);
|
||||
g_free (row_pointers);
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
@@ -297,8 +444,11 @@ gdk_load_png (GBytes *bytes,
|
||||
png_read_end (png, info);
|
||||
|
||||
out_bytes = g_bytes_new_take (buffer, height * stride);
|
||||
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
|
||||
texture = gdk_memory_texture_new_with_color_state (width, height,
|
||||
format, color_state,
|
||||
out_bytes, stride);
|
||||
g_bytes_unref (out_bytes);
|
||||
gdk_color_state_unref (color_state);
|
||||
|
||||
if (options && png_get_text (png, info, &text, &num_texts))
|
||||
{
|
||||
@@ -337,11 +487,14 @@ gdk_save_png (GdkTexture *texture)
|
||||
GBytes *bytes;
|
||||
gsize stride;
|
||||
const guchar *data;
|
||||
GdkColorState *color_state;
|
||||
int png_format;
|
||||
int depth;
|
||||
png_byte chunk_data[4];
|
||||
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
color_state = gdk_texture_get_color_state (texture);
|
||||
format = gdk_texture_get_format (texture);
|
||||
|
||||
switch (format)
|
||||
@@ -436,6 +589,10 @@ gdk_save_png (GdkTexture *texture)
|
||||
/* 2^31-1 is the maximum size for PNG files */
|
||||
png_set_user_limits (png, (1u << 31) - 1, (1u << 31) - 1);
|
||||
|
||||
png_set_keep_unknown_chunks (png, PNG_HANDLE_CHUNK_ALWAYS, NULL, 0);
|
||||
|
||||
png_set_option (png, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON);
|
||||
|
||||
info = png_create_info_struct (png);
|
||||
if (!info)
|
||||
{
|
||||
@@ -465,6 +622,8 @@ gdk_save_png (GdkTexture *texture)
|
||||
PNG_COMPRESSION_TYPE_DEFAULT,
|
||||
PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
gdk_png_set_color_state (png, info, color_state, chunk_data);
|
||||
|
||||
png_write_info (png, info);
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
|
||||
+68
-7
@@ -24,6 +24,7 @@
|
||||
#include "gdkmemorytexture.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include "gdktexturedownloaderprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
@@ -219,6 +220,53 @@ tiff_open_write (GBytes **result)
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Color profile handling */
|
||||
|
||||
static GdkColorState *
|
||||
gdk_tiff_get_color_state (TIFF *tiff)
|
||||
{
|
||||
GdkColorState *color_state;
|
||||
const char *icc_data;
|
||||
guint icc_len;
|
||||
|
||||
if (TIFFGetField (tiff, TIFFTAG_ICCPROFILE, &icc_len, &icc_data))
|
||||
{
|
||||
GBytes *icc_bytes;
|
||||
|
||||
icc_bytes = g_bytes_new (icc_data, icc_len);
|
||||
color_state = gdk_color_state_new_from_icc_profile (icc_bytes, NULL);
|
||||
g_bytes_unref (icc_bytes);
|
||||
if (!color_state)
|
||||
{
|
||||
g_debug ("Failed to load icc profile, assuming SRGB");
|
||||
color_state = GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
}
|
||||
else
|
||||
color_state = GDK_COLOR_STATE_SRGB;
|
||||
|
||||
return color_state;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_tiff_set_color_state (TIFF *tiff,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = gdk_color_state_save_to_icc_profile (color_state, NULL);
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
TIFFSetField (tiff, TIFFTAG_ICCPROFILE,
|
||||
g_bytes_get_size (bytes),
|
||||
g_bytes_get_data (bytes, NULL));
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
|
||||
@@ -282,6 +330,7 @@ gdk_save_tiff (GdkTexture *texture)
|
||||
GBytes *bytes, *result = NULL;
|
||||
GdkTextureDownloader downloader;
|
||||
GdkMemoryFormat format;
|
||||
GdkColorState *color_state;
|
||||
const FormatData *fdata = NULL;
|
||||
|
||||
tif = tiff_open_write (&result);
|
||||
@@ -289,6 +338,7 @@ gdk_save_tiff (GdkTexture *texture)
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
format = gdk_texture_get_format (texture);
|
||||
color_state = gdk_texture_get_color_state (texture);
|
||||
fdata = &format_data[format];
|
||||
|
||||
if (fdata == NULL)
|
||||
@@ -308,6 +358,8 @@ gdk_save_tiff (GdkTexture *texture)
|
||||
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
|
||||
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
|
||||
gdk_tiff_set_color_state (tif, color_state);
|
||||
|
||||
gdk_texture_downloader_init (&downloader, texture);
|
||||
gdk_texture_downloader_set_format (&downloader, fdata->format);
|
||||
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
|
||||
@@ -344,6 +396,7 @@ load_fallback (TIFF *tif,
|
||||
int width, height;
|
||||
guchar *data;
|
||||
GBytes *bytes;
|
||||
GdkColorState *color_state;
|
||||
GdkTexture *texture;
|
||||
|
||||
TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &width);
|
||||
@@ -360,14 +413,18 @@ load_fallback (TIFF *tif,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color_state = gdk_tiff_get_color_state (tif);
|
||||
|
||||
bytes = g_bytes_new_take (data, width * height * 4);
|
||||
|
||||
texture = gdk_memory_texture_new (width, height,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
bytes,
|
||||
width * 4);
|
||||
texture = gdk_memory_texture_new_with_color_state (width, height,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
color_state,
|
||||
bytes,
|
||||
width * 4);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
gdk_color_state_unref (color_state);
|
||||
|
||||
return texture;
|
||||
}
|
||||
@@ -390,6 +447,7 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
gsize stride;
|
||||
int bpp;
|
||||
GBytes *bytes;
|
||||
GdkColorState *color_state;
|
||||
GdkTexture *texture;
|
||||
G_GNUC_UNUSED gint64 before = GDK_PROFILER_CURRENT_TIME;
|
||||
|
||||
@@ -490,13 +548,16 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
line += stride;
|
||||
}
|
||||
|
||||
color_state = gdk_tiff_get_color_state (tif);
|
||||
|
||||
bpp = gdk_memory_format_bytes_per_pixel (format);
|
||||
bytes = g_bytes_new_take (data, width * height * bpp);
|
||||
|
||||
texture = gdk_memory_texture_new (width, height,
|
||||
format,
|
||||
bytes, width * bpp);
|
||||
texture = gdk_memory_texture_new_with_color_state (width, height,
|
||||
format, color_state,
|
||||
bytes, width * bpp);
|
||||
g_bytes_unref (bytes);
|
||||
gdk_color_state_unref (color_state);
|
||||
|
||||
TIFFClose (tif);
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -165,25 +165,29 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
double *scale)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
int desired_scale_factor;
|
||||
|
||||
desired_scale_factor = (int) ceil (desired_scale);
|
||||
|
||||
if (gdk_cursor_get_name (cursor))
|
||||
{
|
||||
struct wl_cursor *c;
|
||||
int scale_factor;
|
||||
|
||||
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
|
||||
goto none;
|
||||
{
|
||||
*hotspot_x = *hotspot_y = 0;
|
||||
*width = *height = 0;
|
||||
*scale = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scale_factor = (int) ceil (desired_scale);
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale_factor,
|
||||
display->cursor_theme,
|
||||
scale_factor,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c && c->image_count > 0)
|
||||
{
|
||||
struct wl_cursor_image *image;
|
||||
int cursor_scale;
|
||||
|
||||
if (image_index >= c->image_count)
|
||||
{
|
||||
@@ -195,23 +199,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
|
||||
image = c->images[image_index];
|
||||
|
||||
cursor_scale = desired_scale_factor;
|
||||
if ((image->width % cursor_scale != 0) ||
|
||||
(image->height % cursor_scale != 0))
|
||||
*width = display->cursor_theme_size;
|
||||
*height = display->cursor_theme_size;
|
||||
*scale = image->width / (double) *width;
|
||||
*hotspot_x = image->hotspot_x / scale_factor;
|
||||
*hotspot_y = image->hotspot_y / scale_factor;
|
||||
|
||||
if (*scale != scale_factor && !use_viewporter)
|
||||
{
|
||||
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
|
||||
"multiple of scale (%d)", image->width, image->height,
|
||||
cursor_scale);
|
||||
cursor_scale = 1;
|
||||
g_warning (G_STRLOC " cursor image size (%d) not an integer "
|
||||
"multiple of theme size (%d)", image->width, *width);
|
||||
*width = image->width;
|
||||
*height = image->height;
|
||||
*hotspot_x = image->hotspot_x;
|
||||
*hotspot_y = image->hotspot_y;
|
||||
*scale = 1;
|
||||
}
|
||||
|
||||
*hotspot_x = image->hotspot_x / cursor_scale;
|
||||
*hotspot_y = image->hotspot_y / cursor_scale;
|
||||
|
||||
*width = image->width / cursor_scale;
|
||||
*height = image->height / cursor_scale;
|
||||
*scale = cursor_scale;
|
||||
|
||||
return wl_cursor_image_get_buffer (image);
|
||||
}
|
||||
}
|
||||
@@ -257,7 +261,7 @@ from_texture:
|
||||
else
|
||||
{
|
||||
if (!use_viewporter)
|
||||
*scale = desired_scale_factor;
|
||||
*scale = ceil (desired_scale);
|
||||
else
|
||||
*scale = desired_scale;
|
||||
|
||||
@@ -294,28 +298,23 @@ from_texture:
|
||||
}
|
||||
|
||||
if (gdk_cursor_get_fallback (cursor))
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
{
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
|
||||
goto from_texture;
|
||||
}
|
||||
|
||||
none:
|
||||
*hotspot_x = 0;
|
||||
*hotspot_y = 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*scale = 1;
|
||||
|
||||
return NULL;
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
guint
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1776,11 +1776,6 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
|
||||
return GDK_SCREEN_XROOTWIN (display_x11->screen) == xroot_window;
|
||||
}
|
||||
|
||||
struct XPointerUngrabInfo {
|
||||
GdkDisplay *display;
|
||||
guint32 time;
|
||||
};
|
||||
|
||||
static void
|
||||
device_grab_update_callback (GdkDisplay *display,
|
||||
gpointer data,
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user