1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
27 #include <core/GP_Context.h>
28 #include <gfx/GP_LineAA.h>
35 /* line description */
46 static int test_line(const struct testcase
*t
)
51 c
= GP_ContextAlloc(t
->w
, t
->h
, GP_PIXEL_G8
);
54 tst_err("Failed to allocate context");
58 /* zero the pixels buffer */
59 memset(c
->pixels
, 0, c
->w
* c
->h
);
61 GP_LineAA(c
, t
->x0
, t
->y0
, t
->x1
, t
->y1
, 0xff);
63 err
= compare_buffers(t
->pixmap
, c
);
71 static struct testcase testcase_line_1px
= {
72 .x0
= (1<<8) + (1<<7),
73 .y0
= (1<<8) + (1<<7),
74 .x1
= (1<<8) + (1<<7),
75 .y1
= (1<<8) + (1<<7),
87 static struct testcase testcase_line_2px
= {
97 0x00, 0x00, 0x00, 0x00,
98 0x00, 0x00, 0x00, 0x00,
99 0x00, 0x00, 0x00, 0x00,
100 0x00, 0x00, 0x00, 0x00,
104 static struct testcase testcase_line_2px_h
= {
114 0x00, 0x00, 0x00, 0x00,
115 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00,
121 static struct testcase testcase_line_2px_v
= {
131 0x00, 0x00, 0x00, 0x00,
132 0x00, 0x00, 0x00, 0x00,
133 0x00, 0x00, 0x00, 0x00,
134 0x00, 0x00, 0x00, 0x00,
139 const struct tst_suite tst_suite
= {
140 .suite_name
= "LineAA Testsuite",
142 {.name
= "LineAA 1px",
144 .data
= &testcase_line_1px
},
146 {.name
= "LineAA 2px",
148 .data
= &testcase_line_2px
},
150 {.name
= "LineAA 2px horizontal",
152 .data
= &testcase_line_2px_h
},
154 {.name
= "LineAA 2px vertical",
156 .data
= &testcase_line_2px_v
},