Commit Graph

7233 Commits

Author SHA1 Message Date
Jonas Ådahl
69d0ff4567 clutter/stage: Move device updating to helper
It takes the list previously gathered. Freeing the list is left to the
caller using a g_autoptr.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
3944daf3c0 clutter/stage: Find devices to update after finish queue redraw
Devices are updated (repicked) as part of the stage update phase, as
their stacking, position and transform might have changed since since
the last update.

The redraw clip was used to avoid unnecessary updating of devices, if
the device in question had it's position outside of the redraw clip. If
the device coordinate was outside of the redraw clip, what was
underneith the device couldn't have changed.

What it failed to do, however, was to update devices if a relayout had
happened in the same update, as it checked the state whether a layout
had happened before attempting to do a relayout, effectively delaying
the device updating to the next update.

This commit changes the behavior to always update the device given the
complete redraw clip caused by all possible relayouts of the same update
as the device update happens in.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
b45cea301e clutter/stage: Rename find-devices-to-update function
It doesn't only update pointers, and it finds which ones to eventually
update.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
14dfe929f2 clutter/stage: Move out tracing from do_update() to callees
This makes the function a bit more cluttered, and it'll always trace
when the same functions are called from other places.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
b9a52ecfdf screen-cast: Only check queued-redraw on the relevant views
We'd check if there was any queued redraw on the stage, but this is
inappropriate for two reasons:

1) A monitor and area screen cast source only cares about damage on a
   subset of the stage.
2) The global pending-redraw is going away when paint scheduling will be
   more view centric.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
33450700dc clutter/stage: Add 'pending_finish_queue_redraws' state
This will allow anyone to finish any queued redraws making their
corresponding damage end up being posted to the stage views. This will
allow units to check whether, so far, any updates are queued on a
particular stage view.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
62f251574f clutter/stage: Always check stage views when checking for full redraw
It's an optimization to check whether there are any redraws on the stage
by checking the 'redraw-pending' field. That field is going away, so
remove that optimization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
59eebd6f6d clutter/stage-view: Pass a pointer to the stage during constuction
This is so that stage views can interact with the stage they are views
of.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
9b054f4a1b clutter/timeline: Add running timeline to frameclock if it changes
It's intended that timelines can change frame clock while running; but
up until now it'd only add itself if the frame clock was set when
started.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
f31a7acab5 clutter/timeline: Add helpers to remove/add timeline to some frame clock
Either the master clock or assigned frame clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
c302f4d379 frame-clock: Make it possible to drive timelines
Add API to add and remove ClutterTimeline objects to the frame clock.
Just as the legacy master clock, having a timeline added to the frame
clock causes the frame clock to continuously reschedule updates until
the timeline is removed.

ClutterTimeline is adapted to be able to be driven by a
ClutterFrameClock. This is done by adding a 'frame-clock' property, and
if set, the timeline will add and remove itself to the frame clock
instead of the master clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
3c4efd13c1 frame-clock: Pass timestamp to frame callback
The timestamp comes from the GSource, meaning it's a more accurate
representation of when the frame started to be dispatched compared to
getting the current time in any callback.

Currently unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
9676db4dbf clutter/master-clock: Move out private timeline declarations
They are intended to be used by other objects than the master clock, so
don't keep the declaration there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
a132c8dc8e frame-clock: Add API to inhibit/uninhibit updates
Equivalent to pause/resume, but ref counted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
cae5b99537 frame-clock: Add callback before the actual frame callback
Aimed to have the frame listener do things like processing events before
the actual frame. In between the before-frame and actual frame,
timelines will be advanced.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
6ffdfff9ee frame-clock: Add basic tracing
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
7e27fb6d56 clutter/frame-clock: Add API to schedule next frame immediately
Aimed to replace the 'skip-sync-delay' mechanism currently used by
XSyncAlarmNotify to schedule an more immediate redraw.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
e743b36cfc clutter/frame-clock: Handle immediate present feedback
In certain scenarios, the frame clock needs to handle present feedback
long before the assumed presentation time happens. To avoid scheduling
the next frame to soon, avoid scheduling one if we were presented half a
frame interval within the last expected presentation time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
96a108ed4e clutter: Add a simple frame clock base
This adds a current unused, apart from tests, frame clock. It just
reschedules given a refresh rate, based on presentation time feedback.

The aiming for it is to be used with a single frame listener (stage
views) that will notify when a frame is presented. It does not aim to
handle multiple frame listeners, instead, it's assumed that different
frame listeners will use their own frame clocks.

Also add a test that verifies that the basic functionality works.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
da633dcc52 clutter/actor: Allocate with the same box if deferred due to transition
When a transition is created for the allocation change, it will delay
the new allocation box getting set depending on transition details.
This, however, means that e.g. the 'needs_allocation' flag never gets
cleared if a transition is created, causing other parts of the code to
get confused thinking it didn't pass through a layout step before paint.

Fix this by calling clutter_actor_allocate_internal() with the current
allocation box if a transition was created, so that we'll properly clear
'needs_allocation' flag.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1345
2020-07-02 17:35:41 +02:00
Jonas Dreßler
df4eeff6f2 clutter/actor: Invalidate stage-views on transformation changes
Since we now have the neccessary infrastructure to get notified about
changes to the absolute transformation matrix, we can also invalidate
the stage-views list on updates to this matrix.

So rename absolute_allocation_changed() to absolute_geometry_changed()
to make it clear this function is not only about allocations, and call
that function recursively for all children on changes to the
transformation matrix, too.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1343
2020-06-30 20:03:53 +02:00
Jonas Dreßler
64304b0b68 clutter/actor: Cache transformations applied using apply_transform vfunc
If we want to invalidate the stage-views list reliably on changes to the
actors transformation matrices, we also need to get notified about
changes to the custom transformations applied using the
apply_transform() vfunc.

So provide a new API that allows invalidating the transformation matrix
for actors implementing custom transformations, too. This in turn allows
us to cache the matrix applied using the apply_transform() vfunc by
moving responsibility of keeping track of the caching from
clutter_actor_real_apply_transform() to
_clutter_actor_apply_modelview_transform().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1343
2020-06-30 19:59:38 +02:00
Jonas Dreßler
c5159e3184 clutter/text: Enable relayout on resource-scale changes
ClutterText needs a new allocation on resource-scale changes, which we
added proper support for in the last commit, so use that API for
ClutterText.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
280429bac8 clutter: Add private API to support resource scale affecting layout
For ClutterText, the resource scale the text is drawn with affects the
size of the allocation: ClutterText will choose a font scale based on
the resource scale, and that font scale can lead to a slight difference
in size compared to the unscaled font.

We currently handle that by queuing a relayout inside the
"resource-scale-changed" signal handler. This solution is a bit
problematic though since it will take one more allocation cycle until
the allocation is actually updated after a scale-change, so the actor is
painted using the wrong allocation for one frame.

Also the current solution can lead to relayout loops in a few cases, for
example if a ClutterText is located near the edge on a 1x scaled monitor
and is moved to intersect a 2x scaled monitor: Now the resource scale
will change to 2 and a new allocation box is calculated; if this
allocation box is slightly smaller than the old one because of the new
font scale, the allocation won't intersect the 2x scaled monitor again
and the resource scale switches back to 1. Now the allocation gets
larger again and intersects the 2x scaled monitor again.

This commit introduces a way to properly support those actors: In case
an actors resource scale might affect its allocation, it should call the
private function clutter_actor_queue_immediate_relayout(). This will
make sure the actor gets a relayout before the upcoming paint happens
afte every resource scale change. Also potential relayout loops can
be handled by the actors themselves using a "phase" argument that's
passed to implementations of the calculate_resource_scale() vfunc.

The new API is private because resource scales are not meant to be used
in a way where the scale affects the allocation. With ClutterText and
the current behavior of Pango, that can't be avoid though, so we need it
anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
98df2dbd05 clutter/actor: Always return a resource scale in get_resource_scale()
Since we now always return a resource scale, we can remove the boolean
return value from clutter_actor_get_resource_scale() and
_clutter_actor_get_real_resource_scale(), and instead simply return the
scale.

While at it, also remove the underscore from the
_clutter_actor_get_real_resource_scale() private API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
4a72ac0516 clutter/actor: Use stage-views list for resource scales
Now that ClutterActor has a convenient API for getting the stage views
an actor is presented on, we can remove a large part of the code for
resource-scale calculation and instead rely on the stage-views list.

The way this works is a bit different from the old resource scales:
clutter_actor_get_resource_scale() always returns a scale, but this
value is only guaranteed to be correct when called from a vfunc_paint()
implementation, in all other cases the value is guessed using the scale
of the parent actor or the last valid scale. Now in case the value
previously reported by clutter_actor_get_resource_scale() turns out to
be wrong, "resource-scale-changed" will be emitted before the next paint
and the actor has a chance to update its resources.

The general idea behind this new implementation is for actors which only
need the scale during painting to continue using
clutter_actor_get_resource_scale() as they do right now, and for actors
which need the resource scale on other occasions, like during size
negotiation, to use the scale reported by
clutter_actor_get_resource_scale() but also listen to the
"resource-scale-changed" signal to eventually redo the work using the
correct scale.

The "guessing" of the scale is done with the intention of always giving
actors a scale to work with so they don't have to fall back to a scale
value the actor itself has to define, and also with the intention of
emitting the "resource-scale-changed" signal as rarely as possible, so
that when an actor is newly created, it won't have to load its resources
multiple times.

The big advantage this has over the old resource scales is that it's now
safe to call clutter_actor_get_resource_scale() from everywhere (before,
calling it from size negotiation functions would usually fail). It will
also make it a lot easier to use the resource scale for complex cases
like ClutterText without risking to get into relayout loops.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
802b24a640 clutter/backend: Introduce a fallback scale set to primary monitor scale
Add private API to ClutterBackend to set a fallback resource scale
available to Clutter. This API will be used for "guessing" the
resource-scale of ClutterActors in case the actor is not attached to a
stage or not properly positioned yet.

We set this value from inside mutters MetaRenderer while creating new
stage-views for each logical monitor. This makes it possible to set the
fallback scale to the scale of the primary monitor, which is the monitor
where most ClutterActors are going to be positioned.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
162aec7802 clutter: Replace ClutterActors resource-scale property with a signal
We're going to refactor resource scales, making the notification of
changes to the resource scale a lot more important than it is right now
(we won't guarantee queried scales are correct outside the paint cycle
anymore).

Having a separate signal/vfunc for this will make the difference between
the new clutter_actor_get_resource_scale() API (which can return a
guessed value) and the notification of changes to the resource scale
(which will be guaranteed to return an up-to-date value) more obvious.

So replace the "resource-scale" property of ClutterActor with a
"resource-scale-changed" signal that's emitted when the resource scale
is recalculated.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
37256cb76b clutter/box-layout: Request the correct size for homogeneous layouts
In case the layout is homogeneous, all children aligned by the box
layout must be allocated the same size. In order to fit them all inside
the container, the size request of the box layout has to look for the
child with the largest size and use that size for all children.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1333
2020-06-29 12:15:06 +02:00
Jonas Dreßler
7f12099ead clutter/box-layout: Add spacing when computing opposite orientation size
ClutterBoxLayout calculates the preferred size of the opposite
orientation (so for example the height if the orientation is horizontal)
by getting the preferred size of the real orientation first, and then
the preferred size of the opposite orientation, using the other size as
for_width/height when doing the request.

Right now, for non-homogeneous layouts this for_width/height does not
adjust for the spacing set on the box layout. This leads to children
being passed a slightly larger for_width/height, which in case of
ClutterText might cause the line to not wrap when it actually should.
This in turn means we can end up with an incorrect preferred size for
the opposite orientation, leading to a wrong allocation.

So fix that and adjust for the spacing just as we do for homogeneous
layouts by subtracting the total spacing from the available size that is
distributed between children.

This fixes the wrong height of the checkbox label reported in
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2574.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1333
2020-06-29 10:07:26 +02:00
Georges Basile Stavracas Neto
7146a6dddb clutter/actor: Remove anchor points and gravity
Drop the bomb.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
dbce29a0ae clutter/actor: Remove scale center and gravity
They're deprecated and, as of now, unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
dc4cb562b7 clutter/actor: Remove rotation center
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
2e086c74e7 Drop ClutterRectangle
And the correcponding CallyRectangle class.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
2802d359e5 Drop ClutterBox
Nobody was subclassing or using it, except for the tests. Replace
it by ClutterActor in the tests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
d54b10b366 clutter/timeline: Remove empty deprecated header
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
d4993c4b22 clutter/stage: Remove all deprecated functions
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
ae49f89cf3 clutter/stage: Remove color property
The property is deprecated and the current implementation simply
redirects it to ClutterActor::background-color, so remove it.

Also update the tests to set the background color directly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
ce3e293a18 clutter: Drop ClutterGroup
It is now unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
8d83dec044 clutter/stage: Subclass ClutterActor
ClutterStage is the one and only subclass of ClutterGroup, but
it overrides basically everything specific to ClutterGroup to
mimic a ClutterActor. What a waste!

Subclass ClutterActor directly and remove all the now useless
vfunc overrides from ClutterStage. Adapt CallyStage to subclass
CallyActor as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
d4953c77c3 clutter/actor: Remove clutter_actor_show_all
Actors are visible by default these days, and this function
is deprecated for a long time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
237f277641 clutter/actor: Remove clutter_actor_unparent
Pretty much the same set of changes of the previous commit, but
for clutter_actor_unparent().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
59e454f01e clutter/actor: Remove clutter_actor_set_parent
Replace it by clutter_actor_add_child(), and update ClutterGroup
to not emit the 'actor-added' anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
0b4cf9c65f clutter/actor: Remove push/pop_internal declarations
They don't even exist anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
82b710688b clutter/main: Remove clutter_get_actor_by_gid
It's unused and doesn't return anything useful these days.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
387a13f0ab clutter/actor: Drop depth property and functions
It is deprecated in favor of the 'z-position' property, and
the implementation itself redirects to the z-position, so
just drop it and replace all get|set_depth calls to their
z-position counterparts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Daniel van Vugt
f511f94aa2 clutter-stage-cogl: Fix uninitialized variable use_clipped_redraw
I noticed my system would fall back to the slow unclipped (and
uncullable) paint path whenever a window touched the left edge of
the screen. Turns out that was a red herring. Just that
`use_clipped_redraw` was uninitialized so clipping/culling was used
randomly.

So the compiler failed to notice `use_clipped_redraw` was uninitialized.
Weirdly, as soon as you fix that it starts complaining that `buffer_age`
might be uninitialized, which appears to be wrong. So we initialize that
too, to shut up the compiler warnings/errors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1323
2020-06-23 09:11:54 +00:00
Jonas Dreßler
5c5dcd58b5 bind-constraint: Don't update preferred size if source contains actor
The ClutterBindConstraint will change the preferred size an actor
reports so it returns the same size as the source actor in some cases.
This behavior was introduced recently with 4f8e518d.

This can lead to infinite loops in case the source actor is a parent of
the actor the BindConstraint is attached to, that's because calling
get_preferred_size() on the source will recursively call
get_preferred_size() on the actor again.

So to avoid those loops, check if the source is a parent of the actor
we're attached to and don't update the preferred size in that case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1282
2020-06-19 14:59:27 +00:00
Jonas Dreßler
6ea0f8facc clutter/clone: Build scale factor for transformation during allocation
For ClutterClones we need to apply a scale to the texture of the clone
to ensure the painted texture of the source actor actually fits the
allocation of the clone. We're doing this using the transformation
matrix instead of using the scale_x/scale_y properties of ClutterActor
to allow users to scale ClutterClones using that API independently.

Now it's quite a bad idea to get the allocation boxes for calculating
that scale using clutter_actor_get_allocation_box(), since that method
will internally do an immediate relayout of the stage in case the actor
isn't allocated. Another side effect of that approach is that it makes
it impossible to invalidate the transform (which will be needed when we
start caching those matrices) properly.

So since we eventually allocate both the source actor and the clone
ourselves anyway, we can simply use the allocation box inside
clutter_clone_allocate() (which is definitely updated and valid at that
point) to calculate the scale factor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1181
2020-06-18 20:19:07 +00:00
Jonas Dreßler
0c1e5b4ee5 clutter/clone: Use scale factor of 1.0 for Z axis
It seems wrong to use the scale factor of the X axis on the Z axis and
it looks like this has been accidentally changed in commit 570fa3f044.

So use a factor of 1.0 instead to not scale the Z axis at all because
the layout machinery only works in X and Y coordinates.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1181
2020-06-18 20:19:07 +00:00