Commit Graph

7384 Commits

Author SHA1 Message Date
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
Corentin Noël
0730ff5b9e clutter/frame-clock: Skip the ClutterFrameListenerIface from the introspection
This can't possibly be used by introspected languages as it is a raw struct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1413
2020-10-13 10:56:50 +02:00
Jonas Ådahl
bf6dde87f8 compositor: Make sure _NET_WM_FRAME_DRAWN timestamp has the right scope
The timestamp sent with _NET_WM_FRAME_DRAWN should be in "high
resolution X server timestamps", meaning they should have the same scope
as the built in X11 32 bit unsigned integer timestamps, i.e. overflow at
the same time.

This was not done correctly when mutter had determined the X server used
the monotonic clock, where it'd just forward the monotonic clock,
confusing any client using _NET_WM_FRAME_DRAWN and friends.

Fix this by 1) splitting the timestamp conversiot into an X11 case and a
display server case, where the display server case simply clamps the
monotonic clock, as it is assumed Xwayland is always usign the monotonic
clock, and 2) if we're a X11 compositing manager, if the X server is
using the monotonic clock, apply the same semantics as the display
server case and always just clamp, or if not, calculate the offset every
10 seconds, and offset the monotonic clock timestamp with the calculated
X server timestamp offset.

This fixes an issue that would occur if mutter (or rather GNOME Shell)
would have been started before a X11 timestamp overflow, after the
overflow happened. In this case, GTK3 clients would get unclamped
timestamps, and get very confused, resulting in frames queued several
weeks into the future.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1494
2020-10-12 14:48:21 +00:00
Jonas Ådahl
53c4ebee82 clutter/private: Make all time unit conversions int64_t
This way there is less risk of ending up with would-be negative unsigned
values.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1494
2020-10-12 14:48:21 +00:00
Georges Basile Stavracas Neto
c7ab5f3f03 clutter/offscreen-effect: Remove clutter_offscreen_effect_get_target_rect
Keeping track of the projected position is costly, and adds quite some complexity
to ClutterOffscreenEffect.pre_paint(). As far as research goes, there's not a
single consumer of this function that uses the position for anything - only size
is used.

Remove clutter_offscreen_effect_get_target_rect(), and drop the annoying position
field from ClutterOffscreenEffect as well. This allows us to stop projecting the
position on pre-paint, and simplify things.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:37 +00:00
Georges Basile Stavracas Neto
cce4d75a38 clutter/deform-effect: Use clutter_offscreen_effect_get_target_size()
We don't read the x/y position anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:37 +00:00
Georges Basile Stavracas Neto
4435bec347 clutter/offscreen-effect: Undeprecate clutter_offscreen_effect_get_target_size()
clutter_offscreen_effect_get_target_rect() is going away soon.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:37 +00:00
Georges Basile Stavracas Neto
cef6534e44 clutter/offscreen-effect: Remove CoglMaterial from public API
Rename clutter_offscreen_effect_get_material() to get_pipeline() and
make it return (actually, stop casting to) a CoglMaterial.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:37 +00:00
Georges Basile Stavracas Neto
f6500042f1 clutter/paint-nodes: Don't skip pipeline node constructor
ClutterPipelineNode will be used by GNOME Shell in the future.
Fortunately for us, CoglPipeline is already usable from GJS,
so we don't need to skip the constructor for the pipeline node.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:37 +00:00
Georges Basile Stavracas Neto
de01dea93e clutter/offscreen-effect: Simplify paint
Simply chain up to get the pre and post paint methods,
instead of reimplementing ClutterEffect.paint()

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:36 +00:00
Georges Basile Stavracas Neto
f5c77df86c clutter/offscreen-effect: Unref framebuffer on pre_paint
Move unreffing the framebuffer to ClutterOffscreenEffect.pre_paint().
This will allow us to properly chain up ClutterOffscreenEffect.paint()
and not reimplement exactly what ClutterEffect does by default.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:36 +00:00
Georges Basile Stavracas Neto
67129c7757 clutter/effect: Don't expose pre and post paint helpers
They're not used outside ClutterEffect.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
2020-10-07 13:30:36 +00:00
Carlos Garnacho
0cab71ea52 clutter: Do not special case allocated events
All events should be allocated, stack allocation is avoided and should
be avoided in the future, probably by making ClutterEvent structs opaque.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1475
2020-10-06 21:33:19 +02:00
Carlos Garnacho
a3c95f6023 clutter: Drop clutter_event_peek()
Peeking doesn't seem such a good idea when we switch to async queues.
Luckily nobody seems to be using this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1475
2020-10-06 21:33:16 +02:00
Georges Basile Stavracas Neto
3cb59050f3 clutter/util: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
462ade5afe clutter/scroll-actor: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
571bf5af6d clutter/pan-action: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
6aa29640d6 clutter/paint-volume: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
eff662f7d7 clutter/paint-nodes: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
aca2880c6a clutter/stage-view: Use graphene APIs
In this case, since we are building the entire matrix by ourselves,
reverse the order of operations (translate + scale → scale + translate)
and build it using graphene-specific APIs.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
dc8f875a8a clutter/offscreen-effect: Stop using CoglMatrix API
Switch to using CoglFramebuffer APIs, which use the modelview matrix
stack. CoglMatrixStack will be ported to graphene APIs later, but it
will be transparent to this change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
f9d1b7ca58 clutter/clone: Use graphene APIs
This is another instance of graphene reversing the order of operations (see
the commit notes of how ClutterActor was ported.) The tl;dr; here is that,
in the CoglMatrix past, we used to do:

  (actor transforms) → scale

and now, it's the other way round:

  scale → (actor transforms)

due to changing from right-handed multiplications (CoglMatrix) to left-handed
ones (graphene_matrix_t).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
2406f225a9 clutter/actor: Use graphene APIs
ClutterActor is a particularly heavy user of matrices, and
switching to graphene_matrix_* APIs means we had to change
the order of operations due to left-hand vs right-hand
differences.

When applying the actor transform, there are 2 main branches
that can be followed: the default transforms, and when a
custom transform is set.

To facilitate review, here's the table that I've made to
guide myself:

+--------------- Case 1: Default Transforms --------------+
|        CoglMatrix          |      graphene_matrix_t     |
+----------------------------+----------------------------+
| multiply (child transform) | translate (-pivot)         |
| translate (allocation)¹    | rotate_x (angle)           |
| translate (pivot)¹         | rotate_y (angle)           |
| translate (translation)¹   | rotate_z (angle)           |
| scale (sx, sy, sz)         | scale (sx, sy, sz)         |
| rotate_z (angle)           | translate (translation)¹   |
| rotate_y (angle)           | translate (pivot)¹         |
| rotate_x (angle)           | translate (allocation)¹    |
| translate (-pivot)         | multiply (child transform) |
+----------------------------+----------------------------+

¹ - these 3 translations are simplified as a single call
    to translate(allocation + pivot + translation)

+---------------- Case 2: Custom Transform ---------------+
|        CoglMatrix          |      graphene_matrix_t     |
+----------------------------+----------------------------+
| multiply (child transform) | translate (-pivot)         |
| translate (allocation)²    | multiply (transform)       |
| translate (pivot)²         | translate (pivot)²         |
| multiply (transform)       | translate (allocation)²    |
| translate (-pivot)         | multiply (child transform) |
+----------------------------+----------------------------+

² - likewise, these 2 translations are simplified as a
    single call to translate(allocation + pivot)

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
cbcbe39f4d clutter/stage: Only use graphene_matrix_* APIs
Switch away from cogl_matrix_* APIs in favor of graphene_matrix_*
ones. Notice that cogl_matrix_get_value() swaps row and column,
which is reflected here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00