Commit Graph

7375 Commits

Author SHA1 Message Date
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
Georges Basile Stavracas Neto
5db1f67d44 clutter/stage: Setup 2D view internally
Move and simplify cogl_matrix_view_2d_in_perspective() to inside
ClutterStage, since it's the only consumer of this API, and remove
it from Cogl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
db23ee5829 cogl/matrix: Move inverse calculation to cogl-graphene.c
This special precision-bearing calculation will be used in other
places, so better share them all here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
3e0c961b76 Replace the CoglMatrix type by graphene_matrix_t
CoglMatrix already is a typedef to graphene_matrix_t. This commit
simply drops the CoglMatrix type, and align parameters. There is
no functional change here, it's simply a find-and-replace commit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
cedb5318da cogl/matrix: Relocate and update projection and transform APIs
Ideally, we would use Graphene to do that, however as of now Graphene
lacks these APIs so we still need these helpers. Since we're preparing
to get rid of CoglMatrix, move them to a separate file, and rename them
with the 'cogl_graphene' prefix.

Since I'm already touching the world with this change, I'm also renaming
cogl_matrix_transform_point() to cogl_graphene_matrix_project_point(),
as per XXX comment, to make it consistent with the transform/projection
semantics in place.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
050053a114 cogl/matrix: Remove custom boxed type
Given that CoglMatrix is simply a typedef to graphene_matrix_t, we can
remove all the GType machinery and reuse Graphene's.

Also remove the clutter-cogl helper, and cogl_matrix_to_graphene_matrix()
which is now unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
1f38494a7a clutter: Register progress function for graphene_matrix_t
Soon, there'll be no CoglMatrix anymore, and to pair CoglMatrix's
progress function, add the same for graphene_matrix_t.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
6512138791 clutter/actor: Cache inverse transform
It turns it to be quite easy to inverse the transform, and doing that
on ClutterActor level means we can actually think about removing
CoglMatrix entirely and using graphene_matrix_t everywhere.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
1d13c52db8 clutter/actor: Split building the transform into a separate function
It'll be used independently by the next commit to ensure ClutterStage
has a valid transform set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
2e986ed3e8 cogl/matrix: Add graphene_matrix_t utility function
CoglMatrix doesn't have a 1:1 mapping of graphene functions, and
sometimes it's just not worth adding wrappers over it. It is easier
to expose the internal graphene_matrix_t and let callers use it
directly.

Add new cogl_matrix_get_graphene_matrix() helper function, and
simplify Clutter's matrix progress function.

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