Commit Graph

16 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 309a546165 gl-renderer: Improve clipper documentation
Add clipper_clip() documentation and improve comments a tiny bit.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +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 2d0d0175d2 gl-renderer: Add init_quad() to clipper
Extract quad bounding box initialization from the GL renderer and move
it to a dedicated initialization function in the clipper. It's used by
both the renderer and the clipping test client, which further reduces
code duplication.

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 aac11c8884 gl-renderer: Remove clip_simple() from clipper
clip_simple() isn't used anymore outside of the clipper. This commit
removes it to simplify the clipper API. Its implementation is moved
straight to the axis-aligned quad clipping path of clip_transformed().

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari edd5d1cc09 gl-renderer: Make clip_transformed() surf parameter constant
Calling clip_transformed() 4 times in a row with the same polygon8 in
commit a4d31fa8bd introduced a bug
because the surf input is modified each time. This is fixed by working
on a local copy. The input parameter is marked constant to reflect the
change on the function prototype.

Fixes #764

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-26 12:15:43 +00:00
Loïc Molinari fff8dbd9b8 gl-renderer: Move clip_quad() to clipper
clip_quad() is a dedicated clipping function for quads that doesn't
depend on any GL renderer internal structures. It can be moved out to
the clipper to be called by both the renderer and the clipping test
client without having to duplicate code.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari 39fee794b5 gl-renderer: Get rid of axis-aligned bbox check in simple clipper
Since both the surface rect and the transformed quad are axis-aligned
in the simple clipping path, non-zero area detection can more
efficiently be checked post-clipping by comparing opposite edges.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +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
Loïc Molinari a4d31fa8bd gl-renderer: Decouple coord space transformation from clipper
The clipper transforms dirty rects to surface space before clipping.
Each dirty rect is transformed by the same matrix for each surface
rect. This change decouples the transformation and the clipping code
to transform and compute the bounding box of dirty rects just once.

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
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