mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 01:17:59 +02:00
Add a1-image-sample and a1-traps-sample tests
Both of these currently fail due to bugs in the way pixman does its sampling.
This commit is contained in:
parent
c11790fded
commit
50d0767c8b
7 changed files with 161 additions and 0 deletions
2
test/.gitignore
vendored
2
test/.gitignore
vendored
|
|
@ -4,6 +4,8 @@ Makefile
|
|||
Makefile.in
|
||||
index.html
|
||||
ref.hash
|
||||
a1-image-sample
|
||||
a1-traps-sample
|
||||
a8-mask
|
||||
big-trap
|
||||
bitmap-font
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ SUBDIRS=pdiff .
|
|||
|
||||
# Here are all the tests that are run unconditionally
|
||||
TESTS = \
|
||||
a1-image-sample$(EXEEXT) \
|
||||
a1-traps-sample$(EXEEXT) \
|
||||
a8-mask$(EXEEXT) \
|
||||
big-trap$(EXEEXT) \
|
||||
caps-joins$(EXEEXT) \
|
||||
|
|
|
|||
BIN
test/a1-image-sample-ref.png
Normal file
BIN
test/a1-image-sample-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 B |
83
test/a1-image-sample.c
Normal file
83
test/a1-image-sample.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright © 2008 Red Hat, Inc.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
#define POINTS 10
|
||||
#define STEP (1.0 / POINTS)
|
||||
#define PAD 1
|
||||
#define WIDTH (PAD + POINTS * 2 + PAD)
|
||||
#define HEIGHT (WIDTH)
|
||||
|
||||
cairo_test_t test = {
|
||||
"a1-image-sample",
|
||||
"Test sample position when drawing images with FILTER_NEAREST",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
/* A single, black pixel */
|
||||
static const uint32_t black_pixel = 0xff000000;
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
int i, j;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_image_surface_create_for_data ((unsigned char *) &black_pixel,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
1, 1, 4);
|
||||
|
||||
/* Fill background white */
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
/* Draw in black */
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
cairo_translate (cr, PAD, PAD);
|
||||
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
|
||||
|
||||
for (i = 0; i < POINTS; i++)
|
||||
for (j = 0; j < POINTS; j++) {
|
||||
cairo_set_source_surface (cr, surface,
|
||||
2 * i + i * STEP, 2 * j + j * STEP);
|
||||
cairo_pattern_set_filter (cairo_get_source (cr),
|
||||
CAIRO_FILTER_NEAREST);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
BIN
test/a1-traps-sample-ref.png
Normal file
BIN
test/a1-traps-sample-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 B |
72
test/a1-traps-sample.c
Normal file
72
test/a1-traps-sample.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright © 2008 Red Hat, Inc.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
#define POINTS 10
|
||||
#define STEP (1.0 / POINTS)
|
||||
#define PAD 1
|
||||
#define WIDTH (PAD + POINTS * 2 + PAD)
|
||||
#define HEIGHT (WIDTH)
|
||||
|
||||
cairo_test_t test = {
|
||||
"a1-traps-sample",
|
||||
"Test sample position when drawing trapezoids with ANTIALIAS_NONE",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
/* Fill background white */
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
/* Draw in black */
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
cairo_translate (cr, PAD, PAD);
|
||||
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
|
||||
|
||||
for (i = 0; i < POINTS; i++)
|
||||
for (j = 0; j < POINTS; j++) {
|
||||
cairo_rectangle (cr, 2 * i + i * STEP, 2 * j + j * STEP, 1, 1);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
|
|
@ -79,6 +79,8 @@ static const char *vector_ignored_tests[] = {
|
|||
/* We can't match the results of tests that depend on
|
||||
* CAIRO_ANTIALIAS_NONE/SUBPIXEL for vector backends
|
||||
* (nor do we care). */
|
||||
"a1-image-sample",
|
||||
"a1-traps-sample",
|
||||
"ft-text-antialias-none",
|
||||
"rectangle-rounding-error",
|
||||
"text-antialias-gray",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue