Commit Graph

22 Commits

Author SHA1 Message Date
Loïc Molinari
ce1705435f gl-renderer: Do not expose clipper_clip() in header
There is no need to expose it since it can be accessed by passing
non-axis aligned quads. Move existing tests to the quad clipper.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-05-30 09:09:45 +00:00
Loïc Molinari
bef1f5fd7d gl-renderer: Remove support for non-quad polygons from clipper
The added complexity is unnecessary, it is limited to polygons of
length less than or equal to 8, there is currently no use for that
feature nor any plans to use it and tests are non-existent.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-05-30 09:09:45 +00:00
Loïc Molinari
5516527f2b tests: Add box32 quad clipper tests
Add a few tests ensuring the box32 quad clipping wrapper works as
expected.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari
e82ce8032c gl-renderer: Fix quad clipper non-zero area check
The non-zero area check of clipper_quad_clip() is incorrect for quads
initialized with a polygon starting with a vertical edge. In order to
handle polygons starting with an horizontal edge and polygons starting
with a vertical one, it must check opposite vertices for equality.

The test previously described as "Box intersects entire smaller
aligned quad" is now described as "Clockwise winding and top/left
initial vertex". This test keeps the same values as before but all
combinations of winding order and first edge orientations are
also tested. The QUAD() macro isn't used anymore to do so.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari
1f9637ec8e tests: Add quad clipper tests
Add quad clipping tests checking intersections at all edges and
corners of axis-aligned and unaligned quads with negative and positive
values.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari
60877f5f55 tests: Improve general purpose clipper tests
Simplify box and quad declarations using dedicated macros.

Hard-coded literals are used instead of preprocessor constants for the
sake of brevity and because, as several new tests will be added, it
appears to be easier to understand those when values are inlined.

Descriptions have been revised to better understand the intent of each
test. Previous descriptions used a coord system with Y pointing up,
new descriptions use Y pointing down in order to improve consistency
with the rest of the code base and to have a common ground when
talking about winding order.

All the tests keep the same input values with the exception of the
last 2 tests with (new) descriptions: "Rotated quad with edges
adjacent to box corners" and "Rotated quad with edges cutting out box
corners". These tests had a different winding order and have been
modified so that all tests use a clockwise order (new axis
convention). The last test also gets a counter-clockwise version in
order to ensure the opposite winding order is correctly supported too.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari
aca0b69a0a tests: Improve clipper test function
When the first vertex passed to the clipper is clipped into two
vertices, the second vertex can sometimes be emitted as the first
clipped vertices while the first vertex is emitted as the last one. A
new utility function assert_vertices() is added to handle that
case. The function also checks the number of clipped vertices and the
clipped vertices in one go.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari
42205628bf gl-renderer: Prefix clipper API
Prefix and slightly rename the clipper structs and funcs:

  - struct clip_vertex -> struct clipper_vertex
  - struct gl_quad     -> struct clipper_quad
  - clip_transformed() -> clipper_clip()
  - init_quad()        -> clipper_quad_init()
  - clip_quad()        -> clipper_quad_clip()
  - clip_quad_box32()  -> clipper_quad_clip_box32()
  - float_difference() -> clipper_float_difference()

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari
f74c5a4102 gl-renderer: Replace clip_transformed() context with a clipping box
Simplify clip_transformed() by replacing its context parameter with a
clipping box parameter. The context struct is still used internally to
pass data around.

Since clip_transformed() doesn't take a context anymore, the clipping
boxes are now declared per test and stored along with the other vertex
data. That prepares the ground to add new tests using different boxes.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari
bf222f1897 gl-renderer: Use clip_vertex struct for boxes in clipper API
Carry on the common vertex representation front by making boxes use
the clip_vertex struct.

A new function clip_quad_box32() is added to clearly separate the main
function taking a clip_vertex struct from the utility function taking
a pixman_box32 struct.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari
b8063dbb13 gl-renderer: Remove polygon8 struct from clipper API
Pass a clip_vertex struct and a size to clip_transformed() instead of
a polygon8 struct to simplify the clipper API by sticking to a common
vertex representation.

Simmplify vertex-clip test since clip_transformed() now works on a
copy of the polygon (commit edd5d1cc09).

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari
49053a2aa2 gl-renderer: Store clipped vertices directly into the vertex buffer
Move vertex clipper back to single-precision floating point
intermediates. Since positions are sent down the graphics hardware as
single-precision values, this prevents useless conversions between
single and double precision values and lets compilers fit twice as
much data into vector registers. It also removes a copy by letting the
clipper store vertices directly into the vertex buffer.

This is mostly reverting the conversion to double-precision that
happened along with the switch to the weston_coord struct for vertex
coordinates (commit 10e70bf23c).

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Derek Foreman
10e70bf23c clipping: Use struct weston_coord in vertex clipping code
Remove the independent x, y floats from the clipping code and replace them
with struct weston_cord. This includes the polygon8 structure as well.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +00:00
Leandro Ribeiro
b4cf450ce1 shared/helpers: use ARRAY_COPY where possible
In "backend-drm: simplify compile time array copy", ARRAY_COPY was
introduced to be used by the DRM-backend.

In this patch we expand its usage to other code where hardcoded arrays
are being copied.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-28 12:17:24 -03: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
Jon Cruz
35b2eaa989 Moved helper macro to a discrete include file.
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15 17:11:45 -07:00
Jon Cruz
4678bab13c Remove redundant #include path component.
Using the parent '../' path component in #include statements makes
the codebase more rigid and is redundant due to proper -I use.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15 17:11:09 -07:00
Bryce Harrington
2cc9297aca tests: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:19 -07:00
Bryce Harrington
a76802685a tests: Cleanup superfluous headers
Mostly remove headers that aren't actually needed for anything.
Add stdint.h to permit dropping xf86drm.h, which is otherwise unneeded.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Marek Chalupa <mchqwerty@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-28 15:54:31 +02:00
Andrew Wedgbury
9cd661e746 Make sure config.h is included before any system headers
There was an issue recently in screen-share.c where config.h was not
being included, resulting in the wrong definition for off_t being used on
32 bit systems. I checked and I don't think this problem is happening
elsewhere, but to help avoid this sort of problem in the future, I went
through and made sure that config.h is included first whenever system
headers are included.

The config.h header should be included before any system headers, failing
to do this can result in the wrong type sizes being defined on certain
systems, e.g. off_t from sys/types.h

Signed-off-by: Andrew Wedgbury <andrew.wedgbury@realvnc.com>
2014-04-07 10:22:28 -07:00
Tomeu Vizoso
0f0a6ffc2e Remove dependency on <GLES2/gl2.h> by replacing GLfloat with float 2013-11-27 22:49:31 -08:00
Sam Spilsbury
b42fb52537 Added tests for the vertex clipping code.
This tests (via the table-driven testing method) that the correct
number of vertices and also the correct vertices themselves
are generated for an clip box and polygon of up to eight vertices.

Also add a libshared-test.la so that we don't have to build weston-test-runner
all the time
2013-09-16 21:40:34 -07:00