Skip to content
Commits on Source (5)
  • Loïc Molinari's avatar
    tests: Improve clipper test function · aca0b69a
    Loïc Molinari authored and Pekka Paalanen's avatar Pekka Paalanen committed
    
    
    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: default avatarLoïc Molinari <loic.molinari@collabora.com>
    aca0b69a
  • Loïc Molinari's avatar
    tests: Improve general purpose clipper tests · 60877f5f
    Loïc Molinari authored and Pekka Paalanen's avatar Pekka Paalanen committed
    
    
    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: default avatarLoïc Molinari <loic.molinari@collabora.com>
    60877f5f
  • Loïc Molinari's avatar
    tests: Add quad clipper tests · 1f9637ec
    Loïc Molinari authored and Pekka Paalanen's avatar Pekka Paalanen committed
    
    
    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: default avatarLoïc Molinari <loic.molinari@collabora.com>
    1f9637ec
  • Loïc Molinari's avatar
    gl-renderer: Fix quad clipper non-zero area check · e82ce803
    Loïc Molinari authored and Pekka Paalanen's avatar Pekka Paalanen committed
    
    
    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: default avatarLoïc Molinari <loic.molinari@collabora.com>
    e82ce803
  • Loïc Molinari's avatar
    tests: Add box32 quad clipper tests · 5516527f
    Loïc Molinari authored and Pekka Paalanen's avatar Pekka Paalanen committed
    
    
    Add a few tests ensuring the box32 quad clipping wrapper works as
    expected.
    
    Signed-off-by: default avatarLoïc Molinari <loic.molinari@collabora.com>
    5516527f
......@@ -332,7 +332,7 @@ clipper_clip(const struct clipper_vertex *polygon,
return n;
}
void
WESTON_EXPORT_FOR_TESTS void
clipper_quad_init(struct clipper_quad *quad,
const struct clipper_vertex polygon[4],
bool axis_aligned)
......@@ -356,7 +356,7 @@ clipper_quad_init(struct clipper_quad *quad,
}
}
int
WESTON_EXPORT_FOR_TESTS int
clipper_quad_clip(struct clipper_quad *quad,
const struct clipper_vertex box[2],
struct clipper_vertex *restrict vertices)
......@@ -374,7 +374,7 @@ clipper_quad_clip(struct clipper_quad *quad,
vertices[i].y = CLIP(quad->polygon[i].y,
box[0].y, box[1].y);
}
if ((vertices[0].x != vertices[1].x) &&
if ((vertices[0].x != vertices[2].x) &&
(vertices[0].y != vertices[2].y))
return 4;
else
......@@ -398,7 +398,7 @@ clipper_quad_clip(struct clipper_quad *quad,
return n;
}
int
WESTON_EXPORT_FOR_TESTS int
clipper_quad_clip_box32(struct clipper_quad *quad,
const struct pixman_box32 *box,
struct clipper_vertex *restrict vertices)
......
This diff is collapsed.