Since a paint node is a combination of surface, view, and output, using
the surface flow in paint node functions can make a confusing twisty mess.
Perfetto flows have in/out degree of one, so we can't properly express the
1 surface to multiple paint nodes relationship with flows.
So for now let's break up the surface and paint node flows, but in the
future we'll have better ways to map multiple flow starts to the same
function via INSTANT events, and we'll be able to better link surface
content update to paint node render.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
A few custom shells want to know when the compositor is going to sleep.
This adds a new sleep signal and emits it when DPMS is going off.
To showcase the feature, this adds a sleep signal listener to
desktop-shell whose handler logs a message.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Since the commit "color-lcms: extract HDR static metadata from profile"
this was all dead code.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Backends should be relying on paint nodes for their information, not
views.
Since we always have a paint node when we want to pass a buffer, we can
pass that instead of a view.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Assertions are the usual way of failing tests in the compositor code,
but it means the test program cannot continue further. It would be
better to save an error exit code and run the compositor to the finish,
and then continue with the next test fixture.
I want to force some paths in GL-renderer output initialization for a
test, and fail otherwise. Calling weston_compositor_exit_with_code()
crashes there though, because the frontend has not installed the exit
handler yet.
Skip the exit handler if it's not there. The error exit code is still
saved, and will eventually bubble out of the compositor.
While at it, let's document these.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Rather than passing a NULL use sizeloc to pass the size. Otherwise
fflush(3) and fclose(3) would die out crashing in libc.
Use size also when printing out to a subscriber.
Fixes: e9665ef36
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Fix the following error:
Generating doc/sphinx/weston-doc-breathe with a custom command
FAILED: [code=1] doc/sphinx/weston
doc/sphinx/run_doxygen_sphinx.sh
/home/pq/git/weston/libweston/compositor.c:10001: error:
Found non-existing group 'client' for the command '@ingroup',
ignoring command (warning treated as error, aborting now)
Fixes: df622cbb20
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
I added these assert()s and have regretted it ever since. I'm sorry.
They've led to a bunch of places that just cargo-cult call
weston_view_update_transform() immediately after dirtying the transform,
as well as a lot of very carefully chosen places that took far too long to
sort out.
weston_view_update_transform() is an immediate return if the transform
isn't dirty, so let's just update them here instead of making everyone
think really hard about when to call weston_view_update_transform().
This should let us remove a few transform updates, and should
make the weston_coord functions a little easier to use.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
When a paint node is drawing rotated content, it's treated like its axis
aligned bounding box. Even if it only contains fully opaque content,
the parts of the axis aligned bounding box outside of that content
are not opaque.
We need to ensure we don't claim a paint node that isn't axis aligned
is fully opaque, or we'll improperly update regions outside of the
really opaque content.
Fixes 485e1796af
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
It makes more sense to update the transform than to bail.
These functions are sort of hints - they have to be correct when true, so
the previous code isn't really buggy. But they make more sense at a glance
this way.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
As weston_surface_attach_solid() can change quite a lot about a surface,
we need to mark it as dirty.
Signed-off-by: Daniel Stone <daniels@collabora.com>
This should cut the cost of debug_scene_view_print_buffer() in half on
ARM A55 CPU. Debug printing is quite expensive on such platform.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Two lines open-coded in two places was not much a problem, but I'm going
to add a new member to weston_buffer that needs freeing, and I want to
do it in just one place.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Use fputs() as much as possible. My theory is that since fprintf() needs
to scan through the format string to find any formatting codes, it must
be less efficient than fputs() that does not scan.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is useful for cases where we already have an open stream which we
can pass straight in and use it when printing node information.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Being able to print the scene-graph straight into a FILE removes one
temporary memory allocation that used to be mandatory. That memory
allocation is now gone from the DRM-backend debug log. It has moved into
the scene-graph log scope. In the case of
weston_log_subscription_printf() it shouldn't matter, because it is only
used when new subscribers appear.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This adds a new output color effect: grayscale. It takes RGB color as
input and computes a gray pixel color using the luminance formula for
linear sRGB:
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
Just like the other color effects we have, this only works for sRGB and
are not enabled when color-management is on.
Note: although the technique is designed to be applied in linear, it's
costly to convert to linear and then back to electrical. As doing the
conversion in electrical still gives a reasonable result, we do it this
way. When we add support for color effects with color-management on,
we'll apply the effect in linear.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Use the new label field instead. The code becomes much simpler.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Subsurfaces labels do not have dynamic fields that change so we can just
use it as is.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is an alternative to using set_label_func to avoid using get_label()
callback. get_label() is inconvenient to set up and to call. It incurs
the cost of creating the string every time it is needed. During
debug logging, the string is needed much more often than it changes.
The new label field simply stores the string, making it easy and cheap
to use. As the trade-off, components that set the label string must
re-create the string when it changes, whether it is needed or not.
For the migration to the new label field, get_label_member callback is
used. It will be deleted once the migration is done.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
On the quest to delete the get_label() vfunc completely, a temporary
default get_label implementation needs to be plugged in. This would
affect all the code that checks whether the get_label vfunc is NULL.
Let's make get_label vfunc non-NULL always intentionally first. We can
delete all the code that checked for NULL, and the bespoke label
replacements in that case. Now all those different "no label" cases are
unified.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Doing
weston_log_subscription_printf(sub, "%s", str);
would malloc a new buffer, copy str into it, flush it our to the
subscriber, and free the buffer before returning.
Using weston_log_subscription_write() instead there is no malloc and
copy. Only open_memstream() has a malloc'd temporary buffer.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
weston_output_init() should be setting all members to a default value,
it can't assume anything is already 0.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Right now, any non-renderer plane only has a single paint node on it. It
can be useful to know what paint node that was after the damage flush.
This will be used shortly to simplify cursor handling in the drm backend.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
I found it confusing to read:
[view] view 3-2-1 will be placed on the renderer: no color transform
The view definitely has a color transform. What this means is:
[view] view 3-2-1 will be placed on the renderer: cannot off-load color transform
I hope that's more clear.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Makes the print-out a little bit tidier. Passing NULL for "%s" is
handled by glibc gracefully, but I'm not sure what standard requires it
if any.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
We have a consistent and more human-friendly name for views. Use it
instead of pointer values, view_idx, and protocol object ID. This makes
the scene-graph print more readable.
I presume the view_idx was just an ad hoc human-readable addressing for
views. It was stable only as long as the scene-graph didn't change. The
view internal_name is always stable and unique.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Views did not have any identification of their own, except the memory
address "%p" (not human-readable) and very likely assumption that a
surface would have only one view (but we support multiple views).
For trace and debug print purposes, give views nice names like we just
added for surfaces. The owning surface is apparent from the view name.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
So far we have had two ways of identifying a weston_surface: by its
memory address "%p", and by its get_label function. The memory address
is not human-friendly and can get recycled. get_label() is not unique,
and in some cases it is client-controllable.
Oh, we also have the protocol object ID, but that does not exist for
internally created weston_surfaces.
We also have weston_surface::s_id, damage_track_id and flow_id. These
are used by some Perfetto instrumentation. s_id comes from a
compositor-wide counter rather than per-client counter, the others are
probably not what I'm looking for.
None of these are really nice for trace and debug prints for identifying
surfaces for human reading. Therefore, let's add one more ID, and with
it, a nice name for each surface.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This adds the framework to track clients with custom data. The first use
is to associate an ID with each client. The ID is much better suited for
debug printing than a pointer value.
The string representation is stored so that it can be overridden if
desired for compositor forked clients like Xwayland or shell helpers.
Change to a struct in the public header forces a major version bump for
this development cycle.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
To make use of recent optimizations for the is_fully_opaque
calculation, not only relying on the opaque region any more.
Signed-off-by: Robert Mader <robert.mader@collabora.com>
When we switch to the deferred state, we want to complete all outstanding
repaints first - even ones started from the idle handler immediately
after we called weston_backend_set_deferred().
Fixes#1090
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Backends can end up in indeterminate/invalid state and be unable to
process updates.
Add a way for the backend to tell the core to stop scheduling repaints,
and a way for the backend to schedule all the repaints that should have
taken place during the invalid state period.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
The paint node is_fully_opaque and is_fully_blended properties are overriden
when the paint node is censored or used to clear a hole for an underlay plane,
in which case the paint node is forced to be a solid color.
Those properties need to be recomputed when the paint node solid state changes,
that is:
- when the view becomes uncensored
- before assigning planes; if the paint node was overriden late in the repaint
loop to clear a hole for an underlay plane, those properties need to be reset
early in the next repaint loop to properly compute the visibility of
underneath views.
Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
CVD correction is composed by a linear transformation, so we should be
able to collapse it into a single matrix multiplication:
Y = M * X
Where Y is the result, X is the original color, and M is the CVD
correction matrix.
As we need to perform CVD correction for every pixel, this can be
beneficial for limited hardware.
In this patch we do that, updating the libweston core code and also the
GL-renderer and its fragment shader.
Suggested-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Commit 008884f28 ("compositor: Move dirty buffer handling to paint node
early update") makes the dirty paint node bit being
cleared in the update early function which makes t too late to check in
the paint node update late where we used to accumulate painted frames.
Just move it before the early update to make we still have a way to
print painted frames counter.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When moving the views between two outputs, the view's paint node is
removed from an output's z order list, but no paint_node_changes are set.
The drm-backend uses paint_node_changes to determine if it can reuse state,
so could leave a stale image behind on a plane until something else
triggered new state generation.
Make z_order_link removal dirty the paint node changes to prevent stale
state reuse.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Users might start the compositor with the scene-graph debug scope which
requires having the clock set-up as implicitly one of the backends needs to be
loaded.
Just avoid doing that until we have one the backends loaded to prevent
a start-up crash.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
The change in 65227cb7d4 is actually destructive, as it causes multiple
drm-backend heads to no longer be repainted at the exact same time at
startup.
This frequently leads to a failure to flip when only one head is properly
set up and others have stale state.
Force stampless finish_frame to skip any time adjustments to restore proper
behaviour.
Fixes: 65227cb7 (compositor: Round repaint times down to possible presentation times)
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Make sure we check if a paint node has been assigned to a view before
trying to dump its contents.
The scene graph dump from the repaint loop should always be ok, but if
we're using weston-debug we could race with the repaint for a new view
and try to print the scene graph before the node is created.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
For now limited to coefficients and ranges that are typically
supported by KMS drivers. We notably leave out alpha modes and
chroma locations for now.
The protocol initialization is guarded by the WESTON_CAP_COLOR_REP
backend capability and thus not enabled anywhere yet.
Signed-off-by: Robert Mader <robert.mader@collabora.com>