Commit Graph

21 Commits

Author SHA1 Message Date
Jan Alexander Steffens (heftig) 0e451e8dc3
libweston/noop-renderer: Check shm_buffer for NULL
Copy the check from the pixman renderer.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/953
Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
2024-09-14 06:38:47 +02:00
Derek Foreman 376b3952a0 libweston: Store shm buffer stride in weston_buffer
After c08a6ff8 moved attach to the render loop, we have a bad situation
when clients delete an attached shm buffer. We try to query the stride
at attach time, but the shm_buffer has been destroyed, and we crash.

Instead of carefully fixing that, I've instead stored the stride at
buffer creation time (as we already do with buffer width and height).
This lets attach succeed in the gl-renderer, keeping the old texture data
available for any upcoming rendering.

Fixes: #927

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Tested-by: Connor Abbott <cwabbott0@gmail.com>
2024-07-04 13:07:54 +03:00
Derek Foreman 290301882f renderers: Pass a paint node to the attach callbacks
Since we only call this from the paint node update code now, we can pass
the paint node directly.

A bit of internal refactoring is required to support copy_content.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 71079ffd1a renderers: Make flush_damage take a weston_paint_node
Currently we're passing in a surface, a buffer, and an output. All of
these things are available in the paint node.

Further, if we pass in the paint node directly, we don't have to walk
a list of paint nodes to figure out if the texture is used in the
upcoming repaint.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Philipp Zabel 155fa3a56a libweston: Add output parameter to weston_renderer::flush_damage()
When flush_damage() is called, the output to be repainted next is
already known. Pass it along into the renderer, which can make use
of this information:

The GL renderer can get a better idea which SHM surface textures
actually have to be updated, in case a surface can be put on a plane
on one output, but not another.

A future Vulkan renderer could record texture uploads into an output
specific command buffer.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-07-14 16:30:52 +00:00
Philipp Zabel 6757bae0f3 pixman-renderer: set renderbuffer via new repaint_output parameter
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>
2023-01-23 20:05:21 +00:00
Philipp Zabel 51c8882991 libweston: move headless_backend::renderer_type to weston_renderer::type
Move the renderer type from struct headless_backend into struct
weston_renderer to store the chosen renderer type in a unified manner.
This will later allow secondary backends to determine the renderer type
chosen by the primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Pekka Paalanen 8636422309 libweston: add weston_renderer::resize_output()
Previously renderers were not told when the output (framebuffer they
need to draw) size changed. Renderers just pulled that information out
from weston_output::current_mode when they happened to need it. This
makes some things awkward, like resizing the shadow or intermediate
buffers. In fact, Pixman-renderer does not even support resizing its
shadow buffer, nor does GL-renderer. DRM-backend has to destroy and
re-create the renderer output state anyway, but rdp, x11 and wayland
backends would be natural users of resizing API.

This commit adds an API for resizing with empty implementations. Actual
implementations will be added in following patches for each renderer
while moving parts of resizing code from backends into the renderers.
No-op renderer needs no implementation.

Only wayland-backend has actual resizing code already, and that is made
to call the new API. Unfortunately, Pixman and GL renderers differ: one
does not blit them while the other does. In order to assert the
functionality of each renderer to keep the API consistent,
wayland-backend needs to lie to pixman-renderer. That's not new, it
already does so in wayland_output_get_shm_buffer() where the 'pm_image'
addresses only the interior area instead of the whole buffer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +00:00
Pekka Paalanen b966fd07ea libweston: change read_format to struct pixel_format_info
Everywhere we are standardising to drm_fourcc.h pixel format codes, and
using struct pixel_format_info as a general handle that allows us to
access the equivalent format in various APIs. In the name of
standardisation, convert weston_compositor::read_format to
pixel_format_info.

Pixman formats are defined CPU-endian, while DRM formats are defined
always little-endian. OpenGL has various definitions. Correctly mapping
between these when the CPU is big-endian is an extra chore we can
hopefully offload to pixel-formats.c.

GL-renderer read_format is still defined based on Pixman format, because
of the pecualiar way OpenGL defines a pixel format with
GL_UNSIGNED_BYTE. That matches the same Pixman format on big-endian but
not the same drm_fourcc.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-08-03 14:33:48 +03:00
Daniel Stone 450ec38d79 noop-renderer: Make sure buffer access doesn't get optimised out
noop-renderer needs to actually access the buffer content, to ensure
that the bad-buffer test works. This was previously done using a
volatile variable, but clang rightly pointed out that the variable
access had no effect (since the volatile stack variable was never read
from, and the source is not volatile), so 9b0b5b57dd changed it to be
explicitly marked it as unused to suppress the compiler warning.

Unfortunately suppressing the warning still leaves the compiler free to
optimise out the access.

Replace the variable decorations with actually using the result of the
read, so we can be really sure that it's never going to be optimised
away.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 11:38:36 +00:00
Daniel Stone 19278569a3 noop-renderer: weston_buffer properties are set by the core
ca9bb01fe6 made it so that we already set shm_buffer, width, height,
etc, in the core. There's no need for the renderer to do this.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 11:38:36 +00:00
Marius Vlad 9b0b5b57dd noop-renderer: Remove volatile and use compiler attribute
clang-13 complains about bitwise xor assigments like the following:

../libweston/noop-renderer.c:62:25: warning: variable 'unused' set but
not used [-Wunused-but-set-variable] volatile unsigned char unused = 0;

Use the __attribute__((unused)) instead.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-16 08:24:59 +00:00
Daniel Stone b5605ccd26 libweston: Remove weston_surface_set_color
Don't do this; instead, create a solid-colour buffer and attach it to
the surface explicitly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 493a4c013e noop-render: Allow solid-color buffers
Refactor the buffer-type check slightly so we can handle solid-color
buffers, which we do exactly nothing with.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone fef8bb275c weston_buffer: Make use of weston_buffer->type
Rather than calling accessors (wl_shm_buffer_get etc) to figure out
which type our buffer is, just look in the structure.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 12675ed19f renderer: Add buffer to flush_damage
We already have the buffer in the caller, and every no-op implementation
will want to access the buffer. So might as well pass it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Guillaume Champagne f1e8fc9dbf libweston: add missing include
Fixes missing prototypes compilation warnings emitted when a function
is defined before its prototype is declared.

These warnings were introduced over time since the switch to meson
because the -Wmissing-protoypes was not included in the compilation
arguments.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-01-29 09:49:41 +00:00
Pekka Paalanen 209187491b noop-renderer: zero-initialize struct
This ensures that all function pointers we do not fill in will be NULL.

I had a crash in the Xwayland test with
https://gitlab.freedesktop.org/wayland/weston/merge_requests/274 without this,
because import_dmabuf was garbage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 3d5d9476e3 Rename compositor.h to libweston/libweston.h
The main idea is to make libweston users use the form

 #include <libweston/libweston.h>

instead of the plain

 #include <compositor.h>

which is prone to name conflicts. This is reflected both in the installed
files, and the internal header search paths so that Weston would use the exact
same form as an external project using libweston would.

The public headers are moved under a new top-level directory include/ to make
them clearly stand out as special (public API).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Jussi Kukkonen 649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Pekka Paalanen b5e3ea218b Rename src/ to libweston/
This clarifies what is supposed to be the libweston code.

v2: screen-share.c is already in compositor/ instead.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
2016-06-23 17:44:54 +03:00