2006-12-05 12:20:17 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2006 M Joonas Pihlaja
|
|
|
|
|
*
|
2006-12-07 01:16:43 +02:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2006-12-05 12:20:17 +02:00
|
|
|
*
|
2006-12-07 01:16:43 +02:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
2006-12-05 12:20:17 +02:00
|
|
|
*
|
|
|
|
|
* Author: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Bug history
|
|
|
|
|
*
|
|
|
|
|
* 2006-12-05 M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
|
|
|
|
|
*
|
|
|
|
|
* The cairo_in_fill () function can sometimes produce false
|
|
|
|
|
* positives when the tessellator produces empty trapezoids
|
|
|
|
|
* and the query point lands exactly on a trapezoid edge.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "cairo-test.h"
|
|
|
|
|
|
2008-09-03 16:38:03 +01:00
|
|
|
static cairo_test_status_t
|
|
|
|
|
preamble (cairo_test_context_t *ctx)
|
2006-12-05 12:20:17 +02:00
|
|
|
{
|
|
|
|
|
int x,y;
|
2006-12-07 02:30:41 +02:00
|
|
|
int width = 10;
|
|
|
|
|
int height = 10;
|
2008-08-11 21:12:45 +01:00
|
|
|
cairo_surface_t *surf;
|
|
|
|
|
cairo_t *cr;
|
2006-12-07 02:30:41 +02:00
|
|
|
int false_positive_count = 0;
|
|
|
|
|
cairo_status_t status;
|
2007-05-08 18:19:56 +01:00
|
|
|
cairo_test_status_t ret;
|
2006-12-07 02:30:41 +02:00
|
|
|
|
2008-08-11 21:12:45 +01:00
|
|
|
surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
|
|
|
|
|
cr = cairo_create (surf);
|
|
|
|
|
cairo_surface_destroy (surf);
|
|
|
|
|
|
2006-12-05 12:20:17 +02:00
|
|
|
/* Empty horizontal trapezoid. */
|
|
|
|
|
cairo_move_to (cr, 0, height/3);
|
|
|
|
|
cairo_line_to (cr, width, height/3);
|
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
|
|
/* Empty non-horizontal trapezoid #1. */
|
|
|
|
|
cairo_move_to (cr, 0, 0);
|
|
|
|
|
cairo_line_to (cr, width, height/2);
|
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
|
|
/* Empty non-horizontal trapezoid #2 intersecting #1. */
|
|
|
|
|
cairo_move_to (cr, 0, height/2);
|
|
|
|
|
cairo_line_to (cr, width, 0);
|
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
2006-12-07 02:30:41 +02:00
|
|
|
status = cairo_status (cr);
|
|
|
|
|
|
|
|
|
|
/* Point sample the tessellated path. */
|
2006-12-05 12:20:17 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
|
if (cairo_in_fill (cr, x, y)) {
|
2006-12-07 02:30:41 +02:00
|
|
|
false_positive_count++;
|
2006-12-05 12:20:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
2006-12-07 02:30:41 +02:00
|
|
|
/* Check that everything went well. */
|
2007-05-08 18:19:56 +01:00
|
|
|
ret = CAIRO_TEST_SUCCESS;
|
2006-12-07 02:30:41 +02:00
|
|
|
if (CAIRO_STATUS_SUCCESS != status) {
|
2008-09-03 16:38:03 +01:00
|
|
|
cairo_test_log (ctx, "Failed to create a test surface and path: %s\n",
|
2006-12-07 02:30:41 +02:00
|
|
|
cairo_status_to_string (status));
|
2009-10-15 14:58:39 -07:00
|
|
|
ret = CAIRO_TEST_XFAILURE;
|
2006-12-07 02:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (0 != false_positive_count) {
|
2008-09-03 16:38:03 +01:00
|
|
|
cairo_test_log (ctx, "Point sampling found %d false positives "
|
2006-12-07 02:30:41 +02:00
|
|
|
"from cairo_in_fill()\n",
|
|
|
|
|
false_positive_count);
|
2009-10-15 14:58:39 -07:00
|
|
|
ret = CAIRO_TEST_XFAILURE;
|
2006-12-07 02:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
2007-05-08 18:19:56 +01:00
|
|
|
return ret;
|
2006-12-05 12:20:17 +02:00
|
|
|
}
|
2008-09-03 16:38:03 +01:00
|
|
|
|
2013-09-29 13:12:55 +02:00
|
|
|
/*
|
|
|
|
|
* XFAIL: The cairo_in_fill () function can sometimes produce false positives
|
|
|
|
|
* when the tessellator produces empty trapezoids and the query point lands
|
|
|
|
|
* exactly on a trapezoid edge.
|
|
|
|
|
*/
|
2008-09-03 16:38:03 +01:00
|
|
|
CAIRO_TEST (in_fill_empty_trapezoid,
|
|
|
|
|
"Test that the tessellator isn't producing obviously empty trapezoids",
|
|
|
|
|
"in, trap", /* keywords */
|
|
|
|
|
NULL, /* requirements */
|
|
|
|
|
0, 0,
|
|
|
|
|
preamble, NULL)
|