Commit Graph

1918 Commits

Author SHA1 Message Date
Daniel Stone
f39b1e9fbd view: Mark view list as dirty when destroying mapped view
If a view is in the view list when it's being destroyed, we need to
rebuild the view list. However, doing so is currently very hairy as
views are created and destroyed at will ... including when rebuilding
the view list.

In preparation for creating and destroying subsurface views at the time
of the action rather than later at repaint time, pull out the immediate
view-list rebuild and simply mark the view list as needing a full
rebuild.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
314f2ba0c3 view: Create subsurface views in weston_view_create()
When we create a new view for a top-level window, also create views for
all its children.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
bf228370ff view: Add view_list_needs_rebuild member
Most of the time when we're changing things about views, we don't need
to throw away the view list and rebuild it from scratch. The only times
when we need to do this are when views have been added to or removed
from the scene graph, or have been restacked within it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
c699253da8 view: Add weston_view_geometry_dirty_internal()
weston_view_geometry_dirty_internal() can be used by internal callers to
mark a view's internal geometry as dirty, without signaling the need for
a full rebuild of the view list.

This is a transitional step towards eliminating
weston_view_geometry_dirty() from public API. Up until recently, the
view-manipulation API has been that users should manually manipulate
lists of transforms, layers, and other internal members, then call
weston_view_geometry_dirty() as well as manually provoking damage.

Now that we have helper functions to handle view manipulation, they
still need to mark the view geometry as being dirty. However, most of
them do not need to invoke a full rebuild of the view_list, which is
only required when views are added or removed from the scene graph, or
restacked.

weston_view_geometry_dirty() will assume that everything has changed
before eventually being ushered out of existence.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
c859dd1b9e surface: Only rebuild subsurface lists when necessary
There's no need to go through and rebuild the subsurface list every
time. In addition to being unnecessary work, it complicates things like
damage tracking.

Track a new surface dirty status indicating that the subsurface tree has
changed in some way, and only rebuild subsurface stacking when this has
occurred.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
ce6afda6a2 surface: Propagate surface status through commit call tree
When we're committing anything, return the collected status of what
we've just made live, including any changes resulting from subsurfaces
having changed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
fc6d4392cb surface: Assert unused subsurface views are not mapped
This is just a consistency check, nothing else.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
49b5df7f78 view: Update child view transforms from parent
weston_view_geometry_dirty() marks the passed-in view as dirty, as well
as all of its children.

weston_view_update_transform() updates the geometry of its ancestors,
then itself.

Users are required (for now) to call weston_view_update_transform() in
order to not experience a disappointing amount of death-by-assert.

Users do not have a pointer to child views which are magically
materialised by the subsurface code.

The end result is disappointing. But it is less disappointing if
updating the transform for a view the user is actually aware exists,
also updates the transform for all its children.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
0ff72e5374 surface: Ensure view is unmapped before destroy signal
When the destroy signal is fired, child views will disassociate
themselves from the parent. This means that we can no longer see what
the child views are - and that recursive unmapping does not work.

Make sure that views are fully unmapped before anything else happens in
destroy, so we can recursively unmap child views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
da8c8f96d2 surface: No need to unmap views before destroy
This happens as a part of weston_view_destroy().

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
17af1c4d20 surface: Unmap subsurface views, not surface, on parent destroy
Per the wl_subsurface spec:
      A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
      and the parent surface is mapped. The order of which one happens
      first is irrelevant. A sub-surface is hidden if the parent becomes
      hidden, or if a NULL wl_buffer is applied. These rules apply
      recursively through the tree of surfaces.
      [...]
      If the parent wl_surface object is destroyed, the sub-surface is
      unmapped.

The terminology is kind of loose. My reading of this is that we should
'unmap' (hide from display, remove from input/focus consideration, etc)
a subsurface immediately when a parent is destroyed.

However, if the child surface is then paired with another parent which
is itself mapped, then the child surface should immediately be mapped,
because it has a non-NULL buffer already applied, and the parent surface
is mapped.

By marking the surface as 'unmapped' on parent destroy, we were removing
it from the scene graph, but also I think breaking the rules on mapping
by requiring another commit when it was reassociated with another,
already mapped, surface.

Removing the explicit surface unmap leaves the surface in the 'mapped'
state, but without any views, which I believe has the intended effect.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
3d9aecc846 surface: Unmap subsurface views when parent is unmapped
Quoth the spec:
      A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
      and the parent surface is mapped. The order of which one happens
      first is irrelevant. A sub-surface is hidden if the parent becomes
      hidden, or if a NULL wl_buffer is applied. These rules apply
      recursively through the tree of surfaces.

We currently apply this rule through reconstructing the view_list at
repaint time, materialising new views and garbage-collecting unwanted
views as appropriate. Since this can be a costly operation, it's best if
we move this closer to the source.

This makes the core recursively unmap any child views when the parent is
unmapped. Future commits will do the same for mapping new views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
3af596a8bc surface: Use parent_view to find subsurface views
View transform parents can be set by anyone. parent_view, on the other
hand, is only set for subsurfaces.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
94a9cc1b24 Split weston_view_create() into public and internal
This is heading towards being able to materialise subsurface views
closer to the source. weston_view_create() - being used only by
window-management code - will ultimately create all required subsurface
views as well. The internal variant will be used by this and also by the
subsurface code as required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
0f99e081c4 surface: Add input-region dirty flag
Used when the input region changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
3bba90764e surface: Add buffer-params dirty flag
This indicates that more than just the content changing, the form of the
buffer has changed in a way which may not be like-for-like to the
previous buffer but require significant reinterpretation. Examples
include the format, opacity, colour state, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
63f67f8a04 surface: Flatten apply_buffer_damage()
This function is now only ever executed conditionally, so flatten it
with an early return.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
eb6d511823 surface: Require wl_surface.attach for damage processing
Both wl_surface.damage and wl_surface.damage_buffer explicitly refer to
the 'pending buffer'. wl_surface.attach states that there is no pending
buffer after the commit is processed, so it follows that a commit which
includes damage but no attach will not process any damage.

Change surface-commit processing to ignore all damage unless a buffer
was attached in the same commit cycle.

(Thanks to @pH5 for his spec analysis which I've just paraphrased here.)

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
d8669679c4 surface: Add position dirty member
This is used when a surface is repositioned via offsets.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
6526346b72 surface: Replace viewport.changed with weston_surface_status
Instead of having an individual bool, reuse the surface state's dirty
status for viewport changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
8255274a92 surface: Replace newly_attached with weston_surface_status
Instead of having a bool for whether or not a buffer has been attached
in this commit cycle, use a status bitmask.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone
160f91b8e1 surface: Only rebuild surface size where necessary
The only time we need to go through recalculating the surface size is
when either the buffer dimensions or the surface transforms have
changed. Now that we have dirty flags, use them to avoid a calculation
where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Derek Foreman
3ec2ebc7e2 libweston: Build view list for all outputs at once
Instead of passing an output to weston_compositor_build_view_list(),
have it set up all the output z_order_lists at once.

This is a preamble for MR !1285 which wants to maintain a compositor
wide dirty bit for the view list.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-04 15:52:21 +01:00
Derek Foreman
8a673efada libweston: Build z_order_list after view_list
Moves the output specific stuff into one place, after the view_list is
already properly set up.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-04 15:52:21 +01:00
marius vlad
3044d8ed72 backend-drm: Use resize_output to allow changing the fb
A video mode change would be needed to change the underlying renderer
framebuffer. All other backends make uses of this so let's do it for the
DRM-backend as well.

This would also be needed for the output capture to function properly as
we need call weston_output_update_capture_info() when a new mode set has
set. Otherwise we'd run into mismatched dimensions for the current mode
versus the dimensions set-up initially in weston_output_capture_source_info.

Signed-off-by: marius vlad <marius.vlad@collabora.com>
2023-07-04 11:41:29 +00:00
Philipp Zabel
1c262efd70 backend-wayland: Prepare for more renderers, reject no-op
Turn the Pixman/GL if/else conditionals into switch cases to make it
easier to add support for other renderers in the future.

Also makes sure that weston --backend=wayland --renderer=noop fails
with an error message instead of segfaulting.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-06-30 16:36:52 +00:00
Philipp Zabel
d46b491c83 backend-x11: Prepare for more renderers, reject no-op
Turn the Pixman/GL if/else conditionals into switch cases to make it
easier to add support for others renderer in the future.

Also makes sure that weston --backend=x11 --renderer=noop fails
with an error message instead of starting with the GL renderer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-30 11:02:28 +00:00
Leandro Ribeiro
c61719e9e9 color-lcms: increase float precision to print segment breaks
There are some cases in which we are seeing segment breaks like this in
the debug scopes: (0.00, 0.00]. A segment whose domain goes from 0 to 0
makes no sense.

This happens because we are printing the breaks with only two decimal
places. Increase that to four, in order to have more accurate
information in the debug scopes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 17:05:06 -03:00
Leandro Ribeiro
625a74d369 color-lcms: properly print 16-bit sampled curves
There's a case we were missing when printing the tone curves: the ones
with zero segments.

These are 16-bit sampled curves. Start taking them into account.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 17:04:15 -03:00
Philipp Zabel
4a40ae7718 libweston: deduplicate compositor shutdown in backend_init failure path
If backend initialization fails, weston_compositor_shutdown() is called
twice, once right away in weston_compositor_load_backend(), and once in
weston_compositor_destroy().
Remove the first and fix a segfault when trying to weston_plane_remove()
the primary plane a second time.

Fixes: 90c11cf40e ("libweston: move weston_compositor_shutdown call out of backends")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-29 19:16:01 +00:00
Leandro Ribeiro
25ffc4ae92 color-lcms: rename curve_set_print() to curveset_print()
Just to be consistent with the other functions in the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Leandro Ribeiro
9486740d21 tests: add color pipeline optimizer tests
This will help us to debug our color pipeline optimizer without the
need to craft special ICC profiles for that. In this initial patch,
we are able to add matrices and curve sets to the pipeline and assure
that the optimizer is doing the right thing.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Leandro Ribeiro
884579bc3c color-lcms: merge power-law curve sets
At the moment, when we merge two curve sets it becomes a sampled one.
With this change, we start merging power-law curve sets and keeping them
as parametric, as we'd rather have a parametric curve than a sampled
one.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Leandro Ribeiro
e4baf5ba09 color-lcms: drop inverse curve sets in sequence
At the moment, when we merge curves we transform them into sampled
curves, even if they were parametric before.

If we have two inverse parametric curve sets in sequence in the color
pipeline, we can drop them both, as merging them would result in the
identity curve. If we don't do that and merge the resulting identity
with another curve set, we'll end up with a sampled curve.

Start dropping inverse curve sets in sequence. This change help us in
the following scenarios:

pipeline:
curve set A, curve set B (inverse of A), curve set C (parametric)

Merging A and B results in identity, and merging that with C results in
a sampled curve. With our changes, we end up with curve set C intact,
and we'd rather end up with a parametric curve than with a sampled one.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Leandro Ribeiro
c54220f09d color-lcms: move code that depend on cmsGetToneCurveSegment() to new file
Move code that depend on cmsGetToneCurveSegment() to a new file:
color-curve-segments.c

This help us to eliminate #if HAVE_CMS_GET_TONE_CURVE_SEGMENT scattered
around color-transform.c, making the code clearer and helping to avoid
mistakes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Leandro Ribeiro
fe1e171e1b color-lcms: minor indentation fix to pipeline optimizer debug scope
Print empty pipeline with the proper indentation.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Max Ihlenfeldt
cccff21538 initialize fourcc with DRM_FORMAT_INVALID
Signed-off-by: Max Ihlenfeldt <max@igalia.com>
2023-06-29 12:36:56 +02:00
Max Ihlenfeldt
a5f3bece5a gl-renderer: Always initialize variable
clang 17 complains that `fourcc` in `gl_renderer_fill_buffer_info()` is
uninitialized in the default case, because it fails to recognize that
if hit, that case will `assert(0)`. To get rid of this complaint, we can
just apply clang's suggestion and initialize the variable with 0 when
declaring it.

Signed-off-by: Max Ihlenfeldt <max@igalia.com>
2023-06-29 11:31:26 +02:00
Derek Foreman
815a560dd4 data-device: Don't make a weston_coord with no valid space
We already only conditionally use base.offset when an icon exists. We
should also avoid trying to create a coordinate with a NULL icon, as it
will fire an assert().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-28 14:37:34 -05:00
Philipp Zabel
90c11cf40e libweston: move weston_compositor_shutdown call out of backends
If we want to support multiple backends, the compositor must take care
to call this once, at the appropriate moment, so stop letting the
backends handle compositor shutdown themselves.

Move the weston_compositor_shutdown() calls from the backend::destroy
callbacks into weston_compositor_destroy() and the calls in the backend
creation error paths into weston_compositor_load_backend().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel
fcde7fae66 backend-wayland: use to_wayland_backend
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel
6d699c3f54 libweston: add weston_backend::shutdown callback
Add a weston_backend::shutdown callback to split out the part of
weston_backend::destroy that needs to be done before compositor
shutdown.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:45 +01:00
Leandro Ribeiro
f9ef4e64ea backend-drm: fix possible leak of struct drm_output
Before this patch, we would leak the drm_output if there was a pending
flip during shutdown.

Now we destroy the drm_output even if there's a pending flip (only
during shutdown, as we don't want to wait until flip completion to
destroy the output).

Also, it fixes a problem where weston_output_enable() is called right
after weston_output_enable() or weston_output_disable() and it could
fail to find available DRM objects (as they are only released after
the flip completion).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-27 10:57:12 +00:00
Daniel Stone
7e1d446279 libweston: Add weston_view::map_signal
It fires when a view is mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone
07103d1842 weston-desktop: Match desktop-shell view mapping semantics
Preserve the same order as desktop-shell for handling view (un)mapping,
so we can move these into a shared helper. These should have no
functional effect but provide a helpful bisect point.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone
2f2e20f3a3 weston_surface: Add map and unmap signals
These signals are emitted when the surface becomes mapped or unmapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Philipp Zabel
47180ad253 backend-wayland: fix error path in wayland_backend_create
Destroy the renderer before disconnecting the Wayland display.

Trying to destroy the GL renderer with the Wayland display already gone
crashes in the Mesa Wayland integration.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-26 13:45:59 +00:00
Philipp Zabel
da683dad57 gl-renderer: clear renderer pointer in gl_renderer_destroy
After freeing the renderer, clear the compositor->renderer pointer to
avoid use-after-free errors.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-26 13:45:59 +00:00
Loïc Molinari
edd5d1cc09 gl-renderer: Make clip_transformed() surf parameter constant
Calling clip_transformed() 4 times in a row with the same polygon8 in
commit a4d31fa8bd introduced a bug
because the surf input is modified each time. This is fixed by working
on a local copy. The input parameter is marked constant to reflect the
change on the function prototype.

Fixes #764

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-26 12:15:43 +00:00
Daniel Stone
386dcd904f build: Switch join_paths(foo, bar) to foo / bar
Available since Meson 0.49.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-22 14:31:57 +01:00