1
0
Fork 0
Commit graph

7066 commits

Author SHA1 Message Date
Jonas Dreßler
e74c2e42cf clutter/stage: Don't assume stage relayouts reallocate everything
With the introduction of "shallow" relayouts, we are now able to enter
allocation cycles not only at the stage but also deeper down the
hierarchy if we know an actors allocation isn't affected by its children
since the NO_LAYOUT flag is set.

Now that means when queuing relayouts it's possible that
`priv->needs_allocation` gets set to TRUE for some actors down the
hierarchy, but not for actors higher up in the hierarchy. An actor tree
where that happens could look like that:

stage -> container -> container2 (NO_LAYOUT) -> textActor

With that tree, if the "textActor" queues a relayout, "container2" will
be added to the relayout hashtable of the stage and the actors "stage"
and "container" will have `priv->needs_allocation` set to FALSE.

Now if another relayout on the stage actor is queued,
`clutter_stage_queue_actor_relayout()` currently removes all the other
hashtable entries in favour of the stage entry, (wrongly) assuming that
will allocate everything. It doesn't allocate everything because in the
example above "container" has `priv->needs_allocation` set to FALSE,
which makes clutter_actor_allocate() return early before allocating its
children, so in the end "container2" will never get a new allocation.

To fix this, stop flushing the relayout hashtable when queuing a
stage-relayout and still add new entries to the hashtable if a stage
relayout is already queued to make sure we still go through all the
previously queued "shallow" relayouts. That shouldn't hurt performance,
too, because as soon as an actor got allocated once, it doesn't need an
allocation anymore and should bail out in clutter_actor_allocate() as
long as it's absolute position didn't change.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1173
2020-04-07 14:34:52 +00:00
Jonas Ådahl
08431a127a clutter/stage: Remove ability to set custom perspective
Unused, and complicates things, so drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
3f068d1138 clutter/stage: Remove unused paint_data/notify fields
It's usage was removed in ec911dc8b9 back
in 2014. Lets get rid of the left over fields.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
6f0e5b0b56 clutter/stage: Remove 'accept-focus' property
Also unused, only valid on X11. Meant for applications. Lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
fe27a6ea3b clutter/stage: Remove hide/show cursor API
This removes it from the stage window API too. It's managed by the
mutter backends, so we don't need the stage window to do it as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
1301770dcb clutter/stage: Remove 'alpha' property
Was unused except for in a test, lets remove it. Half transparent
monitors will probably have to be dealt with some other way anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Georges Basile Stavracas Neto
7d2df52336 clutter/offscreen-effect: Rename CoglPipeline field to 'pipeline'
This is the same case of the layer node: a CoglPipeline field that
is not called 'pipeline' makes it harder to figure out what it
really is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:40 -03:00
Georges Basile Stavracas Neto
5d27e5415d clutter/layer-node: Use non-deprecated cogl_texture_2d_new_with_size()
Use the non-deprecated cogl_texture_2d_new_with_size() function to create
the texture backing the FBO, and set it to pre-multiplied before allocating
it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
625773fba4 clutter/layer-node: Trivial code cleanup
Both the valid and the error code paths end up unreffing
the texture. Move the unref to the shared code path.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
7d79ae7b07 cluter/layer-node: Remove CoglTexture from structure
It is not used anywhere beyond the initializer, and won't be
used later on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
5817779656 clutter/layer-node: Rename CoglPipeline field to 'pipeline'
So it clearly reads what it actually is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Andre Moreira Magalhaes
5f5ce08ba4 clutter/click-action: Do not process captured event if action is disabled
Disabling a click action after a button-press but before a
button-release is captured makes ClutterClickAction connect to
captured-event and never disconnect.

This change fixes it by making sure the captured-event is only
processed if the action is still enabled, otherwise releasing
the action (reset state) and propagating the event.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1170
2020-04-02 13:13:51 -03:00
Jonas Ådahl
223f033780 clutter/offscreen-effect: Don't ever early out out of post paint
If we would, we'd miss popping the framebuffer from the pant context
framebuffer stack.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1166
2020-04-01 18:40:39 +00:00
Jonas Ådahl
50e0ae3cf3 clutter/actor-meta: Warn if an actor modifier is altered mid paint
Nothing should ever disable an actor modifier (e.g. effect) during the
paint sequence, nor should any actor be set or unset on it. If this
would happen, log warnings so that it can be tracked down.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1166
2020-04-01 18:40:39 +00:00
Andre Moreira Magalhaes
902302a174 clutter/actor: Fix pick when actor is not allocated
When selecting the pick regions for an actor we were not considering
whether the actor was allocated and that was causing issues where the
preferred width/height of the actor was used when deciding whether
the actor should be considered as a pick target.

Check if the actor has a valid allocation, in addition to being mapped
and being in pick mode, in clutter_actor_should_pick_paint().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:06 -03:00
Takao Fujiwara
2cfdbbd730 clutter: Enable negative offsets in delete surrounding text
The input method can assign a negative value to
clutter_input_method_delete_surrounding() to move the cursor to the left.
But Wayland protocol accepts positive values in delete_surrounding() and
GTK converts the values to the negative ones in
text_input_delete_surrounding_text_apply().

https://gitlab.gnome.org/GNOME/mutter/issues/539
2020-03-29 11:37:27 +00:00
Georges Basile Stavracas Neto
73250b8f4c clutter/actor: Add culling inhibiting API
This will allow us to continue painting actors that are
outside the visible boundaries of the stage view.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Jonas Dreßler
92710d8f89 clutter/stage-cogl: Check for buffer age early
Fix a regression that got introduced with
c483b52d24 where we started passing the
redraw_clip to paint_stage() instead of creating a temporary view_region
for unclipped redraws: In case we detect an invalid buffer age, we fall
back to doing an unclipped redraw after we passed the first check
setting up may_use_clipped_redraw. That means we didn't reset the
redraw_clip to the view_rect, and we're now going to redraw the stage
using the original redraw clip even though we're swapping the full
framebuffer without damage.

To fix that, check for the buffer age before setting up the
fb_clip_region and the redraw_clip and set may_use_clipped_redraw to
FALSE if the buffer age is invalid, too. This ensures the redraw_clip is
always going to be correctly set to the view rect when we want to force
a full redraw.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1128
2020-03-27 16:37:45 +00:00
Jonas Ådahl
32c99513c8 clutter/actor: Inherit cloned painting when calculating resource scale
When calculating the resource scale of a clone source, we might end up
in situations where we fail to do so, even though we're in a paint. A
real world example when this may happen if this happens:

 * A client creates a toplevel window
 * A client creates a modal dialog for said toplevel window
 * Said client commits a buffer to the modal before the toplevel

If GNOME Shell is in overview mode, the window group is hidden, and the
toplevel window actor is hidden. When the clone tries to paint, it fails
to calculate the resource scale, as the parent of the parent (window
group) is not currently mapped. It would have succeeded if only the
clone source was unmapped, as it deals with the unmapped actor painting
by setting intermediate state while painting, but this does not work
when the *parent* of the source is unmapped as well.

Fix this by inheriting the unmapped clone paint even when calculating
the resource scale.

This also adds a test case that mimics the sequence of events otherwise
triggered by a client. We can't add a Wayland client to test this, where
we actually crash is in the offscreen redirect effect used by the window
dimming feature in GNOME Shell.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/808

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1147
2020-03-26 11:42:23 +01:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Robert Mader
ed4b80cee5 clutter/stage: Rename parameters to match documentation
To silence warnings during GIR generation.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1133
2020-03-18 02:45:43 +01:00
Corentin Noël
b310e1d9d7 clutter-stage: Add annotations to clutter_stage_capture
Especially document that out_captures is an array that is given as output.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1131
2020-03-17 15:14:57 +01:00
Daniel van Vugt
73e3207a85 clutter-actor: Add detail to captured-event
So that subscribers can choose the class of events they're interested in
and not be woken by everything else.

Needed by: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/925

Related to: https://gitlab.gnome.org/GNOME/mutter/issues/283

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1000
2020-02-29 13:34:00 +00:00
Christian Hergert
b7f47ea17f clutter: add tracing for frameclock cycle
This adds a new frameclock tracing mark for a single cycle of the frame
clock. Doing so allows Sysprof to potentially do more with the information
that happens during the frameclock. For example, we can now find
allocations that happen while the frame clock is advancing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1088
2020-02-26 12:33:00 +00:00
Sebastian Keller
71101cab82 clutter/cogl/stage: Remove duplicate region union
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1089
2020-02-26 07:26:10 +00:00
Sebastian Keller
c4b28b0939 clutter/cogl/stage: Don't leak FB damage region on redraw
offset_scale_and_clamp_region() creates a new region resulting in
view_damage which at this point is the only thing left pointing to what
originally was fb_damage getting overwritten and being leaked.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1089
2020-02-26 07:26:10 +00:00
Jonas Ådahl
159c83b914 clutter: Move redraw clip management to views
The stage window handled the redraw clip in a global manner; this would
interfere if we want to paint views individually as it'd mean
intersecting views (i.e. mirrored monitors) would loose the redraw clip
once the first view was painted. It also is awkward to have a global
state for something that is built up before redrawing, and only really
valid during paint, due to buffer damage history.

This commits removes all redraw clip management from the stage window,
moving it all into the stage views. When a redraw clip is added to the
stage, every affected view will get the same redraw clip added to it,
and eventually when painted, the stage window (ClutterStageCogl) will
retrieve the redraw clip for each view as it repaints them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
b68c630329 clutter/cogl/stage: Use g_clear_pointer() to clean up regions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
fe1ccea1e1 clutter: Pass redraw clip via paint context
Instead of users fetching it via `clutter_stage_get_redraw_clip()`, pass
it via the paint context. This is helpful as it is only valid during a
paint, making it more obvious that it needs to be handled differently
when there is no redraw clip (i.e. we're painting off-screen).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
c483b52d24 clutter/stage: Pass redraw clip instead of extents when painting view
That's the struct we have ready, the callee can just call
cairo_region_get_extents() if it only cares about the extents rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
f3dcba27f5 clutter/cogl/stage: Simplify region transform code
Add a helper that scales and clamps a region, aimed to be used when
transforming between framebuffer coordinate space and view coordinate
spaces.

This helps readability by moving out the verbose for loops that deals
with the individual rects of a region to the helper, making the logic
where it's used much simpler.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
86ccc28413 clutter/cogl/stage: Rename have_clip to is_full_redraw
The 'have_clip' variable has repeatedly confused me to meaning that
there is a clip. What it actually means is that the effective clip
covers the whole view; the 'redraw_clip == NULL' meaning full redraw is
an important implementation detail for the context, and makes the
intention of the variable unclear; especially since we will after a
couple of blocks will *always* have a clip, just that it covers the
whole view.

Rename the variable to 'is_full_redraw' and negate the meaning, aiming
to make things a lot more clear.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
0d039c3ba3 clutter/view: Don't take paint rect after paint
It was unused, and will be become unused by the primary paint function
as well, so go ahead and remove it here first.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
adcbc2aa5f clutter/cogl/stage: Use fb size for for fallback fb clip region
When calculating the fallback framebuffer clip region, which should be
the region in framebuffer coordinates, we didn't scale the view layout
with the view framebuffer scale, meaning for any other scale than 1,
we'd draw a too small region of the view. Fix this by just using the
size of the framebuffer directly, avoiding any scale dependent
calculation all together.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
860906246e clutter/cogl/stage: Simplify swap_event boolean logic
We'll expect a swap event if any of the view paints resulted in a swap;
make the logic dealing with this clearer by making changing the less
vilible '|| swap_event' postfix with a up front '|=' operator.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
37d7df612b clutter/stage/cogl: Name variable to make coordinate space obvious
The ambiguous "clip" was renamed to "fb_clip_region", as it was called
at the call site. This should make it more clear that the clip is in
buffer coordinate space.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
0baf4578c8 clutter/stage/cogl: Remove some leftover whitespace
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1c98f01a65 renderer-native: Draw stage separately per CRTC
Prior to this commit the stage was drawn separately for each logical
monitor. This allowed to draw different parts of the stage with
different transformations, e.g. with a different viewport to implement
HiDPI support.

Go even further and have one view per CRTC. This causes the stage to
e.g. draw two mirrored monitors twice, instead of using the same
framebuffer on both. This enables us to do two things: one is to support
tiled monitors and monitor mirroring using the EGLStreams backend; the
other is that it'll enable us to tie rendering directly to the CRTC it
will render for. It is also a requirement for rendering being affected
by CRTC state, such as gamma.

It'll be possible to still inhibit re-drawing of the same content
twice, but it should be implemented differently, so that it will still
be possible to implement features requiring the CRTC split.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
292d2754ae clutter/stage: Remove stray newline
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Christian Hergert
d327cedb83 clutter: avoid redundant _clutter_paint_node_init_types()
This only needs to be initialized once but is in the hot path of creating
new paint nodes (for which we create many). Instead, do this as part of
the clutter_init() workflow to keep it out of the hot path.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1087
2020-02-25 01:14:09 +00:00
Christian Hergert
0c55e87d8f cogl: reduce temporary allocations calculating redraw regions
When calculating regions, a lot of temporary allocations are created. For
the array of rects (which is often a short number of them) we can use
stack allocations up to 1 page (256 cairo_rectangle_int_t). For building
a region of rectangles, cairo and pixman are much faster if you have all
of the rectangles up front or else it mallocs quite a bit of temporary
memory.

If we re-use the cairo_rectangle_int_t array we've already allocated (and
preferably on the stack), we can delay the creation of regions until after
the tight loop.

Additionally, it requires fewer allocations to union two cairo_region_t
than to incrementally union the rectangles into the region.

Before (percentages are of total number of allocations)

     TOTAL    FUNCTION
[ 100.00%]    [Everything]
[ 100.00%]      [gnome-shell --wayland --display-server]
[  99.67%]        _start
[  99.67%]          __libc_start_main
[  99.67%]            main
[  98.60%]              meta_run
[  96.90%]                g_main_loop_run
[  96.90%]                  g_main_context_iterate.isra.0
[  96.90%]                    g_main_context_dispatch
[  90.27%]                      clutter_clock_dispatch
[  86.54%]                        _clutter_stage_do_update
[  85.00%]                          clutter_stage_cogl_redraw
[  84.98%]                            clutter_stage_cogl_redraw_view
[  81.09%]                              cairo_region_union_rectangle

After (overhead has much dropped)

     TOTAL    FUNCTION
[ 100.00%]    [Everything]
[  99.80%]      [gnome-shell --wayland --display-server]
[  99.48%]        _start
[  99.48%]          __libc_start_main
[  99.48%]            main
[  92.37%]              meta_run
[  81.49%]                g_main_loop_run
[  81.49%]                  g_main_context_iterate.isra.0
[  81.43%]                    g_main_context_dispatch
[  39.40%]                      clutter_clock_dispatch
[  26.93%]                        _clutter_stage_do_update
[  25.80%]                          clutter_stage_cogl_redraw
[  25.60%]                            clutter_stage_cogl_redraw_view

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1071
2020-02-24 22:44:35 +00:00
Christian Hergert
81d11ac0a8 clutter: avoid g_signal_emit_by_name() from ClutterActor
g_signal_emit_by_name() is used to emit signals on ClutterContainer when
actors are removed or added. It happens to do various interface lookups
which are a bit unneccessary and can allocate memory.

Simply using emission wrappers makes all of that go away.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1083
2020-02-24 22:36:27 +00:00
Jonas Dreßler
a9b1134dfb clutter/seat: Add API to inhibit unfocus of the cursor surface/actor
Add API to ClutterSeat that allows inhibiting the unsetting of the
pointer focus surface. This can be useful for drawing custom cursor
textures like the magnifier of gnome-shell does.

In the future this API should also control unsetting of Clutters
focus-actor, not just the focus surface, that's not really needed right
now since we never unset the focus-actor anyway.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Christian Hergert
4c421959dc clutter: fix hole in ClutterPaintNode
Fixing the missalignment takes the structure from 80 bytes down to 72.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1081
2020-02-21 22:36:31 +00:00
Jonas Dreßler
d7c7311ceb clutter/seat: Add gtkDoc comments for touch-mode property
It's not that easy to find out when the touch-mode is enabled without
reading the code, so document that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1075
2020-02-21 15:24:58 +00:00
Daniel van Vugt
282b09c17e clutter/actor: Add CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE
Which offscreens actor rendering only in cases where it hasn't changed for
2 frames or more. This avoids the performance penalty of offscreening an
actor whose content is trying to animate at full frame rate. It will
switch automatically.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1069
2020-02-21 18:07:46 +08:00
Christian Hergert
d122b66abc clutter/actor: avoid transform node for identity matrix
If the transform matrix is an identity, then positioning wont change and
we can avoid creating the transform node altogether. This is based on
a similar find in GTK today while reducing temporary allocations.

This cuts the number of transforms created in clutter_actor_paint() by
about half under light testing of GNOME Shell from 6.8% to 2.4% of
allocations.

Before:

    ALLOCATED      TOTAL    FUNCTION
[   20.4 MiB] [  21.20%]    clutter_actor_paint
[   11.0 MiB] [  11.45%]      clutter_paint_node_paint
[    6.6 MiB] [   6.84%]      clutter_transform_node_new
[    2.5 MiB] [   2.61%]      clutter_actor_node_new

After:

    ALLOCATED      TOTAL    FUNCTION
[   33.4 MiB] [  24.12%]    clutter_actor_paint
[   26.2 MiB] [  18.91%]      clutter_paint_node_paint
[    3.4 MiB] [   2.43%]      clutter_actor_node_new
[    3.3 MiB] [   2.41%]      clutter_transform_node_new

Allocation amounts will have differed due to different amounts of running
time, but the % of allocations has now dropped below
clutter_actor_node_new() which should be expected.

https://gitlab.gnome.org/GNOME/mutter/issues/1056
2020-02-20 06:41:34 +00:00
Daniel van Vugt
b70611e3cf clutter/enums: Correct docs about ClutterOffscreenRedirect
The default value is zero, not the flag the docs say.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1068
2020-02-19 17:36:29 +00:00
Florian Müllner
35fe6a40ed clutter: Make clutter_contraint_update_preferred_size() public
This is necessary for gobject-introspection to correctly pick up
the annotations for the corresponding vfunc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1067
2020-02-19 11:57:05 +00:00
Emmanuele Bassi
4f8e518d42 bind-constraint: Update the preferred size
Bind the preferred size of an actor using a BindConstraint to the
preferred size of the source of the constraint, depending on the
coordinate of the constraint.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1070
2020-02-19 08:26:28 -03:00