The #ifndef doesn't work with the built-in static_assert from C++11, so
it ends up getting redefined. It seems that there are other versions of
static_assert internally in some C++ standard library implementations
that have additional arguments, and these also get overwritten by the
two-argument version here.
Detect if we're using a suitably-recent version of C++ and avoid the
redefintion in that case.
Signed-off-by: Ray Smith <rsmith@brightsign.biz>
Use gcc and clang's 'fallthrough' attribute instead of a comment to
fall through switch statements. This allows to request fall through
inside a block and prevents issues with preprocessed files.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
image should be initialised to NULL in case image loading fails
between setjmp() and xzalloc().
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Fix ‘image’ clobbered by ‘longjmp’ warning using volatile.
jpeg_image_data members are now also declared volatile (like
png_image_data members) to explicitly request compilers to store them
on the stack (not in registers) to avoid warnings and bugs later.
Co-authored-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Render wireframe within paint nodes instead of drawing lines in a
second pass. The wireframe is blended over the node in a single draw
call. This slightly simplifies the logic by removing the computation
of a second set of indices and enables wireframe anti-aliasing using
Celes and Abraham's "Fast and versatile texture-based wireframe
rendering" paper from 2011.
Celes and Abraham use a one-dimensional set of texture coords for each
triangle edge, 1.0 for the 2 vertices defining the edge and 0.0 for
the other vertex, which basically define barycentric coords. Texture
mapping and the mip chain is then exploited to give a constant-width
edge. The main drawback of the technique is that contour edges of
node's damage mesh are drawn half as thick as interior lines since
each triangle draws half of each line's thickness.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Wrap compiler builtins into shared functions with proper generic
implementations. __builtin_clz() isn't wrapped for now because its use
by screenshooter is pretty specific. It will be properly wrapped in
the next commit which needs a round up to the next power of 2
function.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
We're now using EGL_EXT_present_opaque and EGL_EXT_surface_compression
in weston-simple-egl, but this breaks the build for people that don't have
them in their system headers.
Pull them in from the khronos headers.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We have a single user of load_image(), and that can be easily replaced
by the new and more flexible weston_image_load() function.
So replace and drop load_image() from the code.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Instead of loading only the pixman image through load_image(), load both
the pixman image and the ICC profile with weston_image_load().
It also sets the struct weston_image as the cairo surface user data and
adds a function so that users can retrieve this.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Follow up of "shared: allow to get ICC profile from PNG using
weston_image_load()". This adds the support to get ICC profiles from
JPEG files.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This introduces the functionality to also load the embedded ICC profile
from an image. For now, this only supports PNG files, but in the next
commit we add the support for JPEG as well.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In the next commits we plan to add support to load ICC profiles that are
embedded in images. So we need something more flexible than
load_image().
This patch introduces a new function that, for now, does the same as
load_image(). For now we keep load_image() as well, but the plan is
to drop it later.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
A paint node with 'n' rects damaged by 'm' quads emits 'n*m' OpenGL
draw calls. This commit batches the 'n*m' clipped polygons into an
indexed triangle strip damage mesh using degenerate triangles. A
single draw call per paint node is emitted to reduce API overhead.
Fan debug mode is disabled for now and will be added back using
batching in the next commits.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Effective from Linux 6.3 onward, this creates the memfd without execute
permissions and prevents that setting from ever being changed. A
run-time fallback is made to not using MFD_NOEXEC_SEAL when
weston compiled on Linux >= 6.3 is run on Linux < 6.3.
Signed-off-by: Sami Uddin <sami.uddin@astc-design.com>
Helper to assert that a value does not have any bit set outside of the
mask. To be used with "all bits mask" of enum types that enumerate bits.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
If png_create_info_struct() fails, we should pass NULL to
png_destroy_read_struct(), and not the address of the info we just
failed to create.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Currently in translate_curve_element() we always translate the curve
into a LUT. But in the future we'll be able to translate the curves to
parametric ones.
So move the current code to a new function
translate_curve_element_LUT(), so that in translate_curve_element() we
are able to call one of the two functions (_LUT() or _parametric()).
No behavior changes, just preparation for the upcoming patches.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Not a behavior change, but this allow us to decide what function pointer
to use within this function (instead of forcing callers to decide that).
In the following commits this will be helpful. We'll add more curves
besides 3x1D LUT's and, depending on the curve, the function pointer
signature may differ.
Also, we now pass the xform directly to the function, and it can select
the curves depending if it is being called for a pre or a post curve.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
A proper dependency on egl is missing for several backends as well as
for libshared. This dependency is necessary to pull in the correct
include directories from the egl.pc pkg-config file.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
When we are destroying the color manager, the components referencing
color profiles should have already been destroyed. We have an assert
in cmnoop_destroy() to make sure that the stock profile has refcount
equal to 1.
But we currently have an issue in Weston. While shutting down with
client surfaces alive, we may leak them. So we try to destroy
the color manager with surfaces still alive, and they may be
referencing color profiles.
We already have a workaround for this in our LittleCMS color plugin,
but we've missed that in color-noop. This fixes that, so now we don't
hit the assert anymore.
As we are already dealing with asserts in color-noop, I took the
liberty to replace the last usage of assert with our own wrapper
in this file.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In this MR we add support to the majority of the interfaces from the
color-management protocol.
That means that we are able to advertise output's images descriptions to
clients, preferred surface images descriptions, and so on. We also
support clients that wants to create ICC-based images descriptions and
set such descriptions for surfaces.
We still don't support the interface to allow clients to create
image descriptions from parameters, but that should be addressed
in the near future.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This is preparation for the CM&HDR protocol implementation. It requires
us to give a unique id to each color-profile, so let's do that.
In this commit we introduce a generic id generator to libweston, and
its first user: the color-profile.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
We forgot to include stdbool to weston-assert.h, but this was not
causing issues because callers of weston_assert_true() themselves
include stdbool.
Add stdbool to weston-assert, as this is the right thing to do.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Add yet another flavor of assertion macros.
Unlike libc assert.h assert(), these cannot be easily disabled by the
build. They also print both the implied expression and the compared
values.
Unlike ZUC macros, there is much less framework code and it can handle
also floating-point types.
The function custom_assert_fail_ can be redefined, meaning that
different compilation units can do different things on failure.
Also the 'compositor' parameter was added to the new macros because we
plan to use these asserts in our log infrastructure, and we want to
print the "failure" messages in the right log scopes. Having the
compositor already in the macros will avoid double work.
Another future possibility is to write specific asserts for the test
suite. So we would be able to write a test suite failure function that
just print what "failed" without aborting.
There is also limited support for custom types.
These are actually pretty similar to libinput's litest macros.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This is because e619a65b09, 'libweston: move gl-borders code into
helper lib' and 6293ab1f90, 'libweston, shared: Move out
weston_shell_get_binding_modifier' moved things out of libweston, and
libweston implicitly depends on xkbcommon.
Rather than just depending on dep_xkbcommon use the deps_for_libweston_users
which includes some other dependencies as well. Had to move it out
of libweston/meson.build and include it in the main meson.build as
libweston/meson.build would have a circular dependency on
libweston/meson.build file.
This fixes the following build issue:
[ 5s] FAILED: libweston/libgl-borders.a.p/gl-borders.c.o
[ 5s] cc -Ilibweston/libgl-borders.a.p -Ilibweston -I../libweston -I. -I.. -Iinclude -I../include -I/usr/include/wayland -I/usr/include/pixman-1 -I/usr/include/cairo
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/webp -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -Wmissing-prototypes
-Wno-unused-parameter -Wno-shift-negative-value -Wno-missing-field-initializers -Wno-pedantic -Wundef -fvisibility=hidden -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIC -MD -MQ libweston/libgl-borders.a.p/gl-borders.c.o -MF
libweston/libgl-borders.a.p/gl-borders.c.o.d -o libweston/libgl-borders.a.p/gl-borders.c.o -c ../libweston/gl-borders.c
[ 5s] In file included from ../libweston/renderer-gl/gl-renderer.h:32,
[ 5s] from ../libweston/gl-borders.h:28,
[ 5s] from ../libweston/gl-borders.c:31:
[ 5s] ../include/libweston/libweston.h:39:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
[ 4s] FAILED: shared/libshared.a.p/config-parser.c.o
[ 4s] cc -Ishared/libshared.a.p -Ishared -I../shared -I. -I.. -Iinclude -I../include -I/usr/include/wayland -I/usr/include/pixman-1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall
-Winvalid-pch -Wextra -Wpedantic -std=gnu99 -Wmissing-prototypes -Wno-unused-parameter -Wno-shift-negative-value -Wno-missing-field-initializers -Wno-pedantic -Wundef -fvisibility=hidden -O2
-Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIC -MD -MQ
shared/libshared.a.p/config-parser.c.o -MF shared/libshared.a.p/config-parser.c.o.d -o shared/libshared.a.p/config-parser.c.o -c ../shared/config-parser.c
[ 4s] In file included from ../shared/config-parser.c:44:
[ 4s] ../include/libweston/libweston.h:39:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When it comes to a window frame, a tablet tool and cursor act almost
identical; they click things, drag things, etc. The tool type and extra
axes don't serve any use in the context of a window frame, so tablet
pointers share the frame_pointer structures used for the mouse pointer.
Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
The hash table implementation is useful for other modules as well. Move it from
xwayland to the shared code.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
For pango_cairo_font_map_set_default().
Fixes#720
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@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>
The previous version used div() to separate the column and row of the
current element, but that function is implemented as a libc call, which
prevented the compiler from vectorising the loop and made matrix
multiplication appear quite high in profiles.
With div() removed, we are down from 64 calls to vfmadd132ss acting on
one float at a time, to just 8 calls to vfmadd132ps when compiled with
AVX2 support (or 16 mulps, 16 addps with SSE2 support only), and the
function isn’t a hot spot any more.
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
unreachable() is used to hint to the compiler that a certain branch
cannot ever be reached. The implementation is taken from Mesa.
Signed-off-by: Daniel Stone <daniels@collabora.com>
libweston contains weston_config and weston_shell_utils utilities
functions so include these in the sphinx documentation as well.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This doesn't really belong into shell-utils, so better move it out to
shared/config-parser. Renamed to weston_config_get_binding_modifier
to maintain the same namespace.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When we build up a matrix from a series of operations, it's very useful
to know if the combined operations still result in something that matches
a wl_output_transform.
This adds a function to test if a matrix leads to a standard output
transform, and returns the transform if it does.
Tests are provided that check if complex series of operations return
expected results - the weston_matrix_needs_filtering function is tested
at the same time.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
If a transformation matrix causes a scale, a rotation not a multiple of 90
degrees or a non-integral translation then textures rendered with
it would benefit from bilinear filtering.
This test is done in a lazy fashion by examining elements of the matrix
to check for a simple pattern that indicates these conditions are met.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This is particularly useful when using the weston-editor which seems to
cause an issue with cairo_debug_reset_static_data(), as that still seems
to find out there are references laying around, causing a crash when
exiting:
../../../../src/cairo-hash.c:217: _cairo_hash_table_destroy: Assertion
`hash_table->live_entries == 0' failed
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Rather than creating a new PangoContext each time the menu redraw
handler is triggered re-use it if one was created previously.
All toytoolkit clients do create a layout (and implicitly a
PangoContext) but only those that have menu redraw
handler installed will create a new layout for each redraw of the menu,
effectively creating a new PangoContext each time.
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
We are already doing that before calling theme_render_frame() so no need
to do it again in layout creation.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>