Commit Graph

1325 Commits

Author SHA1 Message Date
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
Timm Bäder
da85815399 transform: Fix docs to use "transform" instead of "matrix" 2020-06-19 05:26:25 +02:00
Timm Bäder
5dde4c0a39 transform: Fix equal() docs
This has nothing to do with matrices.
2020-06-19 05:26:25 +02:00
Timm Bäder
0c1cfbbad1 transform: Compare 3d points directly 2020-06-19 05:26:24 +02:00
Timm Bäder
a974c83423 gsktransform: Make next == NULL case explicit
This is handled with the is_identity() check as well but this way it's
much more obvious what's happening
2020-06-19 05:26:24 +02:00
Yuri Chornoivan
c0cf839729 Fix minor typos 2020-06-18 10:47:16 +03:00
Matthias Clasen
3d7c1f8950 gsk: Documentation fixups
Document a few missing symbols.
2020-06-05 20:19:45 -04:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Timm Bäder
d5bf3c2cd1 gl renderer: Improve clipping code
don't render a clip to a texture if the new clip does not intersect with
any of the corners of the currently rounded clip.

Fixes #2770
2020-05-24 15:59:05 +02:00
Timm Bäder
094788f1a3 gl renderer: Refactor render_clipped_child 2020-05-24 15:59:05 +02:00
Timm Bäder
23e68c0988 gl renderer: Cache whether clips is rectilinear 2020-05-24 15:59:05 +02:00
Timm Bäder
930d779eb3 gl renderer: don't pretend all transform nodes support being transformed
It doesn't work in the general case. The transform handling could use a
general overhaul though.

Fixes #2773
2020-05-22 21:29:10 +02:00
Timm Bäder
f3ca814f3d gl renderer: Fix some off-by-one and rounding errors in the shadow code
Take 24

Fixes #2759
2020-05-22 21:29:10 +02:00
Timm Bäder
1aa86d23f4 gl renderer: Fix blurred outset shadow slicing
Take 23.

Fixes #2759
2020-05-21 15:32:12 +02:00
Matthias Clasen
ec2aac5b61 gsk: Document blend modes
Add some information about blend modes, mostly taken
from the css compositing spec.

Fixes: #2739
2020-05-18 18:21:39 -04:00
Timm Bäder
01c0acb707 gl renderer: Apply scaled clip when rendering offscreen clipped child 2020-05-17 15:30:28 +02:00
Timm Bäder
007de568c9 gl renderer: Fix an uninitialized value 2020-05-17 08:07:11 +02:00
Matthias Clasen
a2a3aab94d Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #2601

See merge request GNOME/gtk!1918
2020-05-16 23:35:51 +00:00
Matthias Clasen
5851415fca broadway: Don't create overlarge images
Respect that cairo won't create image surfaces larger
than 32767 x 32767.

This makes the one reftest pass that specifically checks
this condition, treeview-crash-too-wide.
2020-05-16 11:27:21 -04:00
Timm Bäder
b2b2070415 Implement diff() for color matrix nodes
This way we don't redraw color matrix nodes all the time.
2020-05-16 08:22:55 +02:00
Timm Bäder
b9ed957af3 gl renderer: Fix nested rounded clip rendering
If the inner clip intersects with the corners of the outer clip, we
potentially need a texture. We should add more fine-grained checks for
this in the future though.

Test case included.
2020-05-13 08:07:55 +02:00
Corentin Noël
076b2f11d2 docs: Fix several missing references in the documentation
This fixes several typos and missing references
2020-05-11 19:26:20 +02:00
Timm Bäder
52ae384bfd gl shaders: unify frag coord handling 2020-05-10 09:30:15 +02:00
Timm Bäder
b98ad549c2 gl renderer: Only destroy shader programs with ids > 0
We may return -1 as an error return value.
2020-05-10 09:30:15 +02:00
Matthias Clasen
d83df5a928 gsk: Fix a typo
We were checking x_offset twice, when we meant to check
x_offset and y_offset. Pointed out by Rafał Mikrut.

Fixes: #2726
2020-05-09 19:40:06 -04:00
Corentin Noël
7df572d308 gsk: Add GskTransform autocleanup definition 2020-05-08 09:14:55 +02:00
Matthias Clasen
79e1c66657 gsk: Don't autoinclude backend-specific headers
Don't install headers for code that we don't build.
And don't include those headers in gsk.h.

Just as we do in gdk, require applications to include
the backend-specific headers they need explicitly.

Update the one affected demo, gtk4-node-editor.
2020-04-24 21:40:30 -04:00
Matthias Clasen
c920796967 gsk: Fall back to cairo if compiling shaders fails
There was already some fallback in place here, but
in other places we were just asserting.
2020-04-17 13:42:33 -04:00
Emmanuele Bassi
20d0d6fae2 Revert "Do not install GSK headers for missing backends"
This reverts commit cd5cded430.

The headers are public, but the symbols availability is conditional on
the GTK build.
2020-04-11 15:41:47 +01:00
Emmanuele Bassi
3f0a830f3c Properly annotate the render node constructors
Now that the GskRenderNode subclasses are recognised as proper
sub-types, we can annotate the constructors with their type. The C API
remains the same.
2020-04-08 16:17:08 +01:00
Emmanuele Bassi
e0323fcdc2 Add get_type() functions for GskRenderNode subclasses
The introspection scanner tries to match a type name with a get_type()
function, in order to correctly identify a type as a class.

If the function is not available, we have two choices:

 - add some special case inside the introspection scanner, similar to
   how GParamSpec subclasses are handled in GObject
 - add a simple get_type() function

The latter is the simplest approach, and we don't need to change that
much, since we still register all render nodes at once.
2020-04-08 16:07:04 +01:00
Emmanuele Bassi
cd5cded430 Do not install GSK headers for missing backends
Broadway and Vulkan renderers are optional; if GTK hasn't been built
with their GSK renderers, we should not install their headers.
2020-04-08 15:41:21 +01:00
Emmanuele Bassi
d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Nirbheek Chauhan
777435c470 meson: Reduce useless relinking on reconfigure
When we reconfigure, `configure_file()` is called again, and
`*.gresource.xml` files are regenerated, which causes many (all?)
binaries to be relinked. Now we only write those out if the contents
actually changed (or if the output didn't already exist).

This is exactly what Meson already does with `configure_file()` when
`command:` is not used.

While we're at it, also do the same for `gen-c-array.py` and
`gentypefuncs.py` for completeness. Now even if the input to those
changes, re-building of those custom targets may not result in
relinking if the outputted C files have the same contents.
2020-04-03 18:41:55 +05:30
Matthias Clasen
68e1c8d3e9 gsk: Don't unconditionally spew to stdout 2020-03-20 10:43:25 -04:00
Alexander Larsson
086a577fd1 broadway: Handle browser hidpi scale factor 2020-03-13 14:59:37 +01:00