Compare commits

..

22 Commits

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

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

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

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

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

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

It will be used in the next commit, it's separate to avoid the diff
being too large.
2024-05-08 19:00:40 +04:00
Alice Mikhaylenko f301ea7936 csstokenizer: Add save() and restore()
We'll need that to check if property values contain variables.
2024-05-08 19:00:40 +04:00
Alice Mikhaylenko a3e9ecd199 cssprovider: Copy bytes when loading
We'll need to keep accessing them later to compute values with variables,
so we can't avoid this anymore.
2024-05-08 19:00:40 +04:00
412 changed files with 5832 additions and 19698 deletions
-1
View File
@@ -459,7 +459,6 @@ reference:
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
- mv _build/docs/reference/gtk/*.html _reference/gtk4/
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/
+2 -57
View File
@@ -1,54 +1,11 @@
Overview of Changes in 4.15.2, xx-xx-xxxx
=========================================
* GtkFileChooserWidget:
- Plug some memory leaks
- Make Ctrl-Shift-N create a new folder
* CSS:
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
- Support relative colors (https://www.w3.org/TR/css-color-5/)
* Accessibility:
- Avoid markup when reading labels
* GSK:
- Subset fonts when serializing node trees
* Wayland:
- Use xdg-dialog protocol for attached dialogs
* Windows:
- Build with UNICODE
* Debugging:
- Add GTK_DEBUG=css for warning about deprecated css syntax
* Tools:
- nodeparser: Add an extract command for data urls
* Deprecations:
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
* Translation updates:
Hebrew
Overview of Changes in 4.15.1, 21-05-2024
Overview of Changes in 4.15.1, xx-xx-xxxx
=========================================
* GtkGraphicsOffload:
- Don't crash without a child
* GtkSpinner:
- Don't animate when unmapped
* CSS:
- Support the :root selector
- Support variables and custom properties (https://www.w3.org/TR/css-variables-1/)
- Implement math functions (https://www.w3.org/TR/css-values-4/)
- Support modern syntax and calc in rgb() and hsl()
* Icontheme:
- Make symbolic svg loading more efficient
@@ -57,22 +14,19 @@ Overview of Changes in 4.15.1, 21-05-2024
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
- Realize child contexts when necessary
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
- vulkan: Recreate swapchains when necessary or beneficial
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
- cairo: Speed up mask nodes, since we use them for symbolic icons
* Wayland:
- Use wl_compositor version 6
@@ -85,22 +39,13 @@ Overview of Changes in 4.15.1, 21-05-2024
* Debugging:
- Show more texture details in the recorder
- Use GTK_DEBUG=css to see CSS deprecations
* macOS:
- Fix problems with events handed back to the OS
- Respect GDK_DEBUG=default-settings
- Allow applictions to handle Dock > Quit
* Deprecations:
- Use of @name colors in CSS
* Translation updates:
Catalan
Georgian
Hungarian
Korean
Portuguese
Turkish
+24 -46
View File
@@ -15,16 +15,16 @@ spec.
The following units are supported for basic datatypes:
Length
: px, pt, em, ex, rem, pc, in, cm, mm
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
Percentage
: %
: %, calc()
Angle
: deg, rad, grad, turn
: deg, grad, turn, calc()
Time
: s, ms
: s, ms, calc()
Length values with the em or ex units are resolved using the font
size value, unless they occur in setting the font-size itself, in
@@ -33,15 +33,11 @@ which case they are resolved using the inherited font size value.
The rem unit is resolved using the initial font size value, which is
not quite the same as the CSS definition of rem.
Length values using physical units (pt, pc, in, cm, mm) are translated
to px using the dpi value specified by the -gtk-dpi property, which is
different from the CSS definition, which uses a fixed dpi of 96.
The calc() notation adds considerable expressive power to all of these
datatypes. There are limits on what types can be combined in such an
expression (e.g. it does not make sense to add a number and a time).
For the full details, see the
[CSS Values and Units](https://www.w3.org/TR/css-values-4/) spec.
The calc() notation adds considerable expressive power. There are limits
on what types can be combined in such an expression (e.g. it does not make
sense to add a number and a time). For the full details, see the
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
spec.
A common pattern among shorthand properties (called 'four sides') is one
where one to four values can be specified, to determine a value for each
@@ -86,54 +82,36 @@ color: var(--prop, green);
## Colors
### CSS Colors
Colors can be expressed in numerous ways in CSS (see the
[Color Module](https://www.w3.org/TR/css-color-5/). GTK supports
many (but not all) of these.
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
syntax, and calc() can be used as well in color expressions. hwb(), oklab(),
oklch(), color(), color-mix() and relative colors are supported as well.
### Non-CSS Colors
GTK extends the CSS syntax with several additional ways to specify colors.
These extensions are deprecated and should be replaced by the equivalent
standard CSS notions.
GTK extends the CSS syntax with several additional ways to specify colors.
The first is a reference to a color defined via a @define-color rule in CSS.
The syntax for @define-color rules is as follows:
```
@define-color name color
@define-color Name Color
```
To refer to the color defined by a @define-color rule, prefix the name with @.
The standard CSS mechanisms that should be used instead of @define-color are
custom properties, :root and var().
GTK also supports color expressions, which allow colors to be transformed to
new ones. Color expressions can be nested, providing a rich language to
define colors. Color expressions resemble functions, taking 1 or more colors
and in some cases a number as arguments.
`lighter(color)`
: produces a brighter variant of `color`.
`lighter(Color)`
: produces a brighter variant of Color
`darker(color)`
: produces a darker variant of `color`.
`darker(Color)`
: produces a darker variant of Color
`shade(color, number)`
: changes the lightness of `color`. The `number` ranges from 0 for black to 2 for white.
`shade(Color, Number)`
: changes the lightness of Color. The number ranges from 0 for black to 2 for white.
`alpha(color, number)`
: multiplies the alpha value of `color` by `number` (between 0 and 1).
`alpha(Color, Number)`
: replaces the alpha value of color with number (between 0 and 1)
`mix(color1, color2, number)`
: interpolates between the two colors.
`mix(Color1, Color2, Number)`
: interpolates between the two colors
## Images
@@ -141,7 +119,7 @@ GTK extends the CSS syntax for images and also uses it for specifying icons.
To load a themed icon, use
```
-gtk-icontheme(name)
-gtk-icontheme(Name)
```
The specified icon name is used to look up a themed icon, while taking into
@@ -170,14 +148,14 @@ and the
syntax makes this available. -gtk-recolor requires a url as first argument.
The remaining arguments specify the color palette to use. If the palette is
not explicitly specified, the current value of the -gtk-icon-palette property
is used.
is used.
GTK supports scaled rendering on hi-resolution displays. This works best if
images can specify normal and hi-resolution variants. From CSS, this can be
done with
```
-gtk-scaled(image1, image2)
-gtk-scaled(Image1, Image2)
```
## GTK CSS Properties
+6 -5
View File
@@ -99,15 +99,16 @@ reaches the requested phase. However, in practice most things
happen at higher levels:
- If you are doing an animation, you can use
[method@Gtk.Widget.add_tick_callback] which will cause a regular
gtk_widget_add_tick_callback() which will cause a regular
beating of the clock with a callback in the Update phase
until you stop the tick.
- If some state changes that causes the size of your widget to
change you call [method@Gtk.Widget.queue_resize] which will request
change you call gtk_widget_queue_resize() which will request
a Layout phase and mark your widget as needing relayout.
- 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.
- 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.
There are also a lot of implicit triggers of these from the
CSS layer (which does animations, resizes and repaints as needed).
@@ -18,7 +18,6 @@ SYNOPSIS
|
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
@@ -100,15 +99,3 @@ exit code is 1. If the images are identical, it is 0.
``--quiet``
Don't write results to stdout.
Extract
^^^^^^^
The ``extract`` command saves all the data urls found in a node file to a given
directory. The file names for the extracted files are derived from the mimetype
of the url.
``--dir=DIRECTORY``
Save extracted files in ``DIRECTORY`` (defaults to the current directory).
-2
View File
@@ -77,13 +77,11 @@ content_files = [
"section-tree-widget.md",
"migrating-2to4.md",
"migrating-3to4.md",
"migrating-4to5.md",
"broadway.md",
"osx.md",
"wayland.md",
"windows.md",
"x11.md",
"tools.md",
"visual_index.md",
]
content_images = [
+29 -53
View File
@@ -14,7 +14,6 @@ expand_content_md_files = [
'running.md',
'migrating-2to4.md',
'migrating-3to4.md',
'migrating-4to5.md',
'actions.md',
'input-handling.md',
'drawing-model.md',
@@ -26,8 +25,7 @@ expand_content_md_files = [
'section-tree-widget.md',
'section-list-widget.md',
'question_index.md',
'visual_index.md',
'tools.md',
'visual_index.md'
]
gtk_images = []
@@ -62,39 +60,39 @@ if get_option('documentation')
build_by_default: true,
install: true,
install_dir: docs_dir,
install_tag: 'doc',
)
endif
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-path-tool', '1', ],
]
if get_option('build-demos')
rst_files += [
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],
[ 'gtk4-widget-factory', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-node-editor', '1', ],
]
rst2man = find_program('rst2man', 'rst2man.py', required: false)
if get_option('man-pages') and not rst2man.found()
error('No rst2man found, but man pages were explicitly enabled')
endif
rst2x_flags = [
'--syntax-highlight=none',
]
if get_option('man-pages') and rst2man.found()
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-path-tool', '1', ],
]
if get_option('man-pages')
if get_option('build-demos')
rst_files += [
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],
[ 'gtk4-widget-factory', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-node-editor', '1', ],
]
endif
rst2man_flags = [
'--syntax-highlight=none',
]
foreach rst: rst_files
man_name = rst[0]
@@ -105,34 +103,12 @@ if get_option('man-pages')
output: '@0@.@1@'.format(man_name, man_section),
command: [
rst2man,
rst2x_flags,
rst2man_flags,
'@INPUT@',
],
capture: true,
install: true,
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
install_tag: 'doc',
)
endforeach
endif
if get_option('documentation')
foreach rst: rst_files
man_name = rst[0]
custom_target(
input: '@0@.rst'.format(man_name),
output: '@0@.html'.format(man_name),
command: [
rst2html5,
rst2x_flags,
'@INPUT@',
],
capture: true,
install: true,
install_dir: docs_dir / 'gtk4',
install_tag: 'doc',
)
endforeach
endif
+1 -98
View File
@@ -58,7 +58,7 @@ use a GtkLabel.
If you have a need for custom drawing that fits into the current
(dark or light) theme, e.g. for rendering a graph, you can still
get the current style foreground color, using
[method@Gtk.Widget.get_color].
[method@Gtk.Widget.get_style_color].
## Local stylesheets are going away
@@ -73,103 +73,6 @@ GTK 5 will no longer provide this functionality. The recommendations
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
and rely on style classes to make your CSS apply only where desired.
## Non-standard CSS extensions are going away
GTK's CSS machinery has a some non-standard extensions around colors:
named colors with \@define-color and color functions: lighter(), darker(),
shade(), alpha(), mix().
GTK now implements equivalent functionality from the CSS specs.
### \@define-color is going away
\@define-color should be replaced by custom properties in the :root scope.
Instead of
```
@define-color fg_color #2e3436
...
box {
color: @fg_color;
}
```
use
```
:root {
--fg-color: #2e3436;
}
...
box {
color: var(--fg-color);
}
```
For more information about custom CSS properties and variables, see the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1/)
spec.
### Color expressions are going away
The color functions can all be replaced by combinations of calc() and color-mix().
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
thus can be handled the same way as shade in the examples below.
Replace
```
a {
color: mix(red, green, 0.8);
}
b {
color: alpha(green, 0.6);
}
c {
color: shade(red, 1.3);
}
d {
color: shade(red, 0.7);
}
```
with
```
a {
color: color-mix(in srgb, red, green 80%);
}
b {
color: rgb(from green, r g b / calc(alpha * 0.6));
}
c {
color: hsl(from red, h calc(s * 1.3) calc(l * 1.3));
}
d {
color: hsl(from red, h calc(s * 0.7) calc(l * 0.7));
}
```
Variations of these replacements are possible.
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
colorspaces, but using OKLAB instead might yield slightly better results.
For more information about color-mix(), see the
[CSS Color](https://drafts.csswg.org/css-color-5) spec.
## Chooser interfaces are going away
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
+1 -1
View File
@@ -64,6 +64,6 @@ GTK is divided into three parts:
[cairo]: https://www.cairographics.org/manual/
[opengl]: https://www.opengl.org/about/
[vulkan]: https://www.vulkan.org/
[pango]: https://docs.gtk.org/Pango/
[pango]: https://docs.gtk.org/pango/
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
[graphene]: https://ebassi.github.io/graphene/
-18
View File
@@ -1,18 +0,0 @@
Title: Tools and Demos
GTK ships with a number of tools and demos that come with their own
documentation in the form of man pages.
- [gtk4-broadwayd](gtk4-broadwayd.html)
- [gtk4-builder-tool](gtk4-builder-tool.html)
- [gtk4-demo](gtk4-demo.html)
- [gtk4-demo-application](gtk4-demo-application.html)
- [gtk4-encode-symbolic-svg](gtk4-encode-symbolic-svg.html)
- [gtk4-icon-browser](gtk4-icon-browser.html)
- [gtk4-launch](gtk4-launch.html)
- [gtk4-node-editor](gtk4-node-editor.html)
- [gtk4-path-tool](gtk4-path-tool.html)
- [gtk4-query-settings](gtk4-query-settings.html)
- [gtk4-rendernode-tool](gtk4-rendernode-tool.html)
- [gtk4-update-icon-cache](gtk4-update-icon-cache.html)
- [gtk4-widget-factory](gtk4-widget-factory.html)
-1
View File
@@ -30,7 +30,6 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.h>
+8 -16
View File
@@ -41,10 +41,8 @@ G_BEGIN_DECLS
#ifdef GDK_ARRAY_NULL_TERMINATED
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
#else
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
#endif
/* make this readable */
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
gsize new_capacity, size, capacity;
gsize new_size, size;
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
capacity = gdk_array(get_capacity) (self);
if (n <= capacity)
return;
if (n <= gdk_array(get_capacity) (self))
return;
size = gdk_array(get_size) (self);
/* capacity * 2 can overflow, that's why we MAX() */
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
#ifdef GDK_ARRAY_PREALLOC
if (self->start == self->preallocated)
{
self->start = g_new (_T_, new_capacity);
self->start = g_new (_T_, new_size);
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
}
else
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
#ifdef GDK_ARRAY_NULL_TERMINATED
if (self->start == NULL)
{
self->start = g_new (_T_, new_capacity);
self->start = g_new (_T_, new_size);
*self->start = *(_T_[1]) { 0 };
}
else
#endif
self->start = g_renew (_T_, self->start, new_capacity);
self->start = g_renew (_T_, self->start, new_size);
self->end = self->start + size;
self->end_allocation = self->start + new_capacity;
self->end_allocation = self->start + new_size;
#ifdef GDK_ARRAY_NULL_TERMINATED
self->end_allocation--;
#endif
@@ -319,7 +312,6 @@ gdk_array(get) (const GdkArray *self,
#undef gdk_array_paste
#undef gdk_array
#undef GDK_ARRAY_REAL_SIZE
#undef GDK_ARRAY_MAX_SIZE
#undef GDK_ARRAY_BY_VALUE
#undef GDK_ARRAY_ELEMENT_TYPE
+14
View File
@@ -522,6 +522,8 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
*
* If the clipboard is not local, this function does nothing but report success.
*
* The @callback must call [method@Gdk.Clipboard.store_finish].
*
* The purpose of this call is to preserve clipboard contents beyond the
* lifetime of an application, so this function is typically called on
* exit. Depending on the platform, the functionality may not be available
@@ -636,6 +638,9 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
* Asynchronously requests an input stream to read the @clipboard's
* contents from.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_finish] to get the result of the operation.
*
* The clipboard will choose the most suitable mime type from the given list
* to fulfill the request, preferring the ones listed first.
*/
@@ -829,6 +834,9 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
* Asynchronously request the @clipboard contents converted to the given
* @type.
*
* When the operation is finished @callback will be called. You must then call
* [method@Gdk.Clipboard.read_value_finish] to get the resulting `GValue`.
*
* For local clipboard contents that are available in the given `GType`,
* the value will be copied directly. Otherwise, GDK will try to use
* [func@content_deserialize_async] to convert the clipboard's data.
@@ -887,6 +895,9 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
*
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_texture_finish] to get the result.
*
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.
@@ -949,6 +960,9 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
*
* Asynchronously request the @clipboard contents converted to a string.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_text_finish] to get the result.
*
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.
-233
View File
@@ -1,233 +0,0 @@
/* gdkcolorstate.c
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
#include <glib/gi18n-lib.h>
/**
* GdkColorState:
*
* A `GdkColorState` object provides the information to interpret
* colors and pixels in a variety of ways.
*
* They are also known as
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
*
* Crucially, GTK knows how to convert colors from one color
* state to another.
*
* `GdkColorState objects are immutable and therefore threadsafe.
*
* Since 4.16
*/
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
gdk_color_state_ref, gdk_color_state_unref);
/* {{{ Public API */
/**
* gdk_color_state_ref:
* @self: a `GdkColorState`
*
* Increase the reference count of @self.
*
* Returns: the object that was passed in
*
* Since: 4.16
*/
GdkColorState *
(gdk_color_state_ref) (GdkColorState *self)
{
return _gdk_color_state_ref (self);
}
/**
* gdk_color_state_unref:
* @self:a `GdkColorState`
*
* Decrease the reference count of @self.
*
* Unless @self is static, it will be freed
* when the reference count reaches zero.
*
* Since: 4.16
*/
void
(gdk_color_state_unref) (GdkColorState *self)
{
_gdk_color_state_unref (self);
}
/**
* gdk_color_state_get_srgb:
*
* Returns the color state object representing the sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb (void)
{
return GDK_COLOR_STATE_SRGB;
}
/**
* gdk_color_state_get_srgb_linear:
*
* Returns the color state object representing the linearized sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
return GDK_COLOR_STATE_SRGB_LINEAR;
}
/**
* gdk_color_state_equal:
* @self: a `GdkColorState`
* @other: another `GdkColorStatee`
*
* Compares two `GdkColorStates` for equality.
*
* Note that this function is not guaranteed to be perfect and two objects
* describing the same color state may compare not equal. However, different
* color states will never compare equal.
*
* Returns: %TRUE if the two color states compare equal
*
* Since: 4.16
*/
gboolean
(gdk_color_state_equal) (GdkColorState *self,
GdkColorState *other)
{
return _gdk_color_state_equal (self, other);
}
/* }}} */
/* {{{ Default implementation */
const char *
gdk_color_state_get_name_from_id (GdkColorStateId id)
{
const char *names[] = {
"srgb", "srgb-linear",
};
return names[id];
}
GdkColorState gdk_default_color_states[] = {
{ NULL, 0 },
{ NULL, 0 },
};
/* }}} */
/* {{{ Private API */
const char *
gdk_color_state_get_name (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
{
switch (GDK_DEFAULT_COLOR_STATE_ID (self))
{
case GDK_COLOR_STATE_ID_SRGB: return "srgb";
case GDK_COLOR_STATE_ID_SRGB_LINEAR: return "srgb-linear";
default: g_assert_not_reached ();
}
}
return self->klass->get_name (self);
}
void
gdk_color_state_print (GdkColorState *self,
GString *string)
{
g_string_append (string, gdk_color_state_get_name (self));
}
GdkMemoryDepth
gdk_color_state_get_min_depth (GdkColorState *self)
{
if (self == GDK_COLOR_STATE_SRGB || self == GDK_COLOR_STATE_SRGB_LINEAR)
return GDK_MEMORY_U8;
return GDK_MEMORY_FLOAT16;
}
/* }}} */
/* {{{ Conversion */
void
gdk_color_state_transform_init (GdkColorStateTransform *tf,
GdkColorState *from,
GdkColorState *to,
gboolean copy_alpha)
{
memset (tf, 0, sizeof (GdkColorStateTransform));
tf->copy_alpha = copy_alpha;
if (from == to)
return;
if (from == GDK_COLOR_STATE_SRGB && to == GDK_COLOR_STATE_SRGB_LINEAR)
tf->step = gtk_rgb_to_linear_srgb;
else if (from == GDK_COLOR_STATE_SRGB_LINEAR && to == GDK_COLOR_STATE_SRGB)
tf->step = gtk_linear_srgb_to_rgb;
else
g_assert_not_reached ();
}
void
gdk_color_state_transform_finish (GdkColorStateTransform *tf)
{
/* Nothing to do for now */
}
void
gdk_color_state_transform (GdkColorStateTransform *tf,
const float *src,
float *dst,
int width)
{
if (tf->step)
{
for (int i = 0; i < width * 4; i += 4)
{
tf->step (src[i], src[i+1], src[i+2],
&dst[i], &dst[i+1], &dst[i+2]);
if (tf->copy_alpha)
dst[i+3] = src[i+3];
}
}
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-50
View File
@@ -1,50 +0,0 @@
/* gdkcolorstate.h
*
* Copyright 2024 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
GDK_AVAILABLE_IN_4_16
GType gdk_color_state_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_ref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
void gdk_color_state_unref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb_linear (void);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
G_END_DECLS
-107
View File
@@ -1,107 +0,0 @@
#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);
}
typedef void (* StepFunc) (float s0, float s1, float s2,
float *d0, float *d1, float *d2);
typedef struct _GdkColorStateTransform GdkColorStateTransform;
struct _GdkColorStateTransform
{
StepFunc step;
gboolean copy_alpha;
};
void gdk_color_state_transform_init (GdkColorStateTransform *tf,
GdkColorState *from,
GdkColorState *to,
gboolean copy_alpha);
void gdk_color_state_transform_finish (GdkColorStateTransform *tf);
void gdk_color_state_transform (GdkColorStateTransform *tf,
const float *src,
float *dst,
int width);
+3
View File
@@ -540,6 +540,9 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
*
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
* indicate a higher priority.
*
* When the operation is finished, @callback will be called. You must then
* call [func@Gdk.content_deserialize_finish] to get the result of the operation.
*/
void
gdk_content_deserialize_async (GInputStream *stream,
+4
View File
@@ -279,6 +279,10 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
* Asynchronously writes the contents of @provider to @stream in the given
* @mime_type.
*
* When the operation is finished @callback will be called. You must then call
* [method@Gdk.ContentProvider.write_mime_type_finish] to get the result
* of the operation.
*
* The given mime type does not need to be listed in the formats returned by
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
+3
View File
@@ -546,6 +546,9 @@ serialize_not_found (GdkContentSerializer *serializer)
*
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
* indicate a higher priority.
*
* When the operation is finished, @callback will be called. You must then
* call [func@Gdk.content_serialize_finish] to get the result of the operation.
*/
void
gdk_content_serialize_async (GOutputStream *stream,
+1 -1
View File
@@ -52,7 +52,7 @@ GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor *fallback);
/**
* GdkCursorGetTextureCallback:
* GdkCursorGetTestureCallback:
* @cursor: the `GdkCursor`
* @cursor_size: the nominal cursor size, in application pixels
* @scale: the device scale
-2
View File
@@ -1874,8 +1874,6 @@ 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,
-1
View File
@@ -130,7 +130,6 @@ 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];
+3 -11
View File
@@ -24,7 +24,6 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkcolorstateprivate.h"
#ifdef HAVE_DMABUF
#include <sys/mman.h>
@@ -2063,15 +2062,12 @@ out:
void
gdk_dmabuf_download_mmap (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GdkMemoryFormat src_format = gdk_texture_get_format (texture);
GdkColorState *src_color_state = gdk_texture_get_color_state (texture);
if (format == src_format &&
gdk_color_state_equal (color_state, src_color_state))
if (format == src_format)
gdk_dmabuf_do_download_mmap (texture, data, stride);
else
{
@@ -2087,12 +2083,8 @@ gdk_dmabuf_download_mmap (GdkTexture *texture,
gdk_dmabuf_do_download_mmap (texture, src_data, src_stride);
gdk_memory_convert (data, stride,
format,
color_state,
src_data, src_stride,
src_format,
src_color_state,
gdk_memory_convert (data, stride, format,
src_data, src_stride, src_format,
width, height);
g_free (src_data);
+1 -2
View File
@@ -35,7 +35,6 @@ void
gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -44,6 +43,6 @@ gdk_dmabuf_downloader_download (GdkDmabufDownloader *self,
g_return_if_fail (GDK_IS_DMABUF_DOWNLOADER (self));
iface = GDK_DMABUF_DOWNLOADER_GET_IFACE (self);
iface->download (self, texture, format, color_state, data, stride);
iface->download (self, texture, format, data, stride);
}
-2
View File
@@ -20,7 +20,6 @@ struct _GdkDmabufDownloaderInterface
void (* download) (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
};
@@ -32,7 +31,6 @@ gboolean gdk_dmabuf_downloader_supports (GdkDmabufDownlo
void gdk_dmabuf_downloader_download (GdkDmabufDownloader *downloader,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
-1
View File
@@ -27,7 +27,6 @@ struct _GdkDmabuf
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
void gdk_dmabuf_download_mmap (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
+2 -12
View File
@@ -62,13 +62,6 @@ struct _GdkDmabufTextureClass
GdkTextureClass parent_class;
};
/**
* gdk_dmabuf_error_quark:
*
* Registers an error quark for [class@Gdk.DmabufTexture] errors.
*
* Returns: the error quark
**/
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
@@ -96,7 +89,6 @@ struct _Download
{
GdkDmabufTexture *texture;
GdkMemoryFormat format;
GdkColorState *color_state;
guchar *data;
gsize stride;
volatile int spinlock;
@@ -110,7 +102,6 @@ gdk_dmabuf_texture_invoke_callback (gpointer data)
gdk_dmabuf_downloader_download (download->texture->downloader,
download->texture,
download->format,
download->color_state,
download->data,
download->stride);
@@ -122,17 +113,16 @@ gdk_dmabuf_texture_invoke_callback (gpointer data)
static void
gdk_dmabuf_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (texture);
Download download = { self, format, color_state, data, stride, 0 };
Download download = { self, format, data, stride, 0 };
if (self->downloader == NULL)
{
#ifdef HAVE_DMABUF
gdk_dmabuf_download_mmap (texture, format, color_state, data, stride);
gdk_dmabuf_download_mmap (texture, format, data, stride);
#endif
return;
}
+6 -2
View File
@@ -134,7 +134,7 @@ gdk_drop_read_local_async (GdkDrop *self,
g_object_get (priv->drag, "content", &content, NULL);
content_formats = gdk_content_provider_ref_formats (content);
g_object_unref (content);
g_object_unref (content);
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
@@ -784,7 +784,7 @@ gdk_drop_read_value_internal (GdkDrop *self,
GdkContentFormats *formats;
GValue *value;
GTask *task;
g_return_if_fail (priv->state != GDK_DROP_STATE_FINISHED);
task = g_task_new (self, cancellable, callback, user_data);
@@ -849,6 +849,10 @@ gdk_drop_read_value_internal (GdkDrop *self,
* Asynchronously request the drag operation's contents converted
* to the given @type.
*
* When the operation is finished @callback will be called. You must
* then call [method@Gdk.Drop.read_value_finish] to get the resulting
* `GValue`.
*
* For local drag-and-drop operations that are available in the given
* `GType`, the value will be copied directly. Otherwise, GDK will
* try to use [func@Gdk.content_deserialize_async] to convert the data.
-2
View File
@@ -1371,8 +1371,6 @@ gdk_event_get_modifier_state (GdkEvent *event)
* Extract the event surface relative x/y coordinates from an event.
*
* This position is in [surface coordinates](coordinates.html).
*
* Returns: whether the positions were set
*/
gboolean
gdk_event_get_position (GdkEvent *event,
-7
View File
@@ -152,13 +152,6 @@ enum {
static GParamSpec *properties[LAST_PROP] = { NULL, };
/**
* gdk_gl_error_quark:
*
* Registers an error quark for [class@Gdk.GLContext] errors.
*
* Returns: the error quark
**/
G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
+9 -18
View File
@@ -24,7 +24,6 @@
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkcolorstateprivate.h"
#include <epoxy/gl.h>
@@ -137,7 +136,6 @@ typedef struct _Download Download;
struct _Download
{
GdkMemoryFormat format;
GdkColorState *color_state;
guchar *data;
gsize stride;
};
@@ -153,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLint q_internal_format, q_internal_srgb_format;
GLint q_internal_format;
GLenum q_format, q_type;
GLint q_swizzle[4];
@@ -166,7 +164,6 @@ 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);
@@ -190,7 +187,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLint gl_internal_format, gl_internal_srgb_format;
GLint gl_internal_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
@@ -202,11 +199,10 @@ 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_srgb_format,
&gl_internal_format,
&gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride &&
download->format == format &&
gdk_color_state_equal (download->color_state, gdk_texture_get_color_state (texture)))
download->format == format)
{
glGetTexImage (GL_TEXTURE_2D,
0,
@@ -229,11 +225,9 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_convert (download->data,
download->stride,
download->format,
download->color_state,
pixels,
stride,
format,
gdk_texture_get_color_state (texture),
texture->width,
texture->height);
@@ -268,7 +262,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_srgb_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
}
@@ -280,7 +274,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_srgb_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
@@ -383,11 +377,9 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_convert (download->data,
download->stride,
download->format,
download->color_state,
pixels,
stride,
actual_format,
gdk_texture_get_color_state (texture),
texture->width,
texture->height);
@@ -401,7 +393,6 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
static void
gdk_gl_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -410,12 +401,11 @@ gdk_gl_texture_download (GdkTexture *texture,
if (self->saved)
{
gdk_texture_do_download (self->saved, format, color_state, data, stride);
gdk_texture_do_download (self->saved, format, data, stride);
return;
}
download.format = format;
download.color_state = color_state;
download.data = data;
download.stride = stride;
@@ -481,7 +471,8 @@ gdk_gl_texture_release (GdkGLTexture *self)
g_return_if_fail (self->saved == NULL);
texture = GDK_TEXTURE (self);
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture)));
drop_gl_resources (self);
}
+6 -343
View File
File diff suppressed because it is too large Load Diff
+1 -13
View File
@@ -57,7 +57,6 @@ 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]);
@@ -65,36 +64,25 @@ 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,
GdkMemoryFormat dest_format,
GdkColorState *dest_color_state,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
GdkColorState *src_color_state,
gsize width,
gsize height);
void gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height);
+11 -9
View File
@@ -22,7 +22,6 @@
#include "gdkmemorytextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkcolorstateprivate.h"
#include "gsk/gl/fp16private.h"
/**
@@ -59,7 +58,6 @@ gdk_memory_texture_dispose (GObject *object)
static void
gdk_memory_texture_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -67,11 +65,9 @@ gdk_memory_texture_download (GdkTexture *texture,
gdk_memory_convert (data, stride,
format,
color_state,
(guchar *) g_bytes_get_data (self->bytes, NULL),
self->stride,
texture->format,
gdk_texture_get_color_state (texture),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
}
@@ -206,7 +202,8 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
}
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture)
gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
{
GdkTexture *result;
GBytes *bytes;
@@ -216,16 +213,21 @@ gdk_memory_texture_from_texture (GdkTexture *texture)
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
if (GDK_IS_MEMORY_TEXTURE (texture))
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
if (gdk_texture_get_format (texture) == format)
return g_object_ref (memtex);
}
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, texture->format, gdk_texture_get_color_state (texture), data, stride);
gdk_texture_do_download (texture, format, data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
texture->format,
format,
bytes,
stride);
g_bytes_unref (bytes);
+2 -1
View File
@@ -28,7 +28,8 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format);
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x,
int y,
+2 -13
View File
@@ -396,18 +396,10 @@ gboolean
*/
char *
gdk_rgba_to_string (const GdkRGBA *rgba)
{
return g_string_free (gdk_rgba_print (rgba, g_string_new ("")), FALSE);
}
GString *
gdk_rgba_print (const GdkRGBA *rgba,
GString *string)
{
if (rgba->alpha > 0.999)
{
g_string_append_printf (string,
"rgb(%d,%d,%d)",
return g_strdup_printf ("rgb(%d,%d,%d)",
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
@@ -418,15 +410,12 @@ gdk_rgba_print (const GdkRGBA *rgba,
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
g_string_append_printf (string,
"rgba(%d,%d,%d,%s)",
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.),
alpha);
}
return string;
}
static gboolean
-3
View File
@@ -72,8 +72,5 @@ _gdk_rgba_equal (gconstpointer p1,
rgba1->alpha == rgba2->alpha;
}
GString * gdk_rgba_print (const GdkRGBA *rgba,
GString *string);
G_END_DECLS
+3 -30
View File
@@ -73,7 +73,6 @@ struct _GdkSurfacePrivate
#ifdef HAVE_EGL
EGLSurface egl_surface;
gboolean egl_surface_high_depth;
gboolean egl_surface_is_srgb;
#endif
gpointer widget;
@@ -1149,11 +1148,9 @@ 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)
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
@@ -1162,40 +1159,16 @@ 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,
attribs);
NULL);
priv->egl_surface_high_depth = high_depth;
priv->egl_surface_is_srgb = !high_depth && display->have_egl_gl_colorspace;
}
#endif
}
gboolean
gdk_surface_get_gl_is_srgb (GdkSurface *self)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
if (priv->egl_surface)
return priv->egl_surface_is_srgb;
return FALSE;
}
GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error)
-2
View File
@@ -302,8 +302,6 @@ 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);
+1 -28
View File
@@ -44,20 +44,12 @@
#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 */
@@ -259,7 +251,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkTexture, gdk_texture, G_TYPE_OBJECT,
static void
gdk_texture_default_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -732,11 +723,10 @@ gdk_texture_get_height (GdkTexture *texture)
void
gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, color_state, data, stride);
GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, data, stride);
}
static gboolean
@@ -894,7 +884,6 @@ gdk_texture_download (GdkTexture *texture,
gdk_texture_do_download (texture,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
data,
stride);
}
@@ -1090,19 +1079,3 @@ gdk_texture_save_to_tiff_bytes (GdkTexture *texture)
return gdk_save_tiff (texture);
}
/**
* gdk_texture_get_color_state:
* @texture: a `GdkTexture`
*
* Returns the color state associated with @texture.
*
* Returns: (transfer none): the color state of the `GdkTexture`
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_get_color_state (GdkTexture *texture)
{
return GDK_COLOR_STATE_SRGB;
}
-3
View File
@@ -98,9 +98,6 @@ gboolean gdk_texture_save_to_tiff (GdkTexture
GDK_AVAILABLE_IN_4_6
GBytes * gdk_texture_save_to_tiff_bytes (GdkTexture *texture);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_texture_get_color_state (GdkTexture *texture);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkTexture, g_object_unref)
G_END_DECLS
+2 -38
View File
@@ -38,10 +38,8 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkcolorstateprivate.h"
#include "gdktextureprivate.h"
G_DEFINE_BOXED_TYPE (GdkTextureDownloader, gdk_texture_downloader,
gdk_texture_downloader_copy,
gdk_texture_downloader_free)
@@ -53,7 +51,6 @@ gdk_texture_downloader_init (GdkTextureDownloader *self,
{
self->texture = g_object_ref (texture);
self->format = GDK_MEMORY_DEFAULT;
self->color_state = GDK_COLOR_STATE_SRGB;
}
void
@@ -202,39 +199,6 @@ gdk_texture_downloader_get_format (const GdkTextureDownloader *self)
return self->format;
}
/**
* gdk_texture_downloader_set_color_state:
* @self: a texture downloader
* @color_state: the color state to use
*
* Sets the color state that the data will be converted to.
*
* Since: 4.16
*/
void
gdk_texture_downloader_set_color_state (GdkTextureDownloader *self,
GdkColorState *color_state)
{
g_clear_pointer (&self->color_state, gdk_color_state_unref);
self->color_state = gdk_color_state_ref (color_state);
}
/**
* gdk_texture_downloader_get_color_state:
* @self: a texture downloader
*
* Gets the color state that the data will be converted to.
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_downloader_get_color_state (const GdkTextureDownloader *self)
{
return self->color_state;
}
/**
* gdk_texture_downloader_download_into:
* @self: a texture downloader
@@ -255,7 +219,7 @@ gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (self->texture) * gdk_memory_format_bytes_per_pixel (self->format));
gdk_texture_do_download (self->texture, self->format, self->color_state, data, stride);
gdk_texture_do_download (self->texture, self->format, data, stride);
}
/**
@@ -296,7 +260,7 @@ gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
stride = self->texture->width * gdk_memory_format_bytes_per_pixel (self->format);
data = g_malloc_n (stride, self->texture->height);
gdk_texture_do_download (self->texture, self->format, self->color_state, data, stride);
gdk_texture_do_download (self->texture, self->format, data, stride);
*out_stride = stride;
return g_bytes_new_take (data, stride * self->texture->height);
-5
View File
@@ -49,11 +49,6 @@ void gdk_texture_downloader_set_format (GdkTextureDownl
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_downloader_get_format (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_16
void gdk_texture_downloader_set_color_state (GdkTextureDownloader *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_texture_downloader_get_color_state (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
-1
View File
@@ -28,7 +28,6 @@ struct _GdkTextureDownloader
/*< private >*/
GdkTexture *texture;
GdkMemoryFormat format;
GdkColorState *color_state;
};
void gdk_texture_downloader_init (GdkTextureDownloader *self,
-2
View File
@@ -46,7 +46,6 @@ struct _GdkTextureClass {
/* mandatory: Download in the given format into data */
void (* download) (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
};
@@ -58,7 +57,6 @@ cairo_surface_t * gdk_texture_download_surface (GdkTexture
void gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
void gdk_texture_diff (GdkTexture *self,
+3
View File
@@ -767,6 +767,9 @@ gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
* This function asynchronously obtains a handle for a toplevel surface
* that can be passed to other processes.
*
* When a handle has been obtained, @callback will be called, and can
* receive the handle via [method@Gdk.Toplevel.export_handle_finish].
*
* It is an error to call this function on a surface that is already
* exported.
*
+3 -6
View File
@@ -118,12 +118,9 @@ typedef enum
/**
* GdkTitlebarGesture:
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK: double click gesture
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK: right click gesture
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK: middle click gesture
*
* The kind of title bar gesture to emit with
* [method@Gdk.Toplevel.titlebar_gesture].
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
*
* Since: 4.4
*/
-1
View File
@@ -74,7 +74,6 @@ typedef cairo_rectangle_int_t GdkRectangle;
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
typedef struct _GdkColorState GdkColorState;
typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
+10 -40
View File
@@ -30,7 +30,6 @@
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkprofilerprivate.h"
#include "gdkmemorytexture.h"
#include <glib/gi18n-lib.h>
#include <math.h>
@@ -95,13 +94,6 @@ enum {
LAST_SIGNAL
};
/**
* gdk_vulkan_error_quark:
*
* Registers an error quark for [class@Gdk.VulkanContext] errors.
*
* Returns: the error quark
**/
G_DEFINE_QUARK (gdk-vulkan-error-quark, gdk_vulkan_error)
static guint signals[LAST_SIGNAL] = { 0 };
@@ -615,8 +607,7 @@ physical_device_check_features (VkPhysicalDevice device)
features |= GDK_VULKAN_FEATURE_YCBCR;
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
features |= GDK_VULKAN_FEATURE_DMABUF;
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
@@ -648,18 +639,15 @@ 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++)
{
@@ -884,9 +872,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
switch ((int) formats[i].format)
{
case VK_FORMAT_B8G8R8A8_UNORM:
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)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
@@ -895,9 +881,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
break;
case VK_FORMAT_R8G8B8A8_UNORM:
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)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
@@ -1302,15 +1286,6 @@ 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`
@@ -1542,7 +1517,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
@@ -1883,9 +1857,8 @@ gdk_display_unref_vulkan (GdkDisplay *display)
{
g_free (key);
vkDestroyShaderModule (display->vk_device,
*((VkShaderModule *)value),
value,
NULL);
g_free (value);
}
g_hash_table_unref (display->vk_shader_modules);
@@ -2013,13 +1986,13 @@ VkShaderModule
gdk_display_get_vk_shader_module (GdkDisplay *self,
const char *resource_name)
{
VkShaderModule *shader;
VkShaderModule shader;
GError *error = NULL;
GBytes *bytes;
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
if (shader)
return *shader;
return shader;
bytes = g_resources_lookup_data (resource_name, 0, &error);
if (bytes == NULL)
@@ -2029,7 +2002,6 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
return VK_NULL_HANDLE;
}
shader = g_new0 (VkShaderModule, 1);
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
&(VkShaderModuleCreateInfo) {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
@@ -2037,20 +2009,18 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
},
NULL,
shader) == VK_SUCCESS)
&shader) == VK_SUCCESS)
{
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
}
else
{
g_free (shader);
return VK_NULL_HANDLE;
shader = VK_NULL_HANDLE;
}
g_bytes_unref (bytes);
return *shader;
return shader;
}
#else /* GDK_RENDERING_VULKAN */
-1
View File
@@ -94,7 +94,6 @@ 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);
+2 -2
View File
@@ -96,12 +96,12 @@ _gdk_macos_drag_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (self, window);
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setDecorated:NO];
_gdk_macos_surface_set_native (self, window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
+3 -13
View File
@@ -52,7 +52,6 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
GdkRectangle bounds;
GdkRectangle final_rect;
int x, y;
int shadow_left, shadow_right, shadow_top, shadow_bottom;
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
g_assert (layout != NULL);
@@ -69,19 +68,10 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
gdk_macos_monitor_get_workarea (monitor, &bounds);
gdk_popup_layout_get_shadow_width (layout,
&shadow_left,
&shadow_right,
&shadow_top,
&shadow_bottom);
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
width,
height,
shadow_left,
shadow_right,
shadow_top,
shadow_bottom,
0, 0, 0, 0, /* shadow-left/right/top/bottom */
monitor,
&bounds,
self->layout,
@@ -316,14 +306,14 @@ _gdk_macos_popup_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setDecorated:NO];
[window setExcludedFromWindowsMenu:YES];
[window setLevel:NSPopUpMenuWindowLevel];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
GDK_END_MACOS_ALLOC_POOL;
+2 -2
View File
@@ -591,11 +591,11 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
defer:NO
screen:screen];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
/* Allow NSWindow to go fullscreen */
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
+1 -4
View File
@@ -6,7 +6,6 @@ gdk_public_sources = files([
'gdkcairo.c',
'gdkcairocontext.c',
'gdkclipboard.c',
'gdkcolorstate.c',
'gdkcontentdeserializer.c',
'gdkcontentformats.c',
'gdkcontentprovider.c',
@@ -76,7 +75,6 @@ gdk_public_headers = files([
'gdkcairo.h',
'gdkcairocontext.h',
'gdkclipboard.h',
'gdkcolorstate.h',
'gdkcontentdeserializer.h',
'gdkcontentformats.h',
'gdkcontentprovider.h',
@@ -130,8 +128,8 @@ install_headers(gdk_deprecated_headers, subdir: 'gtk-4.0/gdk/deprecated')
gdk_sources = gdk_public_sources + gdk_deprecated_sources
gdk_private_h_sources = files([
'gdkdevicetoolprivate.h',
'gdkeventsprivate.h',
'gdkdevicetoolprivate.h',
'gdkhslaprivate.h',
'gdkmonitorprivate.h',
'gdkseatdefaultprivate.h',
@@ -226,7 +224,6 @@ gdk_deps = [
fontconfig_dep,
platform_gio_dep,
pangocairo_dep,
lcms2_dep,
vulkan_dep,
libdrm_dep,
png_dep,
+38 -37
View File
@@ -165,29 +165,25 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
double *scale)
{
GdkTexture *texture;
int desired_scale_factor;
desired_scale_factor = (int) ceil (desired_scale);
if (gdk_cursor_get_name (cursor))
{
struct wl_cursor *c;
int scale_factor;
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
{
*hotspot_x = *hotspot_y = 0;
*width = *height = 0;
*scale = 1;
return NULL;
}
scale_factor = (int) ceil (desired_scale);
goto none;
c = gdk_wayland_cursor_load_for_name (display,
display->cursor_theme,
scale_factor,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale_factor,
gdk_cursor_get_name (cursor));
if (c && c->image_count > 0)
{
struct wl_cursor_image *image;
int cursor_scale;
if (image_index >= c->image_count)
{
@@ -199,23 +195,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
image = c->images[image_index];
*width = display->cursor_theme_size;
*height = display->cursor_theme_size;
*scale = image->width / (double) *width;
*hotspot_x = image->hotspot_x / scale_factor;
*hotspot_y = image->hotspot_y / scale_factor;
if (*scale != scale_factor && !use_viewporter)
cursor_scale = desired_scale_factor;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
{
g_warning (G_STRLOC " cursor image size (%d) not an integer "
"multiple of theme size (%d)", image->width, *width);
*width = image->width;
*height = image->height;
*hotspot_x = image->hotspot_x;
*hotspot_y = image->hotspot_y;
*scale = 1;
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
cursor_scale = 1;
}
*hotspot_x = image->hotspot_x / cursor_scale;
*hotspot_y = image->hotspot_y / cursor_scale;
*width = image->width / cursor_scale;
*height = image->height / cursor_scale;
*scale = cursor_scale;
return wl_cursor_image_get_buffer (image);
}
}
@@ -261,7 +257,7 @@ from_texture:
else
{
if (!use_viewporter)
*scale = ceil (desired_scale);
*scale = desired_scale_factor;
else
*scale = desired_scale;
@@ -298,23 +294,28 @@ from_texture:
}
if (gdk_cursor_get_fallback (cursor))
{
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
}
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
else
{
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
goto from_texture;
}
g_assert_not_reached ();
none:
*hotspot_x = 0;
*hotspot_y = 0;
*width = 0;
*height = 0;
*scale = 1;
return NULL;
}
guint
-111
View File
@@ -97,7 +97,6 @@
#define OUTPUT_VERSION_WITH_DONE 2
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
#define OUTPUT_VERSION 3
#define XDG_WM_DIALOG_VERSION 1
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
#define XDG_WM_BASE_VERSION 6
@@ -338,53 +337,6 @@ static void gdk_wayland_display_remove_output (GdkWaylandDisplay *display_wa
static void gdk_wayland_display_init_xdg_output (GdkWaylandDisplay *display_wayland);
static void gdk_wayland_display_get_xdg_output (GdkWaylandMonitor *monitor);
static void
xx_color_manager_v2_supported_intent (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2,
uint32_t render_intent)
{
GdkWaylandDisplay *display = data;
display->color_manager_supported.intents |= (1 << render_intent);
}
static void
xx_color_manager_v2_supported_feature (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2,
uint32_t feature)
{
GdkWaylandDisplay *display = data;
display->color_manager_supported.features |= (1 << feature);
}
static void
xx_color_manager_v2_supported_tf_named (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2,
uint32_t tf)
{
GdkWaylandDisplay *display = data;
display->color_manager_supported.transfers |= (1 << tf);
}
static void
xx_color_manager_v2_supported_primaries_named (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2,
uint32_t primaries)
{
GdkWaylandDisplay *display = data;
display->color_manager_supported.primaries |= (1 << primaries);
}
static struct xx_color_manager_v2_listener color_manager_listener = {
xx_color_manager_v2_supported_intent,
xx_color_manager_v2_supported_feature,
xx_color_manager_v2_supported_tf_named,
xx_color_manager_v2_supported_primaries_named,
};
static void
gdk_registry_handle_global (void *data,
struct wl_registry *registry,
@@ -430,13 +382,6 @@ gdk_registry_handle_global (void *data,
{
display_wayland->zxdg_shell_v6_id = id;
}
else if (strcmp (interface, "xdg_wm_dialog_v1") == 0)
{
display_wayland->xdg_wm_dialog =
wl_registry_bind (display_wayland->wl_registry, id,
&xdg_wm_dialog_v1_interface,
MIN (version, XDG_WM_DIALOG_VERSION));
}
else if (strcmp (interface, "gtk_shell1") == 0)
{
display_wayland->gtk_shell =
@@ -579,19 +524,6 @@ gdk_registry_handle_global (void *data,
&wp_presentation_interface,
MIN (version, 1));
}
else if (strcmp (interface, "xx_color_manager_v2") == 0)
{
display_wayland->color_manager =
wl_registry_bind (display_wayland->wl_registry, id,
&xx_color_manager_v2_interface,
MIN (version, 2));
xx_color_manager_v2_add_listener (display_wayland->color_manager,
&color_manager_listener,
display_wayland);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
else if (strcmp (interface, wp_single_pixel_buffer_manager_v1_interface.name) == 0)
{
display_wayland->single_pixel_buffer =
@@ -752,49 +684,6 @@ _gdk_wayland_display_open (const char *display_name)
return NULL;
}
if (display_wayland->color_manager)
{
const char *intents[] = {
"perceptual", "relative", "saturation", "absolute", "relative-bpc"
};
const char *features[] = {
"icc-v2-v4", "parametric", "set-primaries", "set-tf-power",
"set-mastering-display-primaries", "extended-target-volume"
};
const char *tf[] = {
"bt709", "gamma22", "gamma28", "st240", "linear", "log100",
"log316", "xvycc", "bt1361", "srgb", "pq", "st428", "hlg"
};
const char *primaries[] = {
"srgb", "pal-m", "pal", "ntsc", "generic-film", "bt2020", "xyz",
"dci-p3", "display-p3", "adobe-rgb",
};
for (int i = 0; i < G_N_ELEMENTS (intents); i++)
{
GDK_DEBUG (MISC, "Rendering intent %d (%s): %s",
i, intents[i], display_wayland->color_manager_supported.intents & (1 << i) ? "" : "");
}
for (int i = 0; i < G_N_ELEMENTS (features); i++)
{
GDK_DEBUG (MISC, "Feature %d (%s): %s",
i, features[i], display_wayland->color_manager_supported.features & (1 << i) ? "" : "");
}
for (int i = 0; i < G_N_ELEMENTS (tf); i++)
{
GDK_DEBUG (MISC, "Transfer function %d (%s): %s",
i, tf[i], display_wayland->color_manager_supported.transfers & (1 << i) ? "" : "");
}
for (int i = 0; i < G_N_ELEMENTS (primaries); i++)
{
GDK_DEBUG (MISC, "Primaries %d (%s): %s",
i, primaries[i], display_wayland->color_manager_supported.primaries& (1 << i) ? "" : "");
}
}
gdk_display_emit_opened (display);
return display;
-10
View File
@@ -41,8 +41,6 @@
#include <gdk/wayland/viewporter-client-protocol.h>
#include <gdk/wayland/presentation-time-client-protocol.h>
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
#include <gdk/wayland/xdg-dialog-v1-client-protocol.h>
#include <gdk/wayland/xx-color-management-v2-client-protocol.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
@@ -104,7 +102,6 @@ struct _GdkWaylandDisplay
DmabufFormatsInfo *dmabuf_formats_info;
struct xdg_wm_base *xdg_wm_base;
struct zxdg_shell_v6 *zxdg_shell_v6;
struct xdg_wm_dialog_v1 *xdg_wm_dialog;
struct gtk_shell1 *gtk_shell;
struct wl_data_device_manager *data_device_manager;
struct wl_subcompositor *subcompositor;
@@ -124,13 +121,6 @@ struct _GdkWaylandDisplay
struct wp_viewporter *viewporter;
struct wp_presentation *presentation;
struct wp_single_pixel_buffer_manager_v1 *single_pixel_buffer;
struct xx_color_manager_v2 *color_manager;
struct {
unsigned int intents;
unsigned int features;
unsigned int transfers;
unsigned int primaries;
} color_manager_supported;
GList *async_roundtrips;
+1 -17
View File
@@ -3866,25 +3866,9 @@ pointer_surface_leave (void *data,
pointer_surface_update_scale (device);
}
static void
pointer_surface_preferred_buffer_scale (void *data,
struct wl_surface *wl_surface,
int32_t factor)
{
}
static void
pointer_surface_preferred_buffer_transform (void *data,
struct wl_surface *wl_surface,
uint32_t transform)
{
}
static const struct wl_surface_listener pointer_surface_listener = {
pointer_surface_enter,
pointer_surface_leave,
pointer_surface_preferred_buffer_scale,
pointer_surface_preferred_buffer_transform,
pointer_surface_leave
};
static void
-1
View File
@@ -39,7 +39,6 @@ struct _GdkWaylandSurface
struct wl_egl_window *egl_window;
struct wp_fractional_scale_v1 *fractional_scale;
struct wp_viewport *viewport;
struct xx_color_management_surface_v2 *color;
} display_server;
struct wl_event_queue *event_queue;
+1 -95
View File
@@ -47,8 +47,6 @@
#include <netinet/in.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "gdksurface-wayland-private.h"
#include "gdktoplevel-wayland-private.h"
@@ -58,7 +56,6 @@
#include "gsk/gskrectprivate.h"
#include <lcms2.h>
/**
* GdkWaylandSurface:
@@ -912,34 +909,6 @@ static const struct wl_surface_listener surface_listener = {
surface_preferred_buffer_transform,
};
static void
image_desc_failed (void *data,
struct xx_image_description_v2 *image_desc,
uint32_t cause,
const char *msg)
{
GDK_DEBUG (MISC, "Drats! Image description failed: %s", msg);
xx_image_description_v2_destroy (image_desc);
}
static void
image_desc_ready (void *data,
struct xx_image_description_v2 *image_desc,
uint32_t identity)
{
GdkWaylandSurface *self = data;
GDK_DEBUG (MISC, "Seting image description on surface");
xx_color_management_surface_v2_set_image_description (self->display_server.color,
image_desc,
XX_COLOR_MANAGER_V2_RENDER_INTENT_PERCEPTUAL);
}
static const struct xx_image_description_v2_listener image_desc_listener = {
image_desc_failed,
image_desc_ready
};
static void
gdk_wayland_surface_create_wl_surface (GdkSurface *surface)
{
@@ -964,68 +933,6 @@ gdk_wayland_surface_create_wl_surface (GdkSurface *surface)
wp_viewporter_get_viewport (display_wayland->viewporter, wl_surface);
}
if (display_wayland->color_manager)
{
self->display_server.color = xx_color_manager_v2_get_surface (display_wayland->color_manager, wl_surface);
if (display_wayland->color_manager_supported.features & (1 << XX_COLOR_MANAGER_V2_FEATURE_PARAMETRIC) &&
display_wayland->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB) &&
display_wayland->color_manager_supported.primaries & (1 << XX_COLOR_MANAGER_V2_PRIMARIES_SRGB) &&
display_wayland->color_manager_supported.intents & (1 << XX_COLOR_MANAGER_V2_RENDER_INTENT_PERCEPTUAL))
{
GDK_DEBUG (MISC, "Using parametric image description");
struct xx_image_description_creator_params_v2 *params;
struct xx_image_description_v2 *desc;
params = xx_color_manager_v2_new_parametric_creator (display_wayland->color_manager);
xx_image_description_creator_params_v2_set_tf_named (params, XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB);
xx_image_description_creator_params_v2_set_primaries_named (params, XX_COLOR_MANAGER_V2_PRIMARIES_SRGB);
desc = xx_image_description_creator_params_v2_create (params);
xx_image_description_v2_add_listener (desc, &image_desc_listener, surface);
}
else if (display_wayland->color_manager_supported.features & (1 << XX_COLOR_MANAGER_V2_FEATURE_ICC_V2_V4))
{
int fd;
char *filename;
cmsHPROFILE profile;
fd = g_file_open_tmp ("gtk-XXXXXX.icc", &filename, NULL);
close (fd);
profile = cmsCreate_sRGBProfile ();
if (cmsSaveProfileToFile (profile, filename))
{
struct xx_image_description_creator_icc_v2 *icc;
struct xx_image_description_v2 *desc;
int fd;
struct stat statbuf;
fd = open (filename, O_RDONLY);
fstat (fd, &statbuf);
GDK_DEBUG (MISC, "Using ICC image description");
icc = xx_color_manager_v2_new_icc_creator (display_wayland->color_manager);
xx_image_description_creator_icc_v2_set_icc_file (icc, fd, 0, statbuf.st_size);
desc = xx_image_description_creator_icc_v2_create (icc);
xx_image_description_v2_add_listener (desc, &image_desc_listener, surface);
close (fd);
}
cmsCloseProfile (profile);
g_unlink (filename);
g_free (filename);
}
else
{
GDK_DEBUG (MISC, "Not using Wayland color management");
}
}
self->display_server.wl_surface = wl_surface;
}
@@ -1079,7 +986,6 @@ gdk_wayland_surface_destroy_wl_surface (GdkWaylandSurface *self)
g_clear_pointer (&self->display_server.viewport, wp_viewport_destroy);
g_clear_pointer (&self->display_server.fractional_scale, wp_fractional_scale_v1_destroy);
g_clear_pointer (&self->display_server.color, xx_color_management_surface_v2_destroy);
g_clear_pointer (&self->display_server.wl_surface, wl_surface_destroy);
@@ -1477,7 +1383,7 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
klass->hide_surface = gdk_wayland_surface_default_hide_surface;
}
/* }}} */
/* }}} */
/* {{{ Private Surface API */
struct wl_output *
+2 -35
View File
@@ -37,7 +37,6 @@
#include <wayland/presentation-time-client-protocol.h>
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
#include <wayland/xdg-dialog-v1-client-protocol.h>
#include <stdlib.h>
#include <stdio.h>
@@ -85,7 +84,6 @@ struct _GdkWaylandToplevel
struct gtk_surface1 *gtk_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_v6 *zxdg_toplevel_v6;
struct xdg_dialog_v1 *xdg_dialog;
} display_server;
GdkWaylandToplevel *transient_for;
@@ -207,7 +205,6 @@ gdk_wayland_toplevel_clear_saved_size (GdkWaylandToplevel *toplevel)
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandToplevel *wayland_toplevel);
static void maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel);
static gboolean maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel);
static void
gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
@@ -218,7 +215,6 @@ gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
g_clear_pointer (&toplevel->display_server.xdg_toplevel, xdg_toplevel_destroy);
g_clear_pointer (&toplevel->display_server.zxdg_toplevel_v6, zxdg_toplevel_v6_destroy);
g_clear_pointer (&toplevel->display_server.xdg_dialog, xdg_dialog_v1_destroy);
if (toplevel->display_server.gtk_surface)
{
@@ -881,8 +877,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *wayland_toplevel)
gdk_wayland_toplevel_set_application_id (GDK_TOPLEVEL (wayland_toplevel), app_id);
maybe_set_gtk_surface_dbus_properties (wayland_toplevel);
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
maybe_set_gtk_surface_modal (wayland_toplevel);
maybe_set_gtk_surface_modal (wayland_toplevel);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
wl_surface_commit (wayland_surface->display_server.wl_surface);
@@ -1094,40 +1089,12 @@ maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel)
}
static gboolean
maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel)
{
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (wayland_toplevel)));
if (!display_wayland->xdg_wm_dialog)
return FALSE;
if (!is_realized_toplevel (GDK_WAYLAND_SURFACE (wayland_toplevel)))
return FALSE;
if (!wayland_toplevel->display_server.xdg_dialog)
{
wayland_toplevel->display_server.xdg_dialog =
xdg_wm_dialog_v1_get_xdg_dialog (display_wayland->xdg_wm_dialog,
wayland_toplevel->display_server.xdg_toplevel);
}
if (GDK_SURFACE (wayland_toplevel)->modal_hint)
xdg_dialog_v1_set_modal (wayland_toplevel->display_server.xdg_dialog);
else
xdg_dialog_v1_unset_modal (wayland_toplevel->display_server.xdg_dialog);
return TRUE;
}
static void
gdk_wayland_toplevel_set_modal_hint (GdkWaylandToplevel *wayland_toplevel,
gboolean modal)
{
GDK_SURFACE (wayland_toplevel)->modal_hint = modal;
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
maybe_set_gtk_surface_modal (wayland_toplevel);
maybe_set_gtk_surface_modal (wayland_toplevel);
}
void
+24 -126
View File
@@ -48,138 +48,36 @@ gdk_wayland_deps = [
wlegldep,
]
# Fields:
# - name: protocol name
# - stability: protocol stability ('private', 'stable' or 'unstable')
# - version: protocol version
# - required: wayland_protocols version check
wlmod = import('unstable-wayland')
proto_sources = [
{
'name': 'gtk-shell',
'stability': 'private',
},
{
'name': 'primary-selection',
'stability': 'unstable',
'version': 1,
},
{
'name': 'pointer-gestures',
'stability': 'unstable',
'version': 1,
},
{
'name': 'viewporter',
'stability': 'stable',
},
{
'name': 'xdg-shell',
'stability': 'unstable',
'version': 6,
},
{
'name': 'xdg-shell',
'stability': 'stable',
},
{
'name': 'xdg-foreign',
'stability': 'unstable',
'version': 1,
},
{
'name': 'xdg-foreign',
'stability': 'unstable',
'version': 2,
},
{
'name': 'tablet',
'stability': 'unstable',
'version': 2,
},
{
'name': 'keyboard-shortcuts-inhibit',
'stability': 'unstable',
'version': 1,
},
{
'name': 'server-decoration',
'stability': 'private',
},
{
'name': 'xdg-output',
'stability': 'unstable',
'version': 1,
},
{
'name': 'idle-inhibit',
'stability': 'unstable',
'version': 1,
},
{
'name': 'xdg-activation',
'stability': 'staging',
'version': 1,
},
{
'name': 'fractional-scale',
'stability': 'staging',
'version': 1,
},
{
'name': 'linux-dmabuf',
'stability': 'unstable',
'version': 1,
},
{
'name': 'presentation-time',
'stability': 'stable',
'version': 1,
},
{
'name': 'single-pixel-buffer',
'stability': 'staging',
'version': 1,
},
{
'name': 'xdg-dialog',
'stability': 'staging',
'version': 1,
},
{
'name': 'xx-color-management',
'stability': 'private',
'version': 2,
},
'protocol/gtk-shell.xml',
'protocol/server-decoration.xml',
wlmod.find_protocol('primary-selection', state: 'unstable', version: 1),
wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1),
wlmod.find_protocol('viewporter', state: 'stable'),
wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6),
wlmod.find_protocol('xdg-shell', state: 'stable'),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2),
wlmod.find_protocol('tablet', state: 'unstable', version: 2),
wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-output', state: 'unstable', version: 1),
wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-activation', state: 'staging', version: 1),
wlmod.find_protocol('fractional-scale', state: 'staging', version: 1),
wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
wlmod.find_protocol('presentation-time', state: 'stable'),
wlmod.find_protocol('single-pixel-buffer', state: 'staging', version: 1),
]
gdk_wayland_gen_headers = []
wlmod = import('unstable-wayland')
foreach p: proto_sources
if wlprotocolsdep.version().version_compare(p.get('required', '>=0'))
if p.get('stability') == 'private'
if (p.has_key('version'))
proto_file = 'protocol/@0@-v@1@.xml'.format(p.get('name'), p.get('version'))
else
proto_file = 'protocol/@0@.xml'.format(p.get('name'))
endif
elif p.get('stability') == 'stable'
proto_file = wlmod.find_protocol(p.get('name'),
state: p.get('stability'),
)
else
proto_file = wlmod.find_protocol(p.get('name'),
state: p.get('stability'),
version: p.get('version'),
)
endif
# Returns a list [.c, .h]
gen = wlmod.scan_xml(proto_file)
assert(gen.length() == 2)
gdk_wayland_sources += gen[0]
gdk_wayland_gen_headers += gen[1]
endif
# Returns a list [.c, .h]
gen = wlmod.scan_xml(p)
assert(gen.length() == 2)
gdk_wayland_sources += gen[0]
gdk_wayland_gen_headers += gen[1]
endforeach
libgdk_wayland = static_library('gdk-wayland',
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -1408,7 +1408,7 @@ register_clipboard_notification ()
WNDCLASS wclass = { 0, };
ATOM klass;
wclass.lpszClassName = L"GdkClipboardNotification";
wclass.lpszClassName = "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 (L"GDK_WORKER_THREAD_WEAKEUP");
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
user32 = LoadLibrary (L"user32.dll");
user32 = LoadLibrary ("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) = 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_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_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_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_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");
_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");
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
(RegisterClipboardFormat (L"application/x-moz-nativeimage")) ||
(RegisterClipboardFormatA ("application/x-moz-nativeimage")) ||
IsClipboardFormatAvailable
(RegisterClipboardFormat (L"UniformResourceLocatorW"))) &&
(RegisterClipboardFormatA ("UniformResourceLocatorW"))) &&
#endif
TRUE)
{
+35 -36
View File
@@ -31,13 +31,12 @@
static struct {
char *name;
const wchar_t *id;
char *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 },
@@ -457,32 +456,32 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL:
result = gdk_win32_hcursor_new (display,
LoadImage (NULL,
cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
cursor->height,
cursor->load_flags),
LoadImageA (NULL,
(const char *) 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,
LoadImage (GetModuleHandle (NULL),
cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
cursor->height,
cursor->load_flags),
LoadImageA (GetModuleHandle (NULL),
(const char *) 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,
LoadImage (this_module (),
cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
cursor->height,
cursor->load_flags),
LoadImageA (this_module (),
(const char *) 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:
@@ -499,12 +498,12 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
}
static Win32Cursor *
win32_cursor_new (GdkWin32CursorLoadType load_type,
wchar_t *resource_name,
int width,
int height,
guint load_flags,
int xcursor_number)
win32_cursor_new (GdkWin32CursorLoadType load_type,
gpointer resource_name,
int width,
int height,
guint load_flags,
int xcursor_number)
{
Win32Cursor *result;
@@ -632,9 +631,9 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
/* Prefer W32 cursors */
if (cursors[i].builtin)
shared_hcursor = LoadImage (NULL, cursors[i].builtin, IMAGE_CURSOR,
size, size,
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
shared_hcursor = LoadImageA (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)
@@ -646,7 +645,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,
(wchar_t*) cursors[i].builtin,
(gpointer) cursors[i].builtin,
size,
size,
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
@@ -661,14 +660,14 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
if (default_cursors[i].name == NULL)
break;
shared_hcursor = LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, size, size,
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
shared_hcursor = LoadImageA (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,
(wchar_t*) default_cursors[i].id,
(gpointer) default_cursors[i].id,
size,
size,
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
@@ -780,8 +779,8 @@ win32hcursor_idc_from_name (GdkWin32Display *display,
continue;
return gdk_win32_hcursor_new (display,
LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
LR_SHARED | LR_DEFAULTSIZE),
LoadImageA (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
LR_SHARED | LR_DEFAULTSIZE),
FALSE);
}
@@ -885,7 +884,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, LoadCursorA (hinstance, name), FALSE);
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
}
static HICON
+5 -5
View File
@@ -121,7 +121,7 @@ gdk_device_manager_win32_finalize (GObject *object)
#if DEBUG_WINTAB
static void
print_lc(LOGCONTEXTA *lc)
print_lc(LOGCONTEXT *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 = GetSystemDirectoryA (&dummy, 0);
n = GetSystemDirectory (&dummy, 0);
if (n <= 0)
return;
wintab32_dll_path = g_malloc (n + 1 + strlen (WINTAB32_DLL));
k = GetSystemDirectoryA (wintab32_dll_path, n);
k = GetSystemDirectory (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 = LoadLibraryA (wintab32_dll_path)) == NULL)
if ((wintab32 = LoadLibrary (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++)
{
LOGCONTEXTA lc;
LOGCONTEXT lc;
/* We open the Wintab device (hmm, what if there are several, or
* can there even be several, probably not?) as a system
+2 -2
View File
@@ -480,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
WNDCLASS wclass = { 0, };
ATOM klass;
wclass.lpszClassName = L"GdkDisplayChange";
wclass.lpszClassName = "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 (L"kernel32.dll"), "ProcessIdToSessionId");
processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle ("kernel32.dll"), "ProcessIdToSessionId");
if (!processIdToSessionId || !processIdToSessionId (GetCurrentProcessId (), &session_id))
session_id = 0;
-1
View File
@@ -134,7 +134,6 @@ struct _GdkWin32Display
guint hasWglEXTSwapControl : 1;
guint hasWglOMLSyncControl : 1;
guint hasWglARBPixelFormat : 1;
guint force_enable_depth_bits : 1;
#ifdef HAVE_EGL
guint hasEglKHRCreateContext : 1;
+1 -1
View File
@@ -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 (L"GDK_WORKER_THREAD_WEAKEUP");
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
/* Signal the main thread that we're ready.
* This is the only time the queue works in reverse.
+3 -3
View File
@@ -419,7 +419,7 @@ set_up_low_level_keyboard_hook (void)
else
WIN32_API_FAILED ("SetWindowsHookEx");
aerosnap_message = RegisterWindowMessage (L"GDK_WIN32_AEROSNAP_MESSAGE");
aerosnap_message = RegisterWindowMessage ("GDK_WIN32_AEROSNAP_MESSAGE");
}
void
@@ -470,7 +470,7 @@ _gdk_events_init (GdkDisplay *display)
};
#endif
got_gdk_events_message = RegisterWindowMessage (L"GDK_WIN32_GOT_EVENTS");
got_gdk_events_message = RegisterWindowMessage ("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 (GetMonitorInfo (nearest_monitor, &nearest_info))
if (GetMonitorInfoA (nearest_monitor, &nearest_info))
{
/* MSDN says that we must specify maximized window
* size as if it was located on the primary monitor.
+7 -21
View File
@@ -142,7 +142,8 @@ get_wgl_pfd (HDC hdc,
pfd->nSize = sizeof (PIXELFORMATDESCRIPTOR);
if (display_win32->hasWglARBPixelFormat)
if (display_win32 != NULL &&
display_win32->hasWglARBPixelFormat)
{
UINT num_formats;
int colorbits = GetDeviceCaps (hdc, BITSPIXEL);
@@ -175,18 +176,15 @@ 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 */
@@ -217,20 +215,8 @@ 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;
@@ -248,7 +234,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, display_win32);
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
if (best_idx != 0)
set_pixel_format_result = SetPixelFormat (display_win32->dummy_context_wgl.hdc,
@@ -283,7 +269,7 @@ create_dummy_gl_window (void)
ATOM klass;
HWND hwnd = NULL;
wclass.lpszClassName = L"GdkGLDummyWindow";
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;
wclass.hInstance = this_module ();
wclass.style = CS_OWNDC;
+2 -2
View File
@@ -730,7 +730,7 @@ _gdk_win32_key_to_string (LONG lParam)
char buf[100];
char *keyname_utf8;
if (GetKeyNameTextA (lParam, buf, sizeof (buf)) &&
if (GetKeyNameText (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 (GetClipboardFormatNameA (format, buf, sizeof (buf)))
if (GetClipboardFormatName (format, buf, sizeof (buf)))
return static_printf ("'%s'", buf);
else
return static_printf ("unk-%#lx", format);
+1 -1
View File
@@ -197,7 +197,7 @@ typedef struct _Win32Cursor Win32Cursor;
struct _Win32Cursor {
GdkWin32CursorLoadType load_type;
wchar_t *resource_name;
gunichar2 *resource_name;
int width;
int height;
guint load_flags;
+3 -3
View File
@@ -326,7 +326,7 @@ RegisterGdkClass (GType wtype)
static WNDCLASSEXW wcl;
ATOM klass = 0;
wcl.cbSize = sizeof (WNDCLASSEXW);
wcl.cbSize = sizeof (WNDCLASSEX);
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)
{
wchar_t sLoc [MAX_PATH+1];
char 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 (!GetMonitorInfo (hmonitor, &hmonitor_info))
if (!GetMonitorInfoA (hmonitor, &hmonitor_info))
return;
if (impl->snap_stash == NULL)
+1 -1
View File
@@ -1,4 +1,4 @@
static const struct { const char *name; const wchar_t *builtin; int type; guchar width; guchar height; guchar hotx; guchar hoty; char *data; } cursors[] = {
static const struct { const char *name; const char *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"
+5
View File
@@ -1776,6 +1776,11 @@ _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,
-26
View File
@@ -758,17 +758,6 @@ 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
@@ -788,7 +777,6 @@ 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;
@@ -877,20 +865,6 @@ 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;
+1 -7
View File
@@ -1483,7 +1483,6 @@ 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])
@@ -1508,7 +1507,6 @@ 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);
@@ -1521,7 +1519,6 @@ 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))
@@ -1537,7 +1534,6 @@ 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);
@@ -1556,7 +1552,6 @@ 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);
@@ -1675,7 +1670,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, gl_internalsrgbformat;
GLint gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
@@ -1718,7 +1713,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
ensure_mipmap,
out_can_mipmap,
&gl_internalformat,
&gl_internalsrgbformat,
&gl_format,
&gl_type,
gl_swizzle);
+3 -2
View File
@@ -972,7 +972,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
if (texture_id == 0)
{
downloaded_texture = gdk_memory_texture_from_texture (texture);
downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
/* The download_texture() call may have switched the GL context. Make sure
* the right context is at work again.
@@ -1471,7 +1471,8 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
}
slices = g_new0 (GskGLTextureSlice, n_slices);
memtex = gdk_memory_texture_from_texture (texture);
memtex = gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture));
if (ensure_mipmap)
{
+2 -5
View File
@@ -23,7 +23,6 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include "gskglcommandqueueprivate.h"
#include "gskgldriverprivate.h"
@@ -128,7 +127,7 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
else
{
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
gl_type = GL_UNSIGNED_BYTE;
}
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
@@ -282,11 +281,9 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
pixel_data = free_data = g_malloc (width * height * 4);
gdk_memory_convert (pixel_data, width * 4,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
GDK_COLOR_STATE_SRGB,
cairo_image_surface_get_data (surface),
stride,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
width, height);
stride = width * 4;
gl_format = GL_RGBA;
@@ -296,7 +293,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_INT_8_8_8_8_REV;
gl_type = GL_UNSIGNED_BYTE;
}
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
+2 -6
View File
@@ -24,7 +24,6 @@
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdktextureprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include "gskglcommandqueueprivate.h"
#include "gskgldriverprivate.h"
@@ -117,11 +116,8 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
pixel_data = free_data = g_malloc (width * height * 4);
gdk_memory_convert (pixel_data, width * 4,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
GDK_COLOR_STATE_SRGB,
surface_data, cairo_image_surface_get_stride (surface),
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
width, height);
GDK_MEMORY_DEFAULT, width, height);
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
}
@@ -129,7 +125,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
{
pixel_data = surface_data;
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
gl_type = GL_UNSIGNED_BYTE;
}
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
-11
View File
@@ -41,15 +41,6 @@
#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;
@@ -104,7 +95,6 @@ static void
gsk_gl_renderer_dmabuf_downloader_download (GdkDmabufDownloader *downloader_,
GdkDmabufTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
@@ -126,7 +116,6 @@ gsk_gl_renderer_dmabuf_downloader_download (GdkDmabufDownloader *downloader_,
downloader = gdk_texture_downloader_new (native);
gdk_texture_downloader_set_format (downloader, format);
gdk_texture_downloader_set_color_state (downloader, color_state);
gdk_texture_downloader_download_into (downloader, data, stride);
gdk_texture_downloader_free (downloader);
-10
View File
@@ -10,7 +10,6 @@
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkprofilerprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h>
@@ -77,7 +76,6 @@ 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);
@@ -87,7 +85,6 @@ static GskGpuImage *
gsk_gl_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -95,7 +92,6 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
format,
color_state,
0,
width,
height);
@@ -111,7 +107,6 @@ 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);
@@ -126,7 +121,6 @@ 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);
@@ -641,7 +635,6 @@ 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])
@@ -661,7 +654,6 @@ 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);
@@ -673,7 +665,6 @@ 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) &&
@@ -697,7 +688,6 @@ 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);
-1
View File
@@ -26,7 +26,6 @@ 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]);
+1 -4
View File
@@ -70,10 +70,7 @@ gsk_gl_frame_cleanup (GskGpuFrame *frame)
if (self->sync)
{
glClientWaitSync (self->sync, 0, -1);
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
glDeleteSync (self->sync);
self->sync = NULL;
g_clear_pointer (&self->sync, glDeleteSync);
}
self->next_texture_slot = 0;
+7 -43
View File
@@ -1,10 +1,9 @@
#include "config.h"
#include "config.h"
#include "gskglimageprivate.h"
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
struct _GskGLImage
{
@@ -74,13 +73,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height,
gboolean is_srgb)
gsize height)
{
GskGLImage *self;
GskGpuImageFlags flags;
GLint swizzle[4];
GLint gl_internal_format, gl_internal_srgb_format;
self = g_object_new (GSK_TYPE_GL_IMAGE, NULL);
@@ -90,25 +87,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
0,
&format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_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 */
@@ -126,7 +109,6 @@ 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)
@@ -134,7 +116,6 @@ 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));
@@ -148,23 +129,11 @@ gsk_gl_image_new (GskGLDevice *device,
required_flags,
&format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_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,
@@ -208,7 +177,6 @@ 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);
@@ -220,14 +188,10 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
0,
&real_format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_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);
+1 -3
View File
@@ -14,11 +14,9 @@ GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDe
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height,
gboolean converts_srgb);
gsize height);
GskGpuImage * gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height);
-1
View File
@@ -23,7 +23,6 @@ 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);
+1 -1
View File
@@ -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) { color2[0], color2[1], color2[2], color2[3] });
&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] });
}
static void
+14 -5
View File
@@ -14,7 +14,7 @@ struct _GskGpuClearOp
GskGpuOp op;
cairo_rectangle_int_t rect;
float color[4];
GdkRGBA color;
};
static void
@@ -29,14 +29,23 @@ 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_print_rgba (string, self->color);
gsk_gpu_rgba_to_float (&self->color, rgba);
gsk_gpu_print_rgba (string, rgba);
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,
@@ -45,7 +54,7 @@ gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuClearOp *self = (GskGpuClearOp *) op;
VkClearValue clear_value;
memcpy (clear_value.color.float32, self->color, sizeof (float) * 4);
gsk_gpu_init_clear_value (&clear_value, &self->color);
vkCmdClearAttachments (state->vk_command_buffer,
1,
@@ -83,7 +92,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[0], self->color[1], self->color[2], self->color[3]);
glClearColor (self->color.red, self->color.green, self->color.blue, self->color.alpha);
glClear (GL_COLOR_BUFFER_BIT);
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]);
@@ -112,5 +121,5 @@ gsk_gpu_clear_op (GskGpuFrame *frame,
self = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
self->rect = *rect;
gsk_gpu_rgba_to_float (color, self->color);
self->color = *color;
}
-86
View File
@@ -1,86 +0,0 @@
#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;
}
-21
View File
@@ -1,21 +0,0 @@
#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
+20 -63
View File
@@ -12,7 +12,6 @@
#include "gsk/gskdebugprivate.h"
#include "gsk/gskprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define MAX_SLICES_PER_ATLAS 64
@@ -253,9 +252,6 @@ struct _GskGpuCachedTexture
GdkTexture *texture;
GskGpuImage *image;
GdkColorState *color_state;
GskGpuImage *image2;
GdkColorState *color_state2;
};
static void
@@ -267,9 +263,6 @@ 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))
{
@@ -332,10 +325,9 @@ gsk_gpu_cached_texture_destroy_cb (gpointer data)
}
static GskGpuCachedTexture *
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image,
GdkColorState *color_state)
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image)
{
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device);
GskGpuCachedTexture *self;
@@ -348,9 +340,6 @@ 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;
@@ -707,14 +696,13 @@ gsk_gpu_device_create_offscreen_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
gsize width,
gsize height)
{
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, color_state, width, height);
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, width, height);
}
void
@@ -862,65 +850,34 @@ gsk_gpu_device_add_atlas_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp)
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
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 || 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
if (!cache || !cache->image || gsk_gpu_cached_texture_is_invalid (cache))
return NULL;
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
return g_object_ref (image);
return g_object_ref (cache->image);
}
void
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image,
GdkColorState *color_state)
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image)
{
GskGpuCachedTexture *cache;
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);
}
cache = gsk_gpu_cached_texture_new (self, texture, image);
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
}
@@ -993,7 +950,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
}
else
{
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, GDK_COLOR_STATE_SRGB, rect.size.width, rect.size.height),
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height),
rect.origin.x = 0;
rect.origin.y = 0;
padding = 0;
+1 -5
View File
@@ -35,7 +35,6 @@ 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,
@@ -65,7 +64,6 @@ 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,
@@ -75,13 +73,11 @@ 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,
GdkColorState *color_state);
GskGpuImage *image);
typedef enum
{
+2 -8
View File
@@ -145,7 +145,7 @@ gsk_gpu_download_op_vk_command (GskGpuOp *op,
GskVulkanDevice *device = GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame));
VkDevice vk_device = gsk_vulkan_device_get_vk_device (device);
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image, gdk_texture_get_color_state (self->texture));
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image);
if (gsk_vulkan_device_has_feature (device, GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT))
{
@@ -249,13 +249,7 @@ gsk_gl_texture_data_free (gpointer user_data)
gdk_gl_context_make_current (data->context);
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
if (data->sync)
{
glDeleteSync (data->sync);
data->sync = NULL;
}
g_clear_pointer (&data->sync, glDeleteSync);
glDeleteTextures (1, &data->texture_id);
g_object_unref (data->context);
+8 -27
View File
@@ -17,7 +17,6 @@
#include "gdk/gdkdmabufdownloaderprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024
@@ -403,26 +402,17 @@ gsk_gpu_frame_get_last_op (GskGpuFrame *self)
}
GskGpuImage *
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture,
GdkColorState **out_color_state)
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
GdkColorState *color_state;
image = GSK_GPU_FRAME_GET_CLASS (self)->upload_texture (self, with_mipmap, texture);
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
else
color_state = gdk_texture_get_color_state (texture);
if (image)
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image, color_state);
*out_color_state = color_state;
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image);
return image;
}
@@ -571,7 +561,6 @@ copy_texture (gpointer user_data,
static void
gsk_gpu_frame_record_rect (GskGpuFrame *self,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -583,7 +572,6 @@ gsk_gpu_frame_record_rect (GskGpuFrame *self,
gsk_gpu_node_processor_process (self,
target,
target_color_state,
clip,
node,
viewport);
@@ -597,7 +585,6 @@ static void
gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -616,14 +603,13 @@ gsk_gpu_frame_record (GskGpuFrame *self,
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_frame_record_rect (self, target, target_color_state, &rect, node, viewport);
gsk_gpu_frame_record_rect (self, target, &rect, node, viewport);
}
}
else
{
gsk_gpu_frame_record_rect (self,
target,
target_color_state,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
@@ -670,7 +656,6 @@ void
gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -678,7 +663,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
{
gsk_gpu_frame_cleanup (self);
gsk_gpu_frame_record (self, timestamp, target, target_color_state, region, node, viewport, texture);
gsk_gpu_frame_record (self, timestamp, target, region, node, viewport, texture);
gsk_gpu_frame_submit (self);
}
@@ -688,7 +673,6 @@ typedef struct _Download Download;
struct _Download
{
GdkMemoryFormat format;
GdkColorState *color_state;
guchar *data;
gsize stride;
};
@@ -702,7 +686,6 @@ do_download (gpointer user_data,
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, download->format);
gdk_texture_downloader_set_color_state (&downloader, download->color_state);
gdk_texture_downloader_download_into (&downloader, download->data, download->stride);
gdk_texture_downloader_finish (&downloader);
@@ -714,16 +697,15 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
gint64 timestamp,
GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, GDK_COLOR_STATE_SRGB, timestamp);
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, timestamp);
if (image == NULL)
image = gsk_gpu_frame_upload_texture (self, FALSE, texture, &color_state);
image = gsk_gpu_frame_upload_texture (self, FALSE, texture);
if (image == NULL)
{
g_critical ("Could not upload texture");
@@ -740,7 +722,6 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
do_download,
g_memdup (&(Download) {
.format = format,
.color_state = color_state,
.data = data,
.stride = stride
}, sizeof (Download)));
+1 -4
View File
@@ -58,8 +58,7 @@ gpointer gsk_gpu_frame_alloc_op (GskGpuF
gsize size);
GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture,
GdkColorState **out_color_state);
GdkTexture *texture);
GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self);
gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self,
gsize size);
@@ -76,7 +75,6 @@ void gsk_gpu_frame_wait (GskGpuF
void gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -85,7 +83,6 @@ void gsk_gpu_frame_download_texture (GskGpuF
gint64 timestamp,
GdkTexture *texture,
GdkMemoryFormat format,
GdkColorState *color_state,
guchar *data,
gsize stride);
GskGpuOp *gsk_gpu_frame_get_last_op (GskGpuFrame *self);
+1 -1
View File
@@ -114,7 +114,7 @@ gsk_gpu_image_toggle_ref_texture (GskGpuImage *self,
g_object_add_toggle_ref (G_OBJECT (self), gsk_gpu_image_texture_toggle_ref_cb, texture);
g_object_unref (self);
}
GdkMemoryFormat
gsk_gpu_image_get_format (GskGpuImage *self)
{
-2
View File
@@ -5,7 +5,6 @@
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskrectprivate.h"
#include "gskenumtypes.h"
#include "gpu/shaders/gskgpumaskinstance.h"
@@ -23,7 +22,6 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
{
GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_;
gsk_gpu_print_enum (string, GSK_TYPE_MASK_MODE, shader->variation);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
+24 -201
View File
@@ -10,7 +10,6 @@
#include "gskgpubluropprivate.h"
#include "gskgpuclearopprivate.h"
#include "gskgpuclipprivate.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpucolorizeopprivate.h"
#include "gskgpucolormatrixopprivate.h"
#include "gskgpucoloropprivate.h"
@@ -45,7 +44,6 @@
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdksubsurfaceprivate.h"
#include "gdk/gdkcolorstateprivate.h"
/* the epsilon we allow pixels to be off due to rounding errors.
* Chosen rather randomly.
@@ -122,7 +120,6 @@ struct _GskGpuNodeProcessor
float opacity;
GskGpuGlobals pending_globals;
GdkColorState *color_state;
};
#define GDK_ARRAY_NAME pattern_buffer
@@ -144,7 +141,6 @@ struct _GskGpuPatternWriter
guint stack;
PatternBuffer buffer;
GdkColorState *color_state;
};
static void gsk_gpu_node_processor_add_node (GskGpuNodeProcessor *self,
@@ -157,7 +153,6 @@ gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
{
g_clear_pointer (&self->modelview, gsk_transform_unref);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static void
@@ -165,7 +160,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GskGpuDescriptors *desc,
GskGpuImage *target,
GdkColorState *color_state,
const cairo_rectangle_int_t *clip,
const graphene_rect_t *viewport)
{
@@ -208,8 +202,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
-viewport->origin.y);
self->opacity = 1.0;
self->pending_globals = GSK_GPU_GLOBAL_MATRIX | GSK_GPU_GLOBAL_SCALE | GSK_GPU_GLOBAL_CLIP | GSK_GPU_GLOBAL_SCISSOR | GSK_GPU_GLOBAL_BLEND;
self->color_state = gdk_color_state_ref (color_state);
}
static void
@@ -346,7 +338,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GdkMemoryDepth depth,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport)
{
GskGpuImage *image;
@@ -368,7 +359,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
frame,
NULL,
image,
color_state,
&area,
viewport);
@@ -391,97 +381,9 @@ gsk_gpu_node_processor_finish_draw (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_finish (self);
}
static GskGpuImage *
gsk_gpu_color_convert (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *from,
GdkColorState *to)
{
GskGpuNodeProcessor other;
int width, height;
GdkMemoryDepth depth;
GskGpuImage *copy;
guint32 descriptor;
graphene_rect_t rect;
if (gdk_color_state_equal (from, to))
return image;
width = gsk_gpu_image_get_width (image);
height = gsk_gpu_image_get_height (image);
depth = gdk_memory_format_get_depth (gsk_gpu_image_get_format (image));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (from));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (to));
rect = GRAPHENE_RECT_INIT (0, 0, width, height);
copy = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
FALSE,
depth,
width, height);
gsk_gpu_node_processor_init (&other,
frame,
NULL,
copy,
to,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
gsk_gpu_render_pass_begin_op (other.frame,
copy,
&(cairo_rectangle_int_t) { 0, 0, width, height },
GSK_RENDER_PASS_OFFSCREEN);
descriptor = gsk_gpu_node_processor_add_image (&other, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
from,
to,
other.desc,
descriptor,
&rect,
&other.offset,
&rect);
gsk_gpu_render_pass_end_op (other.frame,
copy,
GSK_RENDER_PASS_OFFSCREEN);
gsk_gpu_node_processor_finish (&other);
g_object_unref (image);
return copy;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static GskGpuImage * gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds);
void
gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -492,46 +394,10 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame,
frame,
NULL,
target,
GDK_COLOR_STATE_SRGB_LINEAR,
clip,
viewport);
if (gdk_color_state_equal (target_color_state, GDK_COLOR_STATE_SRGB_LINEAR))
{
gsk_gpu_node_processor_add_node (&self, node);
}
else
{
GskGpuImage *image;
graphene_rect_t clip_bounds;
graphene_rect_t bounds;
guint32 descriptor;
gsk_gpu_node_processor_sync_globals (&self, 0);
gsk_gpu_node_processor_get_clip_bounds (&self, &clip_bounds);
image = gsk_gpu_get_node_as_image (frame,
&clip_bounds,
&self.scale,
GDK_COLOR_STATE_SRGB_LINEAR,
node,
&bounds);
descriptor = gsk_gpu_node_processor_add_image (&self, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
GDK_COLOR_STATE_SRGB_LINEAR,
target_color_state,
self.desc,
descriptor,
&bounds,
&self.offset,
&bounds);
g_object_unref (image);
}
gsk_gpu_node_processor_add_node (&self, node);
gsk_gpu_node_processor_finish (&self);
}
@@ -540,7 +406,6 @@ static void
gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_point_t *offset,
const graphene_rect_t *bounds)
{
@@ -554,8 +419,6 @@ gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
self->scale = *scale;
self->stack = 0;
self->color_state = gdk_color_state_ref (color_state);
pattern_buffer_init (&self->buffer);
}
@@ -683,7 +546,6 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
pattern_buffer_clear (&self->buffer);
g_assert (self->stack == 0);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static gboolean
@@ -802,6 +664,20 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
&& int_rect->height == rect->size.height * scale_y;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static gboolean G_GNUC_WARN_UNUSED_RESULT
gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self,
GskRenderNode *node,
@@ -866,7 +742,6 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self,
static GskGpuImage *
gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport,
GskRenderNode *node)
{
@@ -877,7 +752,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
frame,
gsk_render_node_get_preferred_depth (node),
scale,
color_state,
viewport);
if (image == NULL)
return NULL;
@@ -894,7 +768,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
* @frame: frame to render in
* @clip_bounds: region of node that must be included in image
* @scale: scale factor to use for the image
* @color_state: the color state to composite in
* @node: the node to render
* @out_bounds: the actual bounds of the result
*
@@ -916,12 +789,10 @@ static GskGpuImage *
gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds)
{
GskGpuImage *result;
GdkColorState *image_color_state;
switch ((guint) gsk_render_node_get_node_type (node))
{
@@ -930,19 +801,9 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GdkTexture *texture = gsk_texture_node_get_texture (node);
GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
result = gsk_gpu_device_lookup_texture_image (device, texture, color_state, timestamp);
result = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (result == NULL)
{
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture, &image_color_state);
if (result &&
!gdk_color_state_equal (image_color_state, color_state))
{
result = gsk_gpu_color_convert (frame, result, image_color_state, color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, result, color_state);
}
}
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
if (result)
{
@@ -960,8 +821,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
gsk_render_node_ref (node),
(GDestroyNotify) gsk_render_node_unref);
result = gsk_gpu_color_convert (frame, result, GDK_COLOR_STATE_SRGB, color_state);
g_object_ref (result);
*out_bounds = *clip_bounds;
@@ -974,7 +833,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GSK_DEBUG (FALLBACK, "Offscreening node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
result = gsk_gpu_node_processor_create_offscreen (frame,
scale,
color_state,
clip_bounds,
node);
@@ -985,7 +843,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
static GskGpuImage *
gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
GskGpuImageFlags disallowed_flags)
{
@@ -1038,7 +895,6 @@ gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
frame,
NULL,
copy,
color_state,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
@@ -1112,7 +968,6 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
image = gsk_gpu_get_node_as_image (self->frame,
&clip,
&self->scale,
self->color_state,
node,
out_bounds);
if (image == NULL)
@@ -1120,7 +975,6 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
ensure = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
required_flags,
disallowed_flags);
@@ -1131,8 +985,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
gsk_gpu_device_cache_texture_image (gsk_gpu_frame_get_device (self->frame),
gsk_texture_node_get_texture (node),
gsk_gpu_frame_get_timestamp (self->frame),
ensure,
self->color_state);
ensure);
}
return ensure;
@@ -1173,7 +1026,6 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
self->frame,
source_depth,
&self->scale,
self->color_state,
&intermediate_rect);
gsk_gpu_node_processor_sync_globals (&other, 0);
@@ -1353,7 +1205,6 @@ gsk_gpu_node_processor_try_node_as_pattern (GskGpuNodeProcessor *self,
gsk_gpu_pattern_writer_init (&writer,
self->frame,
&self->scale,
self->color_state,
&self->offset,
&clipped);
@@ -1603,7 +1454,6 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&clip_bounds);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_rounded_color_op (other.frame,
@@ -2077,16 +1927,15 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
GskGpuImage *image;
GdkTexture *texture;
gint64 timestamp;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -2096,12 +1945,6 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -2112,7 +1955,6 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_MIPMAP_DEFAULT);
@@ -2159,24 +2001,17 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
guint32 descriptor;
GskGpuImage *image;
GskGpuSampler sampler;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
if (image == NULL)
return FALSE;
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -2185,7 +2020,6 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
{
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT;
@@ -2224,7 +2058,6 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gint64 timestamp;
guint32 descriptor;
gboolean need_mipmap, need_offscreen;
GdkColorState *image_color_state;
need_offscreen = self->modelview != NULL ||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ());
@@ -2248,7 +2081,6 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
clip_bounds.size.height = ceilf (clip_bounds.size.height);
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
graphene_vec2_one (),
self->color_state,
&clip_bounds,
node);
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT);
@@ -2269,10 +2101,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
need_mipmap = scaling_filter == GSK_SCALING_FILTER_TRILINEAR;
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -2282,16 +2114,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
@@ -2456,7 +2282,6 @@ gsk_gpu_node_processor_add_gradient_node (GskGpuNodeProcessor *self,
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&bounds);
other.blend = GSK_GPU_BLEND_ADD;
@@ -3506,7 +3331,6 @@ gsk_gpu_node_processor_repeat_tile (GskGpuNodeProcessor *self,
GSK_DEBUG (FALLBACK, "Offscreening node '%s' for tiling", g_type_name_from_instance ((GTypeInstance *) child));
image = gsk_gpu_node_processor_create_offscreen (self->frame,
&self->scale,
self->color_state,
&clipped_child_bounds,
child);
@@ -4299,7 +4123,6 @@ gsk_gpu_node_processor_create_node_pattern (GskGpuPatternWriter *self,
image = gsk_gpu_get_node_as_image (self->frame,
&bounds,
&self->scale,
self->color_state,
node,
&bounds);
if (image == NULL)

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