Update users of the old coordinate space conversion functions that take
x, y pairs to the new weston_coord versions.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Possibly the least useful place to use this, as the input comes directly
from pixman rects, and the output is more complicated than usual, but
I guess consistency counts for something.
There is some small benefit in switching to weston_matrix_transform_coord
to hide the perspective normalization step and the homogenous coords.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
All through weston we have code that passes int x, y or
float x, y or wl_fixed_t x, y pairs. These pairs are frequently
converted to/from wl_fixed_t and other types.
We also have struct vec2d and struct weston_geometry which also
contain coordinate pairs.
Let's create a family of coordinate vector structures for coordinate
pairs and use it anywhere we sensibly can.
This has a few benefits - it helps remove intermediate conversion
between fixed/float/int types. It lets us roll the homogenous
coordinate normalization bits into helper functions instead of
needing them open coded throughout the source.
Possibly most importantly, it also allows us to do some compile time
validation of what coordinate space we're working in.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
One variant is used when a view is being positioned relative to a parent,
the other is when the view is being given an absolute position in the
global space.
This will help later when surface and global coordinates are different
data types, but for now the two functions do essentially the same thing.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
In commit d611ab24fd "libweston: Update
view transforms more often", a call to weston_view_update_transform()
was introduced to desktop_surface_committed(). It was added between the
point in which we call unset_fullscreen() and
shell_configure_fullscreen(), right after the view geometry dirty bit is
set.
There's a scenario with dual displays in which this change resulted in
the surface being alternated between two outputs:
---
Dual display configuration:
1st display: DP1, with scale 1 - origin 0, 0
2nd display: DP2, with scale 2 - origin 1920, 0
We start the app with the cursor on DP2. Function
desktop_surface_committed() gets called a few times, and it ends up
setting shsurf->saved_x and shsurf->saved_y to the origin of DP2.
Application wants to become fullscreen on DP1, so when the surface gets
committed again and desktop_surface_committed() gets called, we have the
following sequence:
desktop_surface_committed():
was_fullscreen = shsurf->state.fullscreen
is_fullscreen = weston_desktop_surface_get_fullscreen()
if (!weston_surface_is_mapped(desktop_surf))
map(shell, desktop_surf)
return;
/* POINT A, this is important for understanding the issue. */
if (shsurf size didn't change and
fullscreen state didn't change)
return;
if (was_fullscreen)
/* This function calls weston_view_set_pos(saved_x,
* saved_y), and the saved position is the origin of
* DP2. Then it invalidates the saved position */
unset_fullscreen(shsurf)
if (is_fullscreen && !shsurf->saved_position_valid)
/* Saves the position (as it just have been
* invalidated), which will be the origin of DP2
* again. */
shsurf->saved_x = shsurf->view->geometry.x
shsurf->saved_y = shsurf->view->geometry.y
shsurf->saved_position_valid = true
/* This function calls weston_view_assign_output(), which then
* calls weston_surface_assign_output(). The effect of these two
* functions is that the view gets assigned to an output, and to
* choose the output it takes into consideration the position in
* which it is and the area that it occupies on the output. As
* the view has been moved to the origin of DP2, it gets
* assigned to this output. Then Weston sends the enter/leave
* surface events. */
weston_view_update_transform()
if (is_fullscreen)
/* This function positions the view on DP1, because
* that's the output in which the wine app wants to
* become fullscreen. */
shell_configure_fullscreen(shsurf)
/* Now we call weston_view_update_transform() again to each view
* of the surface, and so we end up sending enter/leave surface
* events. But notice that now we are positioned on DP1. */
wl_list_for_each(view, &surface->views, surface_link)
weston_view_update_transform(view);
The next time the surface gets committed and desktop_surface_committed()
gets called, the same sequence will happen. So we'll continue in this
weird loop.
The reason why the surface size changes and we don't return in POINT A
in this scenario is because the application uses a viewport, and then
when its surface moves to the output with scale 2 it sets the surface
size to half its size. That happens for apps that want to keep a
reasonable DPI on scaled displays.
This only happens after the change that introduced the call to
weston_view_update_transform() in this function. Without this call we'd
not reposition the view on DP2 and send enter/leave events at that
point.
---
So in order to avoid that, be more careful before calling
unset_fullscreen() and then shell_configure_fullscreen(). Only do that
when:
- the surface was not fullscreen, and now it becomes.
- the surface was fullscreen, but now it becomes fullscreen on a
different output.
In order to be consistent, do something similar to the maximized state.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Clean up the code a little by dropping the now unnecessary switch case
in drm_output_init_pixman(). As a side effect, this enables all formats
that have a pixman_format entry in the pixel format table:
- rgb565
- xrgb8888
- argb8888
- xbgr8888
- abgr8888
- rgbx8888
- rgba8888
- bgrx8888
- bgra8888
- xrgb2101010
- argb2101010
- xbgr2101010
- abgr2101010
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Use const struct pixel_format_info *format instead of uint32_t
gbm_format for backend and output pixel format.
Since create_gbm_surface() is never called without output->format being
set, drop the unnecessary error message.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Stop using features that Meson 0.63.0 throws deprecation warnings about:
WARNING: Deprecated features used:
* 0.56.0: {'dependency.get_pkgconfig_variable'}
* 0.62.0: {'pkgconfig.generate variable for builtin directories'}
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Make use of meson subprojects support. Allow to optionally build the
libraries required for the VNC backend as subproject of Weston.
Signed-off-by: Stefan Agner <stefan@agner.ch>
[philipp.zabel@gmail.com: update neatvnc and aml versions]
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Prepare for bumping the Meson requirement in meson.build to 0.63.0,
adding support for per-subproject compiler options to allow building
aml and neatvnc as subprojects.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Use struct pixel_format_info pointers instead of uint32_t drm fourcc
values at the API surface for output and image creation.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add a helper function to turn an array of DRM fourccs into an array of
corresponding struct pixel_format_info pointers.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.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>
Xwayland pop-up menus aren't displayed until the mouse moves, or some other
action causes the compositor to repaint.
This is because the shell knows nothing about xwayland override redirect
windows, so it won't assign them an output. Without an output, the
surface commit won't cause a repaint.
Fix this with brute force by updating their geometry on commit. If the
geometry is dirty (and it will be for new surfaces), this will cause an
output to be assigned before the upcoming weston_surface_schedule_repaint()
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Found-by: Hideyuki Nagase <hideyukn@microsoft.com>
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>
This pixman image is not actually used anymore, drop it.
Fixes: 89e1831cd7 ("pixman-renderer: add weston_renderbuffer and create/destroy interface")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Given that pixman_image_create_bits_no_clear() is asked to allocate the
buffer on its own, the _no_clear part is not important. Drop it.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This fixes the situation where screen share seat is not released upon
compositor shut down.
This will have a cascading side-effecting of resulting in an invalid libinput
device reference assert, like the following:
../src/libinput.c:2169: libinput_device_unref: Assertion
`device->refcount > 0' failed.
That happens because at compositor shutdown, the seat created by the
screen share module will *still* be acccesible in compositor instance
seat list, effectively resulting in an invalid unref for a non-existent
libinput device.
This patch rectifies that in such a way that upon compositor shut down
we release the seat in the screen share module which would implicitly
remove it from the compositor instance seat list.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
In case we have multiple outputs let's us choose the first output,
rather use the last one, which would happen when multiple are present in
the system.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
In preparation of having multiple outputs available we should be able to
specify by its name. We just use the default one if none was set-up at all.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Move the call to weston_output_update_capture_info() from the headless
backend into pixman_renderer_output_create(). For this, add an
uint32_t drm_format parameter to struct pixman_renderer_output_options.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Let weston_output_update_capture_info() take a uint32_t drm_format
parameter directly instead of const struct pixel_format_info *format.
No other fields apart from the format were used from this structure.
Without this, callers may have to unnecessarily look up the pixel
format info in cases where the DRM fourcc is already available.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
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>
Now that enum weston_renderer_type is public, there is no need for a
local enum renderer_type in the tests.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
The blit_shadow_to_output() function leaves the generic vertex attrib
arrays 0 and 1 enabled. This commit disables them for consistency with
the other drawing calls of the renderer.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Generic vertex attrib arrays 0 and 1 are constantly enabled across the
entire renderer. This commit enables them:
- once per output repaint instead of once per view repaint,
- once for the 4 borders instead of once for each border,
- once for all the shadow regions instead of once for each region.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
The blending func is constant across the entire renderer. This commit
sets it once per output repaint instead of once per view repaint.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Move the struct gl_renderer_interface pointer from the backends into
the weston_renderer structure. The interface struct only contains
function pointers that never change, so make it const.
Load and initialize the GL renderer in libweston instead of in the
backends, using the new weston_compositor_init_renderer() function.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
As seen in some instances, subsurfaces do not have an entry in their
layer_link, as we bring them into existence rather directly in the
view_list and not using the layer list approach.
This adds two messages to the debug scene graph to point out if the
views aren't really in any layer or if they're indirectly in the view
list using an ancestor (the main parent view actually).
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
We can save a bit of work by using the output_to_buffer_matrix we've
already calculated for the paint node to transform the destination
rectangle, instead of starting over from global regions and doing
individual steps.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We should never hit this because drm_view_transform_supported() filters
out any transforms where it would occur.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
It should harmlessly fail or do nothing, but seeing attempts to set
uniform -1 can be confusing when looking for real shader issues.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Add an output transform function that doesn't use matrices so we can
test our matrix generation by applying it to vectors and comparing with
the non-matrix variant.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>