Commit Graph

1287 Commits

Author SHA1 Message Date
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