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 *****************************************************************************/
30 #include <core/GP_Pixmap.h>
31 #include <core/GP_Blit.h>
32 #include <core/GP_Fill.h>
35 #include "tst_preload.h"
37 #include "../filters/common.c"
40 /* size of the contexes */
44 /* Source rectangle */
48 /* Destination offset */
51 /* If set, is used to check assert correct result */
55 static int clipped_test(struct clipped_test
*test
)
57 int ret
= TST_SUCCESS
;
60 src
= GP_PixmapAlloc(test
->src_w
, test
->src_h
, GP_PIXEL_G8
);
61 dst
= GP_PixmapAlloc(test
->dst_w
, test
->dst_h
, GP_PIXEL_G8
);
67 tst_msg("GP_PixmapAlloc() failed");
71 GP_BlitXYWH_Clipped(src
, test
->x0
, test
->y0
, test
->w0
, test
->h0
,
72 dst
, test
->x1
, test
->y1
);
75 if (compare_buffers(test
->dst
, dst
))
85 static int clipped_test_canaries(struct clipped_test
*test
)
89 tst_malloc_canaries_set(MALLOC_CANARY_BEGIN
);
90 ret
= clipped_test(test
);
92 tst_malloc_canaries_set(MALLOC_CANARY_END
);
93 ret
|= clipped_test(test
);
95 tst_malloc_canaries_set(MALLOC_CANARY_OFF
);
100 static struct clipped_test off_by_one_1
= {
116 static struct clipped_test off_by_one_2
= {
132 static struct clipped_test off_by_one_3
= {
148 static const char empty
[400] = {0};
150 static struct clipped_test empty_src
= {
168 static struct clipped_test out_of_dst_1
= {
186 static struct clipped_test out_of_dst_2
= {
204 static struct clipped_test src_rect_out_of_src
= {
222 static struct clipped_test dst_neg_coords1
= {
237 .dst
= (const char []) {
246 static struct clipped_test dst_big_coords
= {
261 .dst
= (const char []) {
270 static struct clipped_test dst_neg_coords2
= {
285 .dst
= (const char []) {
292 static struct clipped_test dst_neg_coords3
= {
307 .dst
= (const char []) {
314 static struct clipped_test src_inside
= {
329 .dst
= (const char []) {
338 const struct tst_suite tst_suite
= {
339 .suite_name
= "Blit Clipped Testsuite",
341 {.name
= "Empty src",
342 .tst_fn
= clipped_test_canaries
,
344 .flags
= TST_CHECK_MALLOC
},
346 {.name
= "Out of dst 1",
347 .tst_fn
= clipped_test_canaries
,
348 .data
= &out_of_dst_1
,
349 .flags
= TST_CHECK_MALLOC
},
351 {.name
= "Out of dst 2",
352 .tst_fn
= clipped_test_canaries
,
353 .data
= &out_of_dst_2
,
354 .flags
= TST_CHECK_MALLOC
},
356 {.name
= "Src rect out of src",
357 .tst_fn
= clipped_test_canaries
,
358 .data
= &src_rect_out_of_src
,
359 .flags
= TST_CHECK_MALLOC
},
361 {.name
= "Dst negative coords 1",
362 .tst_fn
= clipped_test_canaries
,
363 .data
= &dst_neg_coords1
,
364 .flags
= TST_CHECK_MALLOC
},
366 {.name
= "Dst negative coords 2",
367 .tst_fn
= clipped_test_canaries
,
368 .data
= &dst_neg_coords2
,
369 .flags
= TST_CHECK_MALLOC
},
371 {.name
= "Dst negative coords 3",
372 .tst_fn
= clipped_test_canaries
,
373 .data
= &dst_neg_coords3
,
374 .flags
= TST_CHECK_MALLOC
},
376 {.name
= "Dst big coords",
377 .tst_fn
= clipped_test_canaries
,
378 .data
= &dst_big_coords
,
379 .flags
= TST_CHECK_MALLOC
},
381 {.name
= "Src inside dst",
382 .tst_fn
= clipped_test_canaries
,
384 .flags
= TST_CHECK_MALLOC
},
386 {.name
= "Regression off by one 1",
387 .tst_fn
= clipped_test_canaries
,
388 .data
= &off_by_one_1
,
389 .flags
= TST_CHECK_MALLOC
},
391 {.name
= "Regression off by one 2",
392 .tst_fn
= clipped_test_canaries
,
393 .data
= &off_by_one_2
,
394 .flags
= TST_CHECK_MALLOC
},
396 {.name
= "Regression off by one 3",
397 .tst_fn
= clipped_test_canaries
,
398 .data
= &off_by_one_3
,
399 .flags
= TST_CHECK_MALLOC
},