Commit Graph

1204 Commits

Author SHA1 Message Date
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
Benjamin Otte
e356d59a92 build: Add -Wnull-dereference
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.

Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
2020-03-05 08:14:37 +01:00
Benjamin Otte
7597f6b594 transform: Don't crash for gsk_transform_transform (id, id)
See attached tests
2020-02-21 18:30:13 +01:00
Benjamin Otte
b50093d044 transform: Make sure the identity transform is equal to NULL 2020-02-21 18:25:05 +01:00
Benjamin Otte
41ef6e9fa5 transform: Add optimization for common case
Transforming identity by an other transform does not mean we need to
painstakingly apply the individual steps of other to construct a new
transform, it means we can just return other.

Or in math terms:
  I * B = B
so just return B.
2020-02-21 18:19:16 +01:00
David Hogan
0969d06925 Fix detection of OpenGL 3.3 core GL_ARB_timer_query.
Some systems (notably macOS) will not allow enumeration of an extension that has been promoted to core OpenGL for context in use. This change assumes that GL_ARB_timer_query is available on OpenGL 3.3+.

I could not find definitive information on whether GL_ARB_debug_output or GL_KHR_debug have been added to core. Other extensions in use were addressed by https://gitlab.gnome.org/GNOME/gtk/merge_requests/1422 .
2020-02-14 05:41:01 +11:00
Matthias Clasen
a66ed7c461 gsk: Fix the compiler warning differently 2020-02-13 10:42:21 -05:00
Benjamin Otte
8f6cab6560 cairoblur: Get rid of gdk_cairo_get_clip_rectangle() call
It's about to be removed.
2020-02-13 07:36:38 +01:00
Benjamin Otte
6203cecf97 gsk: Clip shadow node before push_group()
We want to be sure to push a group that's as small as possible, so we
clip to the child's bounds, because that's the smallest we can go.
2020-02-13 07:36:38 +01:00
Benjamin Otte
6f9f18009c gsk: Add a utility function for rectangles
... and use it.
2020-02-13 07:36:38 +01:00
Benjamin Otte
67610b1242 cairoblur: Move the check for early exit
That means we only have one place where we check all kinds of early
exits.
2020-02-13 07:36:38 +01:00
Benjamin Otte
f0993fc881 rendernode: Avoid rounding errors
Compute the pattern matrix directly instead of transforming the cairo_t.

This ensures that when node_size / texture_size is some obscure floating
point value, we don't get rounding issues from scaling by it once we
draw the texture_size rectangle.

I have no actual failure where this comes in handy, but I had written
the code anyway, so decided to keep it.
2020-02-13 07:36:38 +01:00
Benjamin Otte
77d7c713d4 roundedrect: Fix inlining of graphene functions
graphene treats equality for contains() operations as always matching,
so do the same thing.

This is because unlike integer math, floating point cannot do the "as
close as possible to the point, but not reaching it" operation that
integer does by just subtracting 1.
2020-02-13 07:36:38 +01:00
Benjamin Otte
b0369fc300 roundedrect: Fix gsk_rounded_rect_intersects_rect()
The previous code would return FALSE for
  gsk_rounded_rect_intersects_rect (&rounded, &rounded.bounds);
if rounded was indeed rounded.
2020-02-13 07:36:38 +01:00
Matthias Clasen
fb84fe7065 Fix flickery hover
Commit 47c44644b1 was a bit overzealous in fixing
compiler warnings. We still need to call collect_textures,
even if we don't need the number that it returns.
2020-02-12 22:45:24 -05:00
Timm Bäder
52c46e5c24 rendernode: Don't clip when _draw()ing 2020-02-12 16:54:49 +01:00
Timm Bäder
b12a6be9d9 rendernode: draw() only in node bounds
We currently disable when draw()ing nodes using the cairo fallback path,
which means we can't just use cairo_paint(). Use a proper rectangle
instead.

Fixes #2431
2020-02-12 16:54:46 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.

We also expand to  G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
2020-02-12 11:05:01 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Emmanuele Bassi
042a5736fa Merge branch 'share-gl-programs' into 'master'
GskGLRenderer: Share programs between different renderers in same display

See merge request GNOME/gtk!1413
2020-02-11 16:30:16 +00:00
Matthias Clasen
720e48ec51 Merge branch 'handle-max-texture-size' into 'master'
gl: Don't require too large texture for offsreen ops

See merge request GNOME/gtk!1411
2020-02-11 16:23:02 +00:00