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_Pixmap.h>
28 #include <gfx/GP_HLineAA.h>
35 /* line description */
45 static int test_line(const struct testcase
*t
)
50 c
= GP_PixmapAlloc(t
->w
, t
->h
, GP_PIXEL_G8
);
53 tst_err("Failed to allocate pixmap");
57 /* zero the pixels buffer */
58 memset(c
->pixels
, 0, c
->w
* c
->h
);
59 GP_HLineAA(c
, t
->x0
, t
->x1
, t
->y
, 0xff);
61 err
= compare_buffers(t
->pixmap
, c
);
69 static struct testcase testcase_line_len_0_1
= {
84 static struct testcase testcase_line_len_0_2
= {
85 .x0
= (1<<8) + (1<<7),
86 .x1
= (1<<8) + (1<<7),
99 static struct testcase testcase_line_len_0_3
= {
102 .y
= (1<<8) + (1<<7),
114 static struct testcase testcase_line_len_0_4
= {
115 .x0
= (1<<8) + (1<<7),
116 .x1
= (1<<8) + (1<<7),
117 .y
= (1<<8) + (1<<7),
129 static struct testcase testcase_line_len_0_5
= {
130 .x0
= (1<<8) + (1<<3) + 1,
131 .x1
= (1<<8) + (1<<3),
132 .y
= (1<<8) + (1<<2),
144 static struct testcase testcase_line_len_05_1
= {
146 .x1
= (1<<8) + (1<<7),
159 static struct testcase testcase_line_len_05_2
= {
161 .x1
= (1<<8) + (1<<7),
162 .y
= (1<<8) + (1<<7),
175 static struct testcase testcase_line_len_1_1
= {
184 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x80, 0x80, 0x00,
186 0x00, 0x00, 0x00, 0x00,
190 static struct testcase testcase_line_len_1_2
= {
191 .x0
= (1<<8) + (1<<7),
192 .x1
= (2<<8) + (1<<7),
199 0x00, 0x00, 0x00, 0x00,
200 0x00, 0x00, 0xff, 0x00,
201 0x00, 0x00, 0x00, 0x00,
205 static struct testcase testcase_line_len_1_3
= {
208 .y
= (1<<8) + (1<<7),
214 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x40, 0x40, 0x00,
216 0x00, 0x40, 0x40, 0x00,
217 0x00, 0x00, 0x00, 0x00,
221 static struct testcase testcase_line_len_1_4
= {
222 .x0
= (1<<8) + (1<<7),
223 .x1
= (2<<8) + (1<<7),
224 .y
= (1<<8) + (1<<7),
230 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x80, 0x00,
232 0x00, 0x00, 0x80, 0x00,
233 0x00, 0x00, 0x00, 0x00,
237 static struct testcase testcase_line_len_4_1
= {
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247 0x00, 0x80, 0xff, 0xff, 0x80, 0x00,
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 static struct testcase testcase_line_len_4_2
= {
255 .y
= (1<<8) + (1<<7),
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 0x00, 0x40, 0x80, 0x80, 0x40, 0x00,
263 0x00, 0x40, 0x80, 0x80, 0x40, 0x00,
264 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 const struct tst_suite tst_suite
= {
269 .suite_name
= "HLineAA Testsuite",
271 {.name
= "HLineAA len=0 1",
273 .data
= &testcase_line_len_0_1
},
275 {.name
= "HLineAA len=0 2",
277 .data
= &testcase_line_len_0_2
},
279 {.name
= "HLineAA len=0 3",
281 .data
= &testcase_line_len_0_3
},
283 {.name
= "HLineAA len=0 4",
285 .data
= &testcase_line_len_0_4
},
287 {.name
= "HLineAA len=0 5",
289 .data
= &testcase_line_len_0_5
},
291 {.name
= "HLineAA len=0.5 1",
293 .data
= &testcase_line_len_05_1
},
295 {.name
= "HLineAA len=0.5 2",
297 .data
= &testcase_line_len_05_2
},
299 {.name
= "LineAA len=1 1",
301 .data
= &testcase_line_len_1_1
},
303 {.name
= "LineAA len=1 2",
305 .data
= &testcase_line_len_1_2
},
307 {.name
= "LineAA len=1 3",
309 .data
= &testcase_line_len_1_3
},
311 {.name
= "LineAA len=1 4",
313 .data
= &testcase_line_len_1_4
},
315 {.name
= "LineAA len=4 1",
317 .data
= &testcase_line_len_4_1
},
319 {.name
= "LineAA len=4 2",
321 .data
= &testcase_line_len_4_2
},