Currently we flush damage for the "primary plane" every repaint, but this
is folly.
The drm backend may skip rendering entirely if using an all-planes
composition. This could leave the renderer plane in a messy state if a
surface on an overlay plane disappears.
Instead, let the backends flush the primary plane damage when they know
they need to render.
Fixes#864
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine whether the backend is capable of being loaded simultaneously
with other backends.
To stay backwards compatible, the RDP backend can be loaded as primary
backend. It also supports being loaded as secondary backend.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Replace the finish frame handler logic with a call to the
weston_output_finish_frame_from_timer() helper function.
This makes finish_frame_handler() return more exact timestamps
calculated from the previous frame time if the timer callback
was not delayed too much.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Replace the finish frame timer arming logic with a call to the
weston_output_arm_frame_timer() helper function that does the same.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Round up the ms delay to make sure that the finish_frame_timer always
expires after the next frame_time. That way, finish_frame_handler()
never passes a timestamp in the future to weston_output_finish_frame().
Setting frame_time into the future risks hitting an assert in
weston_output_finish_frame(), when it is called from start_repaint_loop
within the frame interval.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.
Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.
In the future, this can be extended to determine the subset of clocks
supported by all backends.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
The ensure_single_mode() helper replaces an output's single mode.
Extract it into libweston so it can be reused by the VNC backend,
and rename it to weston_output_set_single_mode().
At the same time, set the the previously missing
WL_OUTPUT_MODE_CURRENT flag on the new mode.
Fixes#758
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Right now every backend clears output damage from the primary plane when
it repaints. Instead of having this same operation spread across all
the backends, just do it in the core instead.
In the future, we want to remove damage tracking from the primary plane
entirely, and this is a small step in that direction.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
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>
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>
Let the GL renderer render to FBOs for RDP outputs and read the pixels
into the RDP frame buffer. This allows to run the RDP backend with the
GL renderer.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add switch statements where renderer specific API is called to prepare
for adding GL renderer support. No functional change.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Partially revert commit 89e1831cd7 ("pixman-renderer: add
weston_renderbuffer and create/destroy interface") to bring back the
shadow_surface pixman image. The renderbuffer is only wrapped around it.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Consolidates the 'Using GL/Pixman renderer' message emitted by the
PipeWire, RDP, VNC, and X11 backends by moving the weston_log() into
weston_compositor_init_renderer(). Only print the message after
initializing the renderer has succeeded.
This effectively adds the message to the DRM, headless, and Wayland
backends.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Pass the RDP backend to rdp_head_create().
That way the already known backend will not have to be found from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.
Also remove the now unused to_rdp_backend() helper.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Push weston_coord into the notification functions instead of passing
two doubles.
The touch handlers are passed a pointer to a weston_coord, which is
unusual. This is done so we can pass a NULL pointer instead of a
fabricated invalid coordinate when the touch type is TOUCH_UP.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Use struct pixel_format_info pointers instead of pixman_format_code_t
values at the API surface for output and image creation.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add weston_renderbuffer_ref/unref() functions and use them to
eventually destroy the weston_renderbuffer. Drop the explicit
renderbuffer_destroy vfunc from the pixman renderer interface.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Stop calling pixman_renderer_init() from backends directly.
Call it via weston_compositor_init_renderer() instead.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add a private struct pixman_renderbuffer that derives from struct
weston_renderbuffer and move the pixman renderer specific image and link
fields into it.
Add a pixman_renderbuffer_get_image() helper for the backends that need
to access the contained pixman image, RDP and X11.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Add a damage region to struct weston_renderbuffer and use it to replace
the previous_damage tracking in the drm backend.
Keep renderbuffers on a list in struct pixman_output_state and use it
to accumulate damage on all renderbuffers during repaint_output.
Now renderbuffers have to be created when pixman output state already
exists.
Reorder renderer output state and renderbuffer creation accordingly.
With this, pixman_renderer_output_set_hw_extra_damage() can be removed.
This can not yet replace the external damage tracking in the VNC
backend, which needsto know the accumulated damage that is not returned
from repaint_output.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Add a struct weston_renderbuffer parameter to repaint_output and make
backends set the pixman image renderbuffer through this parameter
instead of using pixman_renderer_output_set_buffer()
Turn pixman_renderer_output_set_buffer() static.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Add a create_image_from_ptr vfunc to struct pixman_renderer_interface,
which wraps weston_renderbuffer creation for the pixman renderer via
pixman_image_create_bits(), as well as a renderbuffer_destroy vfunc
to dispose of the pixman image renderbuffer.
Also add create_image_no_clear using pixman_image_create_bits_no_clear()
instead.
Make the backends create and destroy their pixman image renderbuffers
through this interface.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Add a struct pixman_renderer_interface with output_create and
output_destroy vfuncs and store a pointer to it in struct
weston_renderer.
Make all backends access the pixman_renderer_output_create/destroy
functions through this interface and turn them static.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
To avoid retrieving the backend from the compositor all the time, store
a pointer to the rdp backend on its rdp_output structures.
This will be useful once the compositor contains more than one backend.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Passing the backend as a parameter to the weston_backend function
pointers seems more natural and will be very useful once there can be
more than one backend.
Since all backends already store a pointer to the compositor instance,
replace the compositor parameter with the backend in all functions.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Fix the RDP backend to handle to_rdp_head() returning NULL.
In practice, this should only happen once multi-backend support
is enabled.
Fixes: 70b03b2928 ("rdp: Add preliminary rdp multihead support")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This sets up monitor layout callbacks, and enables input event translation
between the RDP space and the weston desktop. The RDP backend now uses
a heads changed callback instead of the simple head configurator.
We only allow a single monitor for now, but in the future RAIL will make
use of multi-head.
As a side effect, scaling is now supported in RDP sessions.
It should be noted that due to differences between RDP and wayland
representation of their global coordinate spaces, mixing DPI leads to
RDP monitor layouts that can't properly be represented in weston.
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
Instead of passing a name, pass a FreeRDP rdpMonitor struct. For now the
only caller will pass a NULL to use default values.
Also, drop static from the function declaration as new code will call it
from another file shortly.
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
In some upcoming changes rdp_output_set_size will be removed. There's
no need to have it do this setup, so move that into output_create.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
In the absence of scale factors, this has been accurate. Once we allow
scaling we need to apply a full transform.
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
Output dimensions are only correct here with unity scaling, but we're
going to allow scale factors shortly. The mode matches what RDP
expects.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
If a client connects to an RDP session it should replace the existing
mode, not add a new one.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
ensure_matching_mode() pays no attention to flags, we must set them on the
returned result afterwards.
This could be reproduced by making the initial connection to an rdp session
using the same mode it picked at startup.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We don't need this anymore. Since we only support one output,
we can use the first output for any place we used to use it.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
If an output exists, it should be cleaned up automatically when we release
all our heads later anyway.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
By the time we get to this failure we may (or may not) have implanted a
listener.
freerdp_listener_free() safely handles passed NULL pointers, so we don't
have to add any additional checks on our end.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Currently, this is what backend->output would be anyway. This is another
step towards removing the singleton output stored in the backend.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Add an explicit request to the backend config to choose the renderer.
Currently, only Pixman remains supported, with auto defaulting to that.
Signed-off-by: Daniel Stone <daniels@collabora.com>