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>
This commit is contained in:
parent
1f9637ec8e
commit
e82ce8032c
|
@ -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
|
||||
|
|
|
@ -583,17 +583,99 @@ static const struct vertex_clip_test_data quad_clip_expected_data[] = {
|
|||
.clipped_n = 5,
|
||||
},
|
||||
|
||||
/* Miscellaneous cases: */
|
||||
/* Box intersects entire smaller aligned quad of different winding
|
||||
* orders and first edge orientations: */
|
||||
|
||||
/* Box intersects entire smaller aligned quad. */
|
||||
/* Clockwise winding and top/left initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX (-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = QUAD(-0.25f, -0.25f, 0.25f, 0.25f),
|
||||
.clipped = QUAD(-0.25f, -0.25f, 0.25f, 0.25f),
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{-0.25f, -0.25f}, { 0.25f, -0.25f},
|
||||
{ 0.25f, 0.25f}, {-0.25f, 0.25f}},
|
||||
.clipped = {{-0.25f, -0.25f}, { 0.25f, -0.25f},
|
||||
{ 0.25f, 0.25f}, {-0.25f, 0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Clockwise winding and top/right initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{ 0.25f, -0.25f}, { 0.25f, 0.25f},
|
||||
{-0.25f, 0.25f}, {-0.25f, -0.25f}},
|
||||
.clipped = {{ 0.25f, -0.25f}, { 0.25f, 0.25f},
|
||||
{-0.25f, 0.25f}, {-0.25f, -0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Clockwise winding and bottom/right initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{ 0.25f, 0.25f}, {-0.25f, 0.25f},
|
||||
{-0.25f, -0.25f}, { 0.25f, -0.25f}},
|
||||
.clipped = {{ 0.25f, 0.25f}, {-0.25f, 0.25f},
|
||||
{-0.25f, -0.25f}, { 0.25f, -0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Clockwise winding and bottom/left initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{-0.25f, 0.25f}, {-0.25f, -0.25f},
|
||||
{ 0.25f, -0.25f}, { 0.25f, 0.25f}},
|
||||
.clipped = {{-0.25f, 0.25f}, {-0.25f, -0.25f},
|
||||
{ 0.25f, -0.25f}, { 0.25f, 0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Counter-clockwise winding and top/left initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{-0.25f, -0.25f}, {-0.25f, 0.25f},
|
||||
{ 0.25f, 0.25f}, { 0.25f, -0.25f}},
|
||||
.clipped = {{-0.25f, -0.25f}, {-0.25f, 0.25f},
|
||||
{ 0.25f, 0.25f}, { 0.25f, -0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Counter-clockwise winding and top/right initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{ 0.25f, -0.25f}, {-0.25f, -0.25f},
|
||||
{-0.25f, 0.25f}, { 0.25f, 0.25f}},
|
||||
.clipped = {{ 0.25f, -0.25f}, {-0.25f, -0.25f},
|
||||
{-0.25f, 0.25f}, { 0.25f, 0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Counter-clockwise winding and bottom/right initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{ 0.25f, 0.25f}, { 0.25f, -0.25f},
|
||||
{-0.25f, -0.25f}, {-0.25f, 0.25f}},
|
||||
.clipped = {{ 0.25f, 0.25f}, { 0.25f, -0.25f},
|
||||
{-0.25f, -0.25f}, {-0.25f, 0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Counter-clockwise winding and bottom/left initial vertex. */
|
||||
{
|
||||
.aligned = true,
|
||||
.box = BOX(-0.50f, -0.50f, 0.50f, 0.50f),
|
||||
.polygon = {{-0.25f, 0.25f}, { 0.25f, 0.25f},
|
||||
{ 0.25f, -0.25f}, {-0.25f, -0.25f}},
|
||||
.clipped = {{-0.25f, 0.25f}, { 0.25f, 0.25f},
|
||||
{ 0.25f, -0.25f}, {-0.25f, -0.25f}},
|
||||
.clipped_n = 4,
|
||||
},
|
||||
|
||||
/* Miscellaneous cases: */
|
||||
|
||||
/* Box intersects entire same size aligned quad. */
|
||||
{
|
||||
.aligned = true,
|
||||
|
|
Loading…
Reference in New Issue