Commit Graph

1560 Commits

Author SHA1 Message Date
Fabio Lagalla
5ac7529771 gskglrenderer: Optimize radial-gradient shader 2021-01-27 12:44:10 +01:00
Fabio Lagalla
bbf68c0d9d gskglrenderer: Optimize linear-gradient shader 2021-01-27 12:44:10 +01:00
Timm Bäder
d9f6b268d3 gl renderer: Use rect_contains_rect() copy
And this way the contains_rect() inside
rounded_inner_rect_contains_rect() goes from 3.3% to 0.79% in the
fishbowl when rendering the levelbars.
2021-01-17 04:39:26 +01:00
Timm Bäder
4d7a01562e gl renderer: Don't reset offset when drawing offscreen 2021-01-17 04:39:26 +01:00
Timm Bäder
650eed7f72 gl renderer: Properly y-flip non-offscreen children of rounded clips 2021-01-17 04:39:26 +01:00
Fabio Lagalla
8c61038b9f gl renderer: print fragment shader info
It was logged twice the vertex shader info, instead
2021-01-11 17:06:03 +01:00
xndcn
34ffdc6e3f gl: Fix implicit leaking of shader object
According to OpenGL spec, a shader object will only be flagged
for deletion unless it has been detached; when a program object
is deleted, those shader objects attached to it will be detached
but not deleted unless they have already been flagged for deletion.

So we shall detach a shader object before it is deleted, and delete
it before the program object is deleted best.
2020-12-29 23:50:45 +08:00
Timm Bäder
108933b655 Merge branch 'wip/chergert/volatile-fixes' into 'master'
types: fix various use of volatile in type registration

See merge request GNOME/gtk!2865
2020-12-29 07:49:12 +00:00
Emmanuel Gil Peyrot
28c4adac24 Fix gtk4-demo’s gears demo on OpenGL ES
Here is a command to reproduce this testcase:
GDK_DEBUG=gl-gles gtk4-demo --run gears

Without this patch, Mesa throws this compile error:
0:130(13): error: no matching function for call to `mod(error, float)'; candidates are:

This is caused by `u_rotation - 90` being of type error since
`u_rotation` is a float and it’s illegal to subtract it with an integer.
2020-12-25 01:21:08 +01:00
Matthias Clasen
7e579bb59a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2997
2020-12-24 07:13:22 +00:00
Benjamin Otte
dee863dbb2 rendernode: Bail if matrix is invalid
Invalid matrices are okay in GSK (and GL), but not in Cairo.

Testcase included.
2020-12-24 06:38:45 +01:00
Matthias Clasen
e854b90293 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2990
2020-12-22 04:53:31 +00:00
Matthias Clasen
9cec9e4ce2 gsk: Export the glyph serialization privately
We want to use the same serialization in the inspector,
so export this function.
2020-12-21 13:11:08 -05:00
Matthias Clasen
26119af7a6 gsk: Improve glyph serialization
The special case for ASCII glyphs is unfortunately not
working very well, because of an oversight in pango:
When I added subpixel positioning, I made pango_shape()
default to not rounding, and make PangoLayout call
pango_shape_with_flags() and pass the rounding information
down. The upshot is that we need to use the _with_flags
variant here and tell it to round position, so it matches
what the text node contains.
2020-12-21 13:08:34 -05:00
Matthias Clasen
aa95ae774f gsk: Fix serialization of glyphs
We were forgetting to put a space between two numbers
in some cases, confusing the parser.

Test included.

Fixes: #3496
2020-12-21 10:49:56 -05:00
Timm Bäder
526c76181e gl renderer: Check for pointer equality in rounded_rect_equal 2020-12-21 15:22:08 +01:00
Timm Bäder
9fefa7b44c rendernode: Different uniformity in border nodes
Means they are different and a diff is impossible.
2020-12-21 10:26:03 +01:00
Timm Bäder
a2a70c3b65 rendernode: Sort diff() requirements by complexity 2020-12-21 10:26:03 +01:00
Timm Bäder
fdda4e4e99 GskTransform: Add nullable annotations to _equals()
Both can be NULL here.
2020-12-21 10:26:03 +01:00
Timm Bäder
e1cf0cff26 gl renderer: Proper state tracking for color matrix ops 2020-12-21 10:26:03 +01:00
Timm Bäder
634fa772c9 gl renderer: Add missing debug output for repeat ops 2020-12-21 10:26:03 +01:00
Timm Bäder
4b3bbe0ecd gl renderer: Create shader-global uniform ops on draw()
This way we can render the first frame of tests/testoutsetshadowdrawing
in 153 ops instead of 183.

And the first frame of gtk4-demo in 260 instead of 300.
2020-12-21 10:26:03 +01:00
Timm Bäder
cde43541d0 gl renderer: Unify new clip/viewport rects in blur_texture() 2020-12-21 10:26:03 +01:00
Timm Bäder
186287ecfb GskTransform: Fix identity transform class name 2020-12-21 10:26:02 +01:00
Timm Bäder
bd5d1615ac GskTransform: Avoid a ref+unref pair
If gsk_transform_is_identity() returned FALSE for the next transform,
the previous code did a ref + unref pair, even though it was unneeded.
2020-12-21 10:26:02 +01:00
Timm Bäder
a8213d7f45 gl renderer: Avoid setting modelview to identical values
The previous comment here was incorrect. We can save the op itself, we
just can't save us the entry in the modelview stack.
2020-12-21 10:26:02 +01:00
Matthias Clasen
d5143a1bf0 Revert "gl renderer: Render too big textures to the clipped area"
This reverts commit 7f6608cbed.
2020-12-19 11:43:56 -05:00
Matthias Clasen
12611fa142 Revert "gl renderer: Take a out graphene_rect in blur_node()"
This reverts commit 7eece7e769.
2020-12-19 11:43:43 -05:00
Timm Bäder
7eece7e769 gl renderer: Take a out graphene_rect in blur_node() 2020-12-16 09:13:12 +01:00
Timm Bäder
7f6608cbed gl renderer: Render too big textures to the clipped area 2020-12-16 08:26:46 +01:00
Timm Bäder
f816a8fb82 gl renderer: Unify viewport setting in add_offscreen_ops()
We use the same rect here a few times.
2020-12-16 08:26:46 +01:00
Matthias Clasen
e1df9a043f Add a doc comment for GskConicGradientNode 2020-12-15 14:18:26 -05:00
Emmanuele Bassi
99e0929d6c build: Use a consistent style for Meson files 2020-12-15 12:46:59 +00:00
Emmanuele Bassi
7975bbfcaa build: Remove linker flags from static libraries
We only need hardening linker flags on the libgtk shared library;
internal static libraries don't really need them.
2020-12-15 11:36:20 +00:00
Emmanuele Bassi
11bca98a29 build: Remove unused variable
We don't need a `gsk_source` variable after all.
2020-12-15 11:35:27 +00:00
Timm Bäder
33ed42d985 gl renderer: Remove RESET_OPACITY flag
We always need to do that (and always passed the flag to
add_offscreen_ops() anyway).
2020-12-06 20:03:35 +01:00
Timm Bäder
1ee4f6138b gl renderer: Reset opacity when rendering blend node children
We render those on a texture, so we need to reset the opacity because
that will be applied when rendering the resulting texture.
2020-12-06 20:01:36 +01:00
Timm Bäder
7b61ef9e0f gl renderer: Initialize rounded rect early 2020-12-06 19:57:48 +01:00
Timm Bäder
b46d077b3a gl renderer: Fix rendering clipped blurred inset shadow nodes 2020-12-06 19:18:10 +01:00
Timm Bäder
e32331d002 gl renderer: Ignore crossfades between equal texture nodes 2020-12-06 19:18:10 +01:00
Timm Bäder
05928608ec gl renderer: Use scale_x and scale_y everywhere
Try to handle two different values for scale in horizontal and vertical
direction better.

Fixes #3431
2020-12-06 19:18:05 +01:00
Christian Hergert
a47c0065fb macos: enable GL renderer by default
Now that the attribute locations are fixed for the GL renderer, we can
enable it by default on macOS.

Fixes #3420
2020-12-04 13:41:31 -08:00
Christian Hergert
6883c2214b gl: specify attribute locations for vUv and aPosition
These positions are not guaranteed to be in a specific order when linked
into the final GPU program. They need to be specified so that our code
in gskglrenderer.c can use known positions for them to match up with
our GskQuadVertex.

This fixes the GL renderer on macOS's OpenGL shader compiler.

Fixes #3420
2020-12-04 13:33:34 -08:00
Benjamin Otte
2c1bd399d2 glrenderer: Implement a shader for conic gradients 2020-12-03 13:07:17 +01:00
Benjamin Otte
fac5fba0dc rendernode: Fix some wrong constants for conic gradients
copy/paste from other nodes left some wrong values in there and that
screwed things up quite a bit.
2020-12-03 13:07:17 +01:00
Benjamin Otte
c907ad83b0 glrenderer: Emit more useful error messages
Catch the error when it happens, so that we can emit a specific and more
helpful error message.

Also verify that all branches in the code now do indeed set a proper
GError when they fail, so that the final catch-all is no longer needed.
Instead, assert that the error is set so that we catch future code
additions early that do not set the GError.
2020-12-03 13:07:17 +01:00
Matthias Clasen
35d2cbefe6 Merge branch 'wip/otte/conic' into 'master'
Add support for conic gradients

See merge request GNOME/gtk!2911
2020-12-03 03:54:24 +00:00
Benjamin Otte
55a242bd81 gsk: Add GskConicGradientNode 2020-12-03 00:47:54 +01:00
Benjamin Otte
71cb7c2063 rendernodeparser: Split out a function 2020-12-02 21:48:35 +01:00
Emmanuele Bassi
2fcd0e21bd Merge branch 'ebassi/for-master' into 'master'
Various documentation fixes

See merge request GNOME/gtk!2900
2020-12-02 13:40:25 +00:00
Christian Hergert
9e1dd15e31 macos: use Cairo renderer by default
Until the GL renderer is working on macOS OpenGL, we need to default
to the Cairo renderer.
2020-12-01 16:24:15 -08:00
Emmanuele Bassi
37f11ab77d docs: Annotate GskRenderer 2020-12-01 15:51:52 +00:00
Emmanuele Bassi
8b898818c2 docs: Annotate the GL shader objects 2020-12-01 15:51:52 +00:00
Emmanuele Bassi
0f62ab6c42 docs: Annotate all render node types 2020-12-01 15:51:52 +00:00
Emmanuele Bassi
c524b72d13 docs: Annotate structure types used by GskRenderNodes 2020-12-01 15:51:52 +00:00
Timm Bäder
da514187f5 gl renderer: Make minimal rounded rects more minimal 2020-11-30 09:21:34 -05:00
Matthias Clasen
ec21d354b9 gsk: doc fixups 2020-11-30 09:21:24 -05:00
Christian Hergert
0d2ea14ac1 types: fix various use of volatile in type registration
The use of volatile was incorrect in GLib and has been that way for
a long time. Recently however that has changed, and this makes GTK
follow suit to avoid using volatile in the type registration.

See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Combined with the above merge request for GLib, this fixes a large
number of compilation warnings when using Clang.
2020-11-18 20:21:33 -08:00
Christian Hergert
82b4c34eca gl: add some debugging information to DEBUG_OPS 2020-11-18 20:16:40 -08:00
Christian Hergert
eae5eaeb21 gl: use glFramebufferTexture2D to set framebuffer texture
When mapping a texture to the framebuffer, we can use the 2D
form instead of the cube mapping form.
2020-11-18 20:09:01 -08:00
Benjamin Otte
1c7daece7a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2855
2020-11-17 19:08:01 +00:00
Benjamin Otte
f2284ff40f rendernode: Rename all gsk_render_node_peek_*() functions
Those are getters, they should be gsk_render_node_get_*() functions.
2020-11-17 19:04:39 +01:00
Emmanuele Bassi
b76e514322 Merge branch 'ebassi/for-master' into 'master'
Introspection fixes

Closes #3281

See merge request GNOME/gtk!2852
2020-11-17 16:04:03 +00:00
Emmanuele Bassi
5a938ad83d Annotate the gsk_border_node_peek_widths() return value
We return a fixed sized C array of floats.
2020-11-17 13:48:07 +00:00
Matthias Clasen
9a29487e25 gsk: Fix a doc oversight 2020-11-17 07:34:52 -05:00
Matthias Clasen
121e61cf01 gsk: Avoid using gtk css types in public api
Using GtkCssSection in public headers here may be
ok from the C perspective, since it all ends up in
the same library anyway. But it causes circular
dependency problems for our gir files that are still
split by namespace.

To avoid this problem, copy the GtkCssLocation struct
struct as GskParseLocation, and pass take two of them
instead of a GtkCssSection in the error callback.

Update all users.

Fixes: #2454
2020-11-16 23:27:44 -05:00
Matthias Clasen
2c9bf55eea Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2846
2020-11-17 01:07:34 +00:00
Christian Hergert
12a9164414 gsk: use glFrameBufferTexture2D and release texture
glFrameBufferTexture maps to all faces of a cube and that is not needed
here. Additionally, texture_id is not deleted after we use the additional
flipped texture, but should be.
2020-11-16 09:26:07 -08:00
Matthias Clasen
57c95937b1 gsk: Fix some docs oversights
These apis have been renamed a few times, and the docs
haven't kept up.
2020-11-16 07:44:41 -05:00
Christoph Reiter
afc73c38ce Always parse GTK/GDK/GSK_DEBUG env vars and make some entries available in non-debug mode
Currently GTK can be built with G_ENABLE_DEBUG which enables various debug code and parsing
of those env vars, or without, which instead of parsing them prints a warning if they are set.
While building with G_ENABLE_DEBUG isn't strictly needed it's the only way to make GTK_DEBUG=interactive work,
which is a nice thing to have always.

This enables parsing of those env vars in any case and allows specific values being marked as also
available when not built with G_ENABLE_DEBUG (interactive for example). If not built with G_ENABLE_DEBUG
then all unavailable values will be marked as such in the help output and a note is added that
GTK needs to be built with G_ENABLE_DEBUG to use them, which should help discoverability.
2020-11-15 11:34:54 +01:00
Emmanuel Gil Peyrot
08193ecf1c gl renderer: Generate queries only on desktop GL
On desktop GL, GL 1.5 or GL_ARB_occlusion_query is required to get the
glGenQueries() etc. symbols.  This isn’t the case on GLES, where they
are provided by GL_EXT_occlusion_query_boolean, and more importantly
have never been made core.

This patch allows gtk4-demo to start when GDK_DEBUG=gl-gles is set, on
my Mali 400 MP running the Lima driver from Mesa.
2020-11-07 21:49:42 +01:00
Timm Bäder
82ca65956f gl renderer: Make debugging code shorter 2020-11-02 14:55:14 -05:00
Timm Bäder
c8c2106f3e gl renderer: Refactor vertex data loading code 2020-11-02 14:55:14 -05:00
Timm Bäder
8178dfb85a gl renderer: Use the load_vertex_data* functions more often 2020-11-02 14:55:14 -05:00
Timm Bäder
50e78198a8 gl renderer: More load_vertex_data* usage 2020-11-02 14:55:14 -05:00
Timm Bäder
ee04cbcfa8 gl renderer: Reword a comment 2020-11-02 14:55:14 -05:00
Timm Bäder
fc312f7ffe gl renderer: Remove an outdated comment 2020-11-02 14:55:14 -05:00
Timm Bäder
e6e964c3f3 gl renderer: Refactor rendering shadow nodes
Also use load_vertex_data_with_region here.
2020-11-02 14:55:14 -05:00
Timm Bäder
df5e796d99 gl renderer: Refactor blurred shadow drawing code
We already have various load_vertex_data* code, so try to reuse that
here.
2020-11-02 14:55:14 -05:00
Timm Bäder
d3239c953d gl renderer: Nine-slice unblurred outset shadows
See #3284
2020-11-02 14:55:13 -05:00
Matthias Clasen
7db58d5f8d gsk: Don't compile unused code
The NodeSample and GskGLImage code is not used,
so don't compile it.
2020-10-30 23:36:39 -04:00
Matthias Clasen
03fec389f4 docs: Add details for gsk_renderer_new_for_surface
Mention the GSK_RENDERER variable here.
2020-10-29 18:21:44 -04:00
Christian Hergert
a3fd46c516 glsl: tweak pre-processor to support Apple GLSL compiler
The Apple GLSL compiler cannot deal with empty pre-processor blocks such as

  #if GSK_GLES
  #elif GSK_LEGACY
2020-10-29 10:57:02 -07:00
Timm Bäder
9109dee072 gl renderer: Don't use blur node bounds
The blur node bounds are different/larger than the ones we use. This
made the textures get stretched to the blur node bounds.

Fixes #3282
2020-10-22 17:46:34 +02:00
Timm Bäder
b6a843a05b gl renderer: Fix two scale_x/y mixups 2020-10-22 17:46:34 +02:00
Sophie Herold
cd0bef9390 Add some missing nullable return annotations 2020-10-17 15:32:36 +02:00
Timm Bäder
07fb33c033 gl renderer: Fix private function name
It's a GskGLRenderer, not a GskGLRender
2020-10-14 15:06:12 -04:00
Timm Bäder
1fe7043be4 gl renderer: Add more scale_x/scale_y code
We really need all of this to be aware of both dimensions of course...
2020-10-14 15:06:12 -04:00
Timm Bäder
0e6014f2f6 gl renderer: Remove two unused uniforms 2020-10-14 15:06:12 -04:00
Timm Bäder
0a4d442849 gl renderer: return empty texture for too small blurred nodes 2020-10-14 15:06:12 -04:00
Timm Bäder
5f9fa13c65 gl renderer: Use op builder to render flipped texture
Otherwise, we don't know about the uniform state
2020-10-14 15:06:12 -04:00
Timm Bäder
161b171004 gl renderer: Remove unused parameter 2020-10-14 15:06:12 -04:00
Timm Bäder
eb345cd033 gl renderer: Use nearest filtering for textures in render_texture()
Makes the output in the node editor a bit more bearable.
2020-10-14 15:06:12 -04:00
Timm Bäder
f456438051 vulkan: Remove double initialization
Clang said:

../gsk/vulkan/gskvulkanrenderpass.c:250:5: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
    .render.node = node
    ^~~~~~~~~~~~~~~~~~~
../gsk/vulkan/gskvulkanrenderpass.c:249:13: note: previous initialization is here
    .type = GSK_VULKAN_OP_FALLBACK,
            ^~~~~~~~~~~~~~~~~~~~~~
2020-10-14 15:06:12 -04:00
Timm Bäder
4735c27e69 gl renderer: Avoid some code duplication 2020-10-14 15:06:12 -04:00
Timm Bäder
44f10c5861 gl renderer: Flip texture in render_texture() 2020-10-14 15:06:12 -04:00
Timm Bäder
44d1e81ae9 glsl: Add a comment 2020-10-14 15:06:12 -04:00
Timm Bäder
ddcff9eb0f gl renderer: simplify ->render() implementation a bit
We already use self->scale_factor when initialized whole_surface,
so set self->scale_factor first.
2020-10-14 15:06:12 -04:00
Timm Bäder
9fe21b7181 shaderbuilder: Print error message after source code
My terminal scrolls down, so showing the error message last makes sense.
2020-10-14 15:06:12 -04:00
Timm Bäder
7bf858b9d0 gl renderer: Add a helper to setup projection matrix 2020-10-14 15:06:12 -04:00
Timm Bäder
bc034d1190 gl renderer: Ignore rendering if accumulated opacity is too small 2020-10-14 15:06:12 -04:00
Timm Bäder
7222a0901d unblurred outset shadow shader: Use premultiply() 2020-10-14 15:06:12 -04:00
Timm Bäder
a0bb248bb3 gl renderer: Use premultiply() in inset shadow shader` 2020-10-14 15:06:12 -04:00
Timm Bäder
982ebf1b69 gradient shaders: Reduce out values as well
We only do 6 color stops here now. Also works around a driver bug.

Fixes #3196
2020-10-05 20:35:34 -04:00
Alexander Larsson
24a27ba44f gl renderer: Fix up texture cache key
The commit e14d2be1 forgot to actually set the parent_rect in the texture
key in the case it is necessary.
2020-10-05 15:43:04 +02:00
Matthias Clasen
cef1cd19ff gsk: Avoid long lines in serialized nodes
When encoding big blobs of data in base64, insert newlines.
Base64 allows it, CSS allows it, so not need to make GtkTextView
struggle with multi-megabyte lines.

Update nodeparser tests to reflect this change.
2020-10-03 13:10:55 -04:00
Matthias Clasen
a9809b0f67 Allow inserting newlines in css strings
Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
2020-10-02 23:40:16 -04:00
Matthias Clasen
9033336a23 css: Move _gtk_css_print_string around
Move this to a separate header, since it is not
parser functionality, and kill the duplicate
gtkcssparserprivate.h header.
2020-10-02 23:40:16 -04:00
Matthias Clasen
dc3b140fd7 Cosmetics 2020-10-01 13:48:24 -04:00
Matthias Clasen
b0da095944 gsk: Fix compiler warnings
We forgot to teach the broadway renderer about new enum
values, and our ci didn't catch it because werror didn't
actually work there until now.
2020-09-30 15:39:30 -04:00
Alexander Larsson
e14d2be1e8 gl renderer: Fix render node texture cache
We're caching two things, either a node itself being rendered, or a
parent storing a cached version of a child as rendered to an offscreen
the size and location of the parent.

If both the parent and child uses the cache this will cause a conflict in
the cache as it is currently use keying of a node pointer which will have
the same value for the node-as-itself and the child-node-of-the-parent.

We fix this by adding another part to the key "pointer_is_child" which means
we can have the same node pointer twice in the cache.

Additionally, in the child-is-rendered-offscreen case the offscreen
result actually depends on the position and size of the parent viewport,
so we need to store the parent bounds in that case.
2020-09-30 14:53:13 +02:00
Matthias Clasen
00c6340777 gsk: Add some more shader docs
Do a pass over the docs and address minor inconsistencies,
cosmetics and formatting differences.

Mention GSK_DEBUG=shaders.
2020-09-29 14:44:31 -04:00
Matthias Clasen
4cfa9ee19f Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2639
2020-09-29 12:57:36 +00:00
Matthias Clasen
07c338b487 gsk: Document radial gradient api 2020-09-29 07:04:07 -04:00
Alexander Larsson
51ab56d33a gl: Track the current uniform state for custom programs
This allows us to avoid updating uniforms if that is not necessary. This
in turn allows us to sometimes reuse the same draw op by just extending the
vertex array size we draw rather than doing a separate glDraw call.

For example, in the fishbowl demo, all the icons added at the same
time will have the same time and size, so we emit single draw calls
with 100s of triangles instead of 100s of draw calls with 2 triangles.
2020-09-29 11:52:39 +02:00
Alexander Larsson
4d697283ae Support GLShaderNode in backends
For vulkan/broadway this just means to ignore it, but for the gl
backend we support (with up to 4 texture inputs, which is similar to
what shadertoy does, so should be widely supported).
2020-09-29 09:51:16 +02:00
Alexander Larsson
7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Matthias Clasen
6e9b58b6f0 gsk: Add more shader debug spew
Print out the full assembled shader sources when
GSK_DEBUG=shaders is given. This is very verbose,
but may be useful to see what we actually pass
to the compiler.
2020-09-29 09:51:16 +02:00
Alexander Larsson
bacb3affb3 gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
2020-09-29 09:51:16 +02:00
Alexander Larsson
9460d0131f gl backend: Add line numbers to source in glsl compilation errors
Almost always the source is created by combining various sources, which
means the line numbers in the error messages are hard to use. Adding
the line numbers to the source in the error message helps with this.
2020-09-29 09:51:16 +02:00
Alexander Larsson
7edcd1748c gl: Properly report error if shader linking fails
In gsk_gl_shader_builder_create_program(), if linking fails we
need to return -1 to indicate error, rather than the old deleted
program id.
2020-09-29 09:51:16 +02:00
Alexander Larsson
6887d0ce24 glrenderer: Move ProgramState into Program
There is no real reason to have this on the side indexed via the
index, as it is stored next to each other anyway. Plus, storing them
together lets use use `Program` structures not in the array.
2020-09-29 09:51:10 +02:00
Matthias Clasen
431f144f37 gsk: Normalize when transforming bounds
Bounds are assumed to be normalized, and transforms
with negative scales or 3d rotations can make us get
negative sizes.

Fix by Benjamin Otte.
2020-09-28 11:34:16 -04:00
Matthias Clasen
9ca9f42452 gsk: Avoid downloading GL textures when possible
I found that the gears demo was spending 40% cpu
downloading a GL texture every frame, only to
upload it again to another context.

While the GSK rendering and the GtkGLArea use different
GL contexts, they are (usually) connected by sharing data
with the same global context, so we can just use the
texture without the download/upload dance. This brings
gears down to < 10% cpu.
2020-09-26 21:55:28 -04:00
Matthias Clasen
c9f6a9f7c5 Merge branch 'gles-texture-colors' into 'master'
Fix uploads of textures in GLES (and make texture uploads better)

See merge request GNOME/gtk!2616
2020-09-25 14:53:19 +00:00
Alexander Larsson
90fc671ef8 gl backend: Avoid roundtripping via surface when updloading
Do custom uploads rather than using gdk_cairo_surface_upload_to_gl(),
because this way we avoids a roundtrip (memcpy and possibly conversion)
to the cairo image surface format.
2020-09-25 10:04:48 +02:00
Alexander Larsson
1001995d49 Correctly upload textures for GLES
GLES doesn't support the GL_BGRA +  GL_UNSIGNED_INT_24_8 hack that
we use on desktop OpenGL to upload textures directly in the cairo
pixel format. This adds the required conversions to all the places
that currently need it.

We also add a data_format to the internal gdk_gl_context_upload_texture()
function to make it clearer what the format are. Currently it is always
the cairo image surface format, but eventually we want to support other
formats so that we can avoid some of the unnecessary conversions we do.

Also, the current gdk_gl_context_upload_texture() code always converts
to a cairo format and uploads that like we did before. Later commits
will allow this to use other upload formats that gl supports to avoid
conversions.
2020-09-25 09:31:43 +02:00
Timm Bäder
fd728ea8bc gl renderer: Lower maximum gradient stop count
6 is still plenty according to my market research.

Should help with #2624
2020-09-24 19:08:22 +02:00
Timm Bäder
8d7b3bade3 gl renderer: Fall back to cairo if gradients use too many stops 2020-09-24 19:08:22 +02:00
Timm Bäder
9eaa8bd1e7 gl renderer: Only return error if creating programs failed 2020-09-24 19:08:22 +02:00
Timm Bäder
15994db74d gl renderer: Use scale_x/y when rendering clipped nodes 2020-09-24 19:08:22 +02:00
Timm Bäder
467be0b7dc gl renderer: Don't use ops_get_scale() when rendering clip nodes
Differentiate between scale_x and scale_y. This works better for e.g.
transform nodes using scaleX().
2020-09-24 19:08:22 +02:00
Timm Bäder
84d2a33c10 gl renderer: Support scaleX/Y better when rendering radial gradients
We should do this everywhere, but this is a start.
2020-09-24 19:08:22 +02:00
Timm Bäder
f938377464 rendernodes: Clarify color_stops arguments 2020-09-18 19:01:10 +02:00
Timm Bäder
6e14b26622 gsk: Add docs for radial gradient nodes 2020-09-18 18:41:01 +02:00
Timm Bäder
5d5fbc69a4 rendernodes: Enfore end > start for radial gradient nodes 2020-09-18 18:29:08 +02:00
Timm Bäder
a770ab34c4 gl renderer: Consolidate color pre-multiplication
Add a common function that tells us what it does and replace all the
manual stuff with it.

Fixes #3170
2020-09-18 15:45:08 +02:00
Timm Bäder
b8e4240751 gl renderer: Add radial gradient shader 2020-09-18 15:39:07 +02:00
Timm Bäder
2c5a4a799a rendernode: Pull local variable into closest scope 2020-09-18 15:39:07 +02:00
Timm Bäder
0c2d00835b gl renderer: Set an error if we don't have one already
We can't fail and not set the error, since caller don't expect that.
2020-09-18 15:39:07 +02:00
Timm Bäder
dbfc172f6a radial gradients: Allow 0 start/end values 2020-09-18 15:39:07 +02:00
Timm Bäder
6a089816fc gsk: Parse radial gradient nodes 2020-09-18 15:39:07 +02:00
Matthias Clasen
ebfb3e771d rendernode: switch to h/vradius 2020-09-18 15:39:04 +02:00
Matthias Clasen
0c6226c20b gsk: Add a radial gradient node
Only a fallback implementation for now.

Fixes #2262
2020-09-18 15:38:55 +02:00
Matthias Clasen
929a56e53c Clean up lots of GTK+ -> GTK
Replace most remaining uses of GTK+ in the docs and
user-visible strings by GTK. Also remove some leftover
"Was added in 3.x" sentences from the docs.
2020-09-12 12:01:04 -04:00
Matthias Clasen
1057588a8f gsk: Fix the gl texture cache
We need to include both the scale and the filtering
in the key for the texture cache, since those affect
the texture.

This fixes misrendering in the recorder in the inspector
whenever transforms are involved. An example where this
was showing up is testrevealer's swing transition.
2020-09-09 13:55:09 -04:00
Matthias Clasen
bab7092a69 Merge branch 'gl-linear' into 'master'
Gl: use linear interpolation

See merge request GNOME/gtk!2523
2020-09-07 21:27:09 +00:00
Matthias Clasen
d595c6ab12 gsk: Complain if we fail to realize a renderer
The only likely place where this is going to happen
is if a renderer was explicitly requested with the
GSK_RENDERER environment variable, and in that case,
it is misleading to silently use a different renderer.
2020-09-07 11:18:45 -04:00
Matthias Clasen
2738d5bc93 gsk: Mention gl as valid value for GSK_RENDERER 2020-09-07 11:18:45 -04:00
Matthias Clasen
e0cc7b5d86 Check for pixel-alignedness for interpolation
When rendering to an offscreen because of transforms,
check if transforming the bounds of the node results
in a non-axis-aligned quad. If it doesn't, we want
GL_NEAREST interpolation to get sharp edges. Otherwise,
we use GL_LINEAR to get better results for things
that are actually transformed.
2020-09-04 13:16:53 -04:00
Matthias Clasen
9843515736 gl: Reshuffle some code
Just rearrange the cases in this switch, no effective change.
2020-09-04 13:16:11 -04:00
Matthias Clasen
41497aeb8b Add gsk_matrix_transform_rect
This is a projecting version of the corresponding
graphene api. While we are at it, rewrite
gsk_matrix_transform_bounds() to use
gsk_matrix_transform_rect().
2020-09-04 13:15:21 -04:00
Matthias Clasen
e36b594867 Replace uses of graphene_matrix_transform_
Replace our uses of graphene_matrix_transform_point,
_point3d and _bounds by our own versions that handle
projective transforms correctly.

This fixes render node bounds being incorrect for widgets
involving projective transforms (e.g. testrevealer swing
transformations), and also fixes picking on such widgets.
2020-09-01 09:18:38 -04:00
Matthias Clasen
99a7a2188a gsk: Add some private transform apis
Some of the graphene_matrix_transform apis don't work
correctly with projective matrices, so add our own
variants.
2020-09-01 09:18:38 -04:00
Timm Bäder
51b398b960 rendernodes: Whitespace 2020-08-29 16:46:28 +02:00
Timm Bäder
c1c2205018 gl renderer: Adjust gaussian blur sigma
To look more like what browsers do.
2020-08-29 16:46:28 +02:00
Timm Bäder
2bff84ca6c gl: Adjust blur radius_multiplier
2.0 Looks much closer to what my browser does.

Fixes #2777
2020-08-29 16:46:25 +02:00
Timm Bäder
e970c69843 gsk: Fix border node diff implementation
This was showing up in the interactive constraint demo in gtk4-demo.
2020-08-29 11:11:29 +02:00
Alexander Larsson
d57e6b754f broadway: Prune fully clipped render nodes
If some node is fully outside the clip region we don't send it to the daemon.
This helps a lot in how much data we send for scrolling viewports.

However, sending partial trees makes node reuse a bit more tricky. We
can't save for reuse any node that could possibly clip different depending on
the clip region, as that could be different next frame. So, unless the
node is fully contained in the current clip (and we thus know it is not
parial) we don't allow reusing that next frame.

This fixes #3086
2020-08-26 18:08:00 +02:00
Alexander Larsson
4b1ea7c4a1 broadway: Track the clip region in the renderer
If we know what can't possibly be visible we may can later decide to
not expose a node.
2020-08-26 16:55:56 +02:00
Matthias Clasen
125ed52ccb Merge branch 'new-sysprof' into 'master'
Port profiling to sysprof-collector api

See merge request GNOME/gtk!2457
2020-08-21 23:58:09 +00:00
Matthias Clasen
d4e069a629 Port tracing to the sysprof collector api
Use the new sysprof collector api to do tracing.
2020-08-21 10:55:01 -04:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02:00
Matthias Clasen
9e5ddeaa8a gsk: Don't leak cairo nodes
Not chaining up in finalize is a leak, after all.
2020-08-06 18:35:41 -04:00
Rico Tzschichholz
7a58a6a097 gsk: Add annotations to improve GIR API 2020-07-31 20:56:36 +02:00
Matthias Clasen
6ab13a6303 gsk: Don't the always_inline function attribute
Visual C doesn't understand it, and the compiler
should know better, anyway.
2020-07-31 13:13:46 -04:00
Chun-wei Fan
d6955d4427 gskrenderer.c: Default to the GL renderer on Windows too
Since we have now made the Win32 GL contexts share the global context as
the other backends have, we are more ready to use the GL renderer by
default on Windows as well.

Note that currently we can only enable this when not running on
OpenGL/ES as the OpenGL/ES shaders are not ready at this point, and the
OpenGL/ES support that we have from libANGLE does not support full
desktop OpenGL operations.
2020-07-31 23:20:14 +08:00
Emmanuele Bassi
4fa891b55d Remove stray gtk-doc annotation
It confuses the g-i scanner, and gtk-doc.
2020-07-28 16:49:13 +01:00
Timm Bäder
ac1f242b6c gl renderer: Throw inset shadows with all !send values away 2020-07-28 05:34:12 +02:00
Timm Bäder
ebbb729aea gl renderer: Linear gradient state tracking 2020-07-28 05:34:12 +02:00
Timm Bäder
dded144313 gl renderer: Assert that we have program state
This is never a problem in reality, just for static analysis.
2020-07-28 05:34:12 +02:00
Timm Bäder
3f59566729 gl renderer: Repat node child bounds can't be NULL 2020-07-28 05:34:12 +02:00
Timm Bäder
e0420bae09 gl renderer: Remove dead code
We aren't using n_corners anyway
2020-07-28 05:34:12 +02:00
Timm Bäder
a3b452725b render nodes: Simplify diffing of uniform border nodes 2020-07-28 05:34:12 +02:00
Timm Bäder
9cdf9847c2 gl: Add a gdk_gl_context_has_debug accessor
Check if the label_object_ etc. functions are gonna do anything at all.
The g_type_name_from_instance calls keep poppoing up in profiles.
2020-07-28 05:34:12 +02:00
Timm Bäder
fa85ec5cf5 GskTransform: Restructure _to_affine and _to_translation
Make the simple cases more explicit.
2020-07-28 05:34:12 +02:00
Timm Bäder
0ce32cd4b5 gl renderer: Save rectilinearity in clip stack
So we don't have to repeatedly call it in pop_clip()
2020-07-28 05:34:12 +02:00
Timm Bäder
756b84033a GskTransform: Remove unused function from private header
We only use this in gsktransform.c
2020-07-28 05:34:12 +02:00
Timm Bäder
5a9b54df96 gl renderer: More color matrix state tracking 2020-07-28 05:34:12 +02:00
Timm Bäder
d7ba281c15 gl renderer: Add contains_rect helper 2020-07-28 05:34:12 +02:00
Timm Bäder
c6c87b97c2 gl renderer: Add own graphene_rect_intersects 2020-07-28 05:34:11 +02:00
Timm Bäder
2fa9dddea6 gsk: Remember border node uniformity
Lots of border nodes have all the same width and the same color.
Renderers might be able to simplifty that, so keep an extra bit per
border node.
2020-07-28 05:34:11 +02:00
Timm Bäder
72d4a83af8 gl renderer: Moar state tracking
Track what we really need to send for inset shadows, which are used
as a border replacement in many cases.

Fishbowl says I can draw around 200-300 more switches per frame like
this too.
2020-07-28 05:34:11 +02:00
Timm Bäder
fcf502a686 gl renderer: Fix scrolledwindow undershoot rendering 2020-07-28 05:34:11 +02:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Christian Hergert
9dbf99d91a macos: prototype new GDK backend for macOS
This is fairly substantial rewrite of the GDK backend for quartz and
renamed to macOS to allow for a greenfield implementation.

Many things have come across from the quartz implementation fairly
intact such as the eventloop integration design and discovery of
event windows from the NSEvent.

However much has been changed to fit in with the new GDK design and
how removal of child GdkWindow have been completely eliminated.
Furthermore, the new GdkPopup allows for regular NSWindow to be used
to provide popovers unlike the previous implementation.

The object design more closely follows the ideal for a GDK backend.

Views have been broken out into subclasses so that we can support
multiple GSK renderer paths such as GL and Cairo (and Metal in the
future). However mixed mode GL and Cairo will not be supported. Currently
only the Cairo renderer has been implemented.

A new frame clock implementation using CVDisplayLink provides more
accurate information about when to draw drawing the next frame. Some
testing will need to be done here to understand the power implications
of this.

This implementation has also gained edge snapping for CSD windows. Some
work was also done to ensure that CSD windows have opaque regions
registered with the display server.

     ** This is still very much a work-in-progress **

Some outstanding work that needs to be done:

 - Finish a GL context for macOS and alternate NSView for GL rendering
   (possibly using speciailized CALayer for OpenGL).
 - Input rework to ensure that we don't loose remapping of keys that was
   dropped from GDK during GTK 4 development.
 - Make sure input methods continue to work.
 - Drag-n-Drop is still very much a work in progress
 - High resolution input scrolling needs various work in GDK to land
   first before we can plumb that to NSEvent.
 - gtk/ has a number of things based on GDK_WINDOWING_QUARTZ that need
   to be updated to use the macOS backend.

But this is good enough to start playing with and breaking things which
is what I'd like to see.
2020-07-21 14:45:12 -07:00
Matthias Clasen
5df1356295 gsk: Remove an unused debug flag
GSK_DEBUG_DIFF was not used anywhere, so remove it.
2020-07-20 07:03:08 -04:00
Timm Bäder
37d7ab88dc gl renderer: Avoid 9-slicing things that can't be
The outline needs to be large enough so changing the size of the outline
does not affect the resulting blurred texture.

Fixes #2776
2020-07-17 05:49:11 +02:00
Timm Bäder
6cde64072d gl renderer: Remove outdated comment 2020-07-17 05:49:11 +02:00
Timm Bäder
6a60b0f591 gl renderer: Try to intersect rounded clips more often 2020-07-17 05:49:11 +02:00
Timm Bäder
339d9f05e4 gl renderer: Remove unused flag 2020-07-17 05:49:11 +02:00
Timm Bäder
34008e6aab gl renderer: Ignore rounded clip that only increase the clip
This fixes the widget factory rendering too much.

In the widget-factory, we generally have a pretty small update area (two
spinners and a progressbar). We take the extents of that as a update
area and inital clip.

However, the first clip node we see is from the toplevel window, which
essentially increases the clip again to almost the entire window.

Fix that by ignoring such cases.
2020-07-17 05:49:11 +02:00
Matthias Clasen
13b37b0ba4 gsk: Fix a transform leak
This was found by running our testsuite under asan.
2020-07-08 17:44:08 -04:00
Matthias Clasen
43b9fc6981 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2162
2020-07-01 01:35:56 +00:00
Matthias Clasen
93a51f77c4 gsk: Better help for GSK_DEBUG
Reuse the newly introduced gdk_parse_debug_var for
GSK_DEBUG.
2020-06-28 13:42:02 -04:00
Timm Bäder
4800dd3f95 rendernode: Trivial whitespace change 2020-06-27 11:22:54 +02:00
Timm Bäder
21f9148155 gl renderer: Fix cross-fade nodes with invisible end child
Only loading the vertex data doesn't draw anything.
2020-06-27 10:51:06 +02:00
Timm Bäder
d4f0593b37 gl renderer: Handle 0/1 progress in crossfade nodes 2020-06-27 10:51:06 +02:00