Commit Graph

7407 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
8a709b5766 clutter/stage: Add pick trace
It will help profiling picking times, and compare this future patches
with status quo.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Jonas Dreßler
cc7c7fa015 clutter/actor: Remove the paint signal and keep the paint vfunc
The "paint" signal of ClutterActor has been a pain for everyone involved
long enough now, turns out we actually use it nowhere except tests
anymore (which has been handled in the last commits), so get rid of it
for good before anyone starts using it again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1522
2020-10-23 22:07:01 +02:00
Carlos Garnacho
027abc6ea7 clutter: Drop unused field in ClutterInputDevice struct
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
8d9dc097e4 clutter: Drop clutter_input_device_set_time()
An input device does not have time on itself, events do. This was made
unused so drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
a76a47fbde clutter: Pass timestamp to clutter_input_device_set_actor()
This function emits crossing events, so needs a (most times truthful)
timestamp. Make it explicit instead of fetching it from the device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
90001f09b3 clutter/main: Drop dead code branches
We shouldn't get an input event that has not a device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
6e49ad436d clutter: Drop clutter_input_device_set_stage()
Also drop the stage argument from clutter_input_device_set_coords()
in consequence. No one uses this already.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
a67f676b0d clutter: Drop clutter_input_device_get_[pointer_]stage()
Input devices are not related to the stage in any way. Drop all the
users that relied on it being so.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
af249ddf44 clutter: Do not depend on device stage on ClutterInputMethod
Look it up through other means.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
f99fc2ae9c clutter: Pass stage on to _clutter_input_device_set_actor()
Don't rely on the device stage, so specify the stage in the callers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
6a6894a397 clutter: Specify stage on clutter_input_device_update() function
This is the function performing the picking, tell it explicitly the
stage it should happen on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
6cb1557d99 backends: Move absolute/relative device mapping to native backend
This is a bit scattered around, with the setter/getter in Clutter, and
it only being only directly honored in Wayland (it goes straight through
device properties in X11).

Make this private native API, and out of public ClutterInputDevice API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
b6a020e9ff clutter: Sanitize ClutterInputDevice header
Move some exposed setters to private headers. It makes some sense to
provide those for backends, not as much to the upper layers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
bd4062a196 clutter: Limit number of touch slots available to a virtual touch device
It's not worth letting these devices have an "unlimited" range of touch
slots. Limiting it to 32 is more than enough to map it with real touch
devices nowadays.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Jonas Dreßler
de610a13f1 clutter/actor: Reset allocation when unrealizing actor
Since commit eb9cd3857d we initialize the allocation of ClutterActors to
an UNINITIALIZED ClutterActorBox. We do that to ensure the actor even
emits notify::allocation in case it got a new valid allocation of
0,0,0,0.

Now there's still the case where an actor gets removed from the
scenegraph and added again to a different parent, in this case we still
don't emit notify::allocation right now in case the new allocation
equals the old one. There's two good reasons to do so though:

1) To Clutter, there's no difference between a newly created actor and
an actor which got removed from the scenegraph, it's not consistent to
always notify the allocation property in the former situation, but not
always notify it in the latter situation.

2) When an allocation changes, Clutter notifies the subtree of that
actor about an absolute geometry change (see the call to
transform_changed() in clutter_actor_set_allocation_internal()). Now
when an actor gets reparented, obviously the absolute geometry might
change, so to make sure transform_changed() is always called in that
case we need to make sure an allocation change happens.

So simply reset the allocation property of the actor to an UNINITIALIZED
ClutterActorBox as soon as it gets unrealized.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1498
2020-10-20 18:22:10 +02:00
Jonas Dreßler
76578e5aa0 clutter/actor: Remove absolute_origin_changed flag again
We introduced the absolute_origin_changed flag when preparing for the
removal of ClutterAllocationFlags in commit dc8e5c7f8b. Turns out in the
mean-time commit df4eeff6f2 happened, which renders the whole
absolute_origin_changed flag moot.

That's because we now notify the whole subtree about the absolute origin
change by calling transform_changed() when the allocation of an actor
changes. transform_changed() traverses the subtree and calls
absolute_geometry_changed() on every actor immediately, which renders
the whole propagation of the absolute_origin_changed flag obsolete.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1498
2020-10-20 18:22:10 +02:00
Jonas Dreßler
29caa5bea5 clutter/actor: Don't queue relayouts inside add/remove_child_internal
Since we now moved the queuing of relayouts into the mapping and
unmapping functions, we no longer need to do it when adding or removing
a child, that's because removing a child always unmaps the child, and
adding it to a stage (if it's visible) will map it.

So remove those calls to queue_relayout() since they're no longer
needed.

With the above we no longer queue a relayout in
clutter_actor_add_child_internal(), that means there's one place where
we need to explicitely queue relayouts now: That's when using the
set_child_at_index/above/below() APIs, those are special because they
avoid unmapping and mapping of actors and would now no longer get a
relayout.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
3bca29f303 clutter/actor: Only allocate when actor is mapped, not only visible
In theory there's no big difference between only handling mapped actors
vs only handling visible actors in clutter_actor_allocate(): The
function is called recursively starting with an actor that is attached
to a stage, so it should only be called on mapped actors anyway.

The behavior of skipping hidden actors was introduced as an optimization
with commit 0eab73dc. Since the last commit, we handle
enable_paint_unmapped a bit better and don't do unnecessary work when
mapping or unmapping, so we can now be a bit stricter enforcing our
invariants and only allow mapped actors in clutter_actor_allocate().

We need to exclude toplevel actors from this check since the stage has a
very different mapped state than normal actors, depending on the
mappedness of the x11 window. Also we need to make an exception for
clones (of course...): Those need their source actor to have an
allocation, which means they might try to force-allocate it, and in that
case we shouldn't bail out of clutter_actor_allocate().

Also moving the clutter_actor_queue_relayout() call from
clutter_actor_real_show() to clutter_actor_real_map() seems to fix a bug
where we don't queue redraws/relayouts on children when a parent gets
shown.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
717b857bd8 clutter/actor: Use separate priv pointer in clutter_actor_real_(un)map
We're accessing self->priv quite often in those functions, it makes
sense to use a separate variable for it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
9b50215008 clutter/actor: Handle getting (un-)mapped during painting differently
We currently support only one case where an actor can get mapped or
unmapped during painting, that is using
_clutter_actor_enable_paint_unmapped() (although we could arguably do a
better job explicitely forbidding it in other cases). This function is
called when painting ClutterClone or MetaWindowActors during
screensharing. It temporarily (fake) realizes and maps the actor and all
its children so it can get painted.

Now a problem will appear when we'll start coupling layout and the
mapped state of actors more closely with the next commit: Since
enable_paint_unmapped() is meant to be enabled and disabled during every
clone paint, we also notify the "mapped" property twice on every clone
paint. That means with the next commit we would queue a relayout for the
source actor on every clone paint.

To avoid this unnecessary work, check whether we're being painted while
unmapped using the new unmapped_paint_branch_counter. Then avoid queuing
relayouts or invalidating paint volumes in that case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
cbf3001bc2 clutter/actor: Add private API to get whether we're painting unmapped
Add new private API to ClutterActor, returning TRUE in case the actor is
being painted while unmapped. This is useful for implementations of the
paint() vfunc or for signal handlers of the "notify::mapped" signal.

Use this API in CallyActor to properly detect "notify::mapped" emissions
while painting unmapped, this fixes detecting the case where
painting-unmapped is used for screencasting.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
bf7cfb877c clutter/actor: Introduce counter for painting in an unmapped branch
Just like the existing in_cloned_branch counter, add a property which
tracks whether the actor is part of a subtree that's being painted while
unmapped. This is going to be useful for a few things, for example
changing the clutter_actor_is_in_clone_paint() API to use
enable_paint_unmapped instead of in_clone_paint.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
734a7cc16f clutter/actor: Alway call queue_relayout() when showing actors
clutter_actor_queue_relayout() detects whether a parent has the
NO_LAYOUT flag set by itself and then queues a shallow relayout for us.
There's no need to duplicate that logic when showing actors, so simply
call clutter_actor_queue_relayout() and let that handle it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
d2f8a30625 clutter/paint-volume: Use graphene for computing union of paint volumes
Apparently clutter_paint_volume_union() has problems building the union
of two paint volumes in eye coordinates, that's probably because of the
negative coordinates that come into play there.

Circumvent that by making even more use of Graphene and letting it take
care of computing the union. We do that by creating two graphene_box_t's
from the axis-aligned paint volumes and intersecting those boxes, then
setting our vertices to the new min and max points of the resulting box.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1507
2020-10-19 21:38:51 +02:00
Hans de Goede
3b181c6754 clutter: Add ClutterSeat::clutter_seat_has_touchscreen() helper function
Add a helper function to determine if a seat has a (physical)
touchscreen associated with it.

Currently src/backends/meta-backend.c has a private version of this
(check_has_physical_touchscreen) and further patches in this patch-set
need the same functionality. So add a generic helper for this to
avoid code duplication.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
2020-10-18 21:35:08 +00:00
Georges Basile Stavracas Neto
bc41a88c92 clutter/stage: Replace _cogl_util_get_eye_planes_for_screen_poly()
_cogl_util_get_eye_planes_for_screen_poly() is quite a complicated beast. Ever
since Clutter became a compositor toolkit, and specially after we switched to
graphene_frustum_t on paint volumes, we can brutally simplify this function.

The new code assumes camera is at (0, 0, 0) at world coordinates (i.e. before
applying the projection). We also consider that the redraw clip are at stage
coordinates. That means that converting the clip rectangle to world rectangle
is simply a matter of projecting the corresponding vertices using the "view"
matrix. Furthermore, we only need to project the top-left, and bottom-right
vertices, since top-right and bottom-left can be derived from those two.

The frustum setup still uses triplets of vertices to setup the planes, except
now the first vertex is always the camera (hardcoded to 0, 0, 0), and the other
two vertices are the projected clip rectangle vertices.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:46:26 -03:00
Georges Basile Stavracas Neto
f7d0461768 clutter/stage: Simplify frustum setup function
We guarantee to never pass NULL clips anymore, so there's no need
to check for such case.

Remove the check for NULL clip, and remove all related variables.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:46:26 -03:00
Georges Basile Stavracas Neto
2ca20783e5 clutter/actor: Remove region culling
We can trust the clip frusta array to encode this information now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:46:26 -03:00
Georges Basile Stavracas Neto
d1d3ac6b20 clutter/stage: Use multiple frusta depending on the redraw clip
The redraw clip region may contain multiple clip rectangles. We currently
only use the extents of this region, but having multiple frusta for each
rectangle is a better alternative, and will allow us to remove the extra
projection we currently do.

Make the clip frustum an array, with multiple frusta.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:46:23 -03:00
Georges Basile Stavracas Neto
63d05565f6 clutter/stage: Move pick cache invalidation out of setup
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
cf9d06164d clutter/stage: Remove outdated comment
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
feb8397c97 clutter/stage: Move clip frustum to ClutterPaintContext
The clip planes / frustum are contextual to painting. In the past, for
the lack of a better place, it was added to ClutterStage, but now we
have an appropriate home for such data: ClutterPaintContext.

Move the frustum to the paint context.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
b6fa26cf45 clutter/stage: Don't setup view on pick
While refactoring the clipping planes / frustum code, it became more and
more evident that we do not need to update them while picking. Picking
nowadays goes through a completely different code path, that does not
rely on paint volume culling.

While it might be interesting to eventually also cull out based on paint
volumes, it certainly won't go through the painting code anymore.

Remove setting up the view when picking, and rename functions appropriatedly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
496aea51af clutter: Remove CLUTTER_CULL_RESULT_PARTIAL
Culling paint volumes don't give this level of detail anymore, and in
fact knowing whether it was partially or fully in was only being used
in a debug path. For the purposes of culling, it doesn't matter if a
given actor is partially or completely inside the frustum; either way,
it must be painted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
80bd44cba0 clutter/actor: Use switch instead of if/else
To improve legibility of the code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
a84dccfd64 clutter/stage: Use graphene_frustum_t for clipping
Instead of 4 planes, use a graphene_frustum_t to store the clipping
planes.

The cautious reviewer might noticed that we are now setting up 6
planes: the 4 planes we were doing before, plus 2 extra planes in
the Z axis. These extra planes simulate an "infinite" Z far, and
an "on-camera" Z near.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
338a9275b4 clutter: Remove ClutterPlane
It is unused now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
964229acf4 clutter/actor: Trivial code shuffling
Retrieving the stage from the actor is almost free, but this is a
hot path anyway and we can bail out before that.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
01ccc54ce8 clutter/actor: Remove unnecessary check
The stage clip is *never* NULL - it is a structure field of ClutterStage
itself.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
793ca68d8c clutter/stage: Use graphene_plane_t for clipping planes
It allows us to remove quite a bunch of code, and not deal with part
of the mind-melting maths behind it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
175851eef7 clutter/stage: Simplify view setup
ClutterStage defines the 8 vertices of a frustum:

  4 ----------------------------- 5
  | \                           / |
  |  \                         /  |
  |   0 --------------------- 1   |
  |   |                       |   |
  |   |                       |   |
  |   3 --------------------- 2   |
  |  /                         \  |
  | /                           \ |
  7 ----------------------------- 6

Then, it uses triplets of vertices to create each  clipping plane.
It only sets up 4 planes (it doesn't clip based on depth), defined
by the following vertices:

 * 0 - 4 - 5
 * 1 - 5 - 6
 * 2 - 6 - 7
 * 0 - 7 - 4

The first 3 triplets are selected using the for-loop. However, the
last triplet is different, and is done out of the loop. It could
have been made simpler by using the "3 - 7 - 4" triplet.

Simplify the current code by using the suggested triplet, calculated
inside the for-loop.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
1f99395d20 clutter: Use graphene_matrix_inverse()
Instead of our own implementation that upscales, then downscales back,
use graphene_matrix_inverse() directly. This is possible after switching
to a z-near value that doesn't have problems with float precision.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
78c648f947 cluter/stage: Use 1.0 for z-near
It doesn't actually matter, since we don't really have cases where we
cross this value, but it's enough to prevent catastrophic cancellation
due to very small float numbers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
d08f724bc3 clutter/actor: Round to 256ths when projecting for picking
Picking is specially sensitive for float precision, and tests can
easily fail when something changes, even if ever so slightly. A
simple way to workaround this is by adjusting the projected points
using the same procedure described at 67cc60cbda.

Round projected points for picking to 256ths.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Georges Basile Stavracas Neto
8809ee9e26 clutter/util: Generalize ROUND_TO_256THS
It'll be reused in other bits of the Clutter codebase. Move it to
an inline function in clutter-private.h

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Jonas Ådahl
29cdc35654 clutter/offscreen-effect: Use memory management helpers more
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
eb14da3874 cogl: Turn CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects
A first step towards abandoning the CoglObject type system: convert
CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects.
CoglFramebuffer is turned into an abstract GObject, while the two others
are currently final. The "winsys" and "platform" are still sprinkled
'void *' in the the non-abstract type instances however.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
de4e59a39b clutter: Don't use CoglHandle to store framebuffers
Better just not lose type informatoin.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
b947dced40 clutter: Stop using cogl_offscreen_new_to_texture()
It's deprecated, drops errors silently, so change to the proper
function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Ray Strode
79e5ec57d2 cally: fix state set leak
cally_actor_action_do_action leaks a state set object in the
case where the actor is defunct, insensitive, or hidden.

This commit plugs the leak.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1225
2020-10-15 08:58:37 +00:00