Commit Graph

1185 Commits

Author SHA1 Message Date
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
Matthias Clasen
9d0393d8e6 Merge branch 'fix-angle-normalization' into 'master'
gsk: Fix angle normalization

See merge request GNOME/gtk!1409
2020-02-11 16:17:14 +00:00
Alexander Larsson
7b0b3d9547 GskGLRenderer: Share programs between different renderers in same display
This is similar to how we share texture atlases. Some added complexity
in that the program state also needed to be shared, so it had to move to
the shared Programs object.

With this change realization of additional GskRenderers when opening
popups went from ~60msec to ~35 msec on average.
2020-02-11 16:58:45 +01:00
Emmanuele Bassi
0df542e494 Declare global counters only in debug builds 2020-02-11 14:47:22 +00:00
Emmanuele Bassi
47c44644b1 Silence compiler warnings in non-debug builds 2020-02-11 14:47:22 +00:00
Alexander Larsson
1f0438e7fe gsk: Fix angle normalization
I was getting assertions that normalize_angle() failed the
result < 260 check. Doing some research on this it turns out
to be a precision issue. If the incomming angle is very slightly
below zero, then adding 360 to it may end up with exactly 360.

I simplified the code a bit to avoid division and rounding, because in
practice most angles will be "just outside" the 0-360 degree anyway.
And i also added a workaround for the "result is 360" case by just
setting it to 0.
2020-02-11 13:51:06 +01:00
Alexander Larsson
8fdb710c0f gl: Don't require too large texture for offsreen ops
When rendering ops to an offscreen texture we take max-texture-size
in consideration and modify the scale we use such that the required
texture does not exceed the limit.

This means some rendering will be blocky/fuzzy, but that is better
than it being clipped.
2020-02-11 13:50:35 +01:00
Matthias Clasen
0e15032635 gsk: Small documentation additions 2020-02-08 19:36:25 -05:00
Timm Bäder
8388791f87 GskTransform: Remove useless fmod check
All angles are in the [0; 360[ range
2020-02-07 13:16:32 -05:00
Timm Bäder
cbb05a3eab GskTransform: add assertions to make normalize_angle() intentions clear
360deg should be expressed as 0deg and no angle should ever be
negative.
2020-02-07 13:16:32 -05:00
Timm Bäder
75ef8d8a50 GskRoundedRect: Inline graphene_rect_contains_rect
Brings gsk_rounded_rect_contains_rect down from 0.54% to 0.14% when
rendering rounded backgrounds.
2020-02-07 13:16:32 -05:00
Benjamin Otte
7e8d8218b9 Revert "Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()"
We're not in the business of adding Cairo APIs. That's Cairo's job.

Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.

This reverts commit afa6cc2369.
2020-02-04 16:43:59 +01:00
Alexander Larsson
afa6cc2369 Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()
This is useful in some parts of the icon theme APIs.
2020-01-29 19:06:16 +01:00
Timm Bäder
05b9a99661 gsk: Remove some unused defines
These are from the GVariant days of render nodes.
2020-01-26 18:21:07 +01:00
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Timm Bäder
f62535affc gl renderer: Avoid some work when rendering border nodes 2020-01-26 18:21:07 +01:00
Matthias Clasen
a297129685 Add a profiler mark around renderer realization
This takes time that is worth calling out.
2020-01-25 01:28:24 -05:00
Timm Bäder
f80a341b4f gl renderer: handle cross-fade nodes with invisible children 2020-01-24 06:19:16 +01:00
Timm Bäder
77f8245c0c gl renderer: Handle blur nodes with invisible children 2020-01-24 06:19:16 +01:00
Timm Bäder
8afdbd6ee3 gl renderer: Make render_rounded_clip_node clearer 2020-01-24 06:19:16 +01:00